diff --git a/gso/workflows/router/promote_p_to_pe.py b/gso/workflows/router/promote_p_to_pe.py index 8fdc746f44837fb6ba051be65d286087ab31ac0a..9df27c9754bb642d6ebe747014b5a8eb1f23dff7 100644 --- a/gso/workflows/router/promote_p_to_pe.py +++ b/gso/workflows/router/promote_p_to_pe.py @@ -246,6 +246,42 @@ def delete_default_routes_real(subscription: dict[str, Any], tt_number: str, pro } +@step("[DRY RUN] Add PE static routes") +def add_pe_static_routes_dry(subscription: dict[str, Any], tt_number: str, process_id: UUIDstr) -> LSOState: + """Perform a dry run of adding the PE static routes.""" + extra_vars = { + "dry_run": True, + "subscription": subscription, + "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - " + f"Delete static default routes (part of P base-config)", + "verb": "add_pe_static_routes", + } + + return { + "playbook_name": "gap_ansible/playbooks/promote_p_to_pe.yaml", + "inventory": {"all": {"hosts": {subscription["router"]["router_fqdn"]: None}}}, + "extra_vars": extra_vars, + } + + +@step("[FOR REAL] Add PE static routes") +def add_pe_static_routes_real(subscription: dict[str, Any], tt_number: str, process_id: UUIDstr) -> LSOState: + """Perform a real run of adding the PE static routes.""" + extra_vars = { + "dry_run": False, + "subscription": subscription, + "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - " + f"Delete static default routes (part of P base-config)", + "verb": "add_pe_static_routes", + } + + return { + "playbook_name": "gap_ansible/playbooks/promote_p_to_pe.yaml", + "inventory": {"all": {"hosts": {subscription["router"]["router_fqdn"]: None}}}, + "extra_vars": extra_vars, + } + + @workflow( "Promote P router to PE router", initial_input_form=wrap_modify_initial_input_form(initial_input_form_generator), @@ -280,6 +316,8 @@ def promote_p_to_pe() -> StepList: >> lso_interaction(add_pe_to_all_p_real) >> lso_interaction(delete_default_routes_dry) >> lso_interaction(delete_default_routes_real) + >> lso_interaction(add_pe_static_routes_dry) + >> lso_interaction(add_pe_static_routes_real) >> lso_interaction(run_post_checks) >> update_subscription_model >> resync diff --git a/test/workflows/router/test_promote_p_to_pe.py b/test/workflows/router/test_promote_p_to_pe.py index 9446d17c6f3e33dbb90a7cfcfa6e9adefac734e8..3a8d3be9c8ff7714c26833bbd01a79388ad8167e 100644 --- a/test/workflows/router/test_promote_p_to_pe.py +++ b/test/workflows/router/test_promote_p_to_pe.py @@ -40,11 +40,11 @@ def test_promote_p_to_pe_success( for _ in range(3): result, step_log = assert_lso_interaction_success(result, process_stat, step_log) result, step_log = resume_workflow(process_stat, step_log, input_data=USER_CONFIRM_EMPTY_FORM) - for _ in range(19): + for _ in range(21): result, step_log = assert_lso_interaction_success(result, process_stat, step_log) state = extract_state(result) assert_complete(result) - assert mock_execute_playbook.call_count == 22 + assert mock_execute_playbook.call_count == 24 assert state["subscription"]["router"]["router_role"] == RouterRole.PE