diff --git a/gso/settings.py b/gso/settings.py index 19f5e28155c827822069b9eef96ed3a8e51f21a7..9d467618886a94a2d67a92979288518842c5288c 100644 --- a/gso/settings.py +++ b/gso/settings.py @@ -168,7 +168,7 @@ class EmailParams(BaseSettings): class SharepointParams(BaseSettings): """Settings for different Sharepoint sites.""" - # TODO: Stricter typing after pydantic 2.x upgrade + # TODO: Stricter typing after Pydantic 2.x upgrade checklist_site_url: str diff --git a/gso/workflows/iptrunk/create_iptrunk.py b/gso/workflows/iptrunk/create_iptrunk.py index e9e304d224c5a9c36314a21050bf878846c8ef70..c3b9612b2fe9552dac470cfbde8a720860f774cf 100644 --- a/gso/workflows/iptrunk/create_iptrunk.py +++ b/gso/workflows/iptrunk/create_iptrunk.py @@ -3,12 +3,13 @@ import json from uuid import uuid4 +from orchestrator.config.assignee import Assignee from orchestrator.forms import FormPage -from orchestrator.forms.validators import Choice, UniqueConstrainedList +from orchestrator.forms.validators import Choice, Label, UniqueConstrainedList from orchestrator.targets import Target from orchestrator.types import FormGenerator, State, SubscriptionLifecycle, UUIDstr from orchestrator.utils.json import json_dumps -from orchestrator.workflow import StepList, conditional, done, init, step, workflow +from orchestrator.workflow import StepList, conditional, done, init, inputstep, step, workflow from orchestrator.workflows.steps import resync, set_status, store_process_subscription from orchestrator.workflows.utils import wrap_create_initial_input_form from pydantic import validator @@ -21,12 +22,13 @@ from gso.products.product_blocks.iptrunk import ( IptrunkType, PhyPortCapacity, ) -from gso.products.product_types.iptrunk import IptrunkInactive +from gso.products.product_types.iptrunk import IptrunkInactive, IptrunkProvisioning from gso.products.product_types.router import Router from gso.services import infoblox, subscriptions from gso.services.crm import get_customer_by_name from gso.services.netbox_client import NetboxClient from gso.services.provisioning_proxy import execute_playbook, pp_interaction +from gso.settings import load_oss_params from gso.utils.helpers import ( LAGMember, available_interfaces_choices, @@ -454,6 +456,27 @@ def netbox_allocate_side_b_interfaces(subscription: IptrunkInactive) -> None: _allocate_interfaces_in_netbox(subscription.iptrunk.iptrunk_sides[1]) +@inputstep("Prompt for new Sharepoint checklist", assignee=Assignee.SYSTEM) +def prompt_start_new_checklist(subscription: IptrunkProvisioning) -> FormGenerator: + """Prompt the operator to start a new checklist in Sharepoint for approving this new IP trunk.""" + oss_params = load_oss_params() + + class SharepointPrompt(FormPage): + class Config: + title = "Start new checklist" + + info_label_1: Label = ( + f"Visit {oss_params.SHAREPOINT.checklist_site_url} and start a new Sharepoint checklist for an IPtrunk " # type: ignore[assignment] + f"from {subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn} to " + f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}." + ) + info_label_2: Label = "Once this is done, click proceed to finish the workflow." # type: ignore[assignment] + + yield SharepointPrompt + + return {} + + @workflow( "Create IP trunk", initial_input_form=wrap_create_initial_input_form(initial_input_form_generator), @@ -491,6 +514,7 @@ def create_iptrunk() -> StepList: >> side_a_is_nokia(netbox_allocate_side_a_interfaces) >> side_b_is_nokia(netbox_allocate_side_b_interfaces) >> set_status(SubscriptionLifecycle.PROVISIONING) + >> prompt_start_new_checklist >> resync >> done ) diff --git a/test/workflows/iptrunk/test_create_iptrunk.py b/test/workflows/iptrunk/test_create_iptrunk.py index b85f6d3fc586949dd07d53f5694e23d251eb69f5..b26bfbe6d68f963f96c972e5165570434e088beb 100644 --- a/test/workflows/iptrunk/test_create_iptrunk.py +++ b/test/workflows/iptrunk/test_create_iptrunk.py @@ -8,12 +8,15 @@ from gso.products.product_blocks.iptrunk import IptrunkType, PhyPortCapacity from gso.services.subscriptions import get_product_id_by_name from gso.utils.helpers import LAGMember from gso.utils.shared_enums import Vendor +from test import USER_CONFIRM_EMPTY_FORM from test.services.conftest import MockedNetboxClient from test.workflows import ( assert_complete, assert_pp_interaction_failure, assert_pp_interaction_success, + assert_suspended, extract_state, + resume_workflow, run_workflow, ) @@ -117,6 +120,9 @@ def test_successful_iptrunk_creation_with_standard_lso_result( for _ in range(6): result, step_log = assert_pp_interaction_success(result, process_stat, step_log) + assert_suspended(result) + result, step_log = resume_workflow(process_stat, step_log, input_data=USER_CONFIRM_EMPTY_FORM) + assert_complete(result) state = extract_state(result) @@ -190,4 +196,7 @@ def test_successful_iptrunk_creation_with_juniper_interface_names( for _ in range(6): result, step_log = assert_pp_interaction_success(result, process_stat, step_log) + assert_suspended(result) + result, step_log = resume_workflow(process_stat, step_log, input_data=USER_CONFIRM_EMPTY_FORM) + assert_complete(result)