Skip to content
Snippets Groups Projects
Verified Commit 7e0ec004 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Update LSO interactions in switch creation workflow

parent 309c7a8a
No related branches found
No related tags found
1 merge request!300Feature/lan switch interconnect
...@@ -17,13 +17,14 @@ from gso.products.product_blocks.switch import SwitchModel ...@@ -17,13 +17,14 @@ from gso.products.product_blocks.switch import SwitchModel
from gso.products.product_types.site import Site from gso.products.product_types.site import Site
from gso.products.product_types.switch import SwitchInactive from gso.products.product_types.switch import SwitchInactive
from gso.services import infoblox from gso.services import infoblox
from gso.services.lso_client import execute_playbook, lso_interaction from gso.services.lso_client import LSOState, lso_interaction
from gso.services.partners import get_partner_by_name from gso.services.partners import get_partner_by_name
from gso.services.sharepoint import SharePointClient from gso.services.sharepoint import SharePointClient
from gso.settings import load_oss_params from gso.settings import load_oss_params
from gso.utils.helpers import active_site_selector, generate_fqdn from gso.utils.helpers import active_site_selector, generate_fqdn
from gso.utils.shared_enums import PortNumber, Vendor from gso.utils.shared_enums import Vendor
from gso.utils.types import TTNumber from gso.utils.types.ip_address import PortNumber
from gso.utils.types.tt_number import TTNumber
from gso.utils.workflow_steps import prompt_sharepoint_checklist_url from gso.utils.workflow_steps import prompt_sharepoint_checklist_url
...@@ -34,6 +35,7 @@ def _initial_input_form_generator(product_name: str) -> FormGenerator: ...@@ -34,6 +35,7 @@ def _initial_input_form_generator(product_name: str) -> FormGenerator:
model_config = ConfigDict(title=product_name) model_config = ConfigDict(title=product_name)
tt_number: TTNumber tt_number: TTNumber
partner: ReadOnlyField("GEANT", default_type=str) # type: ignore[valid-type]
switch_site: active_site_selector() # type: ignore[valid-type] switch_site: active_site_selector() # type: ignore[valid-type]
hostname: str hostname: str
ts_port: PortNumber ts_port: PortNumber
...@@ -63,7 +65,7 @@ def create_subscription(product: UUIDstr, partner: str) -> State: ...@@ -63,7 +65,7 @@ def create_subscription(product: UUIDstr, partner: str) -> State:
"""Create a new subscription object.""" """Create a new subscription object."""
subscription = SwitchInactive.from_product_id(product, get_partner_by_name(partner)["partner_id"]) subscription = SwitchInactive.from_product_id(product, get_partner_by_name(partner)["partner_id"])
return {"subscription": subscription} return {"subscription": subscription, "subscription_id": subscription.subscription_id}
@step("Initialize subscription") @step("Initialize subscription")
...@@ -76,11 +78,11 @@ def initialize_subscription( ...@@ -76,11 +78,11 @@ def initialize_subscription(
hostname: str, hostname: str,
) -> State: ) -> State:
"""Initialize the subscription with user input.""" """Initialize the subscription with user input."""
subscription.switch.switch_site = Site.from_subscription(switch_site).site subscription.switch.site = Site.from_subscription(switch_site).site
subscription.switch.switch_fqdn = generate_fqdn( subscription.switch.fqdn = generate_fqdn(
hostname, subscription.switch.switch_site.site_name, subscription.switch.switch_site.site_country_code hostname, subscription.switch.site.site_name, subscription.switch.site.site_country_code
) )
subscription.switch.switch_ts_port = ts_port subscription.switch.ts_port = ts_port
subscription.switch.switch_vendor = vendor subscription.switch.switch_vendor = vendor
subscription.switch.switch_model = model subscription.switch.switch_model = model
...@@ -88,10 +90,8 @@ def initialize_subscription( ...@@ -88,10 +90,8 @@ def initialize_subscription(
@step("[DRY RUN] Deploy base config") @step("[DRY RUN] Deploy base config")
def deploy_base_config_dry(subscription: dict, tt_number: str, callback_route: str, process_id: UUIDstr) -> None: def deploy_base_config_dry(subscription: dict, tt_number: str, process_id: UUIDstr) -> LSOState:
"""Perform a dry run of provisioning base config on a switch.""" """Perform a dry run of provisioning base config on a switch."""
inventory = subscription["switch"]["switch_fqdn"]
extra_vars = { extra_vars = {
"subscription_json": subscription, "subscription_json": subscription,
"dry_run": True, "dry_run": True,
...@@ -99,19 +99,16 @@ def deploy_base_config_dry(subscription: dict, tt_number: str, callback_route: s ...@@ -99,19 +99,16 @@ def deploy_base_config_dry(subscription: dict, tt_number: str, callback_route: s
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy base config", "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy base config",
} }
execute_playbook( return {
playbook_name="switch_base_config.yaml", "playbook_name": "switch_base_config.yaml",
callback_route=callback_route, "extra_vars": extra_vars,
inventory=inventory, "inventory": {"all": {"hosts": {subscription["switch"]["fqdn"]: None}}},
extra_vars=extra_vars, }
)
@step("[FOR REAL] Deploy base config") @step("[FOR REAL] Deploy base config")
def deploy_base_config_real(subscription: dict, tt_number: str, callback_route: str, process_id: UUIDstr) -> None: def deploy_base_config_real(subscription: dict, tt_number: str, process_id: UUIDstr) -> LSOState:
"""Provision base config on a switch.""" """Provision base config on a switch."""
inventory = subscription["switch"]["switch_fqdn"]
extra_vars = { extra_vars = {
"subscription_json": subscription, "subscription_json": subscription,
"dry_run": False, "dry_run": False,
...@@ -119,12 +116,11 @@ def deploy_base_config_real(subscription: dict, tt_number: str, callback_route: ...@@ -119,12 +116,11 @@ def deploy_base_config_real(subscription: dict, tt_number: str, callback_route:
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy base config", "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy base config",
} }
execute_playbook( return {
playbook_name="switch_base_config.yaml", "playbook_name": "switch_base_config.yaml",
callback_route=callback_route, "extra_vars": extra_vars,
inventory=inventory, "inventory": {"all": {"hosts": {subscription["switch"]["fqdn"]: None}}},
extra_vars=extra_vars, }
)
@inputstep("Prompt for console login", assignee=Assignee.SYSTEM) @inputstep("Prompt for console login", assignee=Assignee.SYSTEM)
...@@ -161,27 +157,26 @@ def create_netbox_device() -> State: ...@@ -161,27 +157,26 @@ def create_netbox_device() -> State:
@step("Run post-deployment checks") @step("Run post-deployment checks")
def run_post_deploy_checks(subscription: dict, callback_route: str) -> None: def run_post_deploy_checks(subscription: dict) -> LSOState:
"""Workflow step for running checks after installing base config.""" """Workflow step for running checks after installing base config."""
execute_playbook( return {
playbook_name="switch_base_config_checks.yaml", "playbook_name": "switch_base_config_checks.yaml",
callback_route=callback_route, "extra_vars": {"subscription_json": subscription},
inventory=subscription["switch"]["switch_fqdn"], "inventory": {"all": {"hosts": {subscription["switch"]["fqdn"]: None}}},
extra_vars={"subscription_json": subscription}, }
)
@step("Create a new SharePoint checklist") @step("Create a new SharePoint checklist")
def create_new_sharepoint_checklist(subscription: SwitchInactive, tt_number: str, process_id: UUIDstr) -> State: def create_new_sharepoint_checklist(subscription: SwitchInactive, tt_number: str, process_id: UUIDstr) -> State:
"""Create a new checklist in SharePoint for approving this router.""" """Create a new checklist in SharePoint for approving this router."""
if not subscription.switch.switch_fqdn: if not subscription.switch.fqdn:
msg = "Switch is missing an FQDN." msg = "Switch is missing an FQDN."
raise ProcessFailureError(msg, details=subscription.subscription_id) raise ProcessFailureError(msg, details=subscription.subscription_id)
new_list_item_url = SharePointClient().add_list_item( new_list_item_url = SharePointClient().add_list_item(
list_name="switch", list_name="switch",
fields={ fields={
"Title": subscription.switch.switch_fqdn, "Title": subscription.switch.fqdn,
"TT_NUMBER": tt_number, "TT_NUMBER": tt_number,
"GAP_PROCESS_URL": f"{load_oss_params().GENERAL.public_hostname}/workflows/{process_id}", "GAP_PROCESS_URL": f"{load_oss_params().GENERAL.public_hostname}/workflows/{process_id}",
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment