diff --git a/gso/oss-params-example.json b/gso/oss-params-example.json index 2ef1cd14749760e423c59676896c32638286989b..74d81cc9ddf2276ada1968af0f6146627fb5084d 100644 --- a/gso/oss-params-example.json +++ b/gso/oss-params-example.json @@ -1,6 +1,7 @@ { "GENERAL": { - "public_hostname": "https://gap.geant.org" + "public_hostname": "https://gap.geant.org", + "isis_high_metric": 999999 }, "NETBOX": { "api": "https://127.0.0.1:8000", diff --git a/gso/settings.py b/gso/settings.py index 2055e96c78e9177aad9f2b06b2871666b4eced70..2c86b723fa71b539df580d8d9eeecd20260dd13c 100644 --- a/gso/settings.py +++ b/gso/settings.py @@ -21,6 +21,7 @@ class GeneralParams(BaseSettings): public_hostname: str """The hostname that :term:`GSO` is publicly served at, used for building the callback URL that the provisioning proxy uses.""" + isis_high_metric: int class CeleryParams(BaseSettings): diff --git a/gso/utils/workflow_steps.py b/gso/utils/workflow_steps.py index 5890d62b76d042eb8d6ff9c95383ab8cbbedf733..f4fcdf2dc505180b6b568659704c3931b7df0d6d 100644 --- a/gso/utils/workflow_steps.py +++ b/gso/utils/workflow_steps.py @@ -9,6 +9,7 @@ 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.settings import load_oss_params def _deploy_base_config( @@ -62,11 +63,12 @@ def deploy_base_config_real( return {"subscription": subscription} -@step("[COMMIT] Set ISIS metric to 90.000") -def set_isis_to_90000(subscription: Iptrunk, process_id: UUIDstr, callback_route: str, tt_number: str) -> State: - """Workflow step for setting the :term:`ISIS` metric to 90k as an arbitrarily high value to drain a link.""" +@step("[COMMIT] Set ISIS metric to very high value") +def set_isis_to_max(subscription: Iptrunk, process_id: UUIDstr, callback_route: str, tt_number: str) -> State: + """Workflow step for setting the :term:`ISIS` metric to an arbitrarily high value to drain a link.""" old_isis_metric = subscription.iptrunk.iptrunk_isis_metric - subscription.iptrunk.iptrunk_isis_metric = 90000 + params = load_oss_params() + subscription.iptrunk.iptrunk_isis_metric = params.GENERAL.isis_high_metric extra_vars = { "wfo_trunk_json": json.loads(json_dumps(subscription)), "dry_run": False, diff --git a/gso/workflows/iptrunk/create_iptrunk.py b/gso/workflows/iptrunk/create_iptrunk.py index e9e304d224c5a9c36314a21050bf878846c8ef70..ac482121a172741bb619985dbc1da2cd6f913d69 100644 --- a/gso/workflows/iptrunk/create_iptrunk.py +++ b/gso/workflows/iptrunk/create_iptrunk.py @@ -27,6 +27,7 @@ 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, @@ -220,13 +221,14 @@ def initialize_subscription( side_b_ae_members: list[dict], ) -> State: """Take all input from the user, and store it in the database.""" + oss_params = load_oss_params() side_a = Router.from_subscription(side_a_node_id).router side_b = Router.from_subscription(side_b_node_id).router subscription.iptrunk.geant_s_sid = geant_s_sid subscription.iptrunk.iptrunk_description = iptrunk_description subscription.iptrunk.iptrunk_type = iptrunk_type subscription.iptrunk.iptrunk_speed = iptrunk_speed - subscription.iptrunk.iptrunk_isis_metric = 90000 + subscription.iptrunk.iptrunk_isis_metric = oss_params.GENERAL.isis_high_metric subscription.iptrunk.iptrunk_minimum_links = iptrunk_minimum_links subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node = side_a diff --git a/gso/workflows/iptrunk/migrate_iptrunk.py b/gso/workflows/iptrunk/migrate_iptrunk.py index 5f1240c56e74c0b16fe76bec4a72b962fbbec7c3..04ae9af565e3a6da1176d1ee3857c4e2255aa850 100644 --- a/gso/workflows/iptrunk/migrate_iptrunk.py +++ b/gso/workflows/iptrunk/migrate_iptrunk.py @@ -41,7 +41,7 @@ from gso.utils.helpers import ( validate_tt_number, ) from gso.utils.shared_enums import Vendor -from gso.utils.workflow_steps import set_isis_to_90000 +from gso.utils.workflow_steps import set_isis_to_max def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: @@ -656,7 +656,7 @@ def migrate_iptrunk() -> StepList: >> unsync >> new_side_is_nokia(netbox_reserve_interfaces) >> calculate_old_side_data - >> pp_interaction(set_isis_to_90000) + >> pp_interaction(set_isis_to_max) >> pp_interaction(disable_old_config_dry) >> pp_interaction(disable_old_config_real) >> pp_interaction(deploy_new_config_dry) diff --git a/gso/workflows/iptrunk/terminate_iptrunk.py b/gso/workflows/iptrunk/terminate_iptrunk.py index 330c90c3fddb35253180b8668d61947f484ce9b7..93f8bd96ae25395228a4837f809081d3179368ee 100644 --- a/gso/workflows/iptrunk/terminate_iptrunk.py +++ b/gso/workflows/iptrunk/terminate_iptrunk.py @@ -25,7 +25,7 @@ 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_90000 +from gso.utils.workflow_steps import set_isis_to_max def initial_input_form_generator() -> FormGenerator: @@ -171,7 +171,7 @@ def terminate_iptrunk() -> StepList: config_steps = ( init - >> pp_interaction(set_isis_to_90000) + >> pp_interaction(set_isis_to_max) >> pp_interaction(deprovision_ip_trunk_dry) >> pp_interaction(deprovision_ip_trunk_real) ) diff --git a/test/conftest.py b/test/conftest.py index b0e8ddbd1ff3a99521d1540d92f2ad519f253131..bc5dd61b0cddbf4c9652d1d6f41fdab34801a1ed 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -97,7 +97,7 @@ def configuration_data() -> dict: s.bind(("", 0)) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) yield { - "GENERAL": {"public_hostname": "https://orchestrator.dev.gap.geant.org"}, + "GENERAL": {"public_hostname": "https://orchestrator.dev.gap.geant.org", "isis_high_metric": 999999}, "NETBOX": {"api": "https://127.0.0.1:8000", "token": "TOKEN"}, "IPAM": { "INFOBLOX": { diff --git a/test/workflows/iptrunk/test_terminate_iptrunk.py b/test/workflows/iptrunk/test_terminate_iptrunk.py index 68b5f4edd155fa7f6e2760c2c36fec02e939f74f..bc890afa53b5e2908f6291294134bea1dd167fba 100644 --- a/test/workflows/iptrunk/test_terminate_iptrunk.py +++ b/test/workflows/iptrunk/test_terminate_iptrunk.py @@ -3,6 +3,7 @@ from unittest.mock import patch import pytest from gso.products import Iptrunk +from gso.settings import load_oss_params from test.services.conftest import MockedNetboxClient from test.workflows import ( assert_complete, @@ -35,6 +36,7 @@ def test_successful_iptrunk_termination( mocked_free_interface.return_value = mocked_netbox.free_interface() # Run workflow + oss_params = load_oss_params() initial_iptrunk_data = [ {"subscription_id": product_id}, { @@ -62,4 +64,4 @@ def test_successful_iptrunk_termination( assert mock_execute_playbook.call_count == 2 assert mock_set_isis_to_90k.call_count == 1 assert mock_infoblox_delete_network.call_count == 2 - assert subscription.iptrunk.iptrunk_isis_metric == 90000 + assert subscription.iptrunk.iptrunk_isis_metric == oss_params.GENERAL.isis_high_metric