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

Commit

Permalink
Merge branch 'main' into url_monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
renukavinay authored May 7, 2024
2 parents 49b0911 + f8e64e8 commit a023af7
Show file tree
Hide file tree
Showing 12 changed files with 455 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
args: ["-l", "120", "--profile", "black"]

- repo: https://github.com/hadialqattan/pycln
rev: v1.3.3
rev: v2.4.0
hooks:
- id: pycln
args: ["--all"]
Expand Down
18 changes: 11 additions & 7 deletions ENDPOINTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
**THIS FILE WAS AUTO-GENERATED DO NOT EDIT**

Generated for: catalystwan-0.33.4
Generated for: catalystwan-0.33.5

All URIs are relative to */dataservice*
HTTP request | Supported Versions | Method | Payload Type | Return Type | Tenancy Mode
Expand Down Expand Up @@ -469,12 +469,15 @@ DELETE /device/action/software/{version_id}||[**ConfigurationSoftwareActions.del
GET /device/action/software/images||[**ConfigurationSoftwareActions.get_list_of_all_images**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration/software_actions.py#L197)||DataSequence[[**SoftwareImageDetails**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration/software_actions.py#L111)]|
GET /device/action/status/{task_id}||[**ConfigurationDashboardStatus.find_status**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_dashboard_status.py#L121)||[**TaskData**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_dashboard_status.py#L100)|
GET /device/action/status/tasks||[**ConfigurationDashboardStatus.find_running_tasks**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_dashboard_status.py#L125)||[**TasksData**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_dashboard_status.py#L113)|
GET /device/action/install/devices/{device_type}||[**ConfigurationDeviceActions.get_list_of_installed_devices**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L182)||DataSequence[[**InstalledDeviceData**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L118)]|
GET /device/action/ztp/upgrade/setting||[**ConfigurationDeviceActions.get_ztp_upgrade_config_setting**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L216)||DataSequence[[**ZTPUpgradeSettings**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L33)]|
POST /device/action/changepartition||[**ConfigurationDeviceActions.process_mark_change_partition**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L232)|[**PartitionActionPayload**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L61)|[**ActionId**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L25)|
POST /device/action/defaultpartition||[**ConfigurationDeviceActions.process_mark_default_partition**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L240)|[**PartitionActionPayload**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L61)|[**ActionId**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L25)|
POST /device/action/install||[**ConfigurationDeviceActions.process_install_operation**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L248)|[**InstallActionPayload**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L109)|[**ActionId**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L25)|
POST /device/action/removepartition||[**ConfigurationDeviceActions.process_remove_partition**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L280)|[**RemovePartitionActionPayload**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L69)|[**ActionId**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L25)|
GET /device/action/install/devices/{device_type}||[**ConfigurationDeviceActions.get_list_of_installed_devices**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L246)||DataSequence[[**InstalledDeviceData**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L182)]|
GET /device/action/ztp/upgrade/setting||[**ConfigurationDeviceActions.get_ztp_upgrade_config_setting**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L280)||DataSequence[[**ZTPUpgradeSettings**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L34)]|
POST /device/action/changepartition||[**ConfigurationDeviceActions.process_mark_change_partition**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L296)|[**PartitionActionPayload**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L92)|[**ActionId**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L26)|
POST /device/action/defaultpartition||[**ConfigurationDeviceActions.process_mark_default_partition**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L304)|[**PartitionActionPayload**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L92)|[**ActionId**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L26)|
POST /device/action/install||[**ConfigurationDeviceActions.process_install_operation**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L312)|[**InstallActionPayload**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L173)|[**ActionId**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L26)|
POST /device/action/lxcactivate||[**ConfigurationDeviceActions.process_lxc_activate**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L316)|[**PartitionActionPayload**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L92)|[**ActionId**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L26)|
POST /device/action/lxcdelete||[**ConfigurationDeviceActions.process_lxc_delete**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L321)|[**PartitionActionPayload**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L92)|[**ActionId**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L26)|
POST /device/action/lxcupgrade||[**ConfigurationDeviceActions.process_lxc_upgrade**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L338)|[**PartitionActionPayload**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L92)|[**ActionId**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L26)|
POST /device/action/removepartition||[**ConfigurationDeviceActions.process_remove_partition**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L347)|[**RemovePartitionActionPayload**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L133)|[**ActionId**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_actions.py#L26)|
POST /template/device/config/config/||[**ConfigurationDeviceTemplate.get_device_configuration_preview**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_template.py#L22)|[**FeatureToCLIPayload**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_device_template.py#L12)|str|PROVIDER
GET /v1/feature-profile/sdwan/system/aaa/schema|>=20.9|[**ConfigurationFeatureProfile.get_sdwan_system_aaa_parcel_schema**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_feature_profile.py#L41)||None|
GET /v1/feature-profile/sdwan/transport/cellular-controller/schema|>=20.9|[**ConfigurationFeatureProfile.get_sdwan_transport_cellular_controller_parcel_schema**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/configuration_feature_profile.py#L46)||None|
Expand Down Expand Up @@ -572,6 +575,7 @@ PUT /settings/configuration/smartLicensing||[**ConfigurationSettings.edit_smart_
GET /app/json/application_protocol.json||[**MiscellaneousEndpoints.get_application_protocols**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/misc.py#L14)||DataSequence[[**ApplicationProtocolMap**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/models/misc/application_protocols.py#L28)]|
GET /device/tier||[**MonitoringDeviceDetails.get_tiers**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring/device_details.py#L191)||DataSequence[[**Tier**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring/device_details.py#L17)]|
GET /device||[**MonitoringDeviceDetails.list_all_devices**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring/device_details.py#L215)||DataSequence[[**DeviceData**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring/device_details.py#L52)]|
GET /security/policy/devicelist||[**MonitoringSecurityPolicy.get_device_list**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring/security_policy.py#L10)||[**SecurityPolicyDeviceList**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/models/monitoring/security_policy.py#L8)|
GET /server/info||[**ServerInfo.get_server_info**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring/server_info.py#L10)||[**ServerInfoResponse**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/models/monitoring/server_info.py#L6)|
GET /statistics/settings/disable/devicelist/{indexName}||[**MonitoringStatus.get_disabled_device_list**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring/status.py#L58)||[**DisabledDeviceListResponse**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring/status.py#L45)|
PUT /statistics/settings/disable/devicelist/{indexName}||[**MonitoringStatus.update_statistics_device_list**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring/status.py#L62)|[**DisabledDeviceList**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring/status.py#L41)|[**UpdateIndexResponse**](https://github.com/cisco-open/cisco-catalyst-wan-sdk/blob/main/catalystwan/endpoints/monitoring/status.py#L49)|
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ alarms_from_n_hours = session.api.alarms.get(from_time=n)
To get all critical alarms from past `n` hours:

```python
from catalystwan.utils.alarm_status import Severity
n = 48
critical_alarms = session.api.alarms.get(from_time=n).filter(severity=Severity.CRITICAL)
```
Expand All @@ -196,6 +197,7 @@ critical_alarms = session.api.alarms.get(from_time=n).filter(severity=Severity.C
session.api.users.get()

# Create user
from catalystwan.endpoints.administration_user_and_group import User
new_user = User(username="new_user", password="new_user", group=["netadmin"], description="new user")
session.api.users.create(new_user)

Expand Down
2 changes: 2 additions & 0 deletions catalystwan/api/api_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from catalystwan.api.tenant_management_api import TenantManagementAPI
from catalystwan.api.tenant_migration_api import TenantMigrationAPI
from catalystwan.api.versions_utils import RepositoryAPI
from catalystwan.api.virtual_image_action_api import LxcActionAPI

if TYPE_CHECKING:
from catalystwan.session import ManagerSession
Expand All @@ -58,6 +59,7 @@ def __init__(self, session: ManagerSession):
self.repository = RepositoryAPI(session)
self.resource_pool = ResourcePoolAPI(session)
self.software = SoftwareActionAPI(session)
self.lxcsoftware = LxcActionAPI(session)
self.partition = PartitionManagerAPI(session)
self.users = UsersAPI(session)
self.cluster_management = ClusterManagementAPI(session)
Expand Down
78 changes: 73 additions & 5 deletions catalystwan/api/versions_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
from pydantic import BaseModel, ConfigDict, Field

from catalystwan.endpoints.configuration.software_actions import SoftwareImageDetails
from catalystwan.endpoints.configuration_device_actions import PartitionDevice
from catalystwan.endpoints.configuration_device_actions import (
InstallLxcImage,
LxcActivateDevice,
LxcUpgradeDevice,
PartitionDevice,
)
from catalystwan.endpoints.configuration_device_inventory import DeviceDetailsResponse
from catalystwan.exceptions import ImageNotInRepositoryError
from catalystwan.typed_list import DataSequence
Expand Down Expand Up @@ -67,6 +72,18 @@ def get_all_software_images(self) -> DataSequence[SoftwareImageDetails]:
software_images = self.session.endpoints.configuration_software_actions.get_list_of_all_images()
return software_images

def get_all_virtual_images(self) -> DataSequence[SoftwareImageDetails]:
"""
Get all info about all software images stored in Vmanage repository
Returns:
list: software images list
"""
software_images = self.session.endpoints.configuration_software_actions.get_list_of_all_images(
"imageType=virtualmachine"
)
return software_images

def get_devices_versions_repository(self) -> Dict[str, DeviceSoftwareRepository]:
"""
Create DeviceSoftwareRepository dataclass,
Expand Down Expand Up @@ -209,6 +226,54 @@ def _validate_devices_required_fields(self, devices: DataSequence[DeviceDetailsR
f"device.device_ip (current value: {device.device_ip})"
)

def get_lxcactivate_device_list(
self,
version_to_set_up: str,
devices: DataSequence[DeviceDetailsResponse],
) -> DataSequence[LxcActivateDevice]:
self._validate_devices_required_fields(devices)
install_image_payload = [
InstallLxcImage(
network_function_type="app-hosting",
version_name=version_to_set_up,
version_type_name="UTD-Snort-Feature",
)
]
devices_payload = DataSequence(
LxcActivateDevice,
[
LxcActivateDevice(
device_id=str(device.uuid),
device_ip=str(device.local_system_ip),
install_images=install_image_payload,
)
for device in devices
], # type: ignore
)

return devices_payload

def get_lxcupgrade_device_list(
self,
version_to_set_up: str,
devices: DataSequence[DeviceDetailsResponse],
) -> DataSequence[LxcUpgradeDevice]:
self._validate_devices_required_fields(devices)
install_image_payload = [InstallLxcImage(version_name=version_to_set_up)]
devices_payload = DataSequence(
LxcUpgradeDevice,
[
LxcUpgradeDevice(
device_id=str(device.uuid),
device_ip=str(device.local_system_ip),
install_images=install_image_payload,
)
for device in devices
], # type: ignore
)

return devices_payload

def _get_device_list_in(
self, version_to_set_up: str, devices: DataSequence[DeviceDetailsResponse], version_type: str
) -> DataSequence[PartitionDevice]:
Expand All @@ -227,8 +292,10 @@ def _get_device_list_in(
self._validate_devices_required_fields(devices)
devices_payload = DataSequence(
PartitionDevice,
[PartitionDevice(device_id=device.uuid, device_ip=device.device_ip) for device in devices], # type: ignore
[PartitionDevice(device_id=str(device.uuid), device_ip=str(device.local_system_ip)) for device in devices],
# type: ignore
)

all_dev_versions = self.repository.get_devices_versions_repository()
for device in devices_payload:
device_versions = getattr(all_dev_versions[device.device_id], version_type)
Expand Down Expand Up @@ -295,9 +362,10 @@ def _get_devices_chosen_version(

devices_payload = DataSequence(
PartitionDevice,
[PartitionDevice(
device_id=device.uuid, device_ip=device.local_system_ip # type: ignore
) for device in devices], # type: ignore
[
PartitionDevice(device_id=device.uuid, device_ip=device.local_system_ip) # type: ignore
for device in devices
], # type: ignore
)
all_dev_versions = self.repository.get_devices_versions_repository()
for device in devices_payload:
Expand Down
Loading

0 comments on commit a023af7

Please sign in to comment.