Skip to content

Commit

Permalink
Changes in assign device to site in danc.py
Browse files Browse the repository at this point in the history
  • Loading branch information
md-rafeek committed Oct 28, 2024
1 parent 31fad33 commit ba3db2f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
15 changes: 9 additions & 6 deletions plugins/module_utils/dnac.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ def get_site_id(self, site_name):

return (site_exists, site_id)

def assign_device_to_site(self, device_ids, site_name, site_id, site_type=None):
def assign_device_to_site(self, device_ids, site_name, site_id):
"""
Assign devices to the specified site.
Args:
Expand All @@ -870,11 +870,14 @@ def assign_device_to_site(self, device_ids, site_name, site_id, site_type=None):
Assigns the specified devices to the site. If the assignment is successful, returns True.
Otherwise, logs an error and returns False along with error details.
"""
if site_type not in ("building", "floor"):
self.msg = "Device(s) can only be assigned to building/floor"
self.log(self.msg, "ERROR")
self.status = "failed"
self.module.fail_json(msg=self.msg)
site_response = self.get_site(site_name)
if site_response.get("response") and site_response["response"][0].get("type"):
site_type = site_response["response"][0].get("type")
if site_type not in ("building", "floor"):
self.msg = "Device(s) can only be assigned to building/floor"
self.log(self.msg, "ERROR")
self.status = "failed"
self.module.fail_json(msg=self.msg)

if self.get_ccc_version_as_integer() <= self.get_ccc_version_as_int_from_str("2.3.5.3"):
try:
Expand Down
9 changes: 4 additions & 5 deletions plugins/modules/accesspoint_workflow_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3026,7 +3026,7 @@ def access_point_provision_new(self, rf_profile, device_id, site_id, site_type):
try:
site_assign_status = self.assign_device_to_site([self.have.get("device_id")],
self.have.get("site_name_hierarchy"),
self.have.get("site_id"), site_type)
self.have.get("site_id"))
if site_assign_status:
self.log('Current device details: {0}'.format(self.pprint(provision_params)), "INFO")
response = self.dnac._exec(
Expand Down Expand Up @@ -3960,9 +3960,9 @@ def bulk_ap_update(self, bulk_config):
self.want = bulk_config.get("common_fields_to_change")
self.want["mac_address"] = each_ap["mac_address"]
ap_name = [ap.get('ap_name') for ap in bulk_config.get("ap_identifier")
if (each_ap["mac_address"] == ap.get('mac_address') or
each_ap["hostname"] == ap.get('hostname') or
each_ap["management_ip_address"] == ap.get('management_ip_address'))]
if (each_ap["mac_address"] == ap.get('mac_address') or
each_ap["hostname"] == ap.get('hostname') or
each_ap["management_ip_address"] == ap.get('management_ip_address'))]
self.want["ap_name"] = ap_name[0]
ap_output_list.append(ap_name[0])
self.log("Access point WANT configuration exists: {0}, Current configuration: {1}"
Expand Down Expand Up @@ -4081,7 +4081,6 @@ def main():
ccc_network.reboot_factory_reset_function(ap_list, reboot_reset)
module.exit_json(**ccc_network.result)


bulk_updates = ccc_network.validated_config[0].get("bulk_update_aps")
if bulk_updates is not None:
ccc_network.log("Bulk List: {0}".format(ccc_network.pprint(bulk_updates)), "INFO")
Expand Down

0 comments on commit ba3db2f

Please sign in to comment.