diff --git a/gso/cli/imports.py b/gso/cli/imports.py index 7bfcbd2afccdd9c13623a4817fc3567c2bfdfe03..fad9d1e14328b4319d60ed066cbc79b188c7b584 100644 --- a/gso/cli/imports.py +++ b/gso/cli/imports.py @@ -53,6 +53,7 @@ from gso.utils.types.ip_address import ( from gso.utils.types.virtual_identifiers import VC_ID, VLAN_ID app: typer.Typer = typer.Typer() +IMPORT_WAIT_MESSAGE = "Waiting for the dust to settle before importing new products..." class CreatePartner(BaseModel): @@ -451,7 +452,7 @@ def _generic_import_product( except ValidationError as e: typer.echo(f"Validation error: {e}") - typer.echo("Waiting for the dust to settle before moving on the importing new products...") + typer.echo(IMPORT_WAIT_MESSAGE) time.sleep(1) # Migrate new products from imported to "full" counterpart. @@ -539,7 +540,7 @@ def import_edge_port(filepath: str = common_filepath_option) -> None: except ValidationError as e: typer.echo(f"Validation error: {e}") - typer.echo("Waiting for the dust to settle before moving on the importing new products...") + typer.echo(IMPORT_WAIT_MESSAGE) time.sleep(1) edge_port_ids = get_subscriptions( @@ -610,7 +611,7 @@ def import_iptrunks(filepath: str = common_filepath_option) -> None: except ValidationError as e: typer.echo(f"Validation error: {e}") - typer.echo("Waiting for the dust to settle before moving on the importing new products...") + typer.echo(IMPORT_WAIT_MESSAGE) time.sleep(1) trunk_ids = get_subscriptions( @@ -670,7 +671,7 @@ def import_l3_core_service(filepath: str = common_filepath_option) -> None: except ValidationError as e: typer.echo(f"Validation error: {e}") - typer.echo("Waiting for the dust to settle before importing new products...") + typer.echo(IMPORT_WAIT_MESSAGE) time.sleep(1) # Migrate new products from imported to "full" counterpart. @@ -728,7 +729,7 @@ def import_layer_2_circuit_service(filepath: str = common_filepath_option) -> No ) except ValidationError as e: typer.echo(f"Validation error: {e}") - typer.echo("Waiting for the dust to settle before importing new products...") + typer.echo(IMPORT_WAIT_MESSAGE) time.sleep(1) # Migrate new products from imported to "full" counterpart. diff --git a/gso/services/lso_client.py b/gso/services/lso_client.py index 9280cbc4dbcbb6d1bb4d111c1f341b22fb0114b7..6f5d8599822c7bf1a94b5274db55ab09e102ac92 100644 --- a/gso/services/lso_client.py +++ b/gso/services/lso_client.py @@ -22,6 +22,7 @@ from unidecode import unidecode from gso import settings logger = logging.getLogger(__name__) +RUNNING_ANSIBLE_PLAYBOOK_STEP_NAME = "Running Ansible playbook" class _LSOState(TypedDict): # noqa: PYI049 @@ -211,7 +212,7 @@ def lso_interaction(provisioning_step: Step) -> StepList: >> _inventory_is_not_empty( begin >> callback_step( - name="Running Ansible playbook", action_step=_execute_playbook, validate_step=_evaluate_results + name=RUNNING_ANSIBLE_PLAYBOOK_STEP_NAME, action_step=_execute_playbook, validate_step=_evaluate_results ) >> step("Inject result title")(lambda: {"lso_result_title": provisioning_step.name}) >> _show_results @@ -243,7 +244,7 @@ def indifferent_lso_interaction(provisioning_step: Step) -> StepList: >> _inventory_is_not_empty( begin >> callback_step( - name="Running Ansible playbook", action_step=_execute_playbook, validate_step=_ignore_results + name=RUNNING_ANSIBLE_PLAYBOOK_STEP_NAME, action_step=_execute_playbook, validate_step=_ignore_results ) >> step("Inject result title")(lambda: {"lso_result_title": provisioning_step.name}) >> _show_results @@ -268,7 +269,9 @@ def anonymous_lso_interaction(provisioning_step: Step, validation_step: Step = _ begin >> provisioning_step >> _inventory_is_not_empty( - callback_step(name="Running Ansible playbook", action_step=_execute_playbook, validate_step=validation_step) + callback_step( + name=RUNNING_ANSIBLE_PLAYBOOK_STEP_NAME, action_step=_execute_playbook, validate_step=validation_step + ) ) >> _clean_state ) @@ -287,7 +290,7 @@ def anonymous_indifferent_lso_interaction(provisioning_step: Step) -> StepList: >> provisioning_step >> _inventory_is_not_empty( callback_step( - name="Running Ansible playbook", + name=RUNNING_ANSIBLE_PLAYBOOK_STEP_NAME, action_step=_execute_playbook, validate_step=_ignore_results, )