mirror of
https://github.com/CiscoDevNet/cml-community.git
synced 2025-11-02 13:03:20 +00:00
updated while loop to account for deleted devices
this will now check all nodes from n0 to n99. I found that deleted nodes breaks the previous script because after 1 node was not found, it ended. to check for nodes higher than n99, edit line 24
This commit is contained in:
@@ -4,17 +4,15 @@ import os
|
|||||||
requests.packages.urllib3.disable_warnings()
|
requests.packages.urllib3.disable_warnings()
|
||||||
from cmlApiCalls import CML as cml
|
from cmlApiCalls import CML as cml
|
||||||
|
|
||||||
#edit the following variables
|
server = "cml.recurve-it.com"
|
||||||
server = "cml.server.com"
|
|
||||||
username = "admin"
|
username = "admin"
|
||||||
password = "CMLpassword123"
|
password = "12qwas!@QWAS12qwas"
|
||||||
lab = "53b3fe"
|
lab = "53b3fe"
|
||||||
|
|
||||||
|
|
||||||
user = os.getlogin()
|
user = os.getlogin()
|
||||||
auth = cml.auth(server, username, password)
|
auth = cml.auth(server, username, password)
|
||||||
|
allNodes = cml.getAllNodes(auth, server, lab)
|
||||||
|
# print(allNodes)
|
||||||
|
N = True
|
||||||
n_id = 0
|
n_id = 0
|
||||||
port = 9000
|
port = 9000
|
||||||
try:
|
try:
|
||||||
@@ -26,9 +24,9 @@ except:
|
|||||||
while n_id < 100:
|
while n_id < 100:
|
||||||
node_id = f"n{n_id}"
|
node_id = f"n{n_id}"
|
||||||
response = cml.getNodesByID(auth, server, lab, node_id)
|
response = cml.getNodesByID(auth, server, lab, node_id)
|
||||||
|
# print(response)
|
||||||
if response == "end of list":
|
if response == "end of list":
|
||||||
#exit after testing 100 nodes
|
print("Node " + node_id + " does not exist, will check all nodes from n0 to n99.")
|
||||||
n_id = n_id + 1
|
n_id = n_id + 1
|
||||||
|
|
||||||
|
|
||||||
@@ -43,7 +41,7 @@ while n_id < 100:
|
|||||||
# turn port number into hex
|
# turn port number into hex
|
||||||
# strip "0x2233" and make it only 4 charators
|
# strip "0x2233" and make it only 4 charators
|
||||||
hexport = hex(port).split('x')[-1]
|
hexport = hex(port).split('x')[-1]
|
||||||
|
print("creating: " + node_label)
|
||||||
with open("config.ini", "r") as config:
|
with open("config.ini", "r") as config:
|
||||||
temp = config.read()
|
temp = config.read()
|
||||||
temp = temp.replace("REPLACE", "0000" + hexport)
|
temp = temp.replace("REPLACE", "0000" + hexport)
|
||||||
|
|||||||
Reference in New Issue
Block a user