Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #808 from cisco-open/cluster-management
Browse files Browse the repository at this point in the history
Add `add_vmanage`, `edit_vmanage` and `get_connected_devices` endpoints for cluster management
  • Loading branch information
przsus authored Sep 30, 2024
2 parents d323862 + 9d885ce commit a542a43
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
3 changes: 2 additions & 1 deletion catalystwan/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from catalystwan.utils.certificate_status import ValidityPeriod
from catalystwan.utils.colors import PrintColors
from catalystwan.utils.creation_tools import FIELD_NAME, asdict, convert_attributes
from catalystwan.utils.persona import Persona
from catalystwan.utils.personality import Personality
from catalystwan.utils.reachability import Reachability

Expand Down Expand Up @@ -281,7 +282,7 @@ class ServiceConfigurationData(DataclassBase):
vmanage_id: str = field(metadata={FIELD_NAME: "vmanageID"})
device_ip: str = field(metadata={FIELD_NAME: "deviceIP"}) # consider using ip4 module to verify
services: dict = field(metadata={FIELD_NAME: "services"}) # consider using nested dataclasses
persona: str = field(default="COMPUTE_AND_DATA") # TODO Enum
persona: Persona = field(default="COMPUTE_AND_DATA")
username: Optional[str] = field(default=None)
password: Optional[str] = field(default=None)

Expand Down
35 changes: 28 additions & 7 deletions catalystwan/endpoints/cluster_management.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Copyright 2023 Cisco Systems, Inc. and its affiliates

# mypy: disable-error-code="empty-body"
from typing import Literal, Optional
from typing import Dict, Literal, Optional
from uuid import UUID

from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict, Field

from catalystwan.endpoints import APIEndpoints, get
from catalystwan.endpoints import JSON, APIEndpoints, get, post, put
from catalystwan.typed_list import DataSequence
from catalystwan.utils.persona import Persona

TenancyModes = Literal["SingleTenant", "MultiTenant"]

Expand All @@ -24,12 +26,30 @@ class VManageDetails(BaseModel):
status: str


class ConnectedDevice(BaseModel):
model_config = ConfigDict(populate_by_name=True)
uuid: UUID
device_id: str = Field(serialization_alias="deviceId", validation_alias="deviceId")


class VManageSetup(BaseModel):
model_config = ConfigDict(populate_by_name=True)
vmanage_id: Optional[str] = Field(default=None, serialization_alias="vmanageID", validation_alias="vmanageID")
device_ip: str = Field(serialization_alias="deviceIP", validation_alias="deviceIP")
username: str
password: str
gen_csr: Optional[bool] = Field(default=None, serialization_alias="genCSR", validation_alias="genCSR")
persona: Persona
services: Optional[Dict[str, Dict[str, bool]]] = Field(default=None)


class ClusterManagement(APIEndpoints):
def add_or_update_user_credentials(self):
# POST /clusterManagement/userCreds
...

def add_vmanage(self):
@post("/clusterManagement/setup")
def add_vmanage(self, payload: VManageSetup) -> JSON:
# POST /clusterManagement/setup
...

Expand All @@ -41,7 +61,8 @@ def configure_vmanage(self):
# POST /clusterManagement/configure
...

def edit_vmanage(self):
@put("/clusterManagement/setup")
def edit_vmanage(self, payload: VManageSetup) -> JSON:
# PUT /clusterManagement/setup
...

Expand All @@ -53,8 +74,8 @@ def get_configured_ip_list(self):
# GET /clusterManagement/iplist/{vmanageID}
...

def get_connected_devices(self):
# GET /clusterManagement/connectedDevices/{vmanageIP}
@get("/clusterManagement/connectedDevices/{vmanageIP}", "data")
def get_connected_devices(self, vmanageIP: str) -> DataSequence[ConnectedDevice]:
...

def get_connected_devices_per_tenant(self):
Expand Down
5 changes: 5 additions & 0 deletions catalystwan/utils/persona.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2024 Cisco Systems, Inc. and its affiliates

from typing import Literal

Persona = Literal["COMPUTE_AND_DATA", "COMPUTE", "DATA"]

0 comments on commit a542a43

Please sign in to comment.