mirror of
https://github.com/kubevirt/kubevirt.core.git
synced 2026-05-07 22:02:38 +00:00
fix(kubevirt_vm): Allow switching between running and run_strategy
Allow switching between running and run_strategy by always clearing the other value. E.g. if run_strategy was provided then running set to None to clear it or vice versa. Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This commit is contained in:
@@ -333,7 +333,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
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -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": {
|
||||||
@@ -383,6 +387,7 @@ CREATED_VM = {
|
|||||||
},
|
},
|
||||||
"spec": {
|
"spec": {
|
||||||
"running": True,
|
"running": True,
|
||||||
|
"runStrategy": None,
|
||||||
"template": {
|
"template": {
|
||||||
"spec": {
|
"spec": {
|
||||||
"domain": {
|
"domain": {
|
||||||
@@ -400,6 +405,7 @@ CREATED_VM_RUN_STRATEGY = {
|
|||||||
"namespace": "default",
|
"namespace": "default",
|
||||||
},
|
},
|
||||||
"spec": {
|
"spec": {
|
||||||
|
"running": None,
|
||||||
"runStrategy": "Manual",
|
"runStrategy": "Manual",
|
||||||
"template": {
|
"template": {
|
||||||
"spec": {
|
"spec": {
|
||||||
@@ -422,6 +428,7 @@ CREATED_VM_LABELS = {
|
|||||||
},
|
},
|
||||||
"spec": {
|
"spec": {
|
||||||
"running": True,
|
"running": True,
|
||||||
|
"runStrategy": None,
|
||||||
"template": {
|
"template": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"labels": {"test": "test"},
|
"labels": {"test": "test"},
|
||||||
@@ -446,6 +453,7 @@ CREATED_VM_ANNOTATIONS = {
|
|||||||
},
|
},
|
||||||
"spec": {
|
"spec": {
|
||||||
"running": True,
|
"running": True,
|
||||||
|
"runStrategy": None,
|
||||||
"template": {
|
"template": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"annotations": {"test": "test"},
|
"annotations": {"test": "test"},
|
||||||
@@ -467,6 +475,7 @@ CREATED_VM_INSTANCETYPE = {
|
|||||||
},
|
},
|
||||||
"spec": {
|
"spec": {
|
||||||
"running": True,
|
"running": True,
|
||||||
|
"runStrategy": None,
|
||||||
"instancetype": {"name": "u1.medium"},
|
"instancetype": {"name": "u1.medium"},
|
||||||
"template": {
|
"template": {
|
||||||
"spec": {
|
"spec": {
|
||||||
@@ -486,6 +495,7 @@ CREATED_VM_PREFERENCE = {
|
|||||||
},
|
},
|
||||||
"spec": {
|
"spec": {
|
||||||
"running": True,
|
"running": True,
|
||||||
|
"runStrategy": None,
|
||||||
"preference": {"name": "fedora"},
|
"preference": {"name": "fedora"},
|
||||||
"template": {
|
"template": {
|
||||||
"spec": {
|
"spec": {
|
||||||
@@ -505,6 +515,7 @@ CREATED_VM_DATAVOLUMETEMPLATE = {
|
|||||||
},
|
},
|
||||||
"spec": {
|
"spec": {
|
||||||
"running": True,
|
"running": True,
|
||||||
|
"runStrategy": None,
|
||||||
"dataVolumeTemplates": [
|
"dataVolumeTemplates": [
|
||||||
{
|
{
|
||||||
"metadata": {"name": "testdv"},
|
"metadata": {"name": "testdv"},
|
||||||
@@ -540,6 +551,7 @@ CREATED_VM_NAME = {
|
|||||||
},
|
},
|
||||||
"spec": {
|
"spec": {
|
||||||
"running": True,
|
"running": True,
|
||||||
|
"runStrategy": None,
|
||||||
"template": {
|
"template": {
|
||||||
"spec": {
|
"spec": {
|
||||||
"domain": {
|
"domain": {
|
||||||
@@ -559,6 +571,7 @@ CREATED_VM_GENERATE_NAME = {
|
|||||||
},
|
},
|
||||||
"spec": {
|
"spec": {
|
||||||
"running": True,
|
"running": True,
|
||||||
|
"runStrategy": None,
|
||||||
"template": {
|
"template": {
|
||||||
"spec": {
|
"spec": {
|
||||||
"domain": {
|
"domain": {
|
||||||
@@ -577,6 +590,7 @@ CREATED_VM_SPECS = {
|
|||||||
},
|
},
|
||||||
"spec": {
|
"spec": {
|
||||||
"running": True,
|
"running": True,
|
||||||
|
"runStrategy": None,
|
||||||
"template": {
|
"template": {
|
||||||
"spec": {
|
"spec": {
|
||||||
"domain": {
|
"domain": {
|
||||||
|
|||||||
Reference in New Issue
Block a user