-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
swim bug fixed - image activation for all the child sites devices - V2.3.7.6 #67
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -937,62 +937,60 @@ def get_device_uuids(self, site_name, device_family, device_role, device_series_ | |
for item_dict in item['response']: | ||
site_response_list.append(item_dict) | ||
else: | ||
try: | ||
response = self.dnac._exec( | ||
family="site_design", | ||
function='get_site_assigned_network_devices', | ||
op_modifies=True, | ||
params={"site_id": site_id}, | ||
) | ||
self.log("Received API response from 'get_site_assigned_network_devices': {0}".format(str(response)), "DEBUG") | ||
response = response.get('response') | ||
site_names = site_name + ".*" | ||
get_site_names = self.get_site(site_names) | ||
self.log(get_site_names) | ||
site_info = {} | ||
|
||
for item in get_site_names['response']: | ||
if 'nameHierarchy' in item and 'id' in item: | ||
site_info[item['nameHierarchy']] = item['id'] | ||
|
||
madhansansel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for site_name, site_id in site_info.items(): | ||
try: | ||
response = self.dnac._exec( | ||
family="site_design", | ||
function='get_site_assigned_network_devices', | ||
op_modifies=True, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True or False? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed the code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. have removed the op_modifies as it is not required for get |
||
params={"site_id": site_id}, | ||
) | ||
self.log("Received API response from 'get_site_assigned_network_devices': {0}".format(str(response)), "DEBUG") | ||
response = response.get('response') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed the code |
||
|
||
if not response: | ||
self.log("No devices found for site '{0}'.". format(site_name), "WARNING") | ||
if not response: | ||
self.log("No devices found for site - '{0}'.". format(site_name), "WARNING") | ||
|
||
except Exception as e: | ||
self.log("Unable to fetch the device(s) associated to the site '{0}' due to '{1}'".format(site_name, str(e)), "WARNING") | ||
return device_uuid_list | ||
for device_id in response: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed the code |
||
device_id_list.append(device_id.get("deviceId")) | ||
|
||
for device_id in response: | ||
device_id_list.append(device_id.get("deviceId")) | ||
except Exception as e: | ||
self.log("Unable to fetch the device(s) associated to the site '{0}' due to '{1}'".format(site_name, str(e)), "WARNING") | ||
return device_uuid_list | ||
|
||
try: | ||
device_params = {} | ||
offset = 0 | ||
limit = self.get_device_details_limit() | ||
initial_exec = False | ||
for device_id in device_id_list: | ||
self.log("Processing device_id: {0}".format(device_id)) | ||
try: | ||
device_list_response = self.dnac._exec( | ||
family="devices", | ||
function="get_device_list", | ||
params={"id": device_id}, | ||
) | ||
|
||
while True: | ||
if initial_exec: | ||
device_params["limit"] = limit | ||
device_params["offset"] = offset * limit | ||
device_list_response = self.dnac._exec( | ||
family="devices", | ||
function='get_device_list', | ||
params=device_params | ||
) | ||
else: | ||
initial_exec = True | ||
device_list_response = self.dnac._exec( | ||
family="devices", | ||
function='get_device_list', | ||
op_modifies=True | ||
) | ||
offset = offset + 1 | ||
self.log("Received API response from 'device_list_response': {0}".format(str(device_list_response)), "DEBUG") | ||
device_response = device_list_response.get('response') | ||
self.log("Received API response: {0}".format(str(device_list_response)), "DEBUG") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed the code |
||
|
||
device_response = device_list_response.get("response") | ||
if not device_response: | ||
break | ||
self.log("No device data found for device_id: {0}".format(device_id), "INFO") | ||
continue | ||
|
||
for device in device_response: | ||
if device.get("instanceUuid") in device_id_list: | ||
if device_family is None or device.get("family") == device_family: | ||
site_response_list.append(device) | ||
|
||
except Exception as e: | ||
self.log("Unable to fetch the device(s) associated to the site '{0}' due to '{1}'".format(site_name, str(e)), "WARNING") | ||
return device_uuid_list | ||
except Exception as e: | ||
self.log("Unable to fetch devices for site '{0}' due to: {1}".format(site_name, str(e)), "WARNING") | ||
return device_uuid_list | ||
|
||
self.device_ips = [] | ||
for item in site_response_list: | ||
|
@@ -1034,7 +1032,7 @@ def get_device_uuids(self, site_name, device_family, device_role, device_series_ | |
offset = offset + 1 | ||
device_response = device_list_response.get('response') | ||
|
||
if not response or not device_response: | ||
if not device_response: | ||
self.log("Failed to retrieve devices associated with the site '{0}' due to empty API response.".format(site_name), "INFO") | ||
break | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.log("Fetched site names: {0}".format(str(get_site_names)), "DEBUG")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed the code