diff --git a/docs/source/module/services/index.rst b/docs/source/module/services/index.rst index d74c2ba8ffee28fad531d1b74ef54c5c8edab88b..7b1a1d5540b8c52e0f64c466184864339b36723a 100644 --- a/docs/source/module/services/index.rst +++ b/docs/source/module/services/index.rst @@ -15,6 +15,6 @@ Submodules crm infoblox librenms_client + lso_client netbox_client - provisioning_proxy subscriptions diff --git a/docs/source/module/services/lso_client.rst b/docs/source/module/services/lso_client.rst new file mode 100644 index 0000000000000000000000000000000000000000..98b9eee9b4c7dcff3fc1b47cde4c3ac3ae3b40a9 --- /dev/null +++ b/docs/source/module/services/lso_client.rst @@ -0,0 +1,6 @@ +``gso.services.lso_client`` +=========================== + +.. automodule:: gso.services.lso_client + :members: + :show-inheritance: diff --git a/docs/source/module/services/provisioning_proxy.rst b/docs/source/module/services/provisioning_proxy.rst deleted file mode 100644 index 756edf2642d865e3104af928fbddd047c3d4ed32..0000000000000000000000000000000000000000 --- a/docs/source/module/services/provisioning_proxy.rst +++ /dev/null @@ -1,6 +0,0 @@ -``gso.services.provisioning_proxy`` -=================================== - -.. automodule:: gso.services.provisioning_proxy - :members: - :show-inheritance: diff --git a/gso/services/provisioning_proxy.py b/gso/services/lso_client.py similarity index 87% rename from gso/services/provisioning_proxy.py rename to gso/services/lso_client.py index 7aba02a4c01b93c476773c0d56f4d86445ce2cf0..50bbbc12c2ec963ef394f09c122b2f5702e3eef1 100644 --- a/gso/services/provisioning_proxy.py +++ b/gso/services/lso_client.py @@ -1,4 +1,4 @@ -"""The Provisioning Proxy service, which interacts with :term:`LSO` running externally. +"""The :term:`LSO` client, which interacts with :term:`LSO` running externally. :term:`LSO` is responsible for executing Ansible playbooks, that deploy subscriptions. """ @@ -33,7 +33,7 @@ def _send_request(parameters: dict, callback_route: str) -> None: :rtype: None """ oss = settings.load_oss_params() - pp_params = oss.PROVISIONING_PROXY + params = oss.PROVISIONING_PROXY # Build up a callback URL of the Provisioning Proxy to return its results to. callback_url = f"{oss.GENERAL.public_hostname}{callback_route}" @@ -41,7 +41,7 @@ def _send_request(parameters: dict, callback_route: str) -> None: logger.debug(debug_msg) parameters.update({"callback": callback_url}) - url = f"{pp_params.scheme}://{pp_params.api_base}/api/playbook" + url = f"{params.scheme}://{params.api_base}/api/playbook" request = requests.post(url, json=parameters, timeout=10) request.raise_for_status() @@ -107,7 +107,7 @@ def execute_playbook( @step("Evaluate provisioning proxy result") -def _evaluate_pp_results(callback_result: dict) -> State: +def _evaluate_results(callback_result: dict) -> State: if callback_result["return_code"] != 0: raise ProcessFailureError(message="Provisioning proxy failure", details=callback_result) @@ -115,12 +115,12 @@ def _evaluate_pp_results(callback_result: dict) -> State: @step("Ignore provisioning proxy result") -def _ignore_pp_results(callback_result: dict) -> State: +def _ignore_results(callback_result: dict) -> State: return {"callback_result": callback_result} @inputstep("Confirm provisioning proxy results", assignee=Assignee("SYSTEM")) -def _show_pp_results(state: State) -> FormGenerator: +def _show_results(state: State) -> FormGenerator: if "callback_result" not in state: return state @@ -136,7 +136,7 @@ def _show_pp_results(state: State) -> FormGenerator: return state -def pp_interaction(provisioning_step: Step) -> StepList: +def lso_interaction(provisioning_step: Step) -> StepList: """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 @@ -153,17 +153,17 @@ def pp_interaction(provisioning_step: Step) -> StepList: >> callback_step( name=provisioning_step.name, action_step=provisioning_step, - validate_step=_evaluate_pp_results, + validate_step=_evaluate_results, ) - >> _show_pp_results + >> _show_results ) -def indifferent_pp_interaction(provisioning_step: Step) -> StepList: +def indifferent_lso_interaction(provisioning_step: Step) -> StepList: """Interact with the provisioning proxy :term:`LSO` using a callback step. - This interaction is identical from the one described in ``pp_interaction()``, with one functional difference. - Whereas the ``pp_interaction()`` will make the workflow step fail on unsuccessful interaction, this step will not. + This interaction is identical from the one described in ``lso_interaction()``, with one functional difference. + Whereas the ``lso_interaction()`` will make the workflow step fail on unsuccessful interaction, this step will not. It is therefore indifferent about the outcome of the Ansible playbook that is executed. .. warning:: @@ -180,7 +180,7 @@ def indifferent_pp_interaction(provisioning_step: Step) -> StepList: >> callback_step( name=provisioning_step.name, action_step=provisioning_step, - validate_step=_ignore_pp_results, + validate_step=_ignore_results, ) - >> _show_pp_results + >> _show_results ) diff --git a/gso/utils/workflow_steps.py b/gso/utils/workflow_steps.py index f4fcdf2dc505180b6b568659704c3931b7df0d6d..522ceaf58587fbfe7ae4555637431c5e90568ca7 100644 --- a/gso/utils/workflow_steps.py +++ b/gso/utils/workflow_steps.py @@ -8,7 +8,7 @@ from orchestrator.types import State, UUIDstr from orchestrator.utils.json import json_dumps from gso.products.product_types.iptrunk import Iptrunk -from gso.services.provisioning_proxy import execute_playbook +from gso.services.lso_client import execute_playbook from gso.settings import load_oss_params diff --git a/gso/workflows/iptrunk/create_iptrunk.py b/gso/workflows/iptrunk/create_iptrunk.py index 8018f66c530ccfec463362d314e9c5e33d5faf34..481ca07838d523e366e7c8387442c0a8dba94336 100644 --- a/gso/workflows/iptrunk/create_iptrunk.py +++ b/gso/workflows/iptrunk/create_iptrunk.py @@ -25,9 +25,9 @@ from gso.products.product_blocks.iptrunk import ( 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.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.provisioning_proxy import execute_playbook, pp_interaction from gso.settings import load_oss_params from gso.utils.helpers import ( LAGMember, @@ -403,7 +403,7 @@ def check_ip_trunk_isis( @step("Register DNS records for both sides of the trunk") def register_dns_records(subscription: IptrunkInactive) -> State: - """Register :term: `DNS` records for both sides of the newly created IPtrunk.""" + """Register :term:`DNS` records for both sides of the newly created IPtrunk.""" for index, side in enumerate(subscription.iptrunk.iptrunk_sides): fqdn = f"{side.iptrunk_side_ae_iface}-0.{side.iptrunk_side_node.router_fqdn}" if not (subscription.iptrunk.iptrunk_ipv4_network and subscription.iptrunk.iptrunk_ipv6_network): @@ -522,12 +522,12 @@ def create_iptrunk() -> StepList: >> initialize_subscription >> get_info_from_ipam >> reserve_interfaces_in_netbox - >> pp_interaction(provision_ip_trunk_iface_dry) - >> pp_interaction(provision_ip_trunk_iface_real) - >> pp_interaction(check_ip_trunk_connectivity) - >> pp_interaction(provision_ip_trunk_isis_iface_dry) - >> pp_interaction(provision_ip_trunk_isis_iface_real) - >> pp_interaction(check_ip_trunk_isis) + >> lso_interaction(provision_ip_trunk_iface_dry) + >> lso_interaction(provision_ip_trunk_iface_real) + >> lso_interaction(check_ip_trunk_connectivity) + >> lso_interaction(provision_ip_trunk_isis_iface_dry) + >> lso_interaction(provision_ip_trunk_isis_iface_real) + >> lso_interaction(check_ip_trunk_isis) >> register_dns_records >> side_a_is_nokia(netbox_allocate_side_a_interfaces) >> side_b_is_nokia(netbox_allocate_side_b_interfaces) diff --git a/gso/workflows/iptrunk/deploy_twamp.py b/gso/workflows/iptrunk/deploy_twamp.py index 8e2e1016b17fbfc6ba5840e8f47a9c831c9ced17..b9003078a016313bab3012cfee8eaf3f11f278ab 100644 --- a/gso/workflows/iptrunk/deploy_twamp.py +++ b/gso/workflows/iptrunk/deploy_twamp.py @@ -10,7 +10,7 @@ from orchestrator.workflows.utils import wrap_modify_initial_input_form from pydantic import validator from gso.products.product_types.iptrunk import Iptrunk -from gso.services.provisioning_proxy import execute_playbook, pp_interaction +from gso.services.lso_client import execute_playbook, lso_interaction from gso.utils.helpers import validate_tt_number @@ -88,8 +88,8 @@ def deploy_twamp() -> StepList: init >> store_process_subscription(Target.MODIFY) >> unsync - >> pp_interaction(deploy_twamp_dry) - >> pp_interaction(deploy_twamp_real) + >> lso_interaction(deploy_twamp_dry) + >> lso_interaction(deploy_twamp_real) >> resync >> done ) diff --git a/gso/workflows/iptrunk/migrate_iptrunk.py b/gso/workflows/iptrunk/migrate_iptrunk.py index 6c6056f5a5beeead97f13c36142b3262d6b0bd02..3ee509cb23ea44bc236ba7f7158b65200c9741aa 100644 --- a/gso/workflows/iptrunk/migrate_iptrunk.py +++ b/gso/workflows/iptrunk/migrate_iptrunk.py @@ -29,8 +29,8 @@ from gso.products.product_types.iptrunk import Iptrunk from gso.products.product_types.router import Router from gso.services import infoblox from gso.services.infoblox import DeletionError +from gso.services.lso_client import execute_playbook, lso_interaction from gso.services.netbox_client import NetboxClient -from gso.services.provisioning_proxy import execute_playbook, pp_interaction from gso.services.subscriptions import get_active_router_subscriptions from gso.utils.helpers import ( LAGMember, @@ -713,21 +713,21 @@ def migrate_iptrunk() -> StepList: >> unsync >> new_side_is_nokia(netbox_reserve_interfaces) >> calculate_old_side_data - >> pp_interaction(set_isis_to_max) - >> pp_interaction(check_ip_trunk_optical_levels) - >> pp_interaction(disable_old_config_dry) - >> pp_interaction(disable_old_config_real) - >> pp_interaction(deploy_new_config_dry) - >> pp_interaction(deploy_new_config_real) + >> lso_interaction(set_isis_to_max) + >> lso_interaction(check_ip_trunk_optical_levels) + >> lso_interaction(disable_old_config_dry) + >> lso_interaction(disable_old_config_real) + >> lso_interaction(deploy_new_config_dry) + >> lso_interaction(deploy_new_config_real) >> confirm_continue_move_fiber - >> pp_interaction(check_ip_trunk_optical_levels) - >> pp_interaction(check_ip_trunk_connectivity) - >> pp_interaction(deploy_new_isis) - >> pp_interaction(check_ip_trunk_isis) + >> lso_interaction(check_ip_trunk_optical_levels) + >> lso_interaction(check_ip_trunk_connectivity) + >> lso_interaction(deploy_new_isis) + >> lso_interaction(check_ip_trunk_isis) >> should_restore_isis_metric(confirm_continue_restore_isis) - >> should_restore_isis_metric(pp_interaction(restore_isis_metric)) - >> pp_interaction(delete_old_config_dry) - >> pp_interaction(delete_old_config_real) + >> should_restore_isis_metric(lso_interaction(restore_isis_metric)) + >> lso_interaction(delete_old_config_dry) + >> lso_interaction(delete_old_config_real) >> update_ipam >> update_subscription_model >> old_side_is_nokia(netbox_remove_old_interfaces) diff --git a/gso/workflows/iptrunk/modify_isis_metric.py b/gso/workflows/iptrunk/modify_isis_metric.py index 8c4ade919b7becdf9a4c4690e2d6f610ae453508..55fea705f8af6595933df3786a96de4bf962b953 100644 --- a/gso/workflows/iptrunk/modify_isis_metric.py +++ b/gso/workflows/iptrunk/modify_isis_metric.py @@ -11,7 +11,7 @@ from orchestrator.workflows.steps import resync, store_process_subscription, uns from orchestrator.workflows.utils import wrap_modify_initial_input_form from gso.products.product_types.iptrunk import Iptrunk -from gso.services.provisioning_proxy import execute_playbook, pp_interaction +from gso.services.lso_client import execute_playbook, lso_interaction def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: @@ -108,8 +108,8 @@ def modify_isis_metric() -> StepList: >> store_process_subscription(Target.MODIFY) >> unsync >> modify_iptrunk_subscription - >> pp_interaction(provision_ip_trunk_isis_iface_dry) - >> pp_interaction(provision_ip_trunk_isis_iface_real) + >> lso_interaction(provision_ip_trunk_isis_iface_dry) + >> lso_interaction(provision_ip_trunk_isis_iface_real) >> resync >> done ) diff --git a/gso/workflows/iptrunk/modify_trunk_interface.py b/gso/workflows/iptrunk/modify_trunk_interface.py index d4e6edb19160c77a429f5a7f307b5897ec5df055..86b43eb55955857148c9184ae9963858bced337c 100644 --- a/gso/workflows/iptrunk/modify_trunk_interface.py +++ b/gso/workflows/iptrunk/modify_trunk_interface.py @@ -22,8 +22,8 @@ from gso.products.product_blocks.iptrunk import ( PhyPortCapacity, ) from gso.products.product_types.iptrunk import Iptrunk +from gso.services.lso_client import execute_playbook, lso_interaction from gso.services.netbox_client import NetboxClient -from gso.services.provisioning_proxy import execute_playbook, pp_interaction from gso.utils.helpers import ( LAGMember, available_interfaces_choices, @@ -401,8 +401,8 @@ def modify_trunk_interface() -> StepList: >> modify_iptrunk_subscription >> side_a_is_nokia(netbox_update_interfaces_side_a) >> side_b_is_nokia(netbox_update_interfaces_side_b) - >> pp_interaction(provision_ip_trunk_iface_dry) - >> pp_interaction(provision_ip_trunk_iface_real) + >> lso_interaction(provision_ip_trunk_iface_dry) + >> lso_interaction(provision_ip_trunk_iface_real) >> side_a_is_nokia(allocate_interfaces_in_netbox_side_a) >> side_b_is_nokia(allocate_interfaces_in_netbox_side_b) >> resync diff --git a/gso/workflows/iptrunk/terminate_iptrunk.py b/gso/workflows/iptrunk/terminate_iptrunk.py index 93f8bd96ae25395228a4837f809081d3179368ee..469491ebde407ddb5d92e9ffbb32e96fbb12d994 100644 --- a/gso/workflows/iptrunk/terminate_iptrunk.py +++ b/gso/workflows/iptrunk/terminate_iptrunk.py @@ -21,8 +21,8 @@ from pydantic import validator from gso.products.product_blocks.iptrunk import IptrunkSideBlock from gso.products.product_types.iptrunk import Iptrunk from gso.services import infoblox +from gso.services.lso_client import execute_playbook, lso_interaction from gso.services.netbox_client import NetboxClient -from gso.services.provisioning_proxy import execute_playbook, pp_interaction from gso.utils.helpers import get_router_vendor, validate_tt_number from gso.utils.shared_enums import Vendor from gso.utils.workflow_steps import set_isis_to_max @@ -171,9 +171,9 @@ def terminate_iptrunk() -> StepList: config_steps = ( init - >> pp_interaction(set_isis_to_max) - >> pp_interaction(deprovision_ip_trunk_dry) - >> pp_interaction(deprovision_ip_trunk_real) + >> lso_interaction(set_isis_to_max) + >> lso_interaction(deprovision_ip_trunk_dry) + >> lso_interaction(deprovision_ip_trunk_real) ) ipam_steps = init >> deprovision_ip_trunk_ipv4 >> deprovision_ip_trunk_ipv6 diff --git a/gso/workflows/router/create_router.py b/gso/workflows/router/create_router.py index 694b4136c8e851962f9bdd81a361f94fc75c50d9..289f201bd45b3064ad352c733a7c81aa1b7b7462 100644 --- a/gso/workflows/router/create_router.py +++ b/gso/workflows/router/create_router.py @@ -17,9 +17,9 @@ from gso.products.product_blocks.router import RouterRole from gso.products.product_types.router import RouterInactive, RouterProvisioning from gso.products.product_types.site import Site from gso.services import infoblox, subscriptions +from gso.services.lso_client import lso_interaction from gso.services.netbox_client import NetboxClient from gso.services.partners import get_partner_by_name -from gso.services.provisioning_proxy import pp_interaction from gso.settings import load_oss_params from gso.utils.helpers import generate_fqdn, iso_from_ipv4 from gso.utils.shared_enums import PortNumber, Vendor @@ -265,15 +265,15 @@ def create_router() -> StepList: >> store_process_subscription(Target.CREATE) >> initialize_subscription >> ipam_allocate_loopback - >> pp_interaction(deploy_base_config_dry) - >> pp_interaction(deploy_base_config_real) + >> lso_interaction(deploy_base_config_dry) + >> lso_interaction(deploy_base_config_real) >> verify_ipam_loopback >> prompt_reboot_router >> prompt_console_login >> prompt_insert_in_ims >> prompt_insert_in_radius >> router_is_nokia(create_netbox_device) - >> pp_interaction(run_checks_after_base_config) + >> lso_interaction(run_checks_after_base_config) >> set_status(SubscriptionLifecycle.PROVISIONING) >> prompt_start_new_checklist >> resync diff --git a/gso/workflows/router/redeploy_base_config.py b/gso/workflows/router/redeploy_base_config.py index 9c9fc3efeb4d4b9fafdc050140eb856dbe3f103d..ffacc0ce7f1e383ac258971a78601bf39ac6af89 100644 --- a/gso/workflows/router/redeploy_base_config.py +++ b/gso/workflows/router/redeploy_base_config.py @@ -9,7 +9,7 @@ from orchestrator.workflows.steps import resync, store_process_subscription, uns from orchestrator.workflows.utils import wrap_modify_initial_input_form from gso.products.product_types.router import Router -from gso.services.provisioning_proxy import pp_interaction +from gso.services.lso_client import lso_interaction from gso.utils.workflow_steps import deploy_base_config_dry, deploy_base_config_real @@ -40,8 +40,8 @@ def redeploy_base_config() -> StepList: init >> store_process_subscription(Target.MODIFY) >> unsync - >> pp_interaction(deploy_base_config_dry) - >> pp_interaction(deploy_base_config_real) + >> lso_interaction(deploy_base_config_dry) + >> lso_interaction(deploy_base_config_real) >> resync >> done ) diff --git a/gso/workflows/router/terminate_router.py b/gso/workflows/router/terminate_router.py index 20ac88dd053c7d231cdf8445d186f02ee81fa2f8..8abc8877367f5c9333852de0e19720f6f01d25d8 100644 --- a/gso/workflows/router/terminate_router.py +++ b/gso/workflows/router/terminate_router.py @@ -20,8 +20,8 @@ from orchestrator.workflows.utils import wrap_modify_initial_input_form from gso.products.product_types.router import Router from gso.services import infoblox +from gso.services.lso_client import execute_playbook, lso_interaction from gso.services.netbox_client import NetboxClient -from gso.services.provisioning_proxy import execute_playbook, pp_interaction from gso.utils.shared_enums import Vendor logger = logging.getLogger(__name__) @@ -123,8 +123,8 @@ def terminate_router() -> StepList: >> store_process_subscription(Target.TERMINATE) >> unsync >> run_ipam_steps(deprovision_loopback_ips) - >> run_config_steps(pp_interaction(remove_config_from_router_dry)) - >> run_config_steps(pp_interaction(remove_config_from_router_real)) + >> run_config_steps(lso_interaction(remove_config_from_router_dry)) + >> run_config_steps(lso_interaction(remove_config_from_router_real)) >> router_is_nokia(remove_device_from_netbox) >> set_status(SubscriptionLifecycle.TERMINATED) >> resync diff --git a/gso/workflows/router/update_ibgp_mesh.py b/gso/workflows/router/update_ibgp_mesh.py index d8ba52a09b36735bd46404a091f7f408ad4f2f66..80f63d21fbcf9c4a87545364504198f3fe67cde4 100644 --- a/gso/workflows/router/update_ibgp_mesh.py +++ b/gso/workflows/router/update_ibgp_mesh.py @@ -14,8 +14,8 @@ from pydantic import root_validator from gso.products.product_blocks.router import RouterRole from gso.products.product_types.router import Router -from gso.services import librenms_client, provisioning_proxy, subscriptions -from gso.services.provisioning_proxy import pp_interaction +from gso.services import librenms_client, lso_client, subscriptions +from gso.services.lso_client import lso_interaction from gso.services.subscriptions import get_active_trunks_that_terminate_on_router from gso.utils.helpers import SNMPVersion @@ -86,7 +86,7 @@ def add_p_to_mesh_dry( "verb": "add_p_to_pe", } - provisioning_proxy.execute_playbook( + lso_client.execute_playbook( playbook_name="update_ibgp_mesh.yaml", callback_route=callback_route, inventory=_generate_pe_inventory(pe_router_list), @@ -106,7 +106,7 @@ def add_p_to_mesh_real( "verb": "add_p_to_pe", } - provisioning_proxy.execute_playbook( + lso_client.execute_playbook( playbook_name="update_ibgp_mesh.yaml", callback_route=callback_route, inventory=_generate_pe_inventory(pe_router_list), @@ -134,7 +134,7 @@ def add_all_pe_to_p_dry( "verb": "add_pe_to_p", } - provisioning_proxy.execute_playbook( + lso_client.execute_playbook( playbook_name="update_ibgp_mesh.yaml", callback_route=callback_route, inventory=subscription["router"]["router_fqdn"], @@ -162,7 +162,7 @@ def add_all_pe_to_p_real( "verb": "add_pe_to_p", } - provisioning_proxy.execute_playbook( + lso_client.execute_playbook( playbook_name="update_ibgp_mesh.yaml", callback_route=callback_route, inventory=subscription["router"]["router_fqdn"], @@ -173,7 +173,7 @@ def add_all_pe_to_p_real( @step("Verify iBGP session health") def check_ibgp_session(subscription: Router, callback_route: str) -> None: """Run a playbook using the provisioning proxy, to check the health of the new iBGP session.""" - provisioning_proxy.execute_playbook( + lso_client.execute_playbook( playbook_name="check_ibgp.yaml", callback_route=callback_route, inventory=subscription.router.router_fqdn, @@ -247,11 +247,11 @@ def update_ibgp_mesh() -> StepList: >> store_process_subscription(Target.MODIFY) >> unsync >> calculate_pe_router_list - >> pp_interaction(add_p_to_mesh_dry) - >> pp_interaction(add_p_to_mesh_real) - >> pp_interaction(add_all_pe_to_p_dry) - >> pp_interaction(add_all_pe_to_p_real) - >> pp_interaction(check_ibgp_session) + >> lso_interaction(add_p_to_mesh_dry) + >> lso_interaction(add_p_to_mesh_real) + >> lso_interaction(add_all_pe_to_p_dry) + >> lso_interaction(add_all_pe_to_p_real) + >> lso_interaction(check_ibgp_session) >> add_device_to_librenms >> prompt_insert_in_radius >> prompt_radius_login diff --git a/test/workflows/__init__.py b/test/workflows/__init__.py index 5470858c105666ac8396b42649c65a02eeef8d0c..a8144aacac102f807324458c14ad0cd04c69c892 100644 --- a/test/workflows/__init__.py +++ b/test/workflows/__init__.py @@ -318,8 +318,8 @@ def user_accept_and_assert_suspended(process_stat, step_log, extra_data=None): return result, step_log -def assert_pp_interaction_success(result: Process, process_stat: ProcessStat, step_log: list): - """Assert a successful pp interaction in a workflow. +def assert_lso_interaction_success(result: Process, process_stat: ProcessStat, step_log: list): + """Assert a successful LSO interaction in a workflow. First, the workflow is awaiting callback. It is resumed but a result from LSO, after which the user submits the confirmation input step. Two assertions are made: the workflow is awaiting callback at first, and suspended when @@ -332,8 +332,8 @@ def assert_pp_interaction_success(result: Process, process_stat: ProcessStat, st return resume_workflow(process_stat, step_log, input_data=USER_CONFIRM_EMPTY_FORM) -def assert_pp_interaction_failure(result: Process, process_stat: ProcessStat, step_log: list): - """Assert a failed pp interaction in a workflow. +def assert_lso_interaction_failure(result: Process, process_stat: ProcessStat, step_log: list): + """Assert a failed LSO interaction in a workflow. First, the workflow is awaiting callback. It is resumed by a "failure" result from LSO, after which the workflow is in a failed state. This failed state is also returned. Two assertions are made: the workflow is awaiting callback at diff --git a/test/workflows/iptrunk/test_create_iptrunk.py b/test/workflows/iptrunk/test_create_iptrunk.py index ce7d54908568773a96a01f5985db1c05df528a47..38611a75e4f2ebf513fcd9875e8dac619dc1ff99 100644 --- a/test/workflows/iptrunk/test_create_iptrunk.py +++ b/test/workflows/iptrunk/test_create_iptrunk.py @@ -12,8 +12,8 @@ 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_lso_interaction_failure, + assert_lso_interaction_success, assert_suspended, extract_state, resume_workflow, @@ -121,7 +121,7 @@ def test_successful_iptrunk_creation_with_standard_lso_result( result, process_stat, step_log = run_workflow("create_iptrunk", initial_site_data) for _ in range(6): - result, step_log = assert_pp_interaction_success(result, process_stat, step_log) + result, step_log = assert_lso_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) @@ -167,9 +167,9 @@ 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) - result, step_log = assert_pp_interaction_success(result, process_stat, step_log) + result, step_log = assert_lso_interaction_success(result, process_stat, step_log) - assert_pp_interaction_failure(result, process_stat, step_log) + assert_lso_interaction_failure(result, process_stat, step_log) assert mock_execute_playbook.call_count == 2 @@ -200,7 +200,7 @@ def test_successful_iptrunk_creation_with_juniper_interface_names( result, process_stat, step_log = run_workflow("create_iptrunk", initial_site_data) for _ in range(6): - result, step_log = assert_pp_interaction_success(result, process_stat, step_log) + result, step_log = assert_lso_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) diff --git a/test/workflows/iptrunk/test_deploy_twamp.py b/test/workflows/iptrunk/test_deploy_twamp.py index 019c67940fef36883349d79b8fd15cc173e52038..c5592738f530a1769c5fd8dd56e02e426950c6ad 100644 --- a/test/workflows/iptrunk/test_deploy_twamp.py +++ b/test/workflows/iptrunk/test_deploy_twamp.py @@ -5,7 +5,7 @@ import pytest from gso.products import Iptrunk from test.workflows import ( assert_complete, - assert_pp_interaction_success, + assert_lso_interaction_success, extract_state, run_workflow, ) @@ -26,7 +26,7 @@ def test_iptrunk_deploy_twamp_success( result, process_stat, step_log = run_workflow("deploy_twamp", initial_input_data) for _ in range(2): - result, step_log = assert_pp_interaction_success(result, process_stat, step_log) + result, step_log = assert_lso_interaction_success(result, process_stat, step_log) assert_complete(result) diff --git a/test/workflows/iptrunk/test_migrate_iptrunk.py b/test/workflows/iptrunk/test_migrate_iptrunk.py index 04ae7c73c2dadb0d36b4402f8292a80fd0844cdf..5640cd646b75083f44d5bfbe37e21d1bfa9115a9 100644 --- a/test/workflows/iptrunk/test_migrate_iptrunk.py +++ b/test/workflows/iptrunk/test_migrate_iptrunk.py @@ -10,7 +10,7 @@ from test import USER_CONFIRM_EMPTY_FORM from test.conftest import UseJuniperSide from test.workflows import ( assert_complete, - assert_pp_interaction_success, + assert_lso_interaction_success, assert_suspended, extract_state, resume_workflow, @@ -110,7 +110,7 @@ def interface_lists_are_equal(list1, list2): @pytest.mark.workflow() @patch("gso.services.infoblox.create_host_by_ip") @patch("gso.services.infoblox.delete_host_by_ip") -@patch("gso.services.provisioning_proxy._send_request") +@patch("gso.services.lso_client._send_request") @patch("gso.services.netbox_client.NetboxClient.get_available_interfaces") @patch("gso.services.netbox_client.NetboxClient.get_available_lags") @patch("gso.services.netbox_client.NetboxClient.create_interface") @@ -148,19 +148,19 @@ def test_migrate_iptrunk_success( result, process_stat, step_log = run_workflow("migrate_iptrunk", migrate_form_input) for _ in range(6): - result, step_log = assert_pp_interaction_success(result, process_stat, step_log) + result, step_log = assert_lso_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) for _ in range(4): - result, step_log = assert_pp_interaction_success(result, process_stat, step_log) + result, step_log = assert_lso_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) for _ in range(3): - result, step_log = assert_pp_interaction_success(result, process_stat, step_log) + result, step_log = assert_lso_interaction_success(result, process_stat, step_log) assert_complete(result) diff --git a/test/workflows/iptrunk/test_modify_isis_metric.py b/test/workflows/iptrunk/test_modify_isis_metric.py index 914998552a4dfe3b88c884138cb281b88712f01c..38f4b4e89e5d178b86c48eaafc32a311f07787c2 100644 --- a/test/workflows/iptrunk/test_modify_isis_metric.py +++ b/test/workflows/iptrunk/test_modify_isis_metric.py @@ -5,14 +5,14 @@ import pytest from gso.products import Iptrunk from test.workflows import ( assert_complete, - assert_pp_interaction_success, + assert_lso_interaction_success, extract_state, run_workflow, ) @pytest.mark.workflow() -@patch("gso.services.provisioning_proxy.execute_playbook") +@patch("gso.services.lso_client.execute_playbook") def test_iptrunk_modify_isis_metric_success( mock_provision_ip_trunk, iptrunk_subscription_factory, @@ -30,7 +30,7 @@ def test_iptrunk_modify_isis_metric_success( result, process_stat, step_log = run_workflow("modify_isis_metric", initial_iptrunk_data) for _ in range(2): - result, step_log = assert_pp_interaction_success(result, process_stat, step_log) + result, step_log = assert_lso_interaction_success(result, process_stat, step_log) assert_complete(result) diff --git a/test/workflows/iptrunk/test_modify_trunk_interface.py b/test/workflows/iptrunk/test_modify_trunk_interface.py index 78bedca5562302e2b6e6c12e3e71bbbb93bf7758..372933d78795bdcbc29800caa6ae0dfac6c27340 100644 --- a/test/workflows/iptrunk/test_modify_trunk_interface.py +++ b/test/workflows/iptrunk/test_modify_trunk_interface.py @@ -8,7 +8,7 @@ from gso.utils.shared_enums import Vendor from test.conftest import UseJuniperSide from test.workflows import ( assert_complete, - assert_pp_interaction_success, + assert_lso_interaction_success, extract_state, run_workflow, ) @@ -121,7 +121,7 @@ def test_iptrunk_modify_trunk_interface_success( result, process_stat, step_log = run_workflow("modify_trunk_interface", input_form_iptrunk_data) for _ in range(2): - result, step_log = assert_pp_interaction_success(result, process_stat, step_log) + result, step_log = assert_lso_interaction_success(result, process_stat, step_log) assert_complete(result) diff --git a/test/workflows/iptrunk/test_terminate_iptrunk.py b/test/workflows/iptrunk/test_terminate_iptrunk.py index bc890afa53b5e2908f6291294134bea1dd167fba..05a94456ab00aa1145f2e1dae1953eae437568ee 100644 --- a/test/workflows/iptrunk/test_terminate_iptrunk.py +++ b/test/workflows/iptrunk/test_terminate_iptrunk.py @@ -7,7 +7,7 @@ from gso.settings import load_oss_params from test.services.conftest import MockedNetboxClient from test.workflows import ( assert_complete, - assert_pp_interaction_success, + assert_lso_interaction_success, extract_state, run_workflow, ) @@ -48,7 +48,7 @@ def test_successful_iptrunk_termination( result, process_stat, step_log = run_workflow("terminate_iptrunk", initial_iptrunk_data) for _ in range(3): - result, step_log = assert_pp_interaction_success(result, process_stat, step_log) + result, step_log = assert_lso_interaction_success(result, process_stat, step_log) assert_complete(result) diff --git a/test/workflows/router/test_create_router.py b/test/workflows/router/test_create_router.py index 62808258924a554a8a0ff763a5943080c81afd45..a6d61729946e11249b8773599edfd3d023499dbb 100644 --- a/test/workflows/router/test_create_router.py +++ b/test/workflows/router/test_create_router.py @@ -11,8 +11,8 @@ from gso.utils.shared_enums import Vendor from test import USER_CONFIRM_EMPTY_FORM from test.workflows import ( assert_complete, - assert_pp_interaction_failure, - assert_pp_interaction_success, + assert_lso_interaction_failure, + assert_lso_interaction_success, assert_suspended, extract_state, resume_workflow, @@ -85,14 +85,14 @@ def test_create_nokia_router_success( ) for _ in range(2): - result, step_log = assert_pp_interaction_success(result, process_stat, step_log) + result, step_log = assert_lso_interaction_success(result, process_stat, step_log) # Handle four consecutive user input steps for _ in range(4): assert_suspended(result) result, step_log = resume_workflow(process_stat, step_log, input_data=USER_CONFIRM_EMPTY_FORM) - result, step_log = assert_pp_interaction_success(result, process_stat, step_log) + result, step_log = assert_lso_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) @@ -173,13 +173,13 @@ def test_create_nokia_router_lso_failure( initial_router_data = [{"product": product_id}, router_creation_input_form_data] result, process_stat, step_log = run_workflow("create_router", initial_router_data) - result, step_log = assert_pp_interaction_success(result, process_stat, step_log) + result, step_log = assert_lso_interaction_success(result, process_stat, step_log) state = extract_state(result) subscription_id = state["subscription_id"] subscription = Router.from_subscription(subscription_id) - assert_pp_interaction_failure(result, process_stat, step_log) + assert_lso_interaction_failure(result, process_stat, step_log) assert subscription.status == "initial" assert subscription.description == f"Router {mock_fqdn}" diff --git a/test/workflows/router/test_redeploy_base_config.py b/test/workflows/router/test_redeploy_base_config.py index 026999d0e9b23f590c5e434aba24d56e4bc47e91..d624d62eb23875156d550852d6bf28af03722b8a 100644 --- a/test/workflows/router/test_redeploy_base_config.py +++ b/test/workflows/router/test_redeploy_base_config.py @@ -5,14 +5,14 @@ import pytest from gso.products import Router from test.workflows import ( assert_complete, - assert_pp_interaction_success, + assert_lso_interaction_success, extract_state, run_workflow, ) @pytest.mark.workflow() -@patch("gso.services.provisioning_proxy._send_request") +@patch("gso.services.lso_client._send_request") def test_redeploy_base_config_success( mock_provision_router, nokia_router_subscription_factory, @@ -26,7 +26,7 @@ def test_redeploy_base_config_success( result, process_stat, step_log = run_workflow("redeploy_base_config", initial_input_data) for _ in range(2): - result, step_log = assert_pp_interaction_success(result, process_stat, step_log) + result, step_log = assert_lso_interaction_success(result, process_stat, step_log) assert_complete(result) diff --git a/test/workflows/router/test_terminate_router.py b/test/workflows/router/test_terminate_router.py index 25307cc6101b6efa4c4ce3ad18ccc907a118b378..bc978824b1f03f03fa7b06a8f5325f1d26959a27 100644 --- a/test/workflows/router/test_terminate_router.py +++ b/test/workflows/router/test_terminate_router.py @@ -3,7 +3,7 @@ from unittest.mock import patch import pytest from gso.products import Router -from test.workflows import assert_complete, assert_pp_interaction_success, extract_state, run_workflow +from test.workflows import assert_complete, assert_lso_interaction_success, extract_state, run_workflow @pytest.mark.workflow() @@ -16,7 +16,7 @@ from test.workflows import assert_complete, assert_pp_interaction_success, extra (False, False), ], ) -@patch("gso.services.provisioning_proxy._send_request") +@patch("gso.services.lso_client._send_request") @patch("gso.workflows.router.terminate_router.NetboxClient.delete_device") @patch("gso.workflows.router.terminate_router.infoblox.delete_host_by_ip") def test_terminate_router_full_success( @@ -36,14 +36,14 @@ def test_terminate_router_full_success( "remove_configuration": remove_configuration, "clean_up_ipam": clean_up_ipam, } - pp_interaction_count = 2 if remove_configuration else 0 + lso_interaction_count = 2 if remove_configuration else 0 # Run workflow initial_router_data = [{"subscription_id": product_id}, router_termination_input_form_data] result, process_stat, step_log = run_workflow("terminate_router", initial_router_data) - for _ in range(pp_interaction_count): - result, step_log = assert_pp_interaction_success(result, process_stat, step_log) + for _ in range(lso_interaction_count): + result, step_log = assert_lso_interaction_success(result, process_stat, step_log) assert_complete(result) @@ -54,4 +54,4 @@ def test_terminate_router_full_success( assert subscription.status == "terminated" assert mock_delete_device.call_count == 1 assert mock_delete_host_by_ip.call_count == (1 if clean_up_ipam else 0) - assert mock_execute_playbook.call_count == pp_interaction_count + assert mock_execute_playbook.call_count == lso_interaction_count diff --git a/test/workflows/router/test_update_ibgp_mesh.py b/test/workflows/router/test_update_ibgp_mesh.py index 8c7da5d5d0abb2a4275f52e2c89cc2c52bc7f51e..b2f6756b8d7820e8e9dedd9f0f23b644eb86bb67 100644 --- a/test/workflows/router/test_update_ibgp_mesh.py +++ b/test/workflows/router/test_update_ibgp_mesh.py @@ -7,7 +7,13 @@ from pydantic_forms.exceptions import FormValidationError from gso.products import Iptrunk from gso.products.product_blocks.router import RouterRole from test import USER_CONFIRM_EMPTY_FORM -from test.workflows import assert_pp_interaction_success, assert_suspended, extract_state, resume_workflow, run_workflow +from test.workflows import ( + assert_lso_interaction_success, + assert_suspended, + extract_state, + resume_workflow, + run_workflow, +) @pytest.fixture() @@ -18,7 +24,7 @@ def ibgp_mesh_input_form_data(iptrunk_subscription_factory, faker): @pytest.mark.workflow() -@patch("gso.workflows.router.update_ibgp_mesh.provisioning_proxy.execute_playbook") +@patch("gso.workflows.router.update_ibgp_mesh.lso_client.execute_playbook") @patch("gso.workflows.router.update_ibgp_mesh.librenms_client.LibreNMSClient.add_device") def test_update_ibgp_mesh_success( mock_librenms_add_device, @@ -32,7 +38,7 @@ def test_update_ibgp_mesh_success( ) for _ in range(5): - result, step_log = assert_pp_interaction_success(result, process_stat, step_log) + result, step_log = assert_lso_interaction_success(result, process_stat, step_log) # Handle two consecutive user input steps for _ in range(2):