Skip to content
Snippets Groups Projects
Verified Commit b1a5e7bd authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

externalise isis_high_metric as configurable parameter in config.json

parent b3d8f7a5
No related branches found
No related tags found
1 merge request!171Externalise the high ISIS metric into oss-params
{
"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",
......
......@@ -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):
......
......@@ -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,
......
......@@ -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
......
......@@ -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)
......
......@@ -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)
)
......
......@@ -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": {
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment