
    Vh                        d dl mZmZmZ eZdZdZdZdZ	d dl
mZmZmZ d dlmZ d dlZd dlZ G d	 d
e      Zd Zedk(  r e        yy)    )absolute_importdivisionprint_functionz?Madhan Sankaranarayanan, Rishita Chowdhary, Abhishek MaheshwariaY  
---
module: swim_intent
short_description: Intent module for SWIM related functions
description:
  - Manage operation related to image importation, distribution, activation and tagging
    image as golden
  - API to fetch a software image from remote file system using URL for HTTP/FTP and
    upload it to Catalyst Center. Supported image files extensions are bin, img, tar,
    smu, pie, aes, iso, ova, tar_gz and qcow2.
  - API to fetch a software image from local file system and upload it to Catalyst
    Center Supported image files extensions are bin, img, tar, smu, pie, aes, iso,
    ova, tar_gz and qcow2.
  - API to tag/untag image as golen for a given family of devices
  - API to distribute a software image on a given device. Software image must be imported
    successfully into Catalyst Center before it can be distributed.
  - API to activate a software image on a given device. Software image must be present
    in the device flash.
version_added: '6.6.0'
extends_documentation_fragment:
  - cisco.dnac.intent_params
author: Madhan Sankaranarayanan (@madhansansel) Rishita Chowdhary (@rishitachowdhary)
  Abhishek Maheshwari (@abmahesh)
options:
  config_verify:
    description: Set to True to verify the Cisco Catalyst Center config after applying
      the playbook config.
    type: bool
    default: false
  state:
    description: The state of Catalyst Center after module completion.
    type: str
    choices: [merged]
    default: merged
  config:
    description: List of details of SWIM image being managed
    type: list
    elements: dict
    required: true
    suboptions:
      import_image_details:
        description: Details of image being imported
        type: dict
        suboptions:
          type:
            description: Specifies the import source, supporting local file import
              (local) or remote url import (remote).
            type: str
          local_image_details:
            description: Details of the local path of the image to be imported.
            type: dict
            suboptions:
              file_path:
                description: Provide the absolute file path needed to import an image
                  from your local system (Eg "/path/to/your/file"). Accepted files
                  formats are -
                  .gz,.bin,.img,.tar,.smu,.pie,.aes,.iso,.ova,.tar_gz,.qcow2,.nfvispkg,.zip,.spa,.rpm.
                type: str
              is_third_party:
                description: Query parameter to determine if the image is from a third
                  party (optional).
                type: bool
              third_party_application_type:
                description: Specify the ThirdPartyApplicationType query parameter
                  to indicate the type of third-party application. Allowed values
                  include WLC, LINUX, FIREWALL, WINDOWS, LOADBALANCER, THIRDPARTY,
                  etc.(optional). WLC (Wireless LAN Controller) - It's a network device
                  that manages and controls multiple wireless access points (APs)
                  in a centralized manner. LINUX - It's an open-source operating system
                  that provides a complete set of software packages and utilities.
                  FIREWALL - It's a network security device that monitors and controls
                  incoming and outgoing network traffic based on predetermined security
                  rules.It acts as a barrier between a trusted internal network and
                  untrusted external networks (such as the internet), preventing unauthorized
                  access. WINDOWS - It's an operating system known for its graphical
                  user interface (GUI) support, extensive compatibility with hardware
                  and software, and widespread use across various applications. LOADBALANCER
                  - It's a network device or software application that distributes
                  incoming network traffic across multiple servers or resources. THIRDPARTY
                  - It refers to third-party images or applications that are not part
                  of the core system. NAM (Network Access Manager) - It's a network
                  management tool or software application that provides centralized
                  control and monitoring of network access policies, user authentication,
                  and device compliance. WAN Optimization - It refers to techniques
                  and technologies used to improve the performance and efficiency
                  of WANs. It includes various optimization techniques such as data
                  compression, caching, protocol optimization, and traffic prioritization
                  to reduce latency, increase throughput, and improve user experience
                  over WAN connections. Unknown - It refers to an unspecified or unrecognized
                  application type. Router - It's a network device that forwards data
                  packets between computer networks. They are essential for connecting
                  multiple networks together and directing traffic between them.
                type: str
              third_party_image_family:
                description: Provide the ThirdPartyImageFamily query parameter to
                  identify the family of the third-party image. Image Family name
                  like PALOALTO, RIVERBED, FORTINET, CHECKPOINT, SILVERPEAK etc. (optional).
                type: str
              third_party_vendor:
                description: Include the ThirdPartyVendor query parameter to specify
                  the vendor of the third party.
                type: str
          url_details:
            description: URL details for SWIM import
            type: dict
            suboptions:
              payload:
                description: Swim Import Via Url's payload.
                type: list
                elements: dict
                suboptions:
                  application_type:
                    description: An optional parameter that specifies the type of
                      application. Allowed values include WLC, LINUX, FIREWALL, WINDOWS,
                      LOADBALANCER, THIRDPARTY, etc. This is only applicable for third-party
                      image types(optional). WLC (Wireless LAN Controller) - It's
                      network device that manages and controls multiple wireless access
                      points (APs) in a centralized manner. LINUX - It's an open source
                      which provide complete operating system with a wide range of
                      software packages and utilities. FIREWALL - It's a network security
                      device that monitors and controls incoming and outgoing network
                      traffic based on predetermined security rules.It acts as a barrier
                      between a trusted internal network and untrusted external networks
                      (such as the internet), preventing unauthorized access. WINDOWS
                      - It's an OS which provides GUI support for various applications,
                      and extensive compatibility with hardware and software. LOADBALANCER
                      - It's a network device or software application that distributes
                      incoming network traffic across multiple servers or resources.
                      THIRDPARTY - It refers to third-party images or applications
                      that are not part of the core system. NAM (Network Access Manager)
                      - It's a network management tool or software application that
                      provides centralized control and monitoring of network access
                      policies, user authentication, and device compliance. WAN Optimization
                      - It refers to techniques and technologies used to improve the
                      performance and efficiency of WANs. It includes various optimization
                      techniques such as data compression, caching, protocol optimization,
                      and traffic prioritization to reduce latency, increase throughput,
                      and improve user experience over WAN connections. Unknown -
                      It refers to an unspecified or unrecognized application type.
                      Router - It's a network device that forwards data packets between
                      computer networks. They are essential for connecting multiple
                      networks together and directing traffic between them.
                    type: str
                  image_family:
                    description: Represents the name of the image family and is applicable
                      only when uploading third-party images. Image Family name like
                      PALOALTO, RIVERBED, FORTINET, CHECKPOINT, SILVERPEAK etc. (optional).
                    type: str
                  source_url:
                    description: A mandatory parameter for importing a SWIM image
                      via a remote URL. This parameter is required when using a URL
                      to import an image.(For example, http://{host}/swim/cat9k_isoxe.16.12.10s.SPA.bin,
                      ftp://user:password@{host}/swim/cat9k_isoxe.16.12.10s.SPA.iso)
                    type: str
                  is_third_party:
                    description: Flag indicates whether the image is uploaded from
                      a third party (optional).
                    type: bool
                  vendor:
                    description: The name of the vendor, that applies only to third-party
                      image types when importing via URL (optional).
                    type: str
              schedule_at:
                description: ScheduleAt query parameter. Epoch Time (The number of
                  milli-seconds since January 1 1970 UTC) at which the distribution
                  should be scheduled (optional).
                type: str
              schedule_desc:
                description: ScheduleDesc query parameter. Custom Description (optional).
                type: str
              schedule_origin:
                description: ScheduleOrigin query parameter. Originator of this call
                  (optional).
                type: str
      tagging_details:
        description: Details for tagging or untagging an image as golden
        type: dict
        suboptions:
          image_name:
            description: SWIM image name which will be tagged or untagged as golden.
            type: str
          device_role:
            description: Defines the device role, with permissible values including
              ALL, UNKNOWN, ACCESS, BORDER ROUTER, DISTRIBUTION, and CORE. ALL - This
              role typically represents all devices within the network, regardless
              of their specific roles or functions. UNKNOWN - This role is assigned
              to devices whose roles or functions have not been identified or classified
              within Cisco Catalsyt Center. This could happen if the platform is unable
              to determine the device's role based on available information. ACCESS
              - This role typically represents switches or access points that serve
              as access points for end-user devices to connect to the network. These
              devices are often located at the edge of the network and provide connectivity
              to end-user devices. BORDER ROUTER - These are devices that connect
              different network domains or segments together. They often serve as
              gateways between different networks, such as connecting an enterprise
              network to the internet or connecting multiple branch offices. DISTRIBUTION
              - This role represents function as distribution switches or routers
              in hierarchical network designs. They aggregate traffic from access
              switches and route it toward the core of the network or toward other
              distribution switches. CORE - This role typically represents high-capacity
              switches or routers that form the backbone of the network. They handle
              large volumes of traffic and provide connectivity between different
              parts of network, such as connecting distribution switches or providing
              interconnection between different network segments.
            type: str
          device_image_family_name:
            description: Device Image family name(Eg Cisco Catalyst 9300 Switch)
            type: str
          site_name:
            description: Site name for which SWIM image will be tagged/untagged as
              golden. If not provided, SWIM image will be mapped to global site.
            type: str
          device_series_name:
            description: This parameter specifies the name of the device series. It
              is used to identify a specific series of devices, such as Cisco Catalyst
              9300 Series Switches, within the Cisco Catalyst Center.
            type: str
            version_added: 6.12.0
          tagging:
            description: Booelan value to tag/untag SWIM image as golden If True then
              the given image will be tagged as golden. If False then the given image
              will be un-tagged as golden.
            type: bool
      image_distribution_details:
        description: Details for SWIM image distribution. Device on which the image
          needs to distributed can be speciifed using any of the following parameters
          - deviceSerialNumber, deviceIPAddress, deviceHostname or deviceMacAddress.
        type: dict
        suboptions:
          device_role:
            description: Defines the device role, with permissible values including
              ALL, UNKNOWN, ACCESS, BORDER ROUTER, DISTRIBUTION, and CORE. ALL - This
              role typically represents all devices within the network, regardless
              of their specific roles or functions. UNKNOWN - This role is assigned
              to devices whose roles or functions have not been identified or classified
              within Cisco Catalsyt Center. This could happen if the platform is unable
              to determine the device's role based on available information. ACCESS
              - This role typically represents switches or access points that serve
              as access points for end-user devices to connect to the network. These
              devices are often located at the edge of the network and provide connectivity
              to end-user devices. BORDER ROUTER - These are devices that connect
              different network domains or segments together. They often serve as
              gateways between different networks, such as connecting an enterprise
              network to the internet or connecting multiple branch offices. DISTRIBUTION
              - This role represents function as distribution switches or routers
              in hierarchical network designs. They aggregate traffic from access
              switches and route it toward the core of the network or toward other
              distribution switches. CORE - This role typically represents high-capacity
              switches or routers that form the backbone of the network. They handle
              large volumes of traffic and provide connectivity between different
              parts of network, such as connecting distribution switches or providing
              interconnection between different network segments.
            type: str
          device_family_name:
            description: Specify the name of the device family such as Switches and
              Hubs, etc.
            type: str
          site_name:
            description: Used to get device details associated to this site.
            type: str
          device_series_name:
            description: This parameter specifies the name of the device series. It
              is used to identify a specific series of devices, such as Cisco Catalyst
              9300 Series Switches, within the Cisco Catalyst Center.
            type: str
            version_added: 6.12.0
          image_name:
            description: SWIM image's name
            type: str
          device_serial_number:
            description: Device serial number where the image needs to be distributed
            type: str
          device_ip_address:
            description: Device IP address where the image needs to be distributed
            type: str
          device_hostname:
            description: Device hostname where the image needs to be distributed
            type: str
          device_mac_address:
            description: Device MAC address where the image needs to be distributed
            type: str
      image_activation_details:
        description: Details for SWIM image activation. Device on which the image
          needs to activated can be speciifed using any of the following parameters
          - deviceSerialNumber, deviceIPAddress, deviceHostname or deviceMacAddress.
        type: dict
        suboptions:
          device_role:
            description: Defines the device role, with permissible values including
              ALL, UNKNOWN, ACCESS, BORDER ROUTER, DISTRIBUTION, and CORE. ALL - This
              role typically represents all devices within the network, regardless
              of their specific roles or functions. UNKNOWN - This role is assigned
              to devices whose roles or functions have not been identified or classified
              within Cisco Catalsyt Center. This could happen if the platform is unable
              to determine the device's role based on available information. ACCESS
              - This role typically represents switches or access points that serve
              as access points for end-user devices to connect to the network. These
              devices are often located at the edge of the network and provide connectivity
              to end-user devices. BORDER ROUTER - These are devices that connect
              different network domains or segments together. They often serve as
              gateways between different networks, such as connecting an enterprise
              network to the internet or connecting multiple branch offices. DISTRIBUTION
              - This role represents function as distribution switches or routers
              in hierarchical network designs. They aggregate traffic from access
              switches and route it toward the core of the network or toward other
              distribution switches. CORE - This role typically represents high-capacity
              switches or routers that form the backbone of the network. They handle
              large volumes of traffic and provide connectivity between different
              parts of network, such as connecting distribution switches or providing
              interconnection between different network segments.
            type: str
          device_family_name:
            description: Specify the name of the device family such as Switches and
              Hubs, etc.
            type: str
          site_name:
            description: Used to get device details associated to this site.
            type: str
          activate_lower_image_version:
            description: ActivateLowerImageVersion flag.
            type: bool
          device_upgrade_mode:
            description: It specifies the mode of upgrade to be applied to the devices
              having the following values - 'install', 'bundle', and 'currentlyExists'.
              install - This mode instructs Cisco Catalyst Center to perform a clean
              installation of the new image on the target devices. When this mode
              is selected, the existing image on the device is completely replaced
              with the new image during the upgrade process. This ensures that the
              device runs only the new image version after the upgrade is completed.
              bundle - This mode instructs Cisco Catalyst Center bundles the new image
              with the existing image on the device before initiating the upgrade
              process. This mode allows for a more efficient upgrade process by preserving
              the existing image on the device while adding the new image as an additional
              bundle. After the upgrade, the device can run either the existing image
              or the new bundled image, depending on the configuration. currentlyExists
              - This mode instructs Cisco Catalyst Center to checks if the target
              devices already have the desired image version installed. If image already
              present on devices, no action is taken and upgrade process is skipped
              for those devices. This mode is useful for avoiding unnecessary upgrades
              on devices that already have the correct image version installed, thereby
              saving time.
            type: str
          distribute_if_needed:
            description: Enable the distribute_if_needed option when activating the
              SWIM image.
            type: bool
          image_name:
            description: SWIM image's name
            type: str
          device_serial_number:
            description: Device serial number where the image needs to be activated
            type: str
          device_ip_address:
            description: Device IP address where the image needs to be activated
            type: str
          device_hostname:
            description: Device hostname where the image needs to be activated
            type: str
          device_mac_address:
            description: Device MAC address where the image needs to be activated
            type: str
          schedule_validate:
            description: ScheduleValidate query parameter. ScheduleValidate, validates
              data before schedule (optional).
            type: bool
requirements:
  - dnacentersdk == 2.4.5
  - python >= 3.9
notes:
  - SDK Method used are
    software_image_management_swim.SoftwareImageManagementSwim.import_software_image_via_url,
    software_image_management_swim.SoftwareImageManagementSwim.tag_as_golden_image,
    software_image_management_swim.SoftwareImageManagementSwim.trigger_software_image_distribution,
    software_image_management_swim.SoftwareImageManagementSwim.trigger_software_image_activation,
  - Paths used are post /dna/intent/api/v1/image/importation/source/url, post /dna/intent/api/v1/image/importation/golden,
    post /dna/intent/api/v1/image/distribution, post /dna/intent/api/v1/image/activation/device,
  - Added the parameter 'dnac_api_task_timeout', 'dnac_task_poll_interval' options
    in v6.13.2.
aR  
- name: Import an image from a URL, tag it as golden and load it on device
  cisco.dnac.swim_intent:
    dnac_host: "{{dnac_host}}"
    dnac_username: "{{dnac_username}}"
    dnac_password: "{{dnac_password}}"
    dnac_verify: "{{dnac_verify}}"
    dnac_port: "{{dnac_port}}"
    dnac_version: "{{dnac_version}}"
    dnac_debug: "{{dnac_debug}}"
    dnac_log_level: "{{dnac_log_level}}"
    dnac_log: true
    config:
      - import_image_details:
          type: remote
          url_details:
            payload:
              - source_url: "http://10.10.10.10/stda/cat9k_iosxe.17.12.01.SPA.bin"
                is_third_party: false
        tagging_details:
          image_name: cat9k_iosxe.17.12.01.SPA.bin
          device_role: ACCESS
          device_image_family_name: Cisco Catalyst 9300 Switch
          site_name: Global/USA/San Francisco/BGL_18
          tagging: true
        image_distribution_details:
          image_name: cat9k_iosxe.17.12.01.SPA.bin
          device_serial_number: FJC2327U0S2
        image_activation_details:
          image_name: cat9k_iosxe.17.12.01.SPA.bin
          schedule_validate: false
          activate_lower_image_version: false
          distribute_if_needed: true
          device_serial_number: FJC2327U0S2
- name: Import an image from local, tag it as golden.
  cisco.dnac.swim_intent:
    dnac_host: "{{dnac_host}}"
    dnac_username: "{{dnac_username}}"
    dnac_password: "{{dnac_password}}"
    dnac_verify: "{{dnac_verify}}"
    dnac_port: "{{dnac_port}}"
    dnac_version: "{{dnac_version}}"
    dnac_debug: "{{dnac_debug}}"
    dnac_log_level: "{{dnac_log_level}}"
    dnac_log: true
    config:
      - import_image_details:
          type: local
          local_image_details:
            file_path: /Users/Downloads/cat9k_iosxe.17.12.01.SPA.bin
            is_third_party: false
        tagging_details:
          image_name: cat9k_iosxe.17.12.01.SPA.bin
          device_role: ACCESS
          device_image_family_name: Cisco Catalyst 9300 Switch
          site_name: Global/USA/San Francisco/BGL_18
          tagging: true
- name: Tag the given image as golden and load it on device
  cisco.dnac.swim_intent:
    dnac_host: "{{dnac_host}}"
    dnac_username: "{{dnac_username}}"
    dnac_password: "{{dnac_password}}"
    dnac_verify: "{{dnac_verify}}"
    dnac_port: "{{dnac_port}}"
    dnac_version: "{{dnac_version}}"
    dnac_debug: "{{dnac_debug}}"
    dnac_log_level: "{{dnac_log_level}}"
    dnac_log: true
    config:
      - tagging_details:
          image_name: cat9k_iosxe.17.12.01.SPA.bin
          device_role: ACCESS
          device_image_family_name: Cisco Catalyst 9300 Switch
          site_name: Global/USA/San Francisco/BGL_18
          tagging: true
- name: Un-tagged the given image as golden and load it on device
  cisco.dnac.swim_intent:
    dnac_host: "{{dnac_host}}"
    dnac_username: "{{dnac_username}}"
    dnac_password: "{{dnac_password}}"
    dnac_verify: "{{dnac_verify}}"
    dnac_port: "{{dnac_port}}"
    dnac_version: "{{dnac_version}}"
    dnac_debug: "{{dnac_debug}}"
    dnac_log_level: "{{dnac_log_level}}"
    dnac_log: true
    config:
      - tagging_details:
          image_name: cat9k_iosxe.17.12.01.SPA.bin
          device_role: ACCESS
          device_image_family_name: Cisco Catalyst 9300 Switch
          site_name: Global/USA/San Francisco/BGL_18
          tagging: false
- name: Distribute the given image on devices associated to that site with specified
    role.
  cisco.dnac.swim_intent:
    dnac_host: "{{dnac_host}}"
    dnac_username: "{{dnac_username}}"
    dnac_password: "{{dnac_password}}"
    dnac_verify: "{{dnac_verify}}"
    dnac_port: "{{dnac_port}}"
    dnac_version: "{{dnac_version}}"
    dnac_debug: "{{dnac_debug}}"
    dnac_log_level: "{{dnac_log_level}}"
    dnac_log: true
    config:
      - image_distribution_details:
          image_name: cat9k_iosxe.17.12.01.SPA.bin
          site_name: Global/USA/San Francisco/BGL_18
          device_role: ALL
          device_family_name: Switches and Hubs
          device_series_name: Cisco Catalyst 9300 Series Switches
- name: Activate the given image on devices associated to that site with specified
    role.
  cisco.dnac.swim_intent:
    dnac_host: "{{dnac_host}}"
    dnac_username: "{{dnac_username}}"
    dnac_password: "{{dnac_password}}"
    dnac_verify: "{{dnac_verify}}"
    dnac_port: "{{dnac_port}}"
    dnac_version: "{{dnac_version}}"
    dnac_debug: "{{dnac_debug}}"
    dnac_log_level: "{{dnac_log_level}}"
    dnac_log: true
    config:
      - image_activation_details:
          image_name: cat9k_iosxe.17.12.01.SPA.bin
          site_name: Global/USA/San Francisco/BGL_18
          device_role: ALL
          device_family_name: Switches and Hubs
          device_series_name: Cisco Catalyst 9300 Series Switches
          scehdule_validate: false
          activate_lower_image_version: true
          distribute_if_needed: true
aI  
#Case: SWIM image is successfully imported, tagged as golden, distributed and activated on a device
response:
  description: A dictionary with activation details as returned by the Catalyst Center Python SDK
  returned: always
  type: dict
  sample: >
    {
      "response": {
                        "additionalStatusURL": String,
                        "data": String,
                        "endTime": 0,
                        "id": String,
                        "instanceTenantId": String,
                        "isError": bool,
                        "lastUpdate": 0,
                        "progress": String,
                        "rootId": String,
                        "serviceType": String,
                        "startTime": 0,
                        "version": 0
                  },
      "msg": String
    }
)DnacBasevalidate_list_of_dictsget_dict_result)AnsibleModuleNc                        e Zd ZdZ fdZd Zd Zd Zd Zd Z	d Z
dd	Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z xZS )	DnacSwimsz9Class containing member attributes for Swim intent modulec                 4    t         |   |       dg| _        y )Nmerged)super__init__supported_states)selfmodule	__class__s     j/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/cisco/dnac/plugins/modules/swim_intent.pyr   zDnacSwims.__init__1  s     !)
    c                 b   | j                   s,d| _        d| _        | j                  | j                  d       | S t	        t	        d      t	        d      t	        d      t	        d            }| j                  | j                         | _         t        | j                   |      \  }}|r;dj                  |      | _        | j                  | j                  d       d| _        | S || _        d	j                  t        |            | _        | j                  | j                  d
       d| _        | S )a  
        Validate the fields provided in the playbook.
        Checks the configuration provided in the playbook against a predefined specification
        to ensure it adheres to the expected structure and data types.
        Parameters:
          - self: The instance of the class containing the 'config' attribute to be validated.
        Returns:
          The method returns an instance of the class with updated attributes:
          - self.msg: A message describing the validation result.
          - self.status: The status of the validation (either 'success' or 'failed').
          - self.validated_config: If successful, a validated version of 'config' parameter.
        Example:
            To use this method, create an instance of the class and call 'validate_input' on it.
          If the validation succeeds, 'self.status' will be 'success' and 'self.validated_config'
          will contain the validated configuration. If it fails, 'self.status' will be 'failed',
          'self.msg' will describe the validation issues.
        successz=Configuration is not available in the playbook for validationERRORdict)type)import_image_detailstagging_detailsimage_distribution_detailsimage_activation_detailsz#Invalid parameters in playbook: {0}failedz2Successfully validated playbook config params: {0}INFO)
configstatusmsglogr   camel_to_snake_caser   formatvalidated_configstr)r   	temp_spec
valid_tempinvalid_paramss       r   validate_inputzDnacSwims.validate_input5  s    & {{#DKVDHHHTXXw'K!%6!2 f-'+'8%)v%6	
	 ..t{{; &<KK&
"
N <CCNSDHHHTXXw'"DKK *GNNsS]_6"r   c                    d}d}d}	 | j                   j                  dddd|i      }|rQ| j                  dj                  t        |            d       |j                  d      }|d   j                  d      }d}||fS # t        $ rb}dj                  |      | _        | j                  | j                  d	       | j                  j                  | j                  
       Y d}~d}~ww xY w)a  
        Parameters:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
        Returns:
            tuple: A tuple containing two values:
            - site_exists (bool): A boolean indicating whether the site exists (True) or not (False).
            - site_id (str or None): The ID of the site if it exists, or None if the site is not found.
        Description:
            This method checks the existence of a site in the Catalyst Center. If the site is found,it sets 'site_exists' to True,
            retrieves the site's ID, and returns both values in a tuple. If the site does not exist, 'site_exists' is set
            to False, and 'site_id' is None. If an exception occurs during the site lookup, an exception is raised.
        FNsitesget_siteTnamefamilyfunctionop_modifiesparamszMAn exception occurred: Site '{0}' does not exist in the Cisco Catalyst Centerr   r#   z*Received API response from 'get_site': {0}DEBUGresponser   id)
dnac_exec	Exceptionr&   r#   r$   r   	fail_jsonr(   get)r   	site_namesite_existssite_idr8   esites          r   r@   zDnacSwims.site_existsh  s     
	0yy# 	*	 ' H HHAHHXWY`a<<
+D1gkk$'GKW%%  	0fmmnwxDHHHTXXw'KK!!dhh!//	0s   !B   	C+	AC&&C+c                    | j                   j                  dddd|i      }| j                  dj                  t	        |            d       |j                  d      }t        |      d	k(  r8|d
   j                  d      }| j                  dj                  ||      d       |S dj                  |      }| j                  |d       | j                  j                  ||       S )  
        Retrieve the unique image ID based on the provided image name.
        Parameters:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
            name (str): The name of the software image to search for.
        Returns:
            str: The unique image ID (UUID) corresponding to the given image name.
        Raises:
            AnsibleFailJson: If the image is not found in the response.
        Description:
            This function sends a request to Cisco Catalyst Center to retrieve details about a software image based on its name.
            It extracts and returns the image ID if a single matching image is found. If no image or multiple
            images are found with the same name, it raises an exception.
        software_image_management_swimget_software_image_detailsT
image_namer1   <Received API response from 'get_software_image_details': {0}r7   r8      r   	imageUuidz SWIM image '{0}' has the ID: {1}r    z#SWIM image '{0}' could not be foundr   r#   r8   	r:   r;   r$   r&   r(   r>   lenr   r=   )r   r0   image_response
image_listimage_iderror_messages         r   get_image_idzDnacSwims.get_image_id  s      31 $'	 ) 
 	OVVWZ[iWjkmtu#''
3

Oq !!}((5HHH7>>tXNPVW 	 BHHNMHH]G,KK!!mn!Mr   c                    | j                   j                  dddd|i      }| j                  dj                  t	        |            d       |j                  d      }t        |      d	k(  r7|d
   j                  d      }| j                  dj                  |      d       |S dj                  |      }| j                  |d       | j                  j                  ||       S )a%  
        Retrieve the unique image name based on the provided image id.
        Parameters:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
            id (str): The unique image ID (UUID) of the software image to search for.
        Returns:
            str: The image name corresponding to the given unique image ID (UUID)
        Raises:
            AnsibleFailJson: If the image is not found in the response.
        Description:
            This function sends a request to Cisco Catalyst Center to retrieve details about a software image based on its id.
            It extracts and returns the image name if a single matching image is found. If no image or multiple
            images are found with the same name, it raises an exception.
        rF   rG   T
image_uuidr1   rI   r7   r8   rJ   r   r0   zISWIM image '{0}' has been fetched successfully from Cisco Catalyst Centerr    zDSWIM image with Id '{0}' could not be found in Cisco Catalyst Centerr   rL   rM   )r   rQ   rO   rP   rH   rR   s         r   get_image_name_from_idz DnacSwims.get_image_name_from_id  s      31 (+	 ) 
 	OVVWZ[iWjkmtu#''
3

Oq #A**62JHH`gghrsu{| 	 ciijrsMHH]G,KK!!mn!Mr   c                     d}| j                   j                  dddd|i      }| j                  dj                  t	        |            d       |j                  d	      }t        |      d
k(  rd}|S )rE   FrF   rG   TrH   r1   rI   r7   r8   rJ   )r:   r;   r$   r&   r(   r>   rN   )r   r0   image_existrO   rP   s        r   is_image_existzDnacSwims.is_image_exist  s|      31 $'	 ) 
 	OVVWZ[iWjkmtu#''
3

Oq Kr   c                    d}| j                   j                  ddd|      }| j                  dj                  t	        |            d       |j                  d      }t        |      d	k(  r@|d
   j                  d      }| j                  dj                  t	        |            d       |S dj                  t	        |            | _        | j                  | j                  d       |S )a  
        Retrieve the unique device ID based on the provided parameters.
        Parameters:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
            params (dict): A dictionary containing parameters to filter devices.
        Returns:
            str: The unique device ID corresponding to the filtered device.
        Description:
            This function sends a request to Cisco Catalyst Center to retrieve a list of devices based on the provided
            filtering parameters. If a single matching device is found, it extracts and returns the device ID. If
            no device or multiple devices match the criteria, it raises an exception.
        Ndevicesget_device_listTr1   1Received API response from 'get_device_list': {0}r7   r8   rJ   r   r9   zDevice Id: {0}r    zYDevice with params: '{0}' not found in Cisco Catalyst Center so can't fetch the device idWARNING)r:   r;   r$   r&   r(   r>   rN   r#   )r   r5   	device_idr8   device_lists        r   get_device_idzDnacSwims.get_device_id  s     	99??&	 # 
 	DKKCPXMZ\cdll:.!#A**40IHH%,,S^<fE
  syyz}  E  {F  GDHHHTXXy)r   c           	      H   g }|sd}| j                  dd       | j                  |      \  }}|s#| j                  dj                  |      d       |S |rL|j                  d      r3|j	                  d      r"| j                  dj                  |      d       nd|z   dz   }||d}	 | j
                  j                  dd	d
|      }	| j                  dj                  t        |	            d       |	d   }	g }|	D ]#  }|d   s	|d   D ]  }|j                  |        % |j                         dk(  rd}|||d}d}| j                         }d}g g }}	 	 |r,||d<   ||z  |d<   | j
                  j                  dd|      }n!d
}| j
                  j                  ddd
|      }|dz   }|j                  d      }|	r|s"| j                  dj                  |      d       n|D ]l  }|d   dk7  r)| j                  d j                  |d!   |d         d       4| j                  d"j                  |d!   |      d       |j                  |d#          n |D ]k  }|d   dk7  r)| j                  d$j                  |d!   |d         d       4| j                  d%j                  |d!         d       |j                  |d#          m 	 p|r|s#| j                  dj                  |      d       |S t        |      j                  t        |            }|S # t        $ r7}
| j                  dj                  |t        |
            d       |cY d}
~
S d}
~
ww xY w# t        $ rG}
d&j                  t        |
            | _        | j                  | j                  d'       |cY d}
~
S d}
~
ww xY w)(a  
        Retrieve a list of device UUIDs based on the specified criteria.
        Parameters:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
            site_name (str): The name of the site for which device UUIDs are requested.
            device_family (str): The family/type of devices to filter on.
            device_role (str): The role of devices to filter on. If None, 'ALL' roles are considered.
            device_series_name(str): Specifies the name of the device series.
        Returns:
            list: A list of device UUIDs that match the specified criteria.
        Description:
            The function checks the reachability status and role of devices in the given site.
            Only devices with "Reachable" status are considered, and filtering is based on the specified
            device family and role (if provided).
        GlobalzlSince site name is not given so it will be fetch all the devices under Global and mark site name as 'Global'r    zwSite '{0}' is not found in the Cisco Catalyst Center, hence unable to fetch associated
                        devices.z.*z7Device series name '{0}' is already in the regex format)rA   device_familyr.   get_membershipTr1   zGUnable to fetch the device(s) associated to the site '{0}' due to '{1}'r^   Nz0Received API response from 'get_membership': {0}r7   devicer8   ALL)seriesr2   roler   Flimitoffsetr[   r\   )r2   r3   r5   rJ   zTFailed to retrieve devices associated with the site '{0}' due to empty API response.reachabilityStatus	ReachablezDevice '{0}' is currently '{1}' and cannot be included in the SWIM distribution/activation
                                    process.managementIpAddresszsDevice '{0}' from site '{1}' is ready for the SWIM distribution/activation
                                process.instanceUuidzUnable to proceed with the device '{0}' for SWIM distribution/activation as its status is
                                    '{1}'.zDevice '{0}' matches to the specified filter requirements and is set for SWIM
                            distribution/activation.zTAn exception occured while fetching the device uuids from Cisco Catalyst Center: {0}r   )r$   r@   r&   
startswithendswithr:   r;   r<   r(   appendupperget_device_details_limitr>   r#   setintersection)r   r?   rd   device_roledevice_series_namedevice_uuid_listr@   rA   site_paramsr8   rB   site_response_listitem	item_dictdevice_paramsrk   rj   initial_execsite_memberships_idsdevice_response_idsdevice_list_responsedevice_responses                         r   get_device_uuidszDnacSwims.get_device_uuids  s]   "  IHH  D  FL  M!%!1!1)!<gHH $$*F9$5v?##!,,T27I7R7RSW7XRYYZlmouv%),>%>%E" *

		$yy) "	 ' H 	CJJ3x=Y[bcH% 	9DJ!%j!1 9I&--i89	9
 %'K )#

 --/461,(-2M'*.4unM(++/99??(!2, ,; ,( $(L+/99??(!2$(,	 ,; ,(  !"6":"::"FHHszz  |E  F  HN  O. FD01[@ "006t<Q7RTXYmTn0oqwy HH ,,2F48M3NPY,Z\bd(//^0DEF , ED01[@ "..4fT:O5PRVWkRl.mouw HH 88>tDY?Z8[]ce'..tN/CDEE ^ #*>HHkrrs|}  @F  G## 34AA#FYBZ[a  	$HH^eefoqtuvqwx  {D  E##	$H  (qxxy|}~y  A7+''(sD   &L B
M C!M 	M,M	M	M	N!<NN!N!c                 n   i }| j                   j                  dd      }| j                  dj                  t	        |            d       |j                  d      }|rt        |d|      }|rA|j                  d      }||d	<   | j                  d
j                  t	        |            d       nmdj                  t	        |            | _        | j                  | j                  d       | j                  j                  | j                  | j                  g       | j                  j                  |       yy)a  
        Retrieve and store the device family identifier based on the provided family name.
        Parameters:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
            family_name (str): The name of the device family for which to retrieve the identifier.
        Returns:
            None
        Raises:
            AnsibleFailJson: If the family name is not found in the response.
        Description:
            This function sends a request to Cisco Catalyst Center to retrieve a list of device family identifiers.It then
            searches for a specific family name within the response and stores its associated identifier. If the family
            name is found, the identifier is stored; otherwise, an exception is raised.
        rF   get_device_family_identifiers)r2   r3   z?Received API response from 'get_device_family_identifiers': {0}r7   r8   deviceFamilydeviceFamilyIdentifierdevice_family_identifierzFamily device indentifier: {0}r    zDevice Family: {0} not foundr   rL   N)r:   r;   r$   r&   r(   r>   r   r#   r   r=   haveupdate)r   family_namer   r8   device_family_dbdevice_family_detailsr   s          r   get_device_family_identifierz&DnacSwims.get_device_family_identifier  s     99??34 # 
 	RYYZ]^fZghjqr#<<
3$34DnVa$b!$+@+D+DE]+^(3K/09@@E]A^_agh9@@[AQR7+%%$((dhhZ%HIIT" r   c                 
   | j                   j                  d      ri }| j                   j                  d      }|j                  d      r:|j                  d      j                  d      d   }| j                  |      }||d<   ni| j                  j                  d      r| j                  j                  d      |d<   n/| j                  dd       | j                  j                  dg 	       |j                  d
      }|rN|dk7  rId}| j                  |      \  }}|rH||d<   | j                  dj                  |t        |            d       nd|d<   | j                  dd       | j                  j                  |       |j                  d      }| j                  |       | j                   j                  d      ri }| j                   j                  d      }	|	j                  d
      }|rHd}| j                  |      \  }}|r0||d<   | j                  dj                  |t        |            d       |	j                  d      r:|	j                  d      j                  d      d   }| j                  |      }||d<   ni| j                  j                  d      r| j                  j                  d      |d<   n/| j                  dd       | j                  j                  dg 	       t        |	j                  d      |	j                  d      |	j                  d      |	j                  d            }
| j                  |
      }|||d<   | j                  j                  |       | j                   j                  d      ri }| j                   j                  d      }|j                  d      r:|j                  d      j                  d      d   }| j                  |      }||d <   ni| j                  j                  d      r| j                  j                  d      |d <   n/| j                  d!d       | j                  j                  d!g 	       |j                  d
      }|rHd}| j                  |      \  }}|r0||d<   | j                  d"j                  |t        |            d#       t        |j                  d      |j                  d      |j                  d      |j                  d            }
| j                  |
      }|||d$<   | j                  j                  |       | j                  d%j                  t        | j                              d#       | S )&a  
        Retrieve and store various software image and device details based on user-provided information.
        Returns:
            self: The current instance of the class with updated 'have' attributes.
        Raises:
            AnsibleFailJson: If required image or device details are not provided.
        Description:
            This function populates the 'have' dictionary with details related to software images, site information,
            device families, distribution devices, and activation devices based on user-provided data in the 'want' dictionary.
            It validates and retrieves the necessary information from Cisco Catalyst Center to support later actions.
        r   rH   /tagging_image_idimported_image_idz&Image details for tagging not providedCRITICALrL   r?   rc   FrA   z'Site {0} exists having the site id: {1}r7   z-1z/Site Name not given by user. Using global site.r^   device_image_family_namedistribution_detailsz*Site '{0}' exists and has the site ID: {1}distribution_image_idz>Image details required for distribution have not been providedr   device_hostnamedevice_serial_numberdevice_ip_addressdevice_mac_address)hostnameserialNumberrn   
macAddressdistribution_device_idactivation_detailsactivation_image_idz<Image details required for activation have not been providedz/The site '{0}' exists and has the site ID '{1}'r    activation_device_idCurrent State (have): {0})wantr>   splitrS   r   r$   r   r=   r@   r&   r(   r   r   r   ra   )r   r   r   r0   rQ   r?   r@   rA   r   r   r~   r_   r   s                r   get_havezDnacSwims.get_have  s    99==*+D"iimm,=>O""<0&**<8>>sCBG,,T2+3'(23+/99==9L+M'( A:N%%*R]_%` (++K8IY(2#)-)9)9))D&g&-DOHHFMMiY\]dYefhop #'YJIVIIT")--.HIK--k:99==/0D#'99==1G#H ,00=I#)-)9)9))D&g&-DOHHIPPQZ\_`g\hikrs $''5+//=CCCHL,,T208,-2304		>Q0R,- Y[bc%%*juw%x -112CD1556LM$8$<$<=P$Q/334HI	M **=9I$1:-.IIT"99==-.D!%/C!D!%%l3)--l;AA#FrJ,,T2.6*+23.2iimm<O.P*+WY`a%%*hsu%v*..{;I#)-)9)9))D&g&-DOHHNUUV_adelamnpvw +//0AB/334JK$6$:$:;N$O-112FG	M **=9I$/8+,IIT"HH077DIIGPr   c                    i }|j                  d      rd|d<   |j                  d      j                  d      j                         |d<   |d   dk(  r$|j                  d      j                  d      |d<   nl|d   d	k(  r$|j                  d      j                  d
      |d<   n@| j                  dj                  |d         d       | j                  j                  d       |j                  d      |d<   |j                  d      |d<   |j                  d      |d<   || _        | j                  dj                  t        | j                              d       | S )a#  
        Retrieve and store import, tagging, distribution, and activation details from playbook configuration.
        Parameters:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
            config (dict): The configuration dictionary containing image import and other details.
        Returns:
            self: The current instance of the class with updated 'want' attributes.
        Raises:
            AnsibleFailJson: If an incorrect import type is specified.
        Description:
            This function parses the playbook configuration to extract information related to image
            import, tagging, distribution, and activation. It stores these details in the 'want' dictionary
            for later use in the Ansible module.
        r   Timport_imager   import_typeremoteurl_detailsurl_import_detailslocallocal_image_detailslocal_import_detailszTThe import type '{0}' provided is incorrect. Only 'local' or 'remote' are supported.r   z8Incorrect import type. Supported Values: local or remoter6   r   r   r   r   r   Desired State (want): {0}r    )r>   lowerr$   r&   r   r=   r   r(   )r   r!   r   s      r   get_wantzDnacSwims.get_want2  s[     ::,-#'D "(**-C"D"H"H"P"V"V"XDM"h.-3ZZ8N-O-S-STa-b)*m$//5zz:P/Q/U/UVk/l+,ovvw{  }J  xK  L  NX  Y%%*d%e"(**->"?'-zz2N'O#$%+ZZ0J%K!"	,33C		NCVLr   c                    	 | j                   j                  d      }|sTd| _        d| _        | j                  | j                  d<   | j                  | j                  d       d| j                  d<   | S |dk(  r=| j                   j                  d	      j                  d
      d   j                  d      }n*| j                   j                  d      j                  d      }|j                  d      d   }| j                  |      }ddddd}|r| j                  |      }|| j                  d<   dj                  |      | _        | j                  | j                  d<   | j                  | j                  d       d| _        d| j                  d<   | S | j                   j                  d      dk(  ri }| j                   j                  d	      j                  d
      d   }t        |j                               }	|j                         D ]  \  }
}|
|	v s||
   }|||<    |g}t        || j                   j                  d	      j                  d      | j                   j                  d	      j                  d      | j                   j                  d	      j                  d            }d}n	| j                   j                  d      j                  d      }t        | j                   j                  d      j                  d      | j                   j                  d      j                  d      | j                   j                  d      j                  d       | j                   j                  d      j                  d!      d"t        j                   j#                  |      t%        |d#      d$fid%&      }d'}| j&                  j)                  d(|d)|*      }| j                  d+j                  |t+        |            d,       i }|j                  d-      j                  d.      }	 | j-                  |      }|j                  d      d   }|rd/|j                  d0      j/                         v rbd)| j                  d<   d| _        d1j                  |      | _        | j                  | j                  d<   | j                  | j                  d       n|r|j                  d2      rd3|j                  d4d5      v rbd6j                  |      | _        | j                  | j                  d<   | j                  | j                  d       d| _        d| j                  d<   nfd7| _        |j                  d4d8j                  |            | _        | j                  | j                  d       | j                  | j                  d-<   | S |r|n|| j                  d-<   |j                  d      d   }| j                  |      }|| j                  d<   | S # t0        $ rN}d7| _        d9| _        | j                  | j                  d:       | j                  | j                  d-<   Y d%}~| S d%}~ww xY w);aU  
        Check the image import type and fetch the image ID for the imported image for further use.
        Parameters:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
        Returns:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
        Description:
            This function checks the type of image import (URL or local) and proceeds with the import operation accordingly.
            It then monitors the import task's progress and updates the 'result' dictionary. If the operation is successful,
            'changed' is set to True.
            Additionally, if tagging, distribution, or activation details are provided, it fetches the image ID for the
            imported image and stores it in the 'have' dictionary for later use.
        r   r   z[Error: Details required for importing SWIM image. Please provide the necessary information.r#   r^   Fchangedr   r   payloadr   
source_urlr   	file_pathr   r   	sourceURLimageFamilyapplicationType
thirdParty)r   image_familyapplication_typeis_third_partyr   z7Image '{0}' already exists in the Cisco Catalyst Centerr    schedule_atschedule_descschedule_origin)r   
scheduleAtscheduleDescscheduleOriginimport_software_image_via_urlr   third_party_vendorthird_party_image_familythird_party_application_typefilerbzapplication/octet-streamN)r   r   r   r   multipart_fieldsmultipart_monitor_callbackimport_local_software_imagerF   Tr1   z#Received API response from {0}: {1}r7   r8   taskIdcompleted successfullyprogressz$Swim Image {0} imported successfullyisErrorzalready existsfailureReason z:SWIM Image {0} already exists in the Cisco Catalyst Centerr   z"SWIM Image {0} seems to be invalidzError: Import image details are not provided in the playbook, or the Import Image API was not
                 triggered successfully. Please ensure the necessary details are provided and verify the status of the Import Image process.r   )r   r>   r"   r#   resultr$   r   rY   rS   r   r&   listkeysitemsr   ospathbasenameopenr:   r;   r(   get_task_detailsr   r<   )r   r   rH   r0   rX   import_key_mappingrQ   import_payload_dicttemp_payloadkeys_to_changekeyvalapi_key_nameimport_image_payloadimport_paramsimport_functionr   r8   task_detailstask_idrB   s                        r   get_diff_importzDnacSwims.get_diff_importW  s   x	/))--6K'x%)XXE"9-).I&h&!YY]]+?@DDYOPQRVVWcd
!YY]]+ABFF{S
 ##C(,D--d3K * -$5".	" ,,T219		-.T[[\`a%)XXE"6*').I&yy}}]+x7&(##yy}}-ABFFyQRST!%&8&=&=&?!@ , 2 2 4 @HCn,'9#'><?+L9@
 )<'<$ $0#yy}}-ABFF}U!%/C!D!H!H!Y#'99==1E#F#J#JK\#]	! #B IIMM*@AEEkR	 $#'99==1G#H#L#LM]#^'+yy}}5K'L'P'PQe'f-1YY]];Q-R-V-VWq-r15?U1V1Z1Z[y1z&,rww/?/?	/JDQZ\`Lac}.~%/3! #@yy7( $	 ' H HH:AA/SVW_S`acjkLll:.228<G#44W=!'',R01\5E5Ej5Q5W5W5YY-1DKK	*"+DKELLTRDH)-DKK&HHTXXv.L$4$4Y$?'<+;+;OR+PP#_#f#fgk#l-1XXE*62&/16I.&.#/#3#3OEiEpEpq{E|#}9526((J/#5 8 7ClDKK
# $))#.r2J((4H-5DII)*K 	/"DKPDHHHTXXw'&*hhDKK
#	/s5   A0X 3DX B X N&X 8A
X 	YAYYc           	         | j                   j                  d      }|j                  d      }| j                  | j                  j                  d            }t	        | j                  j                  d      | j                  j                  d      | j                  j                  d      |j                  dd      j                               }| j                  j                  d	d
d|      }| j                  dj                  t        |            d       |j                  d      }|r|d   }|rh||k(  rcd| _        d| j                  d<   dj                  |      | _        | j                  | j                  d<   | j                  | j                  d       | S |sh||k(  rcd| _        d| j                  d<   dj                  |      | _        | j                  | j                  d<   | j                  | j                  d       | S |rt	        | j                  j                  d      | j                  j                  d      | j                  j                  d      |j                  dd      j                               }| j                  dj                  t        |            d       | j                  j                  d	dd|      }| j                  dj                  t        |            d       ns| j                  dj                  t        |            d       | j                  j                  d	dd|      }| j                  dj                  t        |            d       |sTd| _        d j                  |      | _        | j                  | j                  d!       | j                  | j                  d<   | S i }|j                  d      j                  d"      }	 | j                  |      }|j                  d#      sd$|j                  d%      v r}d| _        d| j                  d<   |j                  d%      | _        | j                  | j                  d<   | j                  | j                  d<   | j                  | j                  d       	 | S |j                  d#      r|j                  d&d'      }	|	rhd(|	v rdd| _        d| j                  d<   |	| _        |	| j                  d<   | j                  | j                  d!       | j                  | j                  d<   	 | S |j                  d&d)      }
d| _        |
| _        |
| j                  d<   | j                  | j                  d!       | j                  | j                  d<   	 | S )*a  
        Tag or untag a software image as golden based on provided tagging details.
        Parameters:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
        Returns:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
        Description:
            This function tags or untags a software image as a golden image in Cisco Catalyst Center based on the provided
            tagging details. The tagging action is determined by the value of the 'tagging' attribute
            in the 'tagging_details' dictionary.If 'tagging' is True, the image is tagged as golden, and if 'tagging'
            is False, the golden tag is removed. The function sends the appropriate request to Cisco Catalyst Center and updates the
            task details in the 'result' dictionary. If the operation is successful, 'changed' is set to True.
        r   taggingr   rA   r   rw   rg   rQ   rA   r   rw   rF   !get_golden_tag_status_of_an_imageTr1   CReceived API response from 'get_golden_tag_status_of_an_image': {0}r7   r8   taggedGoldenr   Fr   zHSWIM Image '{0}' already tagged as Golden image in Cisco Catalyst Centerr#   r    zMSWIM Image '{0}' already un-tagged from Golden image in Cisco Catalyst Center)imageIdsiteIdr   
deviceRolez/Parameters for tagging the image as golden: {0}tag_as_golden_imagez5Received API response from 'tag_as_golden_image': {0}z2Parameters for un-tagging the image as golden: {0}remove_golden_tag_for_imagez=Received API response from 'remove_golden_tag_for_image': {0}r   zXDid not get the response of API so cannot check the Golden tagging status of image - {0}r   r   r   
successfulr   r   r   z%An inheritted tag cannot be un-taggedz6Error: while tagging/un-tagging the golden swim image.)r   r>   rV   r   r   rs   r:   r;   r$   r&   r(   r"   r   r#   r   )r   r   tag_image_goldenrH   image_paramsr8   image_statusr   r   failure_reasonrR   s              r   get_diff_taggingzDnacSwims.get_diff_tagging  s    ))--(9:*..y900?Q1RS
YY]]#56IIMM),%)YY]]3M%N'++M5AGGI	
 99??38	 # 
 	V]]^abj^klnuv<<
+#N3L0@ @').I&ellmwx%)XXE"6*L4D$D').I&jqqr|}%)XXE"6*		&89yy}}Y/'+yy}}5O'P*..}eDJJL	L HHFMMcR^N_`bhiyy7. #	 ' H HHLSSTWX`Tabdkl HHIPPQTUaQbceklyy76 #	 ' H HHT[[\_`h\ijlst"DKqxx  zD  EDHHHTXXw'&*hhDKK
#K,,z*..x8009L##I.<<CSCST^C_3_')-I&'++J7%)XXE"*.((J'6*( ' !!),!-!1!1/2!F!&MQ_&_"*DK-2DKK	*-DH)7DKK&HHTXXw/.2hhDKK
+  %1$4$4_F~$M"*DK,DH)6DKK&HHTXXw/.2hhDKK
+= r   c                 x   	 | j                   j                  dddd|i      }| j                  dj                  t	        |            d       |j                  d      d	   }|j                  d
      }|S # t        $ r<}dj                  t	        |            }| j                  |d       t        |      d}~ww xY w)a  
        Retrieve the management IP address of a device from Cisco Catalyst Center using its ID.
        Parameters:
            - self (object): An instance of a class used for interacting with Cisco Catalyst Center.
            - device_id (str): The unique identifier of the device in Cisco Catalyst Center.
        Returns:
            str: The management IP address of the specified device.
        Raises:
            Exception: If there is an error while retrieving the response from Cisco Catalyst Center.
        Description:
            This method queries Cisco Catalyst Center for the device details based on its unique identifier (ID).
            It uses the 'get_device_list' function in the 'devices' family, extracts the management IP address
            from the response, and returns it. If any error occurs during the process, an exception is raised
            with an appropriate error message logged.
        r[   r\   Tr9   r1   r]   r7   r8   r   rn   zSError occurred while getting the response of device from Cisco Catalyst Center: {0}r   N)r:   r;   r$   r&   r(   r>   r<   )r   r_   r8   	device_iprB   rR   s         r   get_device_ip_from_idzDnacSwims.get_device_ip_from_id]  s    "	+yy * i(	 ' H HHHOOPST\P]^`gh||J/2H %:;I 	+qxxy|}~y  AMHH]G,M**	+s   A1A4 4	B9=7B44B9c                 8   g }d}|j                         D ]  \  }}t        j                         }| j                  j                  d      }	 t        j                         }	|	|z
  |k\  r5| j	                  dj                  |||      d       |j                  |       | j                  |      }
|
j                  d      sQd|
j                  d      v r>d| j                  d	<   d
| _	        | j	                  dj                  ||      d       |dz  }|
j                  d      rFdj                  ||      }| j	                  |d       |
| j                  d<   |j                  |       Rt        j                  | j                  j                  d             K ||fS )a#  
        Check the status of the SWIM (Software Image Management) task for each device.
        Args:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
            swim_task_dict (dict): A dictionary containing the mapping of device IP address to the respective task ID.
            swim_task_name (str): The name of the SWIM task being checked which is either Distribution or Activation.
        Returns:
            tuple: A tuple containing two elements:
                - device_ips_list (list): A list of device IP addresses for which the SWIM task failed.
                - device_count (int): The count of devices for which the SWIM task was successful.
        Description:
            This function iterates through the distribution_task_dict, which contains the mapping of
            device IP address to their respective task ID. It checks the status of the SWIM task for each device by
            repeatedly querying for task details until the task is either completed successfully or fails. If the task
            is successful, the device count is incremented. If the task fails, an error message is logged, and the device
            IP is appended to the device_ips_list and return a tuple containing the device_ips_list and device_count.
        r   dnac_api_task_timeoutTzMax timeout of {0} sec has reached for the task id '{1}' for the device '{2}' and unexpected
                                 task status so moving out to next task idr^   r   r   r   r   r   z*Image {0} successfully for the device '{1}r    rJ   z*Image {0} gets failed for the device '{1}'r   r8   dnac_task_poll_interval)r   timer5   r>   r$   r&   rr   r   r   r"   sleep)r   swim_task_dictswim_task_namedevice_ips_listdevice_countr   r   
start_timemax_timeoutend_timer   	error_msgs               r   check_swim_task_statusz DnacSwims.check_swim_task_status  s   & "0"6"6"8 	GIwJ++//*ABK99;z)k9HH NNTfU`biktNu  xAB#**95#44W=#''	21\5E5Ej5QQ-1DKK	*"+DKHHIPPQ_ajkmst A%L##I. L S STbdm nIHHY0.:DKK
+#**95

4;;??+DEF1 		G< ,,r   c                 	   | j                   j                  d      }|j                  d      }|j                  d      }|j                  dd      }|j                  d      }| j                  ||||      }| j                  j                  d      }d| _        d| _        d| _        | j                  j                  d	      rt        t        | j                  j                  d	      |
      g      }| j                  dj                  t        |            d       | j                  j                  ddd|      }	| j                  dj                  t        |	            d       |	ri }
|	j                  d      j                  d      }	 | j                  |      }
|
j                  d      sQd|
j                  d      v r>d| j                  d<   d| _        d| _        dj                  |      | j                  d<   	 | S |
j                  d      rKd| _        dj                  |      | _        | j                  | j                   d       |
| j                  d<   	 | S |
r|
n|	| j                  d<   | S t#        |      d k(  rEd| _        d!| _        | j                   | j                  d<   | j                  | j                   d"       | S | j                  d#j                  t        |            d       i }|D ]  }| j%                  |      }t        t        ||
      g      }| j                  dj                  t        |            d       | j                  j                  ddd|      }	| j                  dj                  t        |	            d       |	si }
|	j                  d      j                  d      }|||<    | j'                  |d$      \  }}|d k(  rd| _        d%j                  |      | _        n|t#        |      k(  r4d| j                  d<   d| _        d| _        d&j                  |      | _        n]d| j                  d<   d| _        d| _        d'j                  |      | _        | j                  d(j                  t        |            d)       | j                   | j                  d<   | j                  | j                   d       | S )*a  
        Get image distribution parameters from the playbook and trigger image distribution.
        Parameters:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
        Returns:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
        Description:
            This function retrieves image distribution parameters from the playbook's 'distribution_details' and triggers
            the distribution of the specified software image to the specified device. It monitors the distribution task's
            progress and updates the 'result' dictionary. If the operation is successful, 'changed' is set to True.
        r   r?   device_family_namerw   rg   rx   r   Fr   )
deviceUuidrK   )r   zDistribution Params: {0}r    rF   #trigger_software_image_distributionTr1   zEReceived API response from 'trigger_software_image_distribution': {0}r7   r8   r   r   r   r   r   r   z*Image with Id {0} Distributed Successfullyr#   r   z%Image with Id {0} Distribution Failedr   r   zZThe SWIM image distribution task could not proceed because no eligible devices were found.r^   z0Device UUIDs involved in Image Distribution: {0}Distributionz5Image with Id {0} Distribution Failed for all devicesz:Image with Id {0} Distributed Successfully for all devicesz9Image with Id '{0}' Distributed and partially successfullz0For device(s) {0} image Distribution gets failedr   )r   r>   r   r    complete_successful_distributionpartial_successful_distributionsingle_device_distributionr   r$   r&   r(   r:   r;   r   r   r"   r#   rN   r   r  )r   r   r?   rd   rw   rx   ry   rQ   distribution_paramsr8   r   r   distribution_task_dictdevice_uuiddevice_management_ipr  device_distribution_counts                    r   get_diff_distributionzDnacSwims.get_diff_distribution  s     $yy}}-CD(,,[9	,001EF*..}eD1556JK00M;Xjk99==!8905-/4,*/'99==12"&#yy}}-EF& # HH/66s;N7OPRXYyy7> *	 ' H HH\ccdghpdqrt{|!",,z266x@#'#8#8#AL'++I659I9I*9UU15I.&/:>7-Y-`-`ai-jE* K $''	2&.#J#Q#QRZ#[732>J/ K ?KlPXDKK
+% ( K A%#DKsDH!%DKKHHTXXy)KCJJ3O_K`acij!#+ 	GK#'#=#=k#J "&*& # HH/66s;N7OPRXYyy7> *	 ' H HH\ccdghpdqrt{|!",,z266x@?F&';<)	G, 6:5P5PQgiw5x22$)"DKNUUV^_DH&#.>*??%)DKK	"#DK48D1SZZ[cdDH%)DKK	"#DK38D0RYYZbcDHHHGNNsSbOcdfpq!XXE6"r   c                 z
   | j                   j                  d      }|j                  d      }|j                  d      }|j                  dd      }|j                  d      }| j                  ||||      }| j                  j                  d      }d| _        d| _        d| _        | j                  j                  d	      rt        |j                  d
      |j                  d      |j                  d      | j                  j                  d	      |g      g}t        |j                  d      |      }	| j                  dj                  t        |	            d       | j                  j                  ddd|	      }
| j                  dj                  t        |
            d       i }|
j                  d      j                  d      }	 | j                  |      }|j                  d      s@d|j                  d      v r-d| j                  d<   d| j                  d<   d | _        d| _        n\|j                  d      rJd!j                  |      | _        d"| _        || j                  d<   | j                  | j                   d#       | S |r|n|
| j                  d<   | S t#        |      d$k(  rEd | _        d%| _        | j                   | j                  d<   | j                  | j                   d&       | S | j                  d'j                  t        |            d       i }|D ]  }| j%                  |      }t        |j                  d
      |j                  d      |j                  d      ||g      g}t        |j                  d      |      }	| j                  dj                  t        |	            d       | j                  j                  ddd|	      }
| j                  dj                  t        |
            d       |
si }|
j                  d      j                  d      }|||<    | j'                  |d(      \  }}|d$k(  rd"| _        d)j                  |      | _        n|t#        |      k(  r4d| j                  d<   d | _        d| _        d*j                  |      | _        n]d| j                  d<   d | _        d| _        d+j                  |      | _        | j                  d,j                  t        |            d-       | j                   | j                  d<   | j                  | j                   d       | S ).a  
        Get image activation parameters from the playbook and trigger image activation.
        Parameters:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
        Returns:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
        Description:
            This function retrieves image activation parameters from the playbook's 'activation_details' and triggers the
            activation of the specified software image on the specified device. It monitors the activation task's progress and
            updates the 'result' dictionary. If the operation is successful, 'changed' is set to True.
        r   r?   r  rw   rg   rx   r   Fr   activate_lower_image_versiondevice_upgrade_modedistribute_if_needed)activateLowerImageVersiondeviceUpgradeModedistributeIfNeededr  imageUuidListscehdule_validate)schedule_validater   zActivation Params: {0}r    rF   !trigger_software_image_activationTr1   zCReceived API response from 'trigger_software_image_activation': {0}r7   r8   r   r   r   r   r   zImage Activated successfullyr#   r   z.Activation for Image with Id '{0}' gets failedr   r   r   zXThe SWIM image activation task could not proceed because no eligible devices were found.r^   z.Device UUIDs involved in Image Activation: {0}
Activationz5Image with Id '{0}' activation failed for all devicesz:Image with Id '{0}' activated successfully for all devicesz7Image with Id '{0}' activated and partially successfullz.For Device(s) {0} Image activation gets Failedr   )r   r>   r   r   complete_successful_activationpartial_successful_activationsingle_device_activationr   r$   r&   r(   r:   r;   r   r   r"   r#   rN   r   r  )r   r   r?   rd   rw   rx   ry   rQ   r   activation_paramsr8   r   r   activation_task_dictr  r  r  device_activation_counts                     r   get_diff_activationzDnacSwims.get_diff_activation/  s    "YY]]+?@&**;7	*../CD(,,]EB/334HI00M;Xjk99==!67.3+-2*(-%99==/0*<*@*@A_*`"4"8"89N"O#5#9#9:P#Q99==)?@'j G !%"4"8"89L"M! HH-44S9J5KLfUyy7< (	 ' H HHZaabefnbopryzLll:.228<G#44W=#''	21\5E5Ej5QQ-1DKK	*)GDKK&"+DK48D1##I.OVVW_`DH"*DK.:DKK
+HHTXXw/K! $ 7ClDKK
#K A%#DKqDH!%DKKHHTXXy)KAHHM]I^_agh!+ 	EK#'#=#=k#J *<*@*@A_*`"4"8"89N"O#5#9#9:P#Q&'j G !%"4"8"89L"M! HH-44S9J5KLfUyy7< (	 ' H HHZaabefnbopryz!",,z266x@=D$%9:7	E: 483N3NOceq3r00"a'"DKNUUV^_DH$,<(==%)DKK	"#DK26D/SZZ[cdDH%)DKK	"#DK15D.PWWX`aDHHHELLSQ`Mabdno!XXE6"r   c                     |j                  d      r| j                         j                          |j                  d      r| j                         j                          |j                  d      r| j	                         j                          | S )a  
        Get tagging details and then trigger distribution followed by activation if specified in the playbook.
        Parameters:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
            config (dict): The configuration dictionary containing tagging, distribution, and activation details.
        Returns:
            self: The current instance of the class with updated 'result' and 'have' attributes.
        Description:
            This function checks the provided playbook configuration for tagging, distribution, and activation details. It
            then triggers these operations in sequence if the corresponding details are found in the configuration.The
            function monitors the progress of each task and updates the 'result' dictionary accordingly. If any of the
            operations are successful, 'changed' is set to True.
        r   r   r   )r>   r   check_return_statusr  r-  )r   r!   s     r   get_diff_mergedzDnacSwims.get_diff_merged  so     ::'(!!#779::23&&(<<>::01$$&::<r   c                    |dk(  r=| j                   j                  d      j                  d      d   j                  d      }n*| j                   j                  d      j                  d      }|j                  d      d	   }| j                  |      }|r;d
| _        dj                  |      | _        | j                  | j                  d       | S | j                  dj                  |      d       | S )aA  
        Verify the successful import of a software image into Cisco Catalyst Center.
        Args:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
            import_type (str): The type of import, either 'remote' or 'local'.
        Returns:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
        Description:
            This method verifies the successful import of a software image into Cisco Catalyst Center.
            It checks whether the image exists in Catalyst Center based on the provided import type.
            If the image exists, the status is set to 'success', and a success message is logged.
            If the image does not exist, a warning message is logged indicating a potential import failure.
        r   r   r   r   r   r   r   r   r   r   zeThe requested Image '{0}' imported in the Cisco Catalyst Center and Image presence has been verified.r    zThe playbook input for SWIM Image '{0}' does not align with the Cisco Catalyst Center, indicating that image
                        may not have imported successfully.)r   r>   r   rY   r"   r&   r#   r$   )r   r   rH   r0   rX   s        r   verify_diff_importedzDnacSwims.verify_diff_imported  s     ("';<@@KANRRS_`J'=>BB;OJ $R())$/#DK~  F  F  GK  LDHHHTXXv&
  HH ??Evd|VU r   c           	         | j                   j                  d      }|j                  d      }| j                  j                  d      }| j                  |      }t	        | j                  j                  d      | j                  j                  d      | j                  j                  d      |j                  dd      j                               }| j                  d	j                  t        |            d
       | j                  j                  ddd|      }| j                  dj                  t        |            d       |j                  d      }|rt|d   }||k(  rh|r4dj                  |      | _        | j                  | j                  d
       | S dj                  |      | _        | j                  | j                  d
       | S | j                  dd
       | S )a  
        Verify the Golden tagging status of a software image in Cisco Catalyst Center.
        Args:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
        Returns:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
        Description:
            This method verifies the tagging status of a software image in Cisco Catalyst Center.
            It retrieves tagging details from the input, including the desired tagging status and image ID.
            Using the provided image ID, it obtains image parameters required for checking the image status.
            The method then queries Catalyst Center to get the golden tag status of the image.
            If the image status matches the desired tagging status, a success message is logged.
            If there is a mismatch between the playbook input and the Catalyst Center, a warning message is logged.
        r   r   r   rA   r   rw   rg   r   z0Parameters for checking the status of image: {0}r    rF   r   Tr1   r   r7   r8   r   zThe requested image '{0}' has been tagged as golden in the Cisco Catalyst Center and
                             its status has been successfully verified.zThe requested image '{0}' has been un-tagged as golden in the Cisco Catalyst Center and
                            image status has been verified.zMismatch between the playbook input for tagging/un-tagging image as golden and the Cisco Catalyst Center indicates that
                        the tagging/un-tagging task was not executed successfully.)r   r>   r   rV   r   rs   r$   r&   r(   r:   r;   r#   )r   r   r   rQ   rH   r   r8   r   s           r   verify_diff_taggedzDnacSwims.verify_diff_tagged  s     ))--(9:*..y999==!3400:
YY]]#56IIMM),%)YY]]3M%N'++M5AGGI	
 	CJJ3|K\]_ef99??38	 # 
 	V]]^abj^klnuv<<
+#N3L//# KKQ6R\K] HHHTXXv.  ??Evj?Q HHHTXXv.
  HH VW]_ r   c                 *   | j                   j                  d      }| j                  |      }| j                   j                  d      r| j                  rNdj	                  || j                   j                  d            | _        | j                  | j
                  d       | S | j                  dj	                  | j                   j                  d            d       | S | j                  r5dj	                  ||      | _        | j                  | j
                  d       | S | j                  r5dj	                  ||      | _        | j                  | j
                  d       | S dj	                  ||      | _        | j                  | j
                  d       | S )	a  
        Verify the distribution status of a software image in Cisco Catalyst Center.
        Args:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
            import_type (str): The type of import, either 'url' or 'local'.
        Returns:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
        Description:
            This method verifies the distribution status of a software image in Cisco Catalyst Center.
            It retrieves the image ID and name from the input and if distribution device ID is provided, it checks the distribution status for that
            list of specific device and logs the info message based on distribution status.
        r   r   zThe requested image '{0}', associated with the device ID '{1}', has been successfully distributed in the Cisco Catalyst Center
                     and its status has been verified.r    a  Mismatch between the playbook input for distributing the image to the device with ID '{0}' and the actual state in the
                         Cisco Catalyst Center suggests that the distribution task might not have been executed
                         successfully.zThe requested image '{0}', with ID '{1}', has been successfully distributed to all devices within the specified
                     site in the Cisco Catalyst Center.zT"The requested image '{0}', with ID '{1}', has been partially distributed across some devices in the Cisco Catalyst
                     Center.zThe requested image '{0}', with ID '{1}', failed to be distributed across devices in the Cisco Catalyst
                     Center.)	r   r>   rV   r  r&   r#   r$   r  r  r   rQ   rH   s      r   verify_diff_distributedz!DnacSwims.verify_diff_distributed&  s]    99==!8900:
99==12..::@&TYY]][sMt:u 6*$ !  **0&?W1X*Y[ac   22;;A6*h;W HHHTXXv&  11  &z8 < HHHTXXv& 	  &z8 < HHHTXXv&r   c                 ,   | j                   j                  d      }| j                  |      }| j                   j                  d      r| j                  rNdj	                  || j                   j                  d            | _        | j                  | j
                  d       | S | j                  dj	                  || j                   j                  d            d       | S | j                  r5dj	                  ||      | _        | j                  | j
                  d       | S | j                  r5dj	                  ||      | _        | j                  | j
                  d       | S dj	                  ||      | _        | j                  | j
                  d       | S )	a  
        Verify the activation status of a software image in Cisco Catalyst Center.
        Args:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
        Returns:
            self (object): An instance of a class used for interacting with Cisco Catalyst Center.
        Description:
            This method verifies the activation status of a software image in Cisco Catalyst Center and retrieves the image ID and name from
            the input. If activation device ID is provided, it checks the activation status for that specific device. Based on activation status
            a corresponding message is logged.
        r   r   zThe requested image '{0}', associated with the device ID '{1}', has been successfully activated in the Cisco Catalyst
                         Center and its status has been verified.r    a  Mismatch between the playbook's input for activating the image '{0}' on the device with ID '{1}' and the actual state in
                         the Cisco Catalyst Center suggests that the activation task might not have been executed
                         successfully.zThe requested image '{0}', with ID '{1}', has been successfully activated on all devices within the specified site in the
                     Cisco Catalyst Center.z"The requested image '{0}', with ID '{1}', has been partially activated on some devices in the Cisco
                     Catalyst Center.zThe activation of the requested image '{0}', with ID '{1}', failed on devices in the Cisco
                     Catalyst Center.)	r   r>   rV   r)  r&   r#   r$   r'  r(  r6  s      r   verify_diff_activatedzDnacSwims.verify_diff_activatedO  se    99==!6700:
99==/0,,EEKVJX\XaXaXeXef|X}E~ 6*$ !  **0&TYY]]Ka=b*cekm   00//5vj(/K HHHTXXv&  //))/
H)E HHHTXXv& 	))/
H)E HHHTXXv&r   c                    | j                          | j                  dj                  t        | j                              d       | j                  dj                  t        | j
                              d       | j
                  j                  d      }|r| j                  |      j                          | j
                  j                  d      }|r| j                         j                          | j
                  j                  d      }|r| j                         j                          | j
                  j                  d      }|r| j                         j                          | S )a  
        Verify the merged status(Importing/Tagging/Distributing/Actiavting) the SWIM Image in devices in Cisco Catalyst Center.
        Args:
            - self (object): An instance of a class used for interacting with Cisco Catalyst Center.
            - config (dict): The configuration details to be verified.
        Return:
            - self (object): An instance of a class used for interacting with Cisco Catalyst Center.
        Description:
            This method checks the merged status of a configuration in Cisco Catalyst Center by retrieving the current state
            (have) and desired state (want) of the configuration, logs the states, and validates whether the specified
            SWIM operation performed or not.
        r   r    r   r   r   r   r   )r   r$   r&   r(   r   r   r>   r2  r/  r4  r7  r9  )r   r!   r   taggedr   r   s         r   verify_diff_mergedzDnacSwims.verify_diff_mergedw  s    	,33C		NCVL,33C		NCVLiimmM2%%k2FFH01##%99;#yy}}-CD((*>>@!YY]]+?@&&(<<>r   )N)__name__
__module____qualname____doc__r   r,   r@   rS   rV   rY   ra   r   r   r   r   r   r   r   r  r  r-  r0  r2  r4  r7  r9  r<  __classcell__)r   s   @r   r   r   .  s    C+1f#&J!F!F>@~ @##Jyv#JIVyv +D4-lxtCJ4B5n'R&P"r   r   c                     i ddddddddddd	d
gdddddddddddddddddddddddddddddddddddddddddddddd dd!dd"dd#d$d%d&d'd'gd(} t        | d)      }t        |      }|j                  j                  d&      }||j                  vr-d*|_        d+j                  |      |_        |j                          |j                         j                          |j                  j                  d      }|j                  D ]  }|j                          |j                  |      j                          |j                         j                          |j                         j                           |j                  |   |      j                          |s |j                   |   |      j                            |j"                  d-i |j$                   y,).z+ main entry point for module execution
    	dnac_hostTr(   )requiredr   	dnac_port443)r   defaultdnac_usernameadminuser)r   rG  aliasesdnac_password)r   no_logdnac_verifyboolTruednac_versionz2.2.3.3
dnac_debugFdnac_log_levelr^   dnac_log_file_pathzdnac.logdnac_log_appenddnac_logvalidate_response_schemaconfig_verifyr   inti  r     r!   r   r   )rD  r   elementsstater   )rG  choices)argument_specsupports_check_modeinvalidzState {0} is invalidN )r	   r   r5   r>   r   r"   r&   r#   r/  r,   r'   reset_valuesr   r   r   get_diff_state_applyverify_diff_state_apply	exit_jsonr   )element_specr   
dnac_swimsr\  rX  r!   s         r   mainrh    s}   KdE!B %E!B#eU[T\%] $et%D "Fv#F	
 #Uy$I !6e"D %u&K )5Z*P &4'H E B /D0Q $f%G ,e-M .!/L 4VT  xjI!L& /46F 6"J!!'*EJ///%
/66u=
&&(335%%))/:M-- T!F#779""$88:113.
''.v6JJL5J..u5f=QQST F)z(()r   __main__)
__future__r   r   r   r   __metaclass__
__author__DOCUMENTATIONEXAMPLESRETURN8ansible_collections.cisco.dnac.plugins.module_utils.dnacr   r   r   ansible.module_utils.basicr	   r   r  r   rh  r=  ra  r   r   <module>rr     so   
 A @O
zvFN
4 
 5 	 k k\+.*b zF r   