Skip to content

Commit

Permalink
Inventory workflow workflow manager - provision in 2.3.5.3 (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
madhansansel authored Nov 12, 2024
2 parents 3a95406 + 57bd584 commit ae455b6
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions plugins/modules/inventory_workflow_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1700,7 +1700,7 @@ def provisioned_wired_device(self):

for device_info in provision_wired_list:
device_ip = device_info['device_ip']
site_name = device_info['site_name']
site_name_hierarchy = device_info['site_name']
device_ip_list.append(device_ip)
device_type = "Wired"
resync_retry_count = device_info.get("resync_retry_count", 200)
Expand All @@ -1726,9 +1726,9 @@ def provisioned_wired_device(self):
continue

if self.get_ccc_version_as_integer() <= self.get_ccc_version_as_int_from_str("2.3.5.3"):
self.provision_wired_device_v1(device_ip, site_name, device_type)
self.provision_wired_device_v1(device_ip, site_name_hierarchy, device_type)
else:
self.provision_wired_device_v2(device_ip, site_name)
self.provision_wired_device_v2(device_ip, site_name_hierarchy)

# Handle final provisioning results
self.handle_final_provisioning_result(total_devices, self.provision_count, self.already_provisioned_count, device_ip_list, device_type)
Expand Down Expand Up @@ -1791,34 +1791,33 @@ def wait_for_device_managed_state(self, device_ip, retry_count, retry_interval):
self.log("Device '{0}' did not transition to the Managed state within the retry limit.".format(device_ip), "WARNING")
return False

def provision_wired_device_v1(self, device_ip, site_name, device_type):
def provision_wired_device_v1(self, device_ip, site_name_hierarchy, device_type):
"""
Provisions a device for versions <= 2.3.5.6.
Parameters:
device_ip (str): The IP address of the device to provision.
site_name (str): The name of the site where the device will be provisioned.
site_name_hierarchy (str): The name of the site where the device will be provisioned.
device_type (str): The type of device being provisioned.
Returns:
bool: True if provisioning is successful, False otherwise.
Description:
This method provisions a device with the specified IP address,
site name, and device type for software versions 2.3.5.6 or earlier.
It handles the necessary configurations and returns a success status.
"""

provision_params = {'deviceManagementIpAddress': device_ip, 'siteNameHierarchy': site_name}
provision_params = {'deviceManagementIpAddress': device_ip, 'siteNameHierarchy': site_name_hierarchy}
try:
response = self.dnac._exec(family="sda", function='provision_wired_device', op_modifies=True, params=provision_params)
self.log("Received API response from 'provision_wired_device': {0}".format(response), "DEBUG")

if response:
validation_string = "successfully"
self.check_task_response_status(response, validation_string, 'provision_wired_device')
self.deleted_devices.append(device_ip)
self.check_execution_response_status(response, "provision_wired_device").check_return_status()
self.provision_count += 1
self.provisioned_device.append(device_ip)

except Exception as e:
self.handle_provisioning_exception(device_ip, e, device_type)

def provision_wired_device_v2(self, device_ip, site_name):
def provision_wired_device_v2(self, device_ip, site_name_hierarchy):
"""
Provisions a device for versions > 2.3.5.6.
Parameters:
Expand All @@ -1830,7 +1829,7 @@ def provision_wired_device_v2(self, device_ip, site_name):
It performs the necessary configurations and returns a success status.
"""
try:
site_exist, site_id = self.get_site_id(site_name)
site_exist, site_id = self.get_site_id(site_name_hierarchy)
device_ids = self.get_device_ids([device_ip])
device_id = device_ids[0]

Expand All @@ -1840,7 +1839,7 @@ def provision_wired_device_v2(self, device_ip, site_name):
is_device_assigned_to_site = self.is_device_assigned_to_site(device_id)

if not is_device_assigned_to_site:
self.assign_device_to_site(device_ids, site_name, site_id)
self.assign_device_to_site(device_ids, site_name_hierarchy, site_id)

if not is_device_provisioned:
self.provision_device(provision_params, device_ip)
Expand Down

0 comments on commit ae455b6

Please sign in to comment.