Skip to content

Commit

Permalink
refactor: rename i to operation_order
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulFarault committed Nov 13, 2023
1 parent 880735b commit a4f473f
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions tdp/core/models/deployment_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def from_operations(
},
status=DeploymentStateEnum.PLANNED,
)
i = 1
operation_order = 1
for operation in operations:
can_perform_rolling_restart = (
rolling_interval is not None
Expand All @@ -228,26 +228,26 @@ def from_operations(
deployment.operations.append(
OperationModel(
operation=operation.name,
operation_order=i,
operation_order=operation_order,
host=host_name,
extra_vars=list(extra_vars) if extra_vars else None,
state=OperationStateEnum.PLANNED,
)
)
if can_perform_rolling_restart:
i += 1
operation_order += 1
deployment.operations.append(
OperationModel(
operation=OPERATION_SLEEP_NAME,
operation_order=i,
operation_order=operation_order,
host=host_name,
extra_vars=[
f"{OPERATION_SLEEP_VARIABLE}={rolling_interval}"
],
state=OperationStateEnum.PLANNED,
)
)
i += 1
operation_order += 1
return deployment

@staticmethod
Expand All @@ -270,7 +270,9 @@ def from_operations_hosts_vars(
status=DeploymentStateEnum.PLANNED,
)

for order, operation_host_vars in enumerate(operation_host_vars_names, start=1):
for operation_order, operation_host_vars in enumerate(
operation_host_vars_names, start=1
):
operation_name, host_name, var_names = operation_host_vars
if host_name is not None:
collections.check_operations_hosts_exist(
Expand All @@ -285,7 +287,7 @@ def from_operations_hosts_vars(
deployment.operations.append(
OperationModel(
operation=operation_name,
operation_order=order,
operation_order=operation_order,
host=host_name,
extra_vars=var_names,
state=OperationStateEnum.PLANNED,
Expand Down Expand Up @@ -406,8 +408,10 @@ def from_failed_deployment(

failed_operation_id = next(
(
i
for i, operation in enumerate(failed_deployment.operations)
operation_order
for operation_order, operation in enumerate(
failed_deployment.operations
)
if operation.state == OperationStateEnum.FAILURE
),
None,
Expand All @@ -428,12 +432,12 @@ def from_failed_deployment(
deployment.operations = [
OperationModel(
operation=operation,
operation_order=i,
operation_order=operation_order,
host=host,
extra_vars=extra_vars,
state=OperationStateEnum.PLANNED,
)
for i, (operation, host, extra_vars) in enumerate(
for operation_order, (operation, host, extra_vars) in enumerate(
operations_tuple_to_resume, 1
)
]
Expand Down

0 comments on commit a4f473f

Please sign in to comment.