Skip to content
Snippets Groups Projects
Commit 03d0fcda authored by Aleksandr Kurbatov's avatar Aleksandr Kurbatov Committed by Aleksandr Kurbatov
Browse files

SDP mesh functions

- Externalized `update_sdp_mesh_dry` and `_real` into `workflow_steps`
- Added `_update_sdp_single_pe` into `workflow_steps`
- Added necessary imports
parent 65e88e3d
No related branches found
No related tags found
1 merge request!267SDP mesh functions
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import json import json
from typing import Any from typing import Any
from gso.products.product_blocks import router
from orchestrator import inputstep, step from orchestrator import inputstep, step
from orchestrator.config.assignee import Assignee from orchestrator.config.assignee import Assignee
from orchestrator.types import State, UUIDstr from orchestrator.types import State, UUIDstr
...@@ -15,6 +16,7 @@ from pydantic_forms.validators import Label ...@@ -15,6 +16,7 @@ from pydantic_forms.validators import Label
from gso.products.product_types.iptrunk import Iptrunk from gso.products.product_types.iptrunk import Iptrunk
from gso.services import lso_client from gso.services import lso_client
from gso.settings import load_oss_params from gso.settings import load_oss_params
from gso.utils.helpers import generate_inventory_for_active_routers
def _deploy_base_config( def _deploy_base_config(
...@@ -42,6 +44,67 @@ def _deploy_base_config( ...@@ -42,6 +44,67 @@ def _deploy_base_config(
) )
def _update_sdp_mesh(
subscription: dict[str, Any],
callback_route: str,
tt_number: str,
process_id: UUIDstr,
dry_run: bool
) -> None:
inventory=generate_inventory_for_active_routers(
router_role=RouterRole.PE,
router_vendor=Vendor.NOKIA,
exclude_routers=[subscription["router"]["router_fqdn"]]
)
extra_vars = {
"dry_run": dry_run,
"subscription": subscription,
"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": {
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=inventory,
extra_vars=extra_vars,
)
def _update_sdp_single_pe(
subscription: dict[str, Any],
callback_route: str,
tt_number: str,
process_id: UUIDstr,
dry_run: bool
) -> None:
inventory=subscription["router"]["router_fqdn"]
extra_vars = {
"dry_run": dry_run,
"subscription": subscription,
"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.RouterRole.PE, exclude_routers=[subscription["router"]["router_fqdn"]]
)
}
lso_client.execute_playbook(
playbook_name="update_pe_sdp_mesh.yaml",
callback_route=callback_route,
inventory=inventory,
extra_vars=extra_vars,
)
@step("[DRY RUN] Deploy base config") @step("[DRY RUN] Deploy base config")
def deploy_base_config_dry( def deploy_base_config_dry(
subscription: dict[str, Any], subscription: dict[str, Any],
...@@ -68,6 +131,57 @@ def deploy_base_config_real( ...@@ -68,6 +131,57 @@ def deploy_base_config_real(
return {"subscription": subscription} return {"subscription": subscription}
@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
) -> State:
"""Perform a dry run of including new PE router in SDP mesh on other NOKIA PE routers"""
_update_sdp_mesh(subscription, tt_number, callback_route, process_id, dry_run=True)
return {"subscription": subscription}
@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
) -> State:
"""Include new PE router in SDP mesh on other NOKIA PE routers."""
_update_sdp_mesh(subscription, tt_number, callback_route, process_id, dry_run=False)
return {"subscription": subscription}
@step("[DRY RUN] Configure SDP on a new PE to all other Nokia PEs")
def update_sdp_single_pe_dry(
subscription: dict[str, Any],
callback_route: str,
tt_number: str,
process_id: UUIDstr
) -> State:
"""Perform a dry run of configuring SDP on a new PE router to all other NOKIA PE routers"""
_update_sdp_single_pe(subscription, tt_number, callback_route, process_id, dry_run=True)
return {"subscription": subscription}
@step("[FOR REAL] Configure SDP on a new PE to all other Nokia PEs")
def update_sdp_single_pe_real(
subscription: dict[str, Any],
callback_route: str,
tt_number: str,
process_id: UUIDstr
) -> State:
"""Configure SDP on a new PE router to all other NOKIA PE routers."""
_update_sdp_single_pe(subscription, tt_number, callback_route, process_id, dry_run=False)
return {"subscription": subscription}
@step("[FOR REAL] Set ISIS metric to very high value") @step("[FOR REAL] Set ISIS metric to very high value")
def set_isis_to_max(subscription: Iptrunk, process_id: UUIDstr, callback_route: str, tt_number: str) -> State: def set_isis_to_max(subscription: Iptrunk, process_id: UUIDstr, callback_route: str, tt_number: str) -> State:
"""Workflow step for setting the :term:`ISIS` metric to an arbitrarily high value to drain a link.""" """Workflow step for setting the :term:`ISIS` metric to an arbitrarily high value to drain a link."""
......
...@@ -24,7 +24,10 @@ from gso.services.subscriptions import get_all_active_sites ...@@ -24,7 +24,10 @@ from gso.services.subscriptions import get_all_active_sites
from gso.utils.helpers import generate_inventory_for_active_routers from gso.utils.helpers import generate_inventory_for_active_routers
from gso.utils.shared_enums import Vendor from gso.utils.shared_enums import Vendor
from gso.utils.types.tt_number import TTNumber from gso.utils.types.tt_number import TTNumber
from gso.utils.workflow_steps import (
update_sdp_mesh_dry,
update_sdp_mesh_real,
)
def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
"""Promote P router to PE router.""" """Promote P router to PE router."""
...@@ -158,58 +161,6 @@ def create_kentik_device(subscription: Router) -> State: ...@@ -158,58 +161,6 @@ def create_kentik_device(subscription: Router) -> State:
return {"kentik_device": kentik_device} return {"kentik_device": kentik_device}
@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 = {
"dry_run": True,
"subscription": subscription,
"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": {
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(router_role=RouterRole.PE, router_vendor=Vendor.NOKIA),
extra_vars=extra_vars,
)
@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:
"""Update the SDP mesh for L2 circuits(epipes) config on PE NOKIA routers."""
extra_vars = {
"dry_run": False,
"subscription": subscription,
"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": {
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(router_role=RouterRole.PE, router_vendor=Vendor.NOKIA),
extra_vars=extra_vars,
)
@step("[DRY RUN] Remove P from all PEs") @step("[DRY RUN] Remove P from all PEs")
def remove_p_from_pe_dry( def remove_p_from_pe_dry(
subscription: dict[str, Any], callback_route: str, tt_number: str, process_id: UUIDstr subscription: dict[str, Any], callback_route: str, tt_number: str, process_id: UUIDstr
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment