Merge pull request #180 from 0xFelix/running-run-strategy

fix(kubevirt_vm): Allow switching between running and run_strategy
This commit is contained in:
kubevirt-bot
2025-04-29 12:02:27 +02:00
committed by GitHub
2 changed files with 16 additions and 0 deletions

View File

@@ -347,7 +347,9 @@ def create_vm(params: Dict) -> Dict:
if (run_strategy := params.get("run_strategy")) is not None: if (run_strategy := params.get("run_strategy")) is not None:
vm["spec"]["runStrategy"] = run_strategy vm["spec"]["runStrategy"] = run_strategy
vm["spec"]["running"] = None
else: else:
vm["spec"]["runStrategy"] = None
vm["spec"]["running"] = ( vm["spec"]["running"] = (
running if (running := params.get("running")) is not None else True running if (running := params.get("running")) is not None else True
) )

View File

@@ -44,6 +44,7 @@ VM_DEFINITION_CREATE = {
}, },
"spec": { "spec": {
"running": True, "running": True,
"runStrategy": None,
"instancetype": {"name": "u1.medium"}, "instancetype": {"name": "u1.medium"},
"preference": {"name": "fedora"}, "preference": {"name": "fedora"},
"dataVolumeTemplates": [ "dataVolumeTemplates": [
@@ -83,6 +84,7 @@ VM_DEFINITION_RUNNING = {
}, },
"spec": { "spec": {
"running": True, "running": True,
"runStrategy": None,
"template": { "template": {
"spec": { "spec": {
"domain": {"devices": {}}, "domain": {"devices": {}},
@@ -100,6 +102,7 @@ VM_DEFINITION_STOPPED = {
}, },
"spec": { "spec": {
"running": False, "running": False,
"runStrategy": None,
"template": { "template": {
"spec": { "spec": {
"domain": {"devices": {}}, "domain": {"devices": {}},
@@ -116,6 +119,7 @@ VM_DEFINITION_HALTED = {
"namespace": "default", "namespace": "default",
}, },
"spec": { "spec": {
"running": None,
"runStrategy": "Halted", "runStrategy": "Halted",
"template": { "template": {
"spec": { "spec": {
@@ -426,6 +430,7 @@ CREATED_VM = {
}, },
"spec": { "spec": {
"running": True, "running": True,
"runStrategy": None,
"template": { "template": {
"spec": { "spec": {
"domain": { "domain": {
@@ -443,6 +448,7 @@ CREATED_VM_RUN_STRATEGY = {
"namespace": "default", "namespace": "default",
}, },
"spec": { "spec": {
"running": None,
"runStrategy": "Manual", "runStrategy": "Manual",
"template": { "template": {
"spec": { "spec": {
@@ -465,6 +471,7 @@ CREATED_VM_LABELS = {
}, },
"spec": { "spec": {
"running": True, "running": True,
"runStrategy": None,
"template": { "template": {
"metadata": { "metadata": {
"labels": {"test": "test"}, "labels": {"test": "test"},
@@ -489,6 +496,7 @@ CREATED_VM_ANNOTATIONS = {
}, },
"spec": { "spec": {
"running": True, "running": True,
"runStrategy": None,
"template": { "template": {
"metadata": { "metadata": {
"annotations": {"test": "test"}, "annotations": {"test": "test"},
@@ -510,6 +518,7 @@ CREATED_VM_INSTANCETYPE = {
}, },
"spec": { "spec": {
"running": True, "running": True,
"runStrategy": None,
"instancetype": {"name": "u1.medium"}, "instancetype": {"name": "u1.medium"},
"template": { "template": {
"spec": { "spec": {
@@ -529,6 +538,7 @@ CREATED_VM_PREFERENCE = {
}, },
"spec": { "spec": {
"running": True, "running": True,
"runStrategy": None,
"preference": {"name": "fedora"}, "preference": {"name": "fedora"},
"template": { "template": {
"spec": { "spec": {
@@ -548,6 +558,7 @@ CREATED_VM_DATAVOLUMETEMPLATE = {
}, },
"spec": { "spec": {
"running": True, "running": True,
"runStrategy": None,
"dataVolumeTemplates": [ "dataVolumeTemplates": [
{ {
"metadata": {"name": "testdv"}, "metadata": {"name": "testdv"},
@@ -583,6 +594,7 @@ CREATED_VM_NAME = {
}, },
"spec": { "spec": {
"running": True, "running": True,
"runStrategy": None,
"template": { "template": {
"spec": { "spec": {
"domain": { "domain": {
@@ -602,6 +614,7 @@ CREATED_VM_GENERATE_NAME = {
}, },
"spec": { "spec": {
"running": True, "running": True,
"runStrategy": None,
"template": { "template": {
"spec": { "spec": {
"domain": { "domain": {
@@ -620,6 +633,7 @@ CREATED_VM_SPECS = {
}, },
"spec": { "spec": {
"running": True, "running": True,
"runStrategy": None,
"template": { "template": {
"spec": { "spec": {
"domain": { "domain": {