From c81382f05746619378bf0f00e7b4f19f2cf87f15 Mon Sep 17 00:00:00 2001 From: Karel van Klink <karel.vanklink@geant.org> Date: Wed, 8 May 2024 14:16:40 +0200 Subject: [PATCH] Add new sharepoint interaction to iptrunk creation workflow --- gso/workflows/iptrunk/create_iptrunk.py | 32 ++++++++++--------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/gso/workflows/iptrunk/create_iptrunk.py b/gso/workflows/iptrunk/create_iptrunk.py index b1fc64c5..ee3234a2 100644 --- a/gso/workflows/iptrunk/create_iptrunk.py +++ b/gso/workflows/iptrunk/create_iptrunk.py @@ -5,13 +5,12 @@ from typing import Annotated from uuid import uuid4 from annotated_types import Len -from orchestrator.config.assignee import Assignee from orchestrator.forms import FormPage from orchestrator.forms.validators import Choice, Label 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, inputstep, step, workflow +from orchestrator.workflow import StepList, conditional, done, init, 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 AfterValidator, ConfigDict, field_validator @@ -30,6 +29,7 @@ from gso.services import infoblox, subscriptions from gso.services.lso_client import execute_playbook, lso_interaction from gso.services.netbox_client import NetboxClient from gso.services.partners import get_partner_by_name +from gso.services.sharepoint import SharePointClient from gso.settings import load_oss_params from gso.utils.helpers import ( LAGMember, @@ -42,6 +42,7 @@ from gso.utils.helpers import ( validate_tt_number, ) from gso.utils.shared_enums import Vendor +from gso.utils.workflow_steps import prompt_sharepoint_checklist_url def initial_input_form_generator(product_name: str) -> FormGenerator: @@ -492,24 +493,14 @@ 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): - model_config = ConfigDict(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 " - 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." - - yield SharepointPrompt +@step("Create a new SharePoint checklist item") +def create_new_sharepoint_checklist(subscription: IptrunkProvisioning, tt_number: str) -> State: + """Create a new checklist item in SharePoint for approving this IPtrunk.""" + new_list_item_url = SharePointClient().add_list_item( + "ip_trunk", {"Title": subscription.iptrunk.iptrunk_description, "TT_NUMBER": tt_number} + ) - return {} + return {"checklist_url": new_list_item_url} @workflow( @@ -550,7 +541,8 @@ 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 + >> create_new_sharepoint_checklist + >> prompt_sharepoint_checklist_url >> resync >> done ) -- GitLab