Skip to content
Snippets Groups Projects
Verified Commit 0eb62fe2 authored by Aleksandr Kurbatov's avatar Aleksandr Kurbatov Committed by Karel van Klink
Browse files

Patch to `create_nren_l3_core_service` from `update-nren-l3-lso-interaction`

parent 54a33604
No related branches found
No related tags found
1 merge request!298Add BFD configuration to Service binding ports
......@@ -19,6 +19,7 @@ from gso.products.product_blocks.service_binding_port import ServiceBindingPortI
from gso.products.product_types.edge_port import EdgePort
from gso.products.product_types.nren_l3_core_service import NRENL3CoreService, NRENL3CoreServiceInactive
from gso.services.lso_client import LSOState, lso_interaction
from gso.services.partners import get_partner_by_id
from gso.utils.helpers import (
active_edge_port_selector,
partner_choice,
......@@ -148,60 +149,56 @@ def create_subscription(product: UUIDstr, partner: str) -> State:
@step("Initialize subscription")
def initialize_subscription(
subscription: NRENL3CoreServiceInactive, edge_ports: list[dict], binding_port_inputs: list[dict], product_name: str
subscription: NRENL3CoreServiceInactive, edge_port: dict, binding_port_input: dict, product_name: str
) -> State:
"""Take all user inputs and use them to populate the subscription model."""
edge_port_fqdn_list = []
for edge_port_input, sbp_input in zip(edge_ports, binding_port_inputs, strict=False):
edge_port_subscription = EdgePort.from_subscription(edge_port_input["edge_port"])
sbp_bgp_session_list = []
for session in sbp_input["bgp_peers"]:
bfd_settings = BFDSettings.new(subscription_id=uuid4(), **session.pop("bfd_settings"))
sbp_bgp_session_list.append(
BGPSession.new(
subscription_id=uuid4(), **session, bfd_settings=bfd_settings, rtbh_enabled=True, is_multi_hop=True
)
)
v4_bfd_settings = BFDSettings.new(subscription_id=uuid4(), **sbp_input.pop("v4_bfd_settings"))
v6_bfd_settings = BFDSettings.new(subscription_id=uuid4(), **sbp_input.pop("v6_bfd_settings"))
service_binding_port = ServiceBindingPortInactive.new(
edge_port_subscription = EdgePort.from_subscription(edge_port["edge_port"])
sbp_bgp_session_list = [
BGPSession.new(subscription_id=uuid4(), **session, rtbh_enabled=True, is_multi_hop=True)
for session in binding_port_input["bgp_peers"]
]
service_binding_port = ServiceBindingPortInactive.new(
subscription_id=uuid4(),
**binding_port_input,
bgp_session_list=sbp_bgp_session_list,
sbp_type=SBPType.L3,
edge_port=edge_port_subscription.edge_port,
)
subscription.nren_l3_core_service.nren_ap_list.append(
NRENAccessPortInactive.new(
subscription_id=uuid4(),
**sbp_input,
v4_bfd_settings=v4_bfd_settings,
v6_bfd_settings=v6_bfd_settings,
bgp_session_list=sbp_bgp_session_list,
sbp_type=SBPType.L3,
edge_port=edge_port_subscription.edge_port,
ap_type=edge_port["ap_type"],
sbp=service_binding_port,
)
subscription.nren_l3_core_service.nren_ap_list.append(
NRENAccessPortInactive.new(
subscription_id=uuid4(),
ap_type=edge_port_input["ap_type"],
sbp=service_binding_port,
)
)
edge_port_fqdn_list.append(edge_port_subscription.edge_port.node.router_fqdn)
)
edge_port_fqdn_list.append(edge_port_subscription.edge_port.node.router_fqdn)
subscription.description = f"{product_name} service"
partner_name = get_partner_by_id(subscription.customer_id).name
return {"subscription": subscription, "edge_port_fqdn_list": edge_port_fqdn_list}
return {"subscription": subscription, "edge_port_fqdn_list": edge_port_fqdn_list, "partner_name": partner_name}
@step("[DRY RUN] Deploy service binding port")
def provision_sbp_dry(
subscription: dict[str, Any], process_id: UUIDstr, tt_number: str, edge_port_fqdn_list: list[str]
subscription: dict[str, Any], process_id: UUIDstr, tt_number: str, edge_port_fqdn_list: list[str],
partner_name: str
) -> LSOState:
"""Perform a dry run of deploying Service Binding Ports."""
extra_vars = {
"subscription": subscription,
"partner_name": partner_name,
"dry_run": True,
"verb": "deploy",
"object": "sbp",
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
f"Deploy config for {subscription["description"]}",
}
return {
"playbook_name": "manage_sbp.yaml",
"playbook_name": "gap_ansible/playbooks/nren_l3_core_service.yaml",
"inventory": {"all": {"hosts": dict.fromkeys(edge_port_fqdn_list)}},
"extra_vars": extra_vars,
}
......@@ -209,19 +206,22 @@ def provision_sbp_dry(
@step("[FOR REAL] Deploy service binding port")
def provision_sbp_real(
subscription: dict[str, Any], process_id: UUIDstr, tt_number: str, edge_port_fqdn_list: list[str]
subscription: dict[str, Any], process_id: UUIDstr, tt_number: str, edge_port_fqdn_list: list[str],
partner_name: str
) -> LSOState:
"""Deploy Service Binding Ports."""
extra_vars = {
"subscription": subscription,
"partner_name": partner_name,
"dry_run": False,
"verb": "deploy",
"object": "sbp",
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
f"Deploy config for {subscription["description"]}",
}
return {
"playbook_name": "manage_sbp.yaml",
"playbook_name": "gap_ansible/playbooks/nren_l3_core_service.yaml",
"inventory": {"all": {"hosts": dict.fromkeys(edge_port_fqdn_list)}},
"extra_vars": extra_vars,
}
......@@ -230,10 +230,10 @@ def provision_sbp_real(
@step("Check service binding port functionality")
def check_sbp_functionality(subscription: dict[str, Any], edge_port_fqdn_list: list[str]) -> LSOState:
"""Check functionality of deployed Service Binding Ports."""
extra_vars = {"subscription": subscription, "verb": "check"}
extra_vars = {"subscription": subscription, "verb": "check", "object": "sbp"}
return {
"playbook_name": "manage_sbp.yaml",
"playbook_name": "gap_ansible/playbooks/nren_l3_core_service.yaml",
"inventory": {"all": {"hosts": dict.fromkeys(edge_port_fqdn_list)}},
"extra_vars": extra_vars,
}
......@@ -241,19 +241,22 @@ def check_sbp_functionality(subscription: dict[str, Any], edge_port_fqdn_list: l
@step("[DRY RUN] Deploy BGP peers")
def deploy_bgp_peers_dry(
subscription: dict[str, Any], edge_port_fqdn_list: list[str], tt_number: str, process_id: UUIDstr
subscription: dict[str, Any], edge_port_fqdn_list: list[str], tt_number: str, process_id: UUIDstr,
partner_name: str
) -> LSOState:
"""Perform a dry run of deploying :term:`BGP` peers."""
extra_vars = {
"subscription": subscription,
"partner_name": partner_name,
"verb": "deploy",
"object": "bgp",
"dry_run": True,
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
f"Deploying BGP peers for {subscription["description"]}",
}
return {
"playbook_name": "manage_sbp.yaml",
"playbook_name": "gap_ansible/playbooks/nren_l3_core_service.yaml",
"inventory": {"all": {"hosts": dict.fromkeys(edge_port_fqdn_list)}},
"extra_vars": extra_vars,
}
......@@ -261,19 +264,22 @@ def deploy_bgp_peers_dry(
@step("[FOR REAL] Deploy BGP peers")
def deploy_bgp_peers_real(
subscription: dict[str, Any], edge_port_fqdn_list: list[str], tt_number: str, process_id: UUIDstr
subscription: dict[str, Any], edge_port_fqdn_list: list[str], tt_number: str, process_id: UUIDstr,
partner_name: str
) -> LSOState:
"""Deploy :term:`BGP` peers."""
extra_vars = {
"subscription": subscription,
"partner_name": partner_name,
"verb": "deploy",
"object": "bgp",
"dry_run": False,
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - "
f"Deploying BGP peers for {subscription["description"]}",
}
return {
"playbook_name": "manage_sbp.yaml",
"playbook_name": "gap_ansible/playbooks/nren_l3_core_service.yaml",
"inventory": {"all": {"hosts": dict.fromkeys(edge_port_fqdn_list)}},
"extra_vars": extra_vars,
}
......@@ -282,10 +288,10 @@ def deploy_bgp_peers_real(
@step("Check BGP peers")
def check_bgp_peers(subscription: dict[str, Any], edge_port_fqdn_list: list[str]) -> LSOState:
"""Check correct deployment of :term:`BGP` peers."""
extra_vars = {"subscription": subscription, "verb": "check"}
extra_vars = {"subscription": subscription, "verb": "check", "object": "bgp"}
return {
"playbook_name": "manage_sbp.yaml",
"playbook_name": "gap_ansible/playbooks/nren_l3_core_service.yaml",
"inventory": {"all": {"hosts": dict.fromkeys(edge_port_fqdn_list)}},
"extra_vars": extra_vars,
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment