Skip to content
Snippets Groups Projects
Commit d323e78d authored by Mohammad Torkashvand's avatar Mohammad Torkashvand
Browse files

added moodi telemetry to create EdgePort wf

parent 09e63ab9
Branches
Tags
1 merge request!303added moodi telemetry to create EdgePort wf
......@@ -209,6 +209,7 @@ class MoodiParams(BaseSettings):
"""Settings for Moodi."""
host: str
moodi_enabled: bool = False
class OSSParams(BaseSettings):
......
......@@ -7,6 +7,7 @@ from orchestrator import inputstep, step
from orchestrator.config.assignee import Assignee
from orchestrator.types import State, UUIDstr
from orchestrator.utils.json import json_dumps
from orchestrator.workflow import StepList, begin, conditional
from pydantic import ConfigDict
from pydantic_forms.core import FormPage
from pydantic_forms.types import FormGenerator
......@@ -14,7 +15,7 @@ from pydantic_forms.validators import Label
from gso.products.product_blocks.router import RouterRole
from gso.products.product_types.iptrunk import Iptrunk
from gso.services.lso_client import LSOState
from gso.services.lso_client import LSOState, lso_interaction
from gso.settings import load_oss_params
from gso.utils.helpers import generate_inventory_for_active_routers
from gso.utils.shared_enums import Vendor
......@@ -391,25 +392,34 @@ def prompt_sharepoint_checklist_url(checklist_url: str) -> FormGenerator:
return {}
@step("Start Moodi")
def start_moodi(subscription: dict[str, Any]) -> LSOState:
_is_moodi_enabled = conditional(lambda _: load_oss_params().MOODI.moodi_enabled)
def start_moodi() -> StepList:
"""Start monitoring on demand using Moodi Telemetry stack."""
params = load_oss_params()
host = load_oss_params().MOODI.host
return {
"playbook_name": "moodi_telemetry/playbooks/start_moodi.yaml",
"inventory": {"all": {"hosts": {params.MOODI.host: None}}},
"extra_vars": {"subscription": subscription},
}
@step("Start Moodi")
def _start_moodi(subscription: dict[str, Any]) -> LSOState:
return {
"playbook_name": "moodi_telemetry/playbooks/start_moodi.yaml",
"inventory": {"all": {"hosts": {host: None}}},
"extra_vars": {"subscription": subscription},
}
return begin >> _is_moodi_enabled(begin >> lso_interaction(_start_moodi))
@step("Stop Moodi")
def stop_moodi() -> LSOState:
"""Stop monitoring on demand."""
params = load_oss_params()
return {
"playbook_name": "moodi_telemetry/playbooks/stop_moodi.yaml",
"inventory": {"all": {"hosts": {params.MOODI.host: None}}},
"extra_vars": None,
}
def stop_moodi() -> StepList:
"""Stop Moodi Telemetry monitoring on demand."""
host = load_oss_params().MOODI.host
@step("Stop Moodi")
def _stop_moodi() -> LSOState:
return {
"playbook_name": "moodi_telemetry/playbooks/stop_moodi.yaml",
"inventory": {"all": {"hosts": {host: None}}},
"extra_vars": None,
}
return begin >> _is_moodi_enabled(begin >> lso_interaction(_stop_moodi))
......@@ -31,6 +31,7 @@ from gso.utils.helpers import (
)
from gso.utils.types.interfaces import LAGMember, PhysicalPortCapacity
from gso.utils.types.tt_number import TTNumber
from gso.utils.workflow_steps import start_moodi, stop_moodi
from gso.workflows.shared import create_summary_form
......@@ -267,11 +268,13 @@ def create_edge_port() -> StepList:
>> create_subscription
>> store_process_subscription(Target.CREATE)
>> initialize_subscription
>> start_moodi()
>> reserve_interfaces_in_netbox
>> lso_interaction(create_edge_port_dry)
>> lso_interaction(create_edge_port_real)
>> allocate_interfaces_in_netbox
>> set_status(SubscriptionLifecycle.ACTIVE)
>> resync
>> stop_moodi()
>> done
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment