Skip to content

Commit e774c5b

Browse files
committed
refactoring of orch scripts
1 parent 8fcc853 commit e774c5b

File tree

432 files changed

+290
-8604
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

432 files changed

+290
-8604
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from cloudshell.api.cloudshell_api import CloudShellAPISession, CloudShellAPIError
2+
3+
user = "admin"
4+
password = "admin"
5+
server = "localhost"
6+
domain = "Global"
7+
8+
TARGET_ROOT_RESOURCE = "my juniper"
9+
PORT_MODEL_SUFFIX = "GenericPort"
10+
11+
LOGICAL_PORT_SUFFIX = "polatis_logical"
12+
RESOURCE_EXISTS_ERROR_CODE = "114"
13+
RESOURCE_EXISTS_ERROR = "A resource with the same name already exists"
14+
15+
POLATIS_LOGICAL_PORT_ATTR_NAME = "Polatis Logical Port"
16+
17+
api = CloudShellAPISession(host=server, username=user, password=password, domain=domain)
18+
resource_details = api.GetResourceDetails(resourceFullPath=TARGET_ROOT_RESOURCE)
19+
root_model = resource_details.ResourceModelName
20+
port_model = f"{root_model}.{PORT_MODEL_SUFFIX}"
21+
22+
chassis = resource_details.ChildResources[0]
23+
module1 = chassis.ChildResources[0]
24+
25+
for i, curr_port in enumerate(module1.ChildResources):
26+
port_split = curr_port.Name.split("/")
27+
port_name = port_split[-1]
28+
port_path = "/".join(port_split[:-1])
29+
if port_name.endswith(LOGICAL_PORT_SUFFIX):
30+
continue
31+
32+
logical_port_name = f"{port_name}_{LOGICAL_PORT_SUFFIX}"
33+
logical_full_path = f"{port_path}/{logical_port_name}"
34+
logical_address = f"{curr_port.Address}_logical"
35+
36+
try:
37+
api.CreateResource(resourceFamily="CS_Port",
38+
resourceModel=port_model,
39+
resourceName=logical_port_name,
40+
resourceAddress=logical_address,
41+
parentResourceFullPath=module1.Name)
42+
print(f"created logical port {logical_port_name}")
43+
except CloudShellAPIError as e:
44+
if e.code == RESOURCE_EXISTS_ERROR_CODE:
45+
print(f"Port '{logical_port_name}' exists, skipping creation")
46+
47+
api.SetAttributeValue(resourceFullPath=logical_full_path,
48+
attributeName=POLATIS_LOGICAL_PORT_ATTR_NAME,
49+
attributeValue="True")
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from cloudshell.api.cloudshell_api import CloudShellAPISession
2+
3+
user = "admin"
4+
password = "admin"
5+
server = "localhost"
6+
7+
TARGET_MODEL = "<MY_MODEL>"
8+
9+
api = CloudShellAPISession(host=server, username=user, password=password, domain="Global")
10+
11+
duts = api.FindResources(resourceModel=TARGET_MODEL).Resources

automation_api_scripts/update_physical_connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
session = CloudShellAPISession(host=server, username=user, password=password, domain="Global")
88

9-
res = session.UpdatePhysicalConnection(resourceAFullPath="my Cisco Switch/Chassis 0/FastEthernet0-10",
10-
resourceBFullPath="Mock_L1/Blade 1/Port 001",
9+
res = session.UpdatePhysicalConnection(resourceAFullPath="celare dummy 2/Chassis 1/Module 1/Port 10",
10+
resourceBFullPath="L1Mock1/Blade 1/Port 003",
1111
overrideExistingConnections=True)

generic-orchestration-samples/Basic Samples/sample_setup_health_check/health_check_dut.py

Lines changed: 0 additions & 36 deletions
This file was deleted.

generic-orchestration-samples/Move_Users/__main__.py

Lines changed: 0 additions & 57 deletions
This file was deleted.

generic-orchestration-samples/Move_Users/get_all_users.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

generic-orchestration-samples/attach_file_to_reservation_demo/__main__.py

Lines changed: 0 additions & 24 deletions
This file was deleted.
Binary file not shown.
Binary file not shown.

generic-orchestration-samples/attach_file_to_reservation_demo/first_module.py

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)