diff --git a/gso/services/provisioning_proxy.py b/gso/services/provisioning_proxy.py index a3e9f2f68ceadf750ae8c2f9b7972b2da328048e..c36c5a7df7752eaa2f765eba802482051925157e 100644 --- a/gso/services/provisioning_proxy.py +++ b/gso/services/provisioning_proxy.py @@ -4,15 +4,15 @@ """ import json import logging +from functools import partial import requests -from functools import partial from orchestrator import step from orchestrator.config.assignee import Assignee from orchestrator.types import State, UUIDstr, strEnum from orchestrator.utils.errors import ProcessFailureError from orchestrator.utils.json import json_dumps -from orchestrator.workflow import Step, callback_step, begin, StepList, inputstep +from orchestrator.workflow import Step, StepList, begin, callback_step, inputstep from pydantic_forms.core import FormPage, ReadOnlyField from pydantic_forms.types import FormGenerator from pydantic_forms.validators import LongText @@ -285,8 +285,11 @@ def _show_pp_results(state: State) -> FormGenerator: def pp_interaction(provisioning_step: Step) -> StepList: - """ - An interaction with the provisioning proxy :term:`LSO` as a callback step. + """Interact with the provisioning proxy :term:`LSO` using a callback step. + + An asynchronous interaction with the provisioning proxy. This is an external system that executes Ansible playbooks + in order to provision service subscriptions. If the playbook fails, this step will also fail, allowing for the user + to retry provisioning from the UI. :param provisioning_step: A workflow step that performs an operation remotely using the provisioning proxy. :type provisioning_step: :class:`Step` diff --git a/gso/utils/helpers.py b/gso/utils/helpers.py index aa09bc82b46de0bba0ca2352d4c1992cdeb140ed..faea05440e9c012a5ad1996c513a1500e6ccfe84 100644 --- a/gso/utils/helpers.py +++ b/gso/utils/helpers.py @@ -26,10 +26,10 @@ class LAGMember(BaseModel): @step("[COMMIT] Set ISIS metric to 90.000") -def set_isis_to_90000(subscription: Iptrunk, process_id: UUIDstr, tt_number: str) -> State: +def set_isis_to_90000(subscription: Iptrunk, process_id: UUIDstr, callback_route: str, tt_number: str) -> State: old_isis_metric = subscription.iptrunk.iptrunk_isis_metric subscription.iptrunk.iptrunk_isis_metric = 90000 - provisioning_proxy.provision_ip_trunk(subscription, process_id, tt_number, "isis_interface", False) + provisioning_proxy.provision_ip_trunk(subscription, process_id, callback_route, tt_number, "isis_interface", False) return { "subscription": subscription, diff --git a/gso/workflows/router/create_router.py b/gso/workflows/router/create_router.py index 1f452e053cbf4ac225a2fbeddc8f12f2eec88cbb..3f681a0266a2242ff80007ea4eb4769009142827 100644 --- a/gso/workflows/router/create_router.py +++ b/gso/workflows/router/create_router.py @@ -1,4 +1,3 @@ -import secrets from ipaddress import IPv4Network, IPv6Network from typing import Any @@ -7,7 +6,7 @@ from orchestrator.forms import FormPage from orchestrator.forms.validators import Choice from orchestrator.targets import Target from orchestrator.types import FormGenerator, State, SubscriptionLifecycle, UUIDstr -from orchestrator.workflow import StepList, conditional, done, init, step, workflow, Step, callback_step +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 validator diff --git a/test/workflows/__init__.py b/test/workflows/__init__.py index 876b0e3e051d8f1f1fda3739dab8983b953dc1c2..4fcc19905d6b722eeabdc88f345854dea638d8b5 100644 --- a/test/workflows/__init__.py +++ b/test/workflows/__init__.py @@ -42,6 +42,12 @@ def assert_suspended(result): ).issuspend(), f"Unexpected process status. Expected Suspend, but was: {result}" +def assert_awaiting_callback(result): + assert result.on_failed( + _raise_exception + ).isawaitingcallback(), f"Unexpected process status. Expected Awaiting Callback, but was: {result}" + + def assert_aborted(result): assert result.on_failed(_raise_exception).isabort(), f"Unexpected process status. Expected Abort, but was: {result}" diff --git a/test/workflows/iptrunk/test_create_iptrunk.py b/test/workflows/iptrunk/test_create_iptrunk.py index 77ca88fde54d866817cb984e8c703c6bf00e36d8..d5c23c2a631a15e3c329590e695ae56703b3bc2f 100644 --- a/test/workflows/iptrunk/test_create_iptrunk.py +++ b/test/workflows/iptrunk/test_create_iptrunk.py @@ -11,6 +11,7 @@ from gso.utils.helpers import LAGMember from test.services.conftest import MockedNetboxClient from test.workflows import ( assert_aborted, + assert_awaiting_callback, assert_complete, assert_suspended, extract_state, @@ -106,7 +107,7 @@ def test_successful_iptrunk_creation_with_standard_lso_result( product_id = get_product_id_by_name(ProductType.IP_TRUNK) initial_site_data = [{"product": product_id}, *input_form_wizard_data] result, process_stat, step_log = run_workflow("create_iptrunk", initial_site_data) - assert_suspended(result) + assert_awaiting_callback(result) standard_lso_result = { "pp_run_results": { @@ -158,7 +159,7 @@ def test_iptrunk_creation_fails_when_lso_return_code_is_one( initial_site_data = [{"product": product_id}, *input_form_wizard_data] result, process_stat, step_log = run_workflow("create_iptrunk", initial_site_data) - assert_suspended(result) + assert_awaiting_callback(result) standard_lso_result = { "pp_run_results": { diff --git a/test/workflows/iptrunks/iptrunks/test_create_iptrunks.py b/test/workflows/iptrunks/iptrunks/test_create_iptrunks.py index c0d09fb7758acaa602959703d4a9ef061b904a4c..3ec39fd8409e7029c913134dbd01d385d18e8e35 100644 --- a/test/workflows/iptrunks/iptrunks/test_create_iptrunks.py +++ b/test/workflows/iptrunks/iptrunks/test_create_iptrunks.py @@ -2,13 +2,10 @@ from unittest.mock import patch import pytest -from gso.products import Iptrunk -from gso.products.product_blocks import PhyPortCapacity -from gso.products.product_blocks.iptrunk import IptrunkType -from gso.schemas.enums import ProductType -from gso.services.crm import get_customer_by_name +from gso.products import Iptrunk, ProductType +from gso.products.product_blocks.iptrunk import IptrunkType, PhyPortCapacity +from gso.services.crm import customer_selector, get_customer_by_name from gso.services.subscriptions import get_product_id_by_name -from gso.workflows.utils import customer_selector from test.workflows import ( assert_aborted, assert_complete, diff --git a/tox.ini b/tox.ini index c259455be909abd8c44e5405dff9a21101edf224..50b62202234dcc3477beda3930e8ef4d517b0fcf 100644 --- a/tox.ini +++ b/tox.ini @@ -12,6 +12,8 @@ markers = workflow [testenv] passenv = DATABASE_URI_TEST,SKIP_ALL_TESTS +setenv = + OAUTH2_ACTIVE = False deps = coverage flake8