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

move iptrunk workflows to new provisioning proxy endpoint

parent 83a56040
Branches
Tags
1 merge request!131Move provisioning proxy steps to the new LSO endpoint
Showing with 404 additions and 269 deletions
...@@ -6,8 +6,7 @@ from ipaddress import IPv4Address ...@@ -6,8 +6,7 @@ from ipaddress import IPv4Address
from uuid import UUID from uuid import UUID
import pycountry import pycountry
from orchestrator import step from orchestrator.types import UUIDstr
from orchestrator.types import State, UUIDstr
from pydantic import BaseModel, validator from pydantic import BaseModel, validator
from pydantic.fields import ModelField from pydantic.fields import ModelField
from pydantic_forms.validators import Choice from pydantic_forms.validators import Choice
...@@ -15,9 +14,7 @@ from pydantic_forms.validators import Choice ...@@ -15,9 +14,7 @@ from pydantic_forms.validators import Choice
from gso.products.product_blocks.iptrunk import IptrunkInterfaceBlock from gso.products.product_blocks.iptrunk import IptrunkInterfaceBlock
from gso.products.product_blocks.router import RouterVendor from gso.products.product_blocks.router import RouterVendor
from gso.products.product_blocks.site import SiteTier from gso.products.product_blocks.site import SiteTier
from gso.products.product_types.iptrunk import Iptrunk
from gso.products.product_types.router import Router from gso.products.product_types.router import Router
from gso.services import provisioning_proxy
from gso.services.netbox_client import NetboxClient from gso.services.netbox_client import NetboxClient
from gso.services.subscriptions import get_active_subscriptions_by_field_and_value from gso.services.subscriptions import get_active_subscriptions_by_field_and_value
...@@ -39,26 +36,6 @@ class LAGMember(BaseModel): ...@@ -39,26 +36,6 @@ class LAGMember(BaseModel):
return hash((self.interface_name, self.interface_description)) return hash((self.interface_name, self.interface_description))
@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."""
old_isis_metric = subscription.iptrunk.iptrunk_isis_metric
subscription.iptrunk.iptrunk_isis_metric = 90000
provisioning_proxy.provision_ip_trunk(
subscription,
process_id,
callback_route,
tt_number,
"isis_interface",
dry_run=False,
)
return {
"subscription": subscription,
"old_isis_metric": old_isis_metric,
}
def available_interfaces_choices(router_id: UUID, speed: str) -> Choice | None: def available_interfaces_choices(router_id: UUID, speed: str) -> Choice | None:
"""Return a list of available interfaces for a given router and speed. """Return a list of available interfaces for a given router and speed.
......
"""Workflow steps that are shared across multiple workflows.""" """Workflow steps that are shared across multiple workflows."""
import json
from typing import Any from typing import Any
from orchestrator import step from orchestrator import step
from orchestrator.types import State, UUIDstr 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.provisioning_proxy import execute_playbook
...@@ -60,3 +63,31 @@ def deploy_base_config_real( ...@@ -60,3 +63,31 @@ def deploy_base_config_real(
) )
return {"subscription": subscription} 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."""
old_isis_metric = subscription.iptrunk.iptrunk_isis_metric
subscription.iptrunk.iptrunk_isis_metric = 90000
extra_vars = {
"wfo_trunk_json": json.loads(json_dumps(subscription)),
"dry_run": False,
"verb": "deploy",
"config_object": "isis_interface",
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy config for "
f"{subscription.iptrunk.geant_s_sid} ",
}
execute_playbook(
playbook_name="playbooks.yaml",
callback_route=callback_route,
inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n",
extra_vars=extra_vars,
)
return {
"subscription": subscription,
"old_isis_metric": old_isis_metric,
}
"""A creation workflow that deploys a new IP trunk service.""" """A creation workflow that deploys a new IP trunk service."""
import json
from uuid import uuid4 from uuid import uuid4
from orchestrator.forms import FormPage from orchestrator.forms import FormPage
from orchestrator.forms.validators import Choice, UniqueConstrainedList from orchestrator.forms.validators import Choice, UniqueConstrainedList
from orchestrator.targets import Target from orchestrator.targets import Target
from orchestrator.types import FormGenerator, State, SubscriptionLifecycle, UUIDstr from orchestrator.types import FormGenerator, State, SubscriptionLifecycle, UUIDstr
from orchestrator.utils.json import json_dumps
from orchestrator.workflow import StepList, done, init, step, workflow from orchestrator.workflow import StepList, done, init, step, workflow
from orchestrator.workflows.steps import resync, set_status, store_process_subscription from orchestrator.workflows.steps import resync, set_status, store_process_subscription
from orchestrator.workflows.utils import wrap_create_initial_input_form from orchestrator.workflows.utils import wrap_create_initial_input_form
...@@ -20,10 +22,10 @@ from gso.products.product_blocks.iptrunk import ( ...@@ -20,10 +22,10 @@ from gso.products.product_blocks.iptrunk import (
from gso.products.product_blocks.router import RouterVendor from gso.products.product_blocks.router import RouterVendor
from gso.products.product_types.iptrunk import IptrunkInactive, IptrunkProvisioning from gso.products.product_types.iptrunk import IptrunkInactive, IptrunkProvisioning
from gso.products.product_types.router import Router from gso.products.product_types.router import Router
from gso.services import infoblox, provisioning_proxy, subscriptions from gso.services import infoblox, subscriptions
from gso.services.crm import customer_selector from gso.services.crm import customer_selector
from gso.services.netbox_client import NetboxClient from gso.services.netbox_client import NetboxClient
from gso.services.provisioning_proxy import pp_interaction from gso.services.provisioning_proxy import execute_playbook, pp_interaction
from gso.utils.helpers import ( from gso.utils.helpers import (
LAGMember, LAGMember,
available_interfaces_choices, available_interfaces_choices,
...@@ -253,13 +255,21 @@ def provision_ip_trunk_iface_dry( ...@@ -253,13 +255,21 @@ def provision_ip_trunk_iface_dry(
tt_number: str, tt_number: str,
) -> State: ) -> State:
"""Perform a dry run of deploying configuration on both sides of the trunk.""" """Perform a dry run of deploying configuration on both sides of the trunk."""
provisioning_proxy.provision_ip_trunk( extra_vars = {
subscription, "wfo_trunk_json": json.loads(json_dumps(subscription)),
process_id, "dry_run": True,
callback_route, "verb": "deploy",
tt_number, "config_object": "trunk_interface",
"trunk_interface", "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy config for "
dry_run=True, f"{subscription.iptrunk.geant_s_sid} ",
}
execute_playbook(
playbook_name="iptrunks.yaml",
callback_route=callback_route,
inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n",
extra_vars=extra_vars,
) )
return {"subscription": subscription} return {"subscription": subscription}
...@@ -273,13 +283,21 @@ def provision_ip_trunk_iface_real( ...@@ -273,13 +283,21 @@ def provision_ip_trunk_iface_real(
tt_number: str, tt_number: str,
) -> State: ) -> State:
"""Deploy IP trunk configuration on both sides.""" """Deploy IP trunk configuration on both sides."""
provisioning_proxy.provision_ip_trunk( extra_vars = {
subscription, "wfo_trunk_json": json.loads(json_dumps(subscription)),
process_id, "dry_run": False,
callback_route, "verb": "deploy",
tt_number, "config_object": "trunk_interface",
"trunk_interface", "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy config for "
dry_run=False, f"{subscription.iptrunk.geant_s_sid} ",
}
execute_playbook(
playbook_name="iptrunks.yaml",
callback_route=callback_route,
inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n",
extra_vars=extra_vars,
) )
return {"subscription": subscription} return {"subscription": subscription}
...@@ -289,11 +307,16 @@ def provision_ip_trunk_iface_real( ...@@ -289,11 +307,16 @@ def provision_ip_trunk_iface_real(
def check_ip_trunk_connectivity( def check_ip_trunk_connectivity(
subscription: IptrunkProvisioning, subscription: IptrunkProvisioning,
callback_route: str, callback_route: str,
process_id: UUIDstr,
tt_number: str,
) -> State: ) -> State:
"""Check successful connectivity across the new trunk.""" """Check successful connectivity across the new trunk."""
provisioning_proxy.check_ip_trunk(subscription, process_id, callback_route, tt_number, "ping") extra_vars = {"wfo_ip_trunk_json": json.loads(json_dumps(subscription)), "check": "ping"}
execute_playbook(
playbook_name="iptrunks_checks.yaml",
callback_route=callback_route,
inventory=subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn,
extra_vars=extra_vars,
)
return {"subscription": subscription} return {"subscription": subscription}
...@@ -306,7 +329,22 @@ def provision_ip_trunk_isis_iface_dry( ...@@ -306,7 +329,22 @@ def provision_ip_trunk_isis_iface_dry(
tt_number: str, tt_number: str,
) -> State: ) -> State:
"""Perform a dry run of deploying :term:`ISIS` configuration.""" """Perform a dry run of deploying :term:`ISIS` configuration."""
provisioning_proxy.provision_ip_trunk(subscription, process_id, callback_route, tt_number, "isis_interface") extra_vars = {
"wfo_trunk_json": json.loads(json_dumps(subscription)),
"dry_run": True,
"verb": "deploy",
"config_object": "isis_interface",
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy config for "
f"{subscription.iptrunk.geant_s_sid} ",
}
execute_playbook(
playbook_name="iptrunks.yaml",
callback_route=callback_route,
inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n",
extra_vars=extra_vars,
)
return {"subscription": subscription} return {"subscription": subscription}
...@@ -319,13 +357,21 @@ def provision_ip_trunk_isis_iface_real( ...@@ -319,13 +357,21 @@ def provision_ip_trunk_isis_iface_real(
tt_number: str, tt_number: str,
) -> State: ) -> State:
"""Deploy :term:`ISIS` configuration on both sides.""" """Deploy :term:`ISIS` configuration on both sides."""
provisioning_proxy.provision_ip_trunk( extra_vars = {
subscription, "wfo_trunk_json": json.loads(json_dumps(subscription)),
process_id, "dry_run": False,
callback_route, "verb": "deploy",
tt_number, "config_object": "isis_interface",
"isis_interface", "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy config for "
dry_run=False, f"{subscription.iptrunk.geant_s_sid} ",
}
execute_playbook(
playbook_name="iptrunks.yaml",
callback_route=callback_route,
inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n",
extra_vars=extra_vars,
) )
return {"subscription": subscription} return {"subscription": subscription}
...@@ -335,11 +381,16 @@ def provision_ip_trunk_isis_iface_real( ...@@ -335,11 +381,16 @@ def provision_ip_trunk_isis_iface_real(
def check_ip_trunk_isis( def check_ip_trunk_isis(
subscription: IptrunkProvisioning, subscription: IptrunkProvisioning,
callback_route: str, callback_route: str,
process_id: UUIDstr,
tt_number: str,
) -> State: ) -> State:
"""Run an Ansible playbook to confirm :term:`ISIS` adjacency.""" """Run an Ansible playbook to confirm :term:`ISIS` adjacency."""
provisioning_proxy.check_ip_trunk(subscription, process_id, callback_route, tt_number, "isis") extra_vars = {"wfo_ip_trunk_json": json.loads(json_dumps(subscription)), "check": "isis"}
execute_playbook(
playbook_name="iptrunks_checks.yaml",
callback_route=callback_route,
inventory=subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn,
extra_vars=extra_vars,
)
return {"subscription": subscription} return {"subscription": subscription}
......
...@@ -5,6 +5,7 @@ configured to run from A to C. B is then no longer associated with this IP trunk ...@@ -5,6 +5,7 @@ configured to run from A to C. B is then no longer associated with this IP trunk
""" """
import copy import copy
import json
import re import re
from logging import getLogger from logging import getLogger
from typing import NoReturn from typing import NoReturn
...@@ -16,6 +17,7 @@ from orchestrator.forms import FormPage ...@@ -16,6 +17,7 @@ from orchestrator.forms import FormPage
from orchestrator.forms.validators import Choice, Label, UniqueConstrainedList from orchestrator.forms.validators import Choice, Label, UniqueConstrainedList
from orchestrator.targets import Target from orchestrator.targets import Target
from orchestrator.types import FormGenerator, State, UUIDstr from orchestrator.types import FormGenerator, State, UUIDstr
from orchestrator.utils.json import json_dumps
from orchestrator.workflow import StepList, conditional, done, init, inputstep from orchestrator.workflow import StepList, conditional, done, init, inputstep
from orchestrator.workflows.steps import resync, store_process_subscription, unsync from orchestrator.workflows.steps import resync, store_process_subscription, unsync
from orchestrator.workflows.utils import wrap_modify_initial_input_form from orchestrator.workflows.utils import wrap_modify_initial_input_form
...@@ -27,18 +29,17 @@ from gso.products.product_blocks.iptrunk import IptrunkInterfaceBlock ...@@ -27,18 +29,17 @@ from gso.products.product_blocks.iptrunk import IptrunkInterfaceBlock
from gso.products.product_blocks.router import RouterVendor from gso.products.product_blocks.router import RouterVendor
from gso.products.product_types.iptrunk import Iptrunk from gso.products.product_types.iptrunk import Iptrunk
from gso.products.product_types.router import Router from gso.products.product_types.router import Router
from gso.services import provisioning_proxy
from gso.services.netbox_client import NetboxClient from gso.services.netbox_client import NetboxClient
from gso.services.provisioning_proxy import pp_interaction from gso.services.provisioning_proxy import execute_playbook, pp_interaction
from gso.services.subscriptions import get_active_router_subscriptions from gso.services.subscriptions import get_active_router_subscriptions
from gso.utils.helpers import ( from gso.utils.helpers import (
LAGMember, LAGMember,
available_interfaces_choices, available_interfaces_choices,
available_lags_choices, available_lags_choices,
get_router_vendor, get_router_vendor,
set_isis_to_90000,
validate_interface_name_list, validate_interface_name_list,
) )
from gso.utils.workflow_steps import set_isis_to_90000
logger = getLogger(__name__) logger = getLogger(__name__)
...@@ -182,22 +183,29 @@ def disable_old_config_dry( ...@@ -182,22 +183,29 @@ def disable_old_config_dry(
tt_number: str, tt_number: str,
) -> State: ) -> State:
"""Perform a dry run of disabling the old configuration on the routers.""" """Perform a dry run of disabling the old configuration on the routers."""
provisioning_proxy.migrate_ip_trunk( extra_vars = {
subscription, "wfo_trunk_json": json.loads(json_dumps(subscription)),
new_node, "new_node": json.loads(json_dumps(new_node)),
new_lag_interface, "new_lag_interface": new_lag_interface,
new_lag_member_interfaces, "new_lag_member_interfaces": new_lag_member_interfaces,
replace_index, "replace_index": replace_index,
process_id, "verb": "deactivate",
callback_route, "config_object": "deactivate",
tt_number, "dry_run": True,
"deactivate", "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} "
"deactivate", f"- Deploy config for {subscription.iptrunk.geant_s_sid}",
}
execute_playbook(
playbook_name="iptrunks_migration.yaml",
callback_route=callback_route,
inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n"
f"{new_node.router.router_fqdn}\n",
extra_vars=extra_vars,
) )
return { return {"subscription": subscription}
"subscription": subscription,
}
@step("[REAL] Disable configuration on old router") @step("[REAL] Disable configuration on old router")
...@@ -212,18 +220,26 @@ def disable_old_config_real( ...@@ -212,18 +220,26 @@ def disable_old_config_real(
tt_number: str, tt_number: str,
) -> State: ) -> State:
"""Disable old configuration on the routers.""" """Disable old configuration on the routers."""
provisioning_proxy.migrate_ip_trunk( extra_vars = {
subscription, "wfo_trunk_json": json.loads(json_dumps(subscription)),
new_node, "new_node": json.loads(json_dumps(new_node)),
new_lag_interface, "new_lag_interface": new_lag_interface,
new_lag_member_interfaces, "new_lag_member_interfaces": new_lag_member_interfaces,
replace_index, "replace_index": replace_index,
process_id, "verb": "deactivate",
callback_route, "config_object": "deactivate",
tt_number, "dry_run": False,
"deactivate", "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} "
"deactivate", f"- Deploy config for {subscription.iptrunk.geant_s_sid}",
dry_run=False, }
execute_playbook(
playbook_name="iptrunks_migration.yaml",
callback_route=callback_route,
inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n"
f"{new_node.router.router_fqdn}\n",
extra_vars=extra_vars,
) )
return { return {
...@@ -242,28 +258,30 @@ def deploy_new_config_dry( ...@@ -242,28 +258,30 @@ def deploy_new_config_dry(
process_id: UUIDstr, process_id: UUIDstr,
tt_number: str, tt_number: str,
) -> State: ) -> State:
"""Perform a dry run of deploying configuration on the new router. """Perform a dry run of deploying configuration on the new router."""
extra_vars = {
"wfo_trunk_json": json.loads(json_dumps(subscription)),
"new_node": json.loads(json_dumps(new_node)),
"new_lag_interface": new_lag_interface,
"new_lag_member_interfaces": new_lag_member_interfaces,
"replace_index": replace_index,
"verb": "deploy",
"config_object": "trunk_interface",
"dry_run": True,
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} "
f"- Deploy config for {subscription.iptrunk.geant_s_sid}",
}
TODO: set the proper playbook verb execute_playbook(
""" playbook_name="iptrunks_migration.yaml",
provisioning_proxy.migrate_ip_trunk( callback_route=callback_route,
subscription, inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
new_node, f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n"
new_lag_interface, f"{new_node.router.router_fqdn}\n",
new_lag_member_interfaces, extra_vars=extra_vars,
replace_index,
process_id,
callback_route,
tt_number,
"deploy",
"trunk_interface",
) )
logger.warning(PLAYBOOK_VERB_NOT_YET_PROPERLY_SET) return {"subscription": subscription}
return {
"subscription": subscription,
}
@step("Deploy configuration on new router") @step("Deploy configuration on new router")
...@@ -277,29 +295,30 @@ def deploy_new_config_real( ...@@ -277,29 +295,30 @@ def deploy_new_config_real(
process_id: UUIDstr, process_id: UUIDstr,
tt_number: str, tt_number: str,
) -> State: ) -> State:
"""Deploy configuration on the new router. """Deploy configuration on the new router."""
extra_vars = {
"wfo_trunk_json": json.loads(json_dumps(subscription)),
"new_node": json.loads(json_dumps(new_node)),
"new_lag_interface": new_lag_interface,
"new_lag_member_interfaces": new_lag_member_interfaces,
"replace_index": replace_index,
"verb": "deploy",
"config_object": "trunk_interface",
"dry_run": False,
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} "
f"- Deploy config for {subscription.iptrunk.geant_s_sid}",
}
TODO: set the proper playbook verb execute_playbook(
""" playbook_name="iptrunks_migration.yaml",
provisioning_proxy.migrate_ip_trunk( callback_route=callback_route,
subscription, inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
new_node, f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n"
new_lag_interface, f"{new_node.router.router_fqdn}\n",
new_lag_member_interfaces, extra_vars=extra_vars,
replace_index,
process_id,
callback_route,
tt_number,
"deploy",
"trunk_interface",
dry_run=False,
) )
logger.warning(PLAYBOOK_VERB_NOT_YET_PROPERLY_SET) return {"subscription": subscription}
return {
"subscription": subscription,
}
@inputstep("Wait for confirmation", assignee=Assignee.SYSTEM) @inputstep("Wait for confirmation", assignee=Assignee.SYSTEM)
...@@ -328,29 +347,30 @@ def deploy_new_isis( ...@@ -328,29 +347,30 @@ def deploy_new_isis(
process_id: UUIDstr, process_id: UUIDstr,
tt_number: str, tt_number: str,
) -> State: ) -> State:
"""Deploy :term:`ISIS` configuration. """Deploy :term:`ISIS` configuration."""
extra_vars = {
"wfo_trunk_json": json.loads(json_dumps(subscription)),
"new_node": json.loads(json_dumps(new_node)),
"new_lag_interface": new_lag_interface,
"new_lag_member_interfaces": new_lag_member_interfaces,
"replace_index": replace_index,
"verb": "deploy",
"config_object": "isis_interface",
"dry_run": False,
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} "
f"- Deploy config for {subscription.iptrunk.geant_s_sid}",
}
TODO: set the proper playbook verb. execute_playbook(
""" playbook_name="iptrunks_migration.yaml",
provisioning_proxy.migrate_ip_trunk( callback_route=callback_route,
subscription, inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
new_node, f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n"
new_lag_interface, f"{new_node.router.router_fqdn}\n",
new_lag_member_interfaces, extra_vars=extra_vars,
replace_index,
process_id,
callback_route,
tt_number,
"deploy",
"isis_interface",
dry_run=False,
) )
logger.warning(PLAYBOOK_VERB_NOT_YET_PROPERLY_SET) return {"subscription": subscription}
return {
"subscription": subscription,
}
@inputstep("Wait for confirmation", assignee=Assignee.SYSTEM) @inputstep("Wait for confirmation", assignee=Assignee.SYSTEM)
...@@ -378,13 +398,21 @@ def restore_isis_metric( ...@@ -378,13 +398,21 @@ def restore_isis_metric(
) -> State: ) -> State:
"""Restore the :term:`ISIS` metric to its original value.""" """Restore the :term:`ISIS` metric to its original value."""
subscription.iptrunk.iptrunk_isis_metric = old_isis_metric subscription.iptrunk.iptrunk_isis_metric = old_isis_metric
provisioning_proxy.provision_ip_trunk( extra_vars = {
subscription, "wfo_trunk_json": json.loads(json_dumps(subscription)),
process_id, "dry_run": False,
callback_route, "verb": "deploy",
tt_number, "config_object": "isis_interface",
"isis_interface", "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy config for "
dry_run=False, f"{subscription.iptrunk.geant_s_sid} ",
}
execute_playbook(
playbook_name="iptrunks.yaml",
callback_route=callback_route,
inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n",
extra_vars=extra_vars,
) )
return {"subscription": subscription} return {"subscription": subscription}
...@@ -401,25 +429,29 @@ def delete_old_config_dry( ...@@ -401,25 +429,29 @@ def delete_old_config_dry(
process_id: UUIDstr, process_id: UUIDstr,
tt_number: str, tt_number: str,
) -> State: ) -> State:
"""Perform a dry run of deleting the old configuration. """Perform a dry run of deleting the old configuration."""
extra_vars = {
"wfo_trunk_json": json.loads(json_dumps(subscription)),
"new_node": json.loads(json_dumps(new_node)),
"new_lag_interface": new_lag_interface,
"new_lag_member_interfaces": new_lag_member_interfaces,
"replace_index": replace_index,
"verb": "delete",
"config_object": "delete",
"dry_run": True,
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} "
f"- Deploy config for {subscription.iptrunk.geant_s_sid}",
}
TODO: set the proper playbook verb execute_playbook(
""" playbook_name="iptrunks_migration.yaml",
provisioning_proxy.migrate_ip_trunk( callback_route=callback_route,
subscription, inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
new_node, f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n"
new_lag_interface, f"{new_node.router.router_fqdn}\n",
new_lag_member_interfaces, extra_vars=extra_vars,
replace_index,
process_id,
callback_route,
tt_number,
"delete",
"delete",
) )
logger.warning(PLAYBOOK_VERB_NOT_YET_PROPERLY_SET)
return {"subscription": subscription} return {"subscription": subscription}
...@@ -434,26 +466,29 @@ def delete_old_config_real( ...@@ -434,26 +466,29 @@ def delete_old_config_real(
process_id: UUIDstr, process_id: UUIDstr,
tt_number: str, tt_number: str,
) -> State: ) -> State:
"""Delete old configuration from the routers. """Delete old configuration from the routers."""
extra_vars = {
"wfo_trunk_json": json.loads(json_dumps(subscription)),
"new_node": json.loads(json_dumps(new_node)),
"new_lag_interface": new_lag_interface,
"new_lag_member_interfaces": new_lag_member_interfaces,
"replace_index": replace_index,
"verb": "delete",
"config_object": "delete",
"dry_run": False,
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} "
f"- Deploy config for {subscription.iptrunk.geant_s_sid}",
}
TODO: set the proper playbook verb execute_playbook(
""" playbook_name="iptrunks_migration.yaml",
provisioning_proxy.migrate_ip_trunk( callback_route=callback_route,
subscription, inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
new_node, f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n"
new_lag_interface, f"{new_node.router.router_fqdn}\n",
new_lag_member_interfaces, extra_vars=extra_vars,
replace_index,
process_id,
callback_route,
tt_number,
"delete",
"delete",
dry_run=False,
) )
logger.warning(PLAYBOOK_VERB_NOT_YET_PROPERLY_SET)
return {"subscription": subscription} return {"subscription": subscription}
......
"""A modification workflow for setting a new :term:`ISIS` metric for an IP trunk.""" """A modification workflow for setting a new :term:`ISIS` metric for an IP trunk."""
import json
from orchestrator.forms import FormPage from orchestrator.forms import FormPage
from orchestrator.targets import Target from orchestrator.targets import Target
from orchestrator.types import FormGenerator, State, UUIDstr from orchestrator.types import FormGenerator, State, UUIDstr
from orchestrator.utils.json import json_dumps
from orchestrator.workflow import StepList, done, init, step, workflow from orchestrator.workflow import StepList, done, init, step, workflow
from orchestrator.workflows.steps import resync, store_process_subscription, unsync from orchestrator.workflows.steps import resync, store_process_subscription, unsync
from orchestrator.workflows.utils import wrap_modify_initial_input_form from orchestrator.workflows.utils import wrap_modify_initial_input_form
from gso.products.product_types.iptrunk import Iptrunk from gso.products.product_types.iptrunk import Iptrunk
from gso.services import provisioning_proxy from gso.services.provisioning_proxy import execute_playbook, pp_interaction
from gso.services.provisioning_proxy import pp_interaction
def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator: def initial_input_form_generator(subscription_id: UUIDstr) -> FormGenerator:
...@@ -41,7 +43,22 @@ def provision_ip_trunk_isis_iface_dry( ...@@ -41,7 +43,22 @@ def provision_ip_trunk_isis_iface_dry(
tt_number: str, tt_number: str,
) -> State: ) -> State:
"""Perform a dry run of deploying the new :term:`ISIS` metric on both sides of the trunk.""" """Perform a dry run of deploying the new :term:`ISIS` metric on both sides of the trunk."""
provisioning_proxy.provision_ip_trunk(subscription, process_id, callback_route, tt_number, "isis_interface") extra_vars = {
"wfo_trunk_json": json.loads(json_dumps(subscription)),
"dry_run": True,
"verb": "deploy",
"config_object": "isis_interface",
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy config for "
f"{subscription.iptrunk.geant_s_sid} ",
}
execute_playbook(
playbook_name="iptrunks.yaml",
callback_route=callback_route,
inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n",
extra_vars=extra_vars,
)
return {"subscription": subscription} return {"subscription": subscription}
...@@ -54,13 +71,21 @@ def provision_ip_trunk_isis_iface_real( ...@@ -54,13 +71,21 @@ def provision_ip_trunk_isis_iface_real(
tt_number: str, tt_number: str,
) -> State: ) -> State:
"""Deploy the new :term:`ISIS` metric on both sides of the trunk.""" """Deploy the new :term:`ISIS` metric on both sides of the trunk."""
provisioning_proxy.provision_ip_trunk( extra_vars = {
subscription, "wfo_trunk_json": json.loads(json_dumps(subscription)),
process_id, "dry_run": False,
callback_route, "verb": "deploy",
tt_number, "config_object": "isis_interface",
"isis_interface", "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy config for "
dry_run=False, f"{subscription.iptrunk.geant_s_sid} ",
}
execute_playbook(
playbook_name="iptrunks.yaml",
callback_route=callback_route,
inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n",
extra_vars=extra_vars,
) )
return {"subscription": subscription} return {"subscription": subscription}
......
"""A modification workflow that updates the :term:`LAG` interfaces that are part of an existing IP trunk.""" """A modification workflow that updates the :term:`LAG` interfaces that are part of an existing IP trunk."""
import ipaddress import ipaddress
import json
from uuid import uuid4 from uuid import uuid4
from orchestrator.forms import FormPage, ReadOnlyField from orchestrator.forms import FormPage, ReadOnlyField
from orchestrator.forms.validators import UniqueConstrainedList from orchestrator.forms.validators import UniqueConstrainedList
from orchestrator.targets import Target from orchestrator.targets import Target
from orchestrator.types import FormGenerator, State, UUIDstr from orchestrator.types import FormGenerator, State, UUIDstr
from orchestrator.utils.json import json_dumps
from orchestrator.workflow import StepList, done, init, step, workflow from orchestrator.workflow import StepList, done, init, step, workflow
from orchestrator.workflows.steps import resync, store_process_subscription, unsync from orchestrator.workflows.steps import resync, store_process_subscription, unsync
from orchestrator.workflows.utils import wrap_modify_initial_input_form from orchestrator.workflows.utils import wrap_modify_initial_input_form
...@@ -20,9 +22,8 @@ from gso.products.product_blocks.iptrunk import ( ...@@ -20,9 +22,8 @@ from gso.products.product_blocks.iptrunk import (
) )
from gso.products.product_blocks.router import RouterVendor from gso.products.product_blocks.router import RouterVendor
from gso.products.product_types.iptrunk import Iptrunk from gso.products.product_types.iptrunk import Iptrunk
from gso.services import provisioning_proxy
from gso.services.netbox_client import NetboxClient from gso.services.netbox_client import NetboxClient
from gso.services.provisioning_proxy import pp_interaction from gso.services.provisioning_proxy import execute_playbook, pp_interaction
from gso.utils.helpers import ( from gso.utils.helpers import (
LAGMember, LAGMember,
available_interfaces_choices, available_interfaces_choices,
...@@ -215,14 +216,22 @@ def provision_ip_trunk_iface_dry( ...@@ -215,14 +216,22 @@ def provision_ip_trunk_iface_dry(
removed_ae_members: list[str], removed_ae_members: list[str],
) -> State: ) -> State:
"""Perform a dry run of deploying the updated IP trunk.""" """Perform a dry run of deploying the updated IP trunk."""
provisioning_proxy.provision_ip_trunk( extra_vars = {
subscription, "wfo_trunk_json": json.loads(json_dumps(subscription)),
process_id, "dry_run": True,
callback_route, "verb": "deploy",
tt_number, "config_object": "trunk_interface",
"trunk_interface", "removed_ae_members": removed_ae_members,
dry_run=True, "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy config for "
removed_ae_members=removed_ae_members, f"{subscription.iptrunk.geant_s_sid} ",
}
execute_playbook(
playbook_name="iptrunks.yaml",
callback_route=callback_route,
inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n",
extra_vars=extra_vars,
) )
return {"subscription": subscription} return {"subscription": subscription}
...@@ -237,14 +246,22 @@ def provision_ip_trunk_iface_real( ...@@ -237,14 +246,22 @@ def provision_ip_trunk_iface_real(
removed_ae_members: list[str], removed_ae_members: list[str],
) -> State: ) -> State:
"""Provision the new IP trunk with updated interfaces.""" """Provision the new IP trunk with updated interfaces."""
provisioning_proxy.provision_ip_trunk( extra_vars = {
subscription, "wfo_trunk_json": json.loads(json_dumps(subscription)),
process_id, "dry_run": False,
callback_route, "verb": "deploy",
tt_number, "config_object": "trunk_interface",
"trunk_interface", "removed_ae_members": removed_ae_members,
dry_run=False, "commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} - Deploy config for "
removed_ae_members=removed_ae_members, f"{subscription.iptrunk.geant_s_sid} ",
}
execute_playbook(
playbook_name="iptrunks.yaml",
callback_route=callback_route,
inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n",
extra_vars=extra_vars,
) )
return {"subscription": subscription} return {"subscription": subscription}
......
"""A termination workflow for an active IP trunk.""" """A termination workflow for an active IP trunk."""
import ipaddress import ipaddress
import json
from orchestrator.forms import FormPage from orchestrator.forms import FormPage
from orchestrator.forms.validators import Label from orchestrator.forms.validators import Label
from orchestrator.targets import Target from orchestrator.targets import Target
from orchestrator.types import FormGenerator, State, SubscriptionLifecycle, UUIDstr from orchestrator.types import FormGenerator, State, SubscriptionLifecycle, UUIDstr
from orchestrator.utils.json import json_dumps
from orchestrator.workflow import StepList, conditional, done, init, step, workflow from orchestrator.workflow import StepList, conditional, done, init, step, workflow
from orchestrator.workflows.steps import ( from orchestrator.workflows.steps import (
resync, resync,
...@@ -17,10 +19,11 @@ from orchestrator.workflows.utils import wrap_modify_initial_input_form ...@@ -17,10 +19,11 @@ from orchestrator.workflows.utils import wrap_modify_initial_input_form
from gso.products.product_blocks.router import RouterVendor from gso.products.product_blocks.router import RouterVendor
from gso.products.product_types.iptrunk import Iptrunk from gso.products.product_types.iptrunk import Iptrunk
from gso.services import infoblox, provisioning_proxy from gso.services import infoblox
from gso.services.netbox_client import NetboxClient from gso.services.netbox_client import NetboxClient
from gso.services.provisioning_proxy import pp_interaction from gso.services.provisioning_proxy import execute_playbook, pp_interaction
from gso.utils.helpers import get_router_vendor, set_isis_to_90000 from gso.utils.helpers import get_router_vendor
from gso.utils.workflow_steps import set_isis_to_90000
def initial_input_form_generator() -> FormGenerator: def initial_input_form_generator() -> FormGenerator:
...@@ -39,33 +42,25 @@ def initial_input_form_generator() -> FormGenerator: ...@@ -39,33 +42,25 @@ def initial_input_form_generator() -> FormGenerator:
return user_input.dict() return user_input.dict()
@step("Drain traffic from trunk")
def drain_traffic_from_ip_trunk(
subscription: Iptrunk,
process_id: UUIDstr,
callback_route: str,
tt_number: str,
) -> State:
"""Drain all traffic from the trunk.
XXX: Should this not be done with the isis-90k-step?
"""
provisioning_proxy.provision_ip_trunk(
subscription,
process_id,
callback_route,
tt_number,
"isis_interface",
dry_run=False,
)
return {"subscription": subscription}
@step("Deprovision IP trunk [DRY RUN]") @step("Deprovision IP trunk [DRY RUN]")
def deprovision_ip_trunk_dry(subscription: Iptrunk, process_id: UUIDstr, callback_route: str, tt_number: str) -> State: def deprovision_ip_trunk_dry(subscription: Iptrunk, process_id: UUIDstr, callback_route: str, tt_number: str) -> State:
"""Perform a dry run of deleting configuration from the routers.""" """Perform a dry run of deleting configuration from the routers."""
provisioning_proxy.deprovision_ip_trunk(subscription, process_id, callback_route, tt_number, dry_run=True) extra_vars = {
"wfo_trunk_json": json.loads(json_dumps(subscription)),
"dry_run": True,
"verb": "terminate",
"config_object": "trunk_deprovision",
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} "
f"- Remove config for {subscription.iptrunk.geant_s_sid}",
}
execute_playbook(
playbook_name="iptrunks.yaml",
inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n",
extra_vars=extra_vars,
callback_route=callback_route,
)
return {"subscription": subscription} return {"subscription": subscription}
...@@ -73,7 +68,22 @@ def deprovision_ip_trunk_dry(subscription: Iptrunk, process_id: UUIDstr, callbac ...@@ -73,7 +68,22 @@ def deprovision_ip_trunk_dry(subscription: Iptrunk, process_id: UUIDstr, callbac
@step("Deprovision IP trunk [FOR REAL]") @step("Deprovision IP trunk [FOR REAL]")
def deprovision_ip_trunk_real(subscription: Iptrunk, process_id: UUIDstr, callback_route: str, tt_number: str) -> State: def deprovision_ip_trunk_real(subscription: Iptrunk, process_id: UUIDstr, callback_route: str, tt_number: str) -> State:
"""Delete configuration from the routers.""" """Delete configuration from the routers."""
provisioning_proxy.deprovision_ip_trunk(subscription, process_id, callback_route, tt_number, dry_run=False) extra_vars = {
"wfo_trunk_json": json.loads(json_dumps(subscription)),
"dry_run": False,
"verb": "terminate",
"config_object": "trunk_deprovision",
"commit_comment": f"GSO_PROCESS_ID: {process_id} - TT_NUMBER: {tt_number} "
f"- Remove config for {subscription.iptrunk.geant_s_sid}",
}
execute_playbook(
playbook_name="iptrunks.yaml",
inventory=f"{subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.router_fqdn}\n"
f"{subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.router_fqdn}\n",
extra_vars=extra_vars,
callback_route=callback_route,
)
return {"subscription": subscription} return {"subscription": subscription}
......
...@@ -96,15 +96,13 @@ def input_form_wizard_data(request, juniper_router_subscription_factory, nokia_r ...@@ -96,15 +96,13 @@ def input_form_wizard_data(request, juniper_router_subscription_factory, nokia_r
@pytest.mark.workflow() @pytest.mark.workflow()
@patch("gso.workflows.iptrunk.create_iptrunk.provisioning_proxy.check_ip_trunk") @patch("gso.workflows.iptrunk.create_iptrunk.execute_playbook")
@patch("gso.workflows.iptrunk.create_iptrunk.provisioning_proxy.provision_ip_trunk")
@patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v6_network") @patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v6_network")
@patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v4_network") @patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v4_network")
def test_successful_iptrunk_creation_with_standard_lso_result( def test_successful_iptrunk_creation_with_standard_lso_result(
mock_allocate_v4_network, mock_allocate_v4_network,
mock_allocate_v6_network, mock_allocate_v6_network,
mock_provision_ip_trunk, mock_execute_playbook,
mock_check_ip_trunk,
responses, responses,
input_form_wizard_data, input_form_wizard_data,
faker, faker,
...@@ -130,20 +128,17 @@ def test_successful_iptrunk_creation_with_standard_lso_result( ...@@ -130,20 +128,17 @@ def test_successful_iptrunk_creation_with_standard_lso_result(
assert subscription.status == "active" assert subscription.status == "active"
assert subscription.description == f"IP trunk, geant_s_sid:{input_form_wizard_data[0]['geant_s_sid']}" assert subscription.description == f"IP trunk, geant_s_sid:{input_form_wizard_data[0]['geant_s_sid']}"
assert mock_provision_ip_trunk.call_count == 4 assert mock_execute_playbook.call_count == 6
assert mock_check_ip_trunk.call_count == 2
@pytest.mark.workflow() @pytest.mark.workflow()
@patch("gso.workflows.iptrunk.create_iptrunk.provisioning_proxy.check_ip_trunk") @patch("gso.workflows.iptrunk.create_iptrunk.execute_playbook")
@patch("gso.workflows.iptrunk.create_iptrunk.provisioning_proxy.provision_ip_trunk")
@patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v6_network") @patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v6_network")
@patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v4_network") @patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v4_network")
def test_iptrunk_creation_fails_when_lso_return_code_is_one( def test_iptrunk_creation_fails_when_lso_return_code_is_one(
mock_allocate_v4_network, mock_allocate_v4_network,
mock_allocate_v6_network, mock_allocate_v6_network,
mock_provision_ip_trunk, mock_execute_playbook,
mock_check_ip_trunk,
responses, responses,
input_form_wizard_data, input_form_wizard_data,
faker, faker,
...@@ -161,21 +156,18 @@ def test_iptrunk_creation_fails_when_lso_return_code_is_one( ...@@ -161,21 +156,18 @@ def test_iptrunk_creation_fails_when_lso_return_code_is_one(
assert_pp_interaction_failure(result, process_stat, step_log) assert_pp_interaction_failure(result, process_stat, step_log)
assert mock_check_ip_trunk.call_count == 0 assert mock_execute_playbook.call_count == 2
assert mock_provision_ip_trunk.call_count == 2
@pytest.mark.parametrize("input_form_wizard_data", [RouterVendor.JUNIPER], indirect=True) @pytest.mark.parametrize("input_form_wizard_data", [RouterVendor.JUNIPER], indirect=True)
@pytest.mark.workflow() @pytest.mark.workflow()
@patch("gso.workflows.iptrunk.create_iptrunk.provisioning_proxy.check_ip_trunk") @patch("gso.workflows.iptrunk.create_iptrunk.execute_playbook")
@patch("gso.workflows.iptrunk.create_iptrunk.provisioning_proxy.provision_ip_trunk")
@patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v6_network") @patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v6_network")
@patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v4_network") @patch("gso.workflows.iptrunk.create_iptrunk.infoblox.allocate_v4_network")
def test_successful_iptrunk_creation_with_juniper_interface_names( def test_successful_iptrunk_creation_with_juniper_interface_names(
mock_allocate_v4_network, mock_allocate_v4_network,
mock_allocate_v6_network, mock_allocate_v6_network,
mock_provision_ip_trunk, mock_execute_playbook,
mock_check_ip_trunk,
responses, responses,
input_form_wizard_data, input_form_wizard_data,
faker, faker,
......
...@@ -107,8 +107,7 @@ def interface_lists_are_equal(list1, list2): ...@@ -107,8 +107,7 @@ def interface_lists_are_equal(list1, list2):
indirect=True, indirect=True,
) )
@pytest.mark.workflow() @pytest.mark.workflow()
@patch("gso.workflows.iptrunk.migrate_iptrunk.provisioning_proxy.migrate_ip_trunk") @patch("gso.services.provisioning_proxy.execute_playbook")
@patch("gso.workflows.iptrunk.migrate_iptrunk.provisioning_proxy.provision_ip_trunk")
@patch("gso.services.netbox_client.NetboxClient.get_available_interfaces") @patch("gso.services.netbox_client.NetboxClient.get_available_interfaces")
@patch("gso.services.netbox_client.NetboxClient.get_available_lags") @patch("gso.services.netbox_client.NetboxClient.get_available_lags")
@patch("gso.services.netbox_client.NetboxClient.create_interface") @patch("gso.services.netbox_client.NetboxClient.create_interface")
...@@ -126,8 +125,7 @@ def test_migrate_iptrunk_success( ...@@ -126,8 +125,7 @@ def test_migrate_iptrunk_success(
mocked_create_interface, mocked_create_interface,
mocked_get_available_lags, mocked_get_available_lags,
mocked_get_available_interfaces, mocked_get_available_interfaces,
mock_provision_ip_trunk, mock_execute_playbook,
mock_migrate_ip_trunk,
migrate_form_input, migrate_form_input,
data_config_filename: PathLike, data_config_filename: PathLike,
): ):
...@@ -165,8 +163,7 @@ def test_migrate_iptrunk_success( ...@@ -165,8 +163,7 @@ def test_migrate_iptrunk_success(
subscription = Iptrunk.from_subscription(subscription_id) subscription = Iptrunk.from_subscription(subscription_id)
assert subscription.status == "active" assert subscription.status == "active"
assert mock_provision_ip_trunk.call_count == 2 assert mock_execute_playbook.call_count == 9
assert mock_migrate_ip_trunk.call_count == 7
# get some values from form # get some values from form
new_router = migrate_form_input[2]["new_node"] new_router = migrate_form_input[2]["new_node"]
......
...@@ -12,7 +12,7 @@ from test.workflows import ( ...@@ -12,7 +12,7 @@ from test.workflows import (
@pytest.mark.workflow() @pytest.mark.workflow()
@patch("gso.workflows.iptrunk.modify_isis_metric.provisioning_proxy.provision_ip_trunk") @patch("gso.services.provisioning_proxy.execute_playbook")
def test_iptrunk_modify_isis_metric_success( def test_iptrunk_modify_isis_metric_success(
mock_provision_ip_trunk, mock_provision_ip_trunk,
iptrunk_subscription_factory, iptrunk_subscription_factory,
......
...@@ -89,7 +89,7 @@ def input_form_iptrunk_data( ...@@ -89,7 +89,7 @@ def input_form_iptrunk_data(
indirect=True, indirect=True,
) )
@pytest.mark.workflow() @pytest.mark.workflow()
@patch("gso.workflows.iptrunk.modify_trunk_interface.provisioning_proxy.provision_ip_trunk") @patch("gso.workflows.iptrunk.modify_trunk_interface.execute_playbook")
@patch("gso.services.netbox_client.NetboxClient.get_available_interfaces") @patch("gso.services.netbox_client.NetboxClient.get_available_interfaces")
@patch("gso.services.netbox_client.NetboxClient.attach_interface_to_lag") @patch("gso.services.netbox_client.NetboxClient.attach_interface_to_lag")
@patch("gso.services.netbox_client.NetboxClient.reserve_interface") @patch("gso.services.netbox_client.NetboxClient.reserve_interface")
...@@ -138,7 +138,7 @@ def test_iptrunk_modify_trunk_interface_success( ...@@ -138,7 +138,7 @@ def test_iptrunk_modify_trunk_interface_success(
new_side_b_sid = input_form_iptrunk_data[3]["side_b_ae_geant_a_sid"] new_side_b_sid = input_form_iptrunk_data[3]["side_b_ae_geant_a_sid"]
new_side_b_ae_members = input_form_iptrunk_data[3]["side_b_ae_members"] new_side_b_ae_members = input_form_iptrunk_data[3]["side_b_ae_members"]
# Only Nokia interfaces will checked # Only Nokia interfaces are checked
vendor_side_a = subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.vendor vendor_side_a = subscription.iptrunk.iptrunk_sides[0].iptrunk_side_node.vendor
vendor_side_b = subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.vendor vendor_side_b = subscription.iptrunk.iptrunk_sides[1].iptrunk_side_node.vendor
num_ifaces = (len(new_side_a_ae_members) if vendor_side_a == RouterVendor.NOKIA else 0) + ( num_ifaces = (len(new_side_a_ae_members) if vendor_side_a == RouterVendor.NOKIA else 0) + (
......
...@@ -13,8 +13,8 @@ from test.workflows import ( ...@@ -13,8 +13,8 @@ from test.workflows import (
@pytest.mark.workflow() @pytest.mark.workflow()
@patch("gso.workflows.iptrunk.terminate_iptrunk.provisioning_proxy.provision_ip_trunk") @patch("gso.workflows.iptrunk.terminate_iptrunk.execute_playbook")
@patch("gso.workflows.iptrunk.terminate_iptrunk.provisioning_proxy.deprovision_ip_trunk") @patch("gso.utils.workflow_steps.execute_playbook")
@patch("gso.workflows.iptrunk.terminate_iptrunk.infoblox.delete_network") @patch("gso.workflows.iptrunk.terminate_iptrunk.infoblox.delete_network")
@patch("gso.services.netbox_client.NetboxClient.delete_interface") @patch("gso.services.netbox_client.NetboxClient.delete_interface")
@patch("gso.services.netbox_client.NetboxClient.free_interface") @patch("gso.services.netbox_client.NetboxClient.free_interface")
...@@ -22,8 +22,8 @@ def test_successful_iptrunk_termination( ...@@ -22,8 +22,8 @@ def test_successful_iptrunk_termination(
mocked_free_interface, mocked_free_interface,
mocked_delete_interface, mocked_delete_interface,
mock_infoblox_delete_network, mock_infoblox_delete_network,
mock_deprovision_ip_trunk, mock_set_isis_to_90k,
mock_provision_ip_trunk, mock_execute_playbook,
iptrunk_subscription_factory, iptrunk_subscription_factory,
faker, faker,
data_config_filename, data_config_filename,
...@@ -59,7 +59,7 @@ def test_successful_iptrunk_termination( ...@@ -59,7 +59,7 @@ def test_successful_iptrunk_termination(
subscription = Iptrunk.from_subscription(subscription_id) subscription = Iptrunk.from_subscription(subscription_id)
assert subscription.status == "terminated" assert subscription.status == "terminated"
assert mock_provision_ip_trunk.call_count == 1 assert mock_execute_playbook.call_count == 2
assert mock_deprovision_ip_trunk.call_count == 2 assert mock_set_isis_to_90k.call_count == 1
assert mock_infoblox_delete_network.call_count == 2 assert mock_infoblox_delete_network.call_count == 2
assert subscription.iptrunk.iptrunk_isis_metric == 90000 assert subscription.iptrunk.iptrunk_isis_metric == 90000
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment