Skip to content
Snippets Groups Projects
Commit 9185644e authored by Aleksandr Kurbatov's avatar Aleksandr Kurbatov
Browse files

Updated `promote_p_to_pe`

Changes:
- sequence of steps
- small changes in steps extra_vars, inventories, verbs, descriptions
parent f6c3d6af
No related branches found
Tags 2.27
1 merge request!260Updated `promote_p_to_pe`
Pipeline #88652 failed
......@@ -10,7 +10,7 @@ from orchestrator.targets import Target
from orchestrator.types import FormGenerator, State, UUIDstr
from orchestrator.utils.errors import ProcessFailureError
from orchestrator.utils.json import json_dumps
from orchestrator.workflow import StepList, begin, done, inputstep, step, workflow
from orchestrator.workflow import StepList, begin, conditional, done, inputstep, step, workflow
from orchestrator.workflows.steps import resync, store_process_subscription, unsync
from orchestrator.workflows.utils import wrap_modify_initial_input_form
from pydantic import ConfigDict, model_validator
......@@ -158,7 +158,7 @@ def create_kentik_device(subscription: Router) -> State:
return {"kentik_device": kentik_device}
@step("[DRY RUN] Update SDP mesh")
@step("[DRY RUN] Include new PE into SDP mesh on other Nokia PEs")
def update_sdp_mesh_dry(subscription: dict[str, Any], callback_route: str, tt_number: str, process_id: UUIDstr) -> None:
"""Perform a dry run for updating the SDP mesh with the new router."""
extra_vars = {
......@@ -167,20 +167,19 @@ def update_sdp_mesh_dry(subscription: dict[str, Any], callback_route: str, tt_nu
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
f"Update the SDP mesh for L2circuits(epipes) config on PE NOKIA routers",
"verb": "update_sdp_mesh",
"pe_router_list": generate_inventory_for_active_routers(router_role=RouterRole.PE, router_vendor=Vendor.NOKIA)[
"all"
]["hosts"],
"pe_router_list": {subscription["router"]["router_fqdn"]: {"lo4": str(subscription["router"]["router_lo_ipv4_address"]),
"lo6": str(subscription["router"]["router_lo_ipv6_address"])}}
}
lso_client.execute_playbook(
playbook_name="update_pe_sdp_mesh.yaml",
callback_route=callback_route,
inventory=generate_inventory_for_active_routers(RouterRole.PE),
inventory=generate_inventory_for_active_routers(router_role=RouterRole.PE, router_vendor=Vendor.NOKIA),
extra_vars=extra_vars,
)
@step("[FOR REAL] Update SDP mesh")
@step("[FOR REAL] Include new PE into SDP mesh on other Nokia PEs")
def update_sdp_mesh_real(
subscription: dict[str, Any], callback_route: str, tt_number: str, process_id: UUIDstr
) -> None:
......@@ -191,29 +190,28 @@ def update_sdp_mesh_real(
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
f"Update the SDP mesh for l2circuits(epipes) config on PE NOKIA routers",
"verb": "update_sdp_mesh",
"pe_router_list": generate_inventory_for_active_routers(router_role=RouterRole.PE, router_vendor=Vendor.NOKIA)[
"all"
]["hosts"],
"pe_router_list": {subscription["router"]["router_fqdn"]: {"lo4": str(subscription["router"]["router_lo_ipv4_address"]),
"lo6": str(subscription["router"]["router_lo_ipv6_address"])}}
}
lso_client.execute_playbook(
playbook_name="update_pe_sdp_mesh.yaml",
callback_route=callback_route,
inventory=generate_inventory_for_active_routers(RouterRole.PE),
inventory=generate_inventory_for_active_routers(router_role=RouterRole.PE, router_vendor=Vendor.NOKIA),
extra_vars=extra_vars,
)
@step("[DRY RUN] Remove P from P")
@step("[DRY RUN] Remove P from all PEs")
def remove_p_from_pe_dry(
subscription: dict[str, Any], callback_route: str, tt_number: str, process_id: UUIDstr
) -> None:
"""Perform a dry run of removing the P routers from the PE router."""
"""Perform a dry run of removing the P router from all the PE routers."""
extra_vars = {
"dry_run": True,
"subscription": subscription,
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
f"Remove P only roter neighbour {subscription["router"]["router_fqdn"]} from P only group",
f"Remove P-only router neighbour {subscription["router"]["router_fqdn"]} from PE routers P-only group",
"verb": "remove_p_from_pe",
}
......@@ -225,16 +223,16 @@ def remove_p_from_pe_dry(
)
@step("[FOR REAL] Remove P from PE")
@step("[FOR REAL] Remove P from all PEs")
def remove_p_from_pe_real(
subscription: dict[str, Any], callback_route: str, tt_number: str, process_id: UUIDstr
) -> None:
"""Remove the P routers from the PE router."""
"""Remove the P router from all the PE routers."""
extra_vars = {
"dry_run": False,
"subscription": subscription,
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
f"Remove P only roter neighbour {subscription["router"]["router_fqdn"]} from P only group",
f"Remove P-only router neighbour {subscription["router"]["router_fqdn"]} from PE routers P-only group",
"verb": "remove_p_from_pe",
}
......@@ -299,7 +297,7 @@ def add_pe_to_pe_mesh_dry(
"dry_run": True,
"subscription": subscription,
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
f"Add promoted router to all PE routers in iGEANT/iGEANT.",
f"Add promoted router to all PE routers in iGEANT/iGEANT6.",
"verb": "add_pe_to_pe_mesh",
}
......@@ -320,7 +318,7 @@ def add_pe_to_pe_mesh_real(
"dry_run": False,
"subscription": subscription,
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
f"Add promoted router to all PE routers in iGEANT/iGEANT.",
f"Add promoted router to all PE routers in iGEANT/iGEANT6.",
"verb": "add_pe_to_pe_mesh",
}
......@@ -482,7 +480,7 @@ def add_pe_to_all_p_dry(subscription: dict[str, Any], callback_route: str, tt_nu
"subscription": subscription,
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
f"Add promoted router to all PE routers in iGEANT/iGEANT6",
"verb": "add_pe_to_p",
"verb": "add_pe_to_all_p",
}
lso_client.execute_playbook(
......@@ -503,7 +501,7 @@ def add_pe_to_all_p_real(
"subscription": subscription,
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
f"Add promoted router to all PE routers in iGEANT/iGEANT6",
"verb": "add_pe_to_p",
"verb": "add_pe_to_all_p",
}
lso_client.execute_playbook(
......@@ -563,17 +561,20 @@ def delete_default_routes_real(
)
def promote_p_to_pe() -> StepList:
"""Promote a P router to a PE router."""
router_is_juniper = conditional(lambda state: state["subscription"]["router"]["vendor"] == Vendor.JUNIPER)
router_is_pe = conditional(lambda state: state["subscription"]["router"]["router_role"] == RouterRole.PE)
return (
begin
>> store_process_subscription(Target.MODIFY)
>> router_is_juniper(done)
>> router_is_pe(done)
>> unsync
>> lso_interaction(set_isis_overload)
>> lso_interaction(deploy_pe_base_config_dry)
>> lso_interaction(deploy_pe_base_config_real)
>> prompt_insert_in_earl
>> create_kentik_device
>> lso_interaction(update_sdp_mesh_dry)
>> lso_interaction(update_sdp_mesh_real)
>> lso_interaction(remove_p_from_pe_dry)
>> lso_interaction(remove_p_from_pe_real)
>> lso_interaction(add_pe_mesh_to_pe_dry)
......@@ -584,14 +585,16 @@ def promote_p_to_pe() -> StepList:
>> lso_interaction(deploy_routing_instances_dry)
>> lso_interaction(deploy_routing_instances_real)
>> lso_interaction(check_l3_services)
>> lso_interaction(remove_isis_overload)
>> update_subscription_model
>> lso_interaction(update_sdp_mesh_dry)
>> lso_interaction(update_sdp_mesh_real)
>> lso_interaction(add_all_p_to_pe_dry)
>> lso_interaction(add_all_p_to_pe_real)
>> lso_interaction(add_pe_to_all_p_dry)
>> lso_interaction(add_pe_to_all_p_real)
>> lso_interaction(delete_default_routes_dry)
>> lso_interaction(delete_default_routes_real)
>> lso_interaction(remove_isis_overload)
>> update_subscription_model
>> resync
>> done
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment