Skip to content

Conversation

@BregaladTaran
Copy link
Collaborator

No description provided.

self._state = None
self._staging_enabled = False
self._staging_start_remaining = True
self._staging_abort_on_failure = False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marpauli-cisco do we need to have all 3 as standalone properties? I think that we have an object in UI, API and exported topologies. Also, we should call it node_staging even though the name will likely change,

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these attributes represent values from data on Lab creation, but we don't use individual setters for all three values, but only one setter for single property node_staging that is a dict containing these three.

self._state = None
self._staging_enabled = False
self._staging_start_remaining = True
self._staging_abort_on_failure = False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these attributes represent values from data on Lab creation, but we don't use individual setters for all three values, but only one setter for single property node_staging that is a dict containing these three.

Comment on lines +338 to +369
@property
def staging_enabled(self) -> bool:
"""Return whether node staging is enabled for the lab."""
self.sync_topology_if_outdated()
return self._staging_enabled

@staging_enabled.setter
def staging_enabled(self, value: bool) -> None:
"""Set whether node staging is enabled for the lab."""
self._set_staging_property("staging_enabled", value)

@property
def staging_start_remaining(self) -> bool:
"""Return whether to start remaining nodes after staged nodes complete."""
self.sync_topology_if_outdated()
return self._staging_start_remaining

@staging_start_remaining.setter
def staging_start_remaining(self, value: bool) -> None:
"""Set whether to start remaining nodes after staged nodes complete."""
self._set_staging_property("staging_start_remaining", value)

@property
def staging_abort_on_failure(self) -> bool:
"""Return whether to abort remaining nodes if a staged node fails."""
self.sync_topology_if_outdated()
return self._staging_abort_on_failure

@staging_abort_on_failure.setter
def staging_abort_on_failure(self, value: bool) -> None:
"""Set whether to abort remaining nodes if a staged node fails."""
self._set_staging_property("staging_abort_on_failure", value)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace these properties and setters with single property node_staging - dict containing these three

Comment on lines +1977 to +1985
if node_staging:
self._staging_enabled = node_staging.get("enabled", self._staging_enabled)
self._staging_start_remaining = node_staging.get(
"start_remaining", self._staging_start_remaining
)
self._staging_abort_on_failure = node_staging.get(
"abort_on_failure", self._staging_abort_on_failure
)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if node_staging:
self._staging_enabled = node_staging.get("enabled", self._staging_enabled)
self._staging_start_remaining = node_staging.get(
"start_remaining", self._staging_start_remaining
)
self._staging_abort_on_failure = node_staging.get(
"abort_on_failure", self._staging_abort_on_failure
)

Comment on lines +672 to +674
staging_enabled: bool | None = None,
staging_start_remaining: bool | None = None,
staging_abort_on_failure: bool | None = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
staging_enabled: bool | None = None,
staging_start_remaining: bool | None = None,
staging_abort_on_failure: bool | None = None,
node_staging: dict | None = None,

Comment on lines +695 to +699
:param staging_enabled: Whether node staging is enabled for the lab.
:param staging_start_remaining: Whether to start remaining nodes after
priority nodes complete.
:param staging_abort_on_failure: Whether to abort startup if any node
fails to start.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:param staging_enabled: Whether node staging is enabled for the lab.
:param staging_start_remaining: Whether to start remaining nodes after
priority nodes complete.
:param staging_abort_on_failure: Whether to abort startup if any node
fails to start.
:param node_staging: Parameter for node staging (enabled, abort_on_failure, start_remainig)

Comment on lines +704 to +717

node_staging = {
k: v
for k, v in {
"enabled": staging_enabled,
"start_remaining": staging_start_remaining,
"abort_on_failure": staging_abort_on_failure,
}.items()
if v is not None
}

if node_staging:
body["node_staging"] = node_staging

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
node_staging = {
k: v
for k, v in {
"enabled": staging_enabled,
"start_remaining": staging_start_remaining,
"abort_on_failure": staging_abort_on_failure,
}.items()
if v is not None
}
if node_staging:
body["node_staging"] = node_staging
if node_staging:
body["node_staging"] = node_staging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants