Skip to content

Commit

Permalink
SIMPLE-6084 Fixed a regression in create_node method to preserve comp…
Browse files Browse the repository at this point in the history
…atibility with older CML releases
  • Loading branch information
tmikuska committed Nov 25, 2023
1 parent 8e2af0c commit 410a1df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 1 addition & 3 deletions virl2_client/models/lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,8 @@ def create_node(
for key in ("image_definition", "configuration"):
if key not in kwargs:
kwargs[key] = None

if "compute_id" in kwargs:
kwargs.pop("compute_id")
kwargs["resource_pool"] = None
kwargs.pop("compute_id", None)
node = self._create_node_local(node_id, **kwargs)
return node

Expand Down
16 changes: 11 additions & 5 deletions virl2_client/models/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,11 @@ def configuration(self) -> str | None:

@configuration.setter
def configuration(self, value: str | list | dict) -> None:
"""Set the configuration."""
self._set_node_property("configuration", value)
self._set_configuration(value)

def _set_configuration(self, value: str | list | dict) -> None:
"""
Set the content of:
- the main configuration file if passed a string,
Expand All @@ -430,14 +435,13 @@ def configuration(self, value: str | list | dict) -> None:
:param value: The configuration data in one of three formats.
"""
self._set_node_property("configuration", value)
if self._configuration is None:
self._configuration = []
if isinstance(value, str):
if not self._configuration:
self._configuration.append({"name": "Main", "content": value})
else:
if self._configuration:
self._configuration[0]["content"] = value
else:
self._configuration.append({"name": "Main", "content": value})
return
new_configs = value if isinstance(value, list) else [value]
new_configs_by_name = {
Expand Down Expand Up @@ -898,7 +902,9 @@ def update(
node_data = node_data["data"]

for key, value in node_data.items():
if key == "configuration" and exclude_configurations:
if key == "configuration":
if not exclude_configurations:
self._set_configuration(value)
continue
if key == "operational":
self.sync_operational(node_data)
Expand Down

0 comments on commit 410a1df

Please sign in to comment.