summaryrefslogtreecommitdiffstats
path: root/ansible_collections/cisco/ise/plugins/action
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/cisco/ise/plugins/action')
-rw-r--r--ansible_collections/cisco/ise/plugins/action/active_directory_groups_by_domain_info.py19
-rw-r--r--ansible_collections/cisco/ise/plugins/action/configuration.py (renamed from ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping.py)141
-rw-r--r--ansible_collections/cisco/ise/plugins/action/configuration_info.py90
-rw-r--r--ansible_collections/cisco/ise/plugins/action/connector_config.py (renamed from ansible_collections/cisco/ise/plugins/action/trustsec_vn.py)126
-rw-r--r--ansible_collections/cisco/ise/plugins/action/connector_config_info.py101
-rw-r--r--ansible_collections/cisco/ise/plugins/action/dataconnect_info.py90
-rw-r--r--ansible_collections/cisco/ise/plugins/action/dataconnect_settings_info.py90
-rw-r--r--ansible_collections/cisco/ise/plugins/action/dataconnect_settings_password.py (renamed from ansible_collections/cisco/ise/plugins/action/trustsec_vn_bulk_create.py)8
-rw-r--r--ansible_collections/cisco/ise/plugins/action/dataconnect_settings_password_expiry.py (renamed from ansible_collections/cisco/ise/plugins/action/trustsec_sg_vn_mapping_bulk_update.py)8
-rw-r--r--ansible_collections/cisco/ise/plugins/action/dataconnect_settings_status.py (renamed from ansible_collections/cisco/ise/plugins/action/trustsec_sg_vn_mapping_bulk_delete.py)8
-rw-r--r--ansible_collections/cisco/ise/plugins/action/device_administration_authentication_rules.py4
-rw-r--r--ansible_collections/cisco/ise/plugins/action/device_administration_authorization_rules.py1
-rw-r--r--ansible_collections/cisco/ise/plugins/action/device_administration_conditions.py3
-rw-r--r--ansible_collections/cisco/ise/plugins/action/device_administration_global_exception_rules.py1
-rw-r--r--ansible_collections/cisco/ise/plugins/action/device_administration_local_exception_rules.py1
-rw-r--r--ansible_collections/cisco/ise/plugins/action/device_administration_network_conditions.py18
-rw-r--r--ansible_collections/cisco/ise/plugins/action/device_administration_time_date_conditions.py3
-rw-r--r--ansible_collections/cisco/ise/plugins/action/dictionary_references_info.py90
-rw-r--r--ansible_collections/cisco/ise/plugins/action/endpoint.py16
-rw-r--r--ansible_collections/cisco/ise/plugins/action/filter_policy.py3
-rw-r--r--ansible_collections/cisco/ise/plugins/action/mnt_session_active_count_info.py2
-rw-r--r--ansible_collections/cisco/ise/plugins/action/network_access_authentication_rules.py4
-rw-r--r--ansible_collections/cisco/ise/plugins/action/network_access_authorization_rules.py2
-rw-r--r--ansible_collections/cisco/ise/plugins/action/network_access_conditions.py3
-rw-r--r--ansible_collections/cisco/ise/plugins/action/network_access_global_exception_rules.py1
-rw-r--r--ansible_collections/cisco/ise/plugins/action/network_access_local_exception_rules.py1
-rw-r--r--ansible_collections/cisco/ise/plugins/action/network_access_time_date_conditions.py3
-rw-r--r--ansible_collections/cisco/ise/plugins/action/network_device_group.py6
-rw-r--r--ansible_collections/cisco/ise/plugins/action/node_primary_to_standalone.py2
-rw-r--r--ansible_collections/cisco/ise/plugins/action/node_secondary_to_primary.py2
-rw-r--r--ansible_collections/cisco/ise/plugins/action/node_services_profiler_probe_config.py1
-rw-r--r--ansible_collections/cisco/ise/plugins/action/node_standalone_to_primary.py2
-rw-r--r--ansible_collections/cisco/ise/plugins/action/personas_check_standalone.py2
-rw-r--r--ansible_collections/cisco/ise/plugins/action/personas_export_certs.py2
-rw-r--r--ansible_collections/cisco/ise/plugins/action/personas_promote_primary.py2
-rw-r--r--ansible_collections/cisco/ise/plugins/action/personas_register_node.py2
-rw-r--r--ansible_collections/cisco/ise/plugins/action/personas_update_roles_services.py4
-rw-r--r--ansible_collections/cisco/ise/plugins/action/rest_id_store.py5
-rw-r--r--ansible_collections/cisco/ise/plugins/action/subscriber.py (renamed from ansible_collections/cisco/ise/plugins/action/trustsec_nbar_app.py)76
-rw-r--r--ansible_collections/cisco/ise/plugins/action/subscriber_bulk.py (renamed from ansible_collections/cisco/ise/plugins/action/trustsec_sg_vn_mapping_bulk_create.py)12
-rw-r--r--ansible_collections/cisco/ise/plugins/action/subscriber_imsi_info.py98
-rw-r--r--ansible_collections/cisco/ise/plugins/action/subscriber_info.py (renamed from ansible_collections/cisco/ise/plugins/action/trustsec_sg_vn_mapping_info.py)24
-rw-r--r--ansible_collections/cisco/ise/plugins/action/system_certificate.py16
-rw-r--r--ansible_collections/cisco/ise/plugins/action/test_connector.py98
-rw-r--r--ansible_collections/cisco/ise/plugins/action/trustsec_nbar_app_info.py141
-rw-r--r--ansible_collections/cisco/ise/plugins/action/trustsec_sg_vn_mapping.py267
-rw-r--r--ansible_collections/cisco/ise/plugins/action/trustsec_vn_bulk_delete.py88
-rw-r--r--ansible_collections/cisco/ise/plugins/action/trustsec_vn_bulk_update.py88
-rw-r--r--ansible_collections/cisco/ise/plugins/action/trustsec_vn_info.py141
-rw-r--r--ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping_bulk_create.py88
-rw-r--r--ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping_bulk_delete.py88
-rw-r--r--ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping_bulk_update.py88
-rw-r--r--ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping_info.py141
53 files changed, 887 insertions, 1434 deletions
diff --git a/ansible_collections/cisco/ise/plugins/action/active_directory_groups_by_domain_info.py b/ansible_collections/cisco/ise/plugins/action/active_directory_groups_by_domain_info.py
index c303d3b77..76f1adff1 100644
--- a/ansible_collections/cisco/ise/plugins/action/active_directory_groups_by_domain_info.py
+++ b/ansible_collections/cisco/ise/plugins/action/active_directory_groups_by_domain_info.py
@@ -80,15 +80,12 @@ class ActionModule(ActionBase):
self._result.update(dict(ise_response={}))
ise = ISESDK(params=self._task.args)
+ response = ise.exec(
+ family="active_directory",
+ function='get_groups_by_domain',
+ params=self.get_object(self._task.args)
+ ).response['ERSActiveDirectoryGroups']
- id = self._task.args.get("id")
- name = self._task.args.get("name")
- if not name and not id:
- response = ise.exec(
- family="active_directory",
- function='get_groups_by_domain',
- params=self.get_object(self._task.args)
- ).response['ERSActiveDirectoryGroups']
- self._result.update(dict(ise_response=response))
- self._result.update(ise.exit_json())
- return self._result
+ self._result.update(dict(ise_response=response))
+ self._result.update(ise.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping.py b/ansible_collections/cisco/ise/plugins/action/configuration.py
index b137aa8cc..de3fe1eff 100644
--- a/ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping.py
+++ b/ansible_collections/cisco/ise/plugins/action/configuration.py
@@ -32,97 +32,46 @@ from ansible_collections.cisco.ise.plugins.plugin_utils.exceptions import (
argument_spec = ise_argument_spec()
# Add arguments specific for this module
argument_spec.update(dict(
- state=dict(type="str", default="present", choices=["present", "absent"]),
- id=dict(type="str"),
- isData=dict(type="bool"),
- isDefaultVlan=dict(type="bool"),
- lastUpdate=dict(type="str"),
- maxValue=dict(type="int"),
- name=dict(type="str"),
- vnId=dict(type="str"),
- vnName=dict(type="str"),
+ state=dict(type="str", default="present", choices=["present"]),
+ enableEPO=dict(type="bool"),
+ enableRCM=dict(type="bool"),
))
required_if = [
- ("state", "present", ["id", "name"], True),
- ("state", "absent", ["id", "name"], True),
+ ("state", "present", [], True),
]
required_one_of = []
mutually_exclusive = []
required_together = []
-class TrustsecVnVlanMapping(object):
+class Configuration(object):
def __init__(self, params, ise):
self.ise = ise
self.new_object = dict(
- id=params.get("id"),
- is_data=params.get("isData"),
- is_default_vlan=params.get("isDefaultVlan"),
- last_update=params.get("lastUpdate"),
- max_value=params.get("maxValue"),
- name=params.get("name"),
- vn_id=params.get("vnId"),
- vn_name=params.get("vnName"),
+ enable_epo=params.get("enableEPO"),
+ enable_rcm=params.get("enableRCM"),
)
def get_object_by_name(self, name):
- # NOTICE: Get does not support/work for filter by name with EQ
+ # NOTICE: Does not have a get by name method or it is in another action
result = None
- gen_items_responses = self.ise.exec(
- family="vn_vlan_mapping",
- function="get_vn_vlan_mappings_generator",
- params={"filter": "name.EQ.{name}".format(name=name)}
- )
- try:
- for items_response in gen_items_responses:
- items = items_response.response['response']
- result = get_dict_result(items, 'name', name)
- if result:
- return result
- except (TypeError, AttributeError) as e:
- self.ise.fail_json(
- msg=(
- "An error occured when executing operation."
- " Check the configuration of your API Settings and API Gateway settings on your ISE server."
- " This collection assumes that the API Gateway, the ERS APIs and OpenAPIs are enabled."
- " You may want to enable the (ise_debug: True) argument."
- " The error was: {error}"
- ).format(error=e)
- )
- except Exception:
- result = None
- return result
+ items = self.ise.exec(
+ family="configuration",
+ function="get_configuration"
+ ).response
+ result = get_dict_result(items, 'name', name)
return result
def get_object_by_id(self, id):
- try:
- result = self.ise.exec(
- family="vn_vlan_mapping",
- function="get_vn_vlan_mapping_by_id",
- handle_func_exception=False,
- params={"id": id}
- ).response['response']
- except (TypeError, AttributeError) as e:
- self.ise.fail_json(
- msg=(
- "An error occured when executing operation."
- " Check the configuration of your API Settings and API Gateway settings on your ISE server."
- " This collection assumes that the API Gateway, the ERS APIs and OpenAPIs are enabled."
- " You may want to enable the (ise_debug: True) argument."
- " The error was: {error}"
- ).format(error=e)
- )
- except Exception:
- result = None
- if isinstance(result, list) and len(result) > 0:
- return result[0]
+ # NOTICE: Does not have a get by id method or it is in another action
+ result = None
return result
def exists(self):
+ prev_obj = None
id_exists = False
name_exists = False
- prev_obj = None
o_id = self.new_object.get("id")
name = self.new_object.get("name")
if o_id:
@@ -135,8 +84,6 @@ class TrustsecVnVlanMapping(object):
_id = prev_obj.get("id")
if id_exists and name_exists and o_id != _id:
raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object")
- if _id:
- prev_obj = self.get_object_by_id(_id)
it_exists = prev_obj is not None and isinstance(prev_obj, dict)
return (it_exists, prev_obj)
@@ -144,14 +91,8 @@ class TrustsecVnVlanMapping(object):
requested_obj = self.new_object
obj_params = [
- ("id", "id"),
- ("isData", "is_data"),
- ("isDefaultVlan", "is_default_vlan"),
- ("lastUpdate", "last_update"),
- ("maxValue", "max_value"),
- ("name", "name"),
- ("vnId", "vn_id"),
- ("vnName", "vn_name"),
+ ("enableEPO", "enable_epo"),
+ ("enableRCM", "enable_rcm"),
]
# Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params
# If any does not have eq params, it requires update
@@ -159,38 +100,13 @@ class TrustsecVnVlanMapping(object):
requested_obj.get(ansible_param))
for (ise_param, ansible_param) in obj_params)
- def create(self):
- result = self.ise.exec(
- family="vn_vlan_mapping",
- function="create_vn_vlan_mapping",
- params=self.new_object,
- ).response
- return result
-
def update(self):
id = self.new_object.get("id")
name = self.new_object.get("name")
result = None
- if not id:
- id_ = self.get_object_by_name(name).get("id")
- self.new_object.update(dict(id=id_))
- result = self.ise.exec(
- family="vn_vlan_mapping",
- function="update_vn_vlan_mapping_by_id",
- params=self.new_object
- ).response
- return result
-
- def delete(self):
- id = self.new_object.get("id")
- name = self.new_object.get("name")
- result = None
- if not id:
- id_ = self.get_object_by_name(name).get("id")
- self.new_object.update(dict(id=id_))
result = self.ise.exec(
- family="vn_vlan_mapping",
- function="delete_vn_vlan_mapping_by_id",
+ family="configuration",
+ function="update_configuration",
params=self.new_object
).response
return result
@@ -230,12 +146,11 @@ class ActionModule(ActionBase):
self._check_argspec()
ise = ISESDK(params=self._task.args)
- obj = TrustsecVnVlanMapping(self._task.args, ise)
+ obj = Configuration(self._task.args, ise)
state = self._task.args.get("state")
response = None
-
if state == "present":
(obj_exists, prev_obj) = obj.exists()
if obj_exists:
@@ -249,19 +164,7 @@ class ActionModule(ActionBase):
response = prev_obj
ise.object_already_present()
else:
- ise_create_response = obj.create()
- (obj_exists, created_obj) = obj.exists()
- response = created_obj
- ise.object_created()
-
- elif state == "absent":
- (obj_exists, prev_obj) = obj.exists()
- if obj_exists:
- obj.delete()
- response = prev_obj
- ise.object_deleted()
- else:
- ise.object_already_absent()
+ ise.fail_json("Object does not exists, plugin only has update")
self._result.update(dict(ise_response=response))
self._result.update(ise.exit_json())
diff --git a/ansible_collections/cisco/ise/plugins/action/configuration_info.py b/ansible_collections/cisco/ise/plugins/action/configuration_info.py
new file mode 100644
index 000000000..d3ed0d5fe
--- /dev/null
+++ b/ansible_collections/cisco/ise/plugins/action/configuration_info.py
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2021, Cisco Systems
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+
+__metaclass__ = type
+from ansible.plugins.action import ActionBase
+
+try:
+ from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
+ AnsibleArgSpecValidator,
+ )
+except ImportError:
+ ANSIBLE_UTILS_IS_INSTALLED = False
+else:
+ ANSIBLE_UTILS_IS_INSTALLED = True
+from ansible.errors import AnsibleActionFail
+from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
+ ISESDK,
+ ise_argument_spec,
+)
+
+# Get common arguements specification
+argument_spec = ise_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __init__(self, *args, **kwargs):
+ if not ANSIBLE_UTILS_IS_INSTALLED:
+ raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
+ super(ActionModule, self).__init__(*args, **kwargs)
+ self._supports_async = False
+ self._supports_check_mode = True
+ self._result = None
+
+ # Checks the supplied parameters against the argument spec for this module
+ def _check_argspec(self):
+ aav = AnsibleArgSpecValidator(
+ data=self._task.args,
+ schema=dict(argument_spec=argument_spec),
+ schema_format="argspec",
+ schema_conditionals=dict(
+ required_if=required_if,
+ required_one_of=required_one_of,
+ mutually_exclusive=mutually_exclusive,
+ required_together=required_together,
+ ),
+ name=self._task.action,
+ )
+ valid, errors, self._task.args = aav.validate()
+ if not valid:
+ raise AnsibleActionFail(errors)
+
+ def get_object(self, params):
+ new_object = dict(
+ )
+ return new_object
+
+ def run(self, tmp=None, task_vars=None):
+ self._task.diff = False
+ self._result = super(ActionModule, self).run(tmp, task_vars)
+ self._result["changed"] = False
+ self._check_argspec()
+
+ self._result.update(dict(ise_response={}))
+
+ ise = ISESDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ name = self._task.args.get("name")
+ if not name and not id:
+ response = ise.exec(
+ family="configuration",
+ function='get_configuration',
+ params=self.get_object(self._task.args)
+ ).response
+ self._result.update(dict(ise_response=response))
+ self._result.update(ise.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/ise/plugins/action/trustsec_vn.py b/ansible_collections/cisco/ise/plugins/action/connector_config.py
index ff1dd8fd7..8e124b7ed 100644
--- a/ansible_collections/cisco/ise/plugins/action/trustsec_vn.py
+++ b/ansible_collections/cisco/ise/plugins/action/connector_config.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (c) 2021, Cisco Systems
+# Copyright (c) 2023, Cisco Systems
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -33,68 +33,54 @@ argument_spec = ise_argument_spec()
# Add arguments specific for this module
argument_spec.update(dict(
state=dict(type="str", default="present", choices=["present", "absent"]),
- additionalAttributes=dict(type="str"),
- id=dict(type="str"),
- lastUpdate=dict(type="str"),
- name=dict(type="str"),
+ additionalProperties=dict(type="dict"),
+ attributes=dict(type="dict"),
+ connectorName=dict(type="str"),
+ connectorType=dict(type="str"),
+ deltasyncSchedule=dict(type="dict"),
+ description=dict(type="str"),
+ enabled=dict(type="bool"),
+ fullsyncSchedule=dict(type="dict"),
+ protocol=dict(type="str"),
+ skipCertificateValidations=dict(type="bool"),
+ url=dict(type="dict"),
))
required_if = [
- ("state", "present", ["id", "name"], True),
- ("state", "absent", ["id", "name"], True),
+ ("state", "present", ["connectorName"], True),
+ ("state", "absent", ["connectorName"], True),
]
required_one_of = []
mutually_exclusive = []
required_together = []
-class TrustsecVn(object):
+class ConnectorConfig(object):
def __init__(self, params, ise):
self.ise = ise
self.new_object = dict(
- additional_attributes=params.get("additionalAttributes"),
- id=params.get("id"),
- last_update=params.get("lastUpdate"),
- name=params.get("name"),
+ additional_properties=params.get("additionalProperties"),
+ attributes=params.get("attributes"),
+ connector_name=params.get("connectorName"),
+ connector_type=params.get("connectorType"),
+ deltasync_schedule=params.get("deltasyncSchedule"),
+ description=params.get("description"),
+ enabled=params.get("enabled"),
+ fullsync_schedule=params.get("fullsyncSchedule"),
+ protocol=params.get("protocol"),
+ skip_certificate_validations=params.get("skipCertificateValidations"),
+ url=params.get("url"),
)
def get_object_by_name(self, name):
- # NOTICE: Get does not support/work for filter by name with EQ
- result = None
- gen_items_responses = self.ise.exec(
- family="virtual_network",
- function="get_virtual_networks_generator",
- params={"filter": "name.EQ.{name}".format(name=name)}
- )
- try:
- for items_response in gen_items_responses:
- items = items_response.response['response']
- result = get_dict_result(items, 'name', name)
- if result:
- return result
- except (TypeError, AttributeError) as e:
- self.ise.fail_json(
- msg=(
- "An error occured when executing operation."
- " Check the configuration of your API Settings and API Gateway settings on your ISE server."
- " This collection assumes that the API Gateway, the ERS APIs and OpenAPIs are enabled."
- " You may want to enable the (ise_debug: True) argument."
- " The error was: {error}"
- ).format(error=e)
- )
- except Exception:
- result = None
- return result
- return result
-
- def get_object_by_id(self, id):
try:
result = self.ise.exec(
- family="virtual_network",
- function="get_virtual_network_by_id",
+ family="edda",
+ function="get_connector_config_by_connector_name",
+ params={"connector_name": name},
handle_func_exception=False,
- params={"id": id}
).response['response']
+ result = get_dict_result(result, 'connectorName', name)
except (TypeError, AttributeError) as e:
self.ise.fail_json(
msg=(
@@ -107,8 +93,11 @@ class TrustsecVn(object):
)
except Exception:
result = None
- if isinstance(result, list) and len(result) > 0:
- return result[0]
+ return result
+
+ def get_object_by_id(self, id):
+ # NOTICE: Does not have a get by id method or it is in another action
+ result = None
return result
def exists(self):
@@ -116,7 +105,7 @@ class TrustsecVn(object):
name_exists = False
prev_obj = None
o_id = self.new_object.get("id")
- name = self.new_object.get("name")
+ name = self.new_object.get("connectorName")
if o_id:
prev_obj = self.get_object_by_id(o_id)
id_exists = prev_obj is not None and isinstance(prev_obj, dict)
@@ -127,8 +116,6 @@ class TrustsecVn(object):
_id = prev_obj.get("id")
if id_exists and name_exists and o_id != _id:
raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object")
- if _id:
- prev_obj = self.get_object_by_id(_id)
it_exists = prev_obj is not None and isinstance(prev_obj, dict)
return (it_exists, prev_obj)
@@ -136,10 +123,17 @@ class TrustsecVn(object):
requested_obj = self.new_object
obj_params = [
- ("additionalAttributes", "additional_attributes"),
- ("id", "id"),
- ("lastUpdate", "last_update"),
- ("name", "name"),
+ ("additionalProperties", "additional_properties"),
+ ("attributes", "attributes"),
+ ("connectorName", "connector_name"),
+ ("connectorType", "connector_type"),
+ ("deltasyncSchedule", "deltasync_schedule"),
+ ("description", "description"),
+ ("enabled", "enabled"),
+ ("fullsyncSchedule", "fullsync_schedule"),
+ ("protocol", "protocol"),
+ ("skipCertificateValidations", "skip_certificate_validations"),
+ ("url", "url"),
]
# Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params
# If any does not have eq params, it requires update
@@ -149,8 +143,8 @@ class TrustsecVn(object):
def create(self):
result = self.ise.exec(
- family="virtual_network",
- function="create_virtual_network",
+ family="edda",
+ function="create_connector_config",
params=self.new_object,
).response
return result
@@ -159,12 +153,12 @@ class TrustsecVn(object):
id = self.new_object.get("id")
name = self.new_object.get("name")
result = None
- if not id:
- id_ = self.get_object_by_name(name).get("id")
- self.new_object.update(dict(id=id_))
+ if not name:
+ name_ = self.get_object_by_id(id).get("name")
+ self.new_object.update(dict(name=name_))
result = self.ise.exec(
- family="virtual_network",
- function="update_virtual_network_by_id",
+ family="edda",
+ function="update_connector_config_by_connector_name",
params=self.new_object
).response
return result
@@ -173,12 +167,12 @@ class TrustsecVn(object):
id = self.new_object.get("id")
name = self.new_object.get("name")
result = None
- if not id:
- id_ = self.get_object_by_name(name).get("id")
- self.new_object.update(dict(id=id_))
+ if not name:
+ name_ = self.get_object_by_id(id).get("name")
+ self.new_object.update(dict(name=name_))
result = self.ise.exec(
- family="virtual_network",
- function="delete_virtual_network_by_id",
+ family="edda",
+ function="delete_connector_config_by_connector_name",
params=self.new_object
).response
return result
@@ -218,7 +212,7 @@ class ActionModule(ActionBase):
self._check_argspec()
ise = ISESDK(params=self._task.args)
- obj = TrustsecVn(self._task.args, ise)
+ obj = ConnectorConfig(self._task.args, ise)
state = self._task.args.get("state")
diff --git a/ansible_collections/cisco/ise/plugins/action/connector_config_info.py b/ansible_collections/cisco/ise/plugins/action/connector_config_info.py
new file mode 100644
index 000000000..05bd40cbe
--- /dev/null
+++ b/ansible_collections/cisco/ise/plugins/action/connector_config_info.py
@@ -0,0 +1,101 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2023, Cisco Systems
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+
+__metaclass__ = type
+from ansible.plugins.action import ActionBase
+
+try:
+ from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
+ AnsibleArgSpecValidator,
+ )
+except ImportError:
+ ANSIBLE_UTILS_IS_INSTALLED = False
+else:
+ ANSIBLE_UTILS_IS_INSTALLED = True
+from ansible.errors import AnsibleActionFail
+from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
+ ISESDK,
+ ise_argument_spec,
+)
+
+# Get common arguements specification
+argument_spec = ise_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ connectorName=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __init__(self, *args, **kwargs):
+ if not ANSIBLE_UTILS_IS_INSTALLED:
+ raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
+ super(ActionModule, self).__init__(*args, **kwargs)
+ self._supports_async = False
+ self._supports_check_mode = True
+ self._result = None
+
+ # Checks the supplied parameters against the argument spec for this module
+ def _check_argspec(self):
+ aav = AnsibleArgSpecValidator(
+ data=self._task.args,
+ schema=dict(argument_spec=argument_spec),
+ schema_format="argspec",
+ schema_conditionals=dict(
+ required_if=required_if,
+ required_one_of=required_one_of,
+ mutually_exclusive=mutually_exclusive,
+ required_together=required_together,
+ ),
+ name=self._task.action,
+ )
+ valid, errors, self._task.args = aav.validate()
+ if not valid:
+ raise AnsibleActionFail(errors)
+
+ def get_object(self, params):
+ new_object = dict(
+ connector_name=params.get("connectorName"),
+ )
+ return new_object
+
+ def run(self, tmp=None, task_vars=None):
+ self._task.diff = False
+ self._result = super(ActionModule, self).run(tmp, task_vars)
+ self._result["changed"] = False
+ self._check_argspec()
+
+ self._result.update(dict(ise_response={}))
+
+ ise = ISESDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ name = self._task.args.get("connectorName")
+ if name:
+ response = ise.exec(
+ family="edda",
+ function='get_connector_config_by_connector_name',
+ params=self.get_object(self._task.args)
+ ).response['response']
+ self._result.update(dict(ise_response=response))
+ self._result.update(ise.exit_json())
+ return self._result
+ if not name and not id:
+ response = ise.exec(
+ family="edda",
+ function='get_connector_config',
+ params=self.get_object(self._task.args)
+ ).response['response']
+ self._result.update(dict(ise_response=response))
+ self._result.update(ise.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/ise/plugins/action/dataconnect_info.py b/ansible_collections/cisco/ise/plugins/action/dataconnect_info.py
new file mode 100644
index 000000000..ffd19d387
--- /dev/null
+++ b/ansible_collections/cisco/ise/plugins/action/dataconnect_info.py
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2021, Cisco Systems
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+
+__metaclass__ = type
+from ansible.plugins.action import ActionBase
+
+try:
+ from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
+ AnsibleArgSpecValidator,
+ )
+except ImportError:
+ ANSIBLE_UTILS_IS_INSTALLED = False
+else:
+ ANSIBLE_UTILS_IS_INSTALLED = True
+from ansible.errors import AnsibleActionFail
+from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
+ ISESDK,
+ ise_argument_spec,
+)
+
+# Get common arguements specification
+argument_spec = ise_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __init__(self, *args, **kwargs):
+ if not ANSIBLE_UTILS_IS_INSTALLED:
+ raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
+ super(ActionModule, self).__init__(*args, **kwargs)
+ self._supports_async = False
+ self._supports_check_mode = True
+ self._result = None
+
+ # Checks the supplied parameters against the argument spec for this module
+ def _check_argspec(self):
+ aav = AnsibleArgSpecValidator(
+ data=self._task.args,
+ schema=dict(argument_spec=argument_spec),
+ schema_format="argspec",
+ schema_conditionals=dict(
+ required_if=required_if,
+ required_one_of=required_one_of,
+ mutually_exclusive=mutually_exclusive,
+ required_together=required_together,
+ ),
+ name=self._task.action,
+ )
+ valid, errors, self._task.args = aav.validate()
+ if not valid:
+ raise AnsibleActionFail(errors)
+
+ def get_object(self, params):
+ new_object = dict(
+ )
+ return new_object
+
+ def run(self, tmp=None, task_vars=None):
+ self._task.diff = False
+ self._result = super(ActionModule, self).run(tmp, task_vars)
+ self._result["changed"] = False
+ self._check_argspec()
+
+ self._result.update(dict(ise_response={}))
+
+ ise = ISESDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ name = self._task.args.get("name")
+ if not name and not id:
+ response = ise.exec(
+ family="dataconnect_services",
+ function='get_odbc_detail',
+ params=self.get_object(self._task.args)
+ ).response['response']
+ self._result.update(dict(ise_response=response))
+ self._result.update(ise.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/ise/plugins/action/dataconnect_settings_info.py b/ansible_collections/cisco/ise/plugins/action/dataconnect_settings_info.py
new file mode 100644
index 000000000..5d794c926
--- /dev/null
+++ b/ansible_collections/cisco/ise/plugins/action/dataconnect_settings_info.py
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2021, Cisco Systems
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+
+__metaclass__ = type
+from ansible.plugins.action import ActionBase
+
+try:
+ from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
+ AnsibleArgSpecValidator,
+ )
+except ImportError:
+ ANSIBLE_UTILS_IS_INSTALLED = False
+else:
+ ANSIBLE_UTILS_IS_INSTALLED = True
+from ansible.errors import AnsibleActionFail
+from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
+ ISESDK,
+ ise_argument_spec,
+)
+
+# Get common arguements specification
+argument_spec = ise_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __init__(self, *args, **kwargs):
+ if not ANSIBLE_UTILS_IS_INSTALLED:
+ raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
+ super(ActionModule, self).__init__(*args, **kwargs)
+ self._supports_async = False
+ self._supports_check_mode = True
+ self._result = None
+
+ # Checks the supplied parameters against the argument spec for this module
+ def _check_argspec(self):
+ aav = AnsibleArgSpecValidator(
+ data=self._task.args,
+ schema=dict(argument_spec=argument_spec),
+ schema_format="argspec",
+ schema_conditionals=dict(
+ required_if=required_if,
+ required_one_of=required_one_of,
+ mutually_exclusive=mutually_exclusive,
+ required_together=required_together,
+ ),
+ name=self._task.action,
+ )
+ valid, errors, self._task.args = aav.validate()
+ if not valid:
+ raise AnsibleActionFail(errors)
+
+ def get_object(self, params):
+ new_object = dict(
+ )
+ return new_object
+
+ def run(self, tmp=None, task_vars=None):
+ self._task.diff = False
+ self._result = super(ActionModule, self).run(tmp, task_vars)
+ self._result["changed"] = False
+ self._check_argspec()
+
+ self._result.update(dict(ise_response={}))
+
+ ise = ISESDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ name = self._task.args.get("name")
+ if not name and not id:
+ response = ise.exec(
+ family="dataconnect_services",
+ function='get_dataconnect_service',
+ params=self.get_object(self._task.args)
+ ).response['response']
+ self._result.update(dict(ise_response=response))
+ self._result.update(ise.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/ise/plugins/action/trustsec_vn_bulk_create.py b/ansible_collections/cisco/ise/plugins/action/dataconnect_settings_password.py
index 95943d628..0fd96ad3e 100644
--- a/ansible_collections/cisco/ise/plugins/action/trustsec_vn_bulk_create.py
+++ b/ansible_collections/cisco/ise/plugins/action/dataconnect_settings_password.py
@@ -27,7 +27,7 @@ from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
argument_spec = ise_argument_spec()
# Add arguments specific for this module
argument_spec.update(dict(
- payload=dict(type="list"),
+ password=dict(type="str", no_log=True),
))
required_if = []
@@ -65,7 +65,7 @@ class ActionModule(ActionBase):
def get_object(self, params):
new_object = dict(
- payload=params.get("payload"),
+ password=params.get("password"),
)
return new_object
@@ -78,8 +78,8 @@ class ActionModule(ActionBase):
ise = ISESDK(params=self._task.args)
response = ise.exec(
- family="virtual_network",
- function="bulk_create_virtual_networks",
+ family="dataconnect_services",
+ function="update_dataconnect_password",
params=self.get_object(self._task.args),
).response
diff --git a/ansible_collections/cisco/ise/plugins/action/trustsec_sg_vn_mapping_bulk_update.py b/ansible_collections/cisco/ise/plugins/action/dataconnect_settings_password_expiry.py
index f84f91108..f9db60ec8 100644
--- a/ansible_collections/cisco/ise/plugins/action/trustsec_sg_vn_mapping_bulk_update.py
+++ b/ansible_collections/cisco/ise/plugins/action/dataconnect_settings_password_expiry.py
@@ -27,7 +27,7 @@ from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
argument_spec = ise_argument_spec()
# Add arguments specific for this module
argument_spec.update(dict(
- payload=dict(type="list"),
+ passwordExpiresInDays=dict(type="int"),
))
required_if = []
@@ -65,7 +65,7 @@ class ActionModule(ActionBase):
def get_object(self, params):
new_object = dict(
- payload=params.get("payload"),
+ password_expires_in_days=params.get("passwordExpiresInDays"),
)
return new_object
@@ -78,8 +78,8 @@ class ActionModule(ActionBase):
ise = ISESDK(params=self._task.args)
response = ise.exec(
- family="sg_vn_mapping",
- function="bulk_update_sg_vn_mappings",
+ family="dataconnect_services",
+ function="update_dataconnect_password_expiry",
params=self.get_object(self._task.args),
).response
diff --git a/ansible_collections/cisco/ise/plugins/action/trustsec_sg_vn_mapping_bulk_delete.py b/ansible_collections/cisco/ise/plugins/action/dataconnect_settings_status.py
index ab7effb63..e7232ab0e 100644
--- a/ansible_collections/cisco/ise/plugins/action/trustsec_sg_vn_mapping_bulk_delete.py
+++ b/ansible_collections/cisco/ise/plugins/action/dataconnect_settings_status.py
@@ -27,7 +27,7 @@ from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
argument_spec = ise_argument_spec()
# Add arguments specific for this module
argument_spec.update(dict(
- payload=dict(type="list"),
+ isEnabled=dict(type="bool"),
))
required_if = []
@@ -65,7 +65,7 @@ class ActionModule(ActionBase):
def get_object(self, params):
new_object = dict(
- payload=params.get("payload"),
+ is_enabled=params.get("isEnabled"),
)
return new_object
@@ -78,8 +78,8 @@ class ActionModule(ActionBase):
ise = ISESDK(params=self._task.args)
response = ise.exec(
- family="sg_vn_mapping",
- function="bulk_delete_sg_vn_mappings",
+ family="dataconnect_services",
+ function="set_data_connect_service",
params=self.get_object(self._task.args),
).response
diff --git a/ansible_collections/cisco/ise/plugins/action/device_administration_authentication_rules.py b/ansible_collections/cisco/ise/plugins/action/device_administration_authentication_rules.py
index 8ef7ec09e..58e3d55d6 100644
--- a/ansible_collections/cisco/ise/plugins/action/device_administration_authentication_rules.py
+++ b/ansible_collections/cisco/ise/plugins/action/device_administration_authentication_rules.py
@@ -22,7 +22,6 @@ from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
ISESDK,
ise_argument_spec,
ise_compare_equality,
- get_dict_result,
)
from ansible_collections.cisco.ise.plugins.plugin_utils.exceptions import (
InconsistentParameters,
@@ -33,6 +32,7 @@ argument_spec = ise_argument_spec()
# Add arguments specific for this module
argument_spec.update(dict(
state=dict(type="str", default="present", choices=["present", "absent"]),
+ identitySourceId=dict(type="str"),
identitySourceName=dict(type="str"),
ifAuthFail=dict(type="str"),
ifProcessFail=dict(type="str"),
@@ -58,6 +58,7 @@ class DeviceAdministrationAuthenticationRules(object):
def __init__(self, params, ise):
self.ise = ise
self.new_object = dict(
+ identity_source_id=params.get("identitySourceId"),
identity_source_name=params.get("identitySourceName"),
if_auth_fail=params.get("ifAuthFail"),
if_process_fail=params.get("ifProcessFail"),
@@ -133,6 +134,7 @@ class DeviceAdministrationAuthenticationRules(object):
requested_obj = self.new_object
obj_params = [
+ ("identitySourceId", "identity_source_id"),
("identitySourceName", "identity_source_name"),
("ifAuthFail", "if_auth_fail"),
("ifProcessFail", "if_process_fail"),
diff --git a/ansible_collections/cisco/ise/plugins/action/device_administration_authorization_rules.py b/ansible_collections/cisco/ise/plugins/action/device_administration_authorization_rules.py
index c1a42a95c..2645800ce 100644
--- a/ansible_collections/cisco/ise/plugins/action/device_administration_authorization_rules.py
+++ b/ansible_collections/cisco/ise/plugins/action/device_administration_authorization_rules.py
@@ -22,7 +22,6 @@ from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
ISESDK,
ise_argument_spec,
ise_compare_equality,
- get_dict_result,
)
from ansible_collections.cisco.ise.plugins.plugin_utils.exceptions import (
InconsistentParameters,
diff --git a/ansible_collections/cisco/ise/plugins/action/device_administration_conditions.py b/ansible_collections/cisco/ise/plugins/action/device_administration_conditions.py
index 97df92d65..3f32c7c94 100644
--- a/ansible_collections/cisco/ise/plugins/action/device_administration_conditions.py
+++ b/ansible_collections/cisco/ise/plugins/action/device_administration_conditions.py
@@ -37,6 +37,7 @@ argument_spec.update(dict(
id=dict(type="str"),
name=dict(type="str"),
attributeName=dict(type="str"),
+ attributeId=dict(type="str"),
attributeValue=dict(type="str"),
dictionaryName=dict(type="str"),
dictionaryValue=dict(type="str"),
@@ -70,6 +71,7 @@ class DeviceAdministrationConditions(object):
id=params.get("id"),
name=params.get("name"),
attribute_name=params.get("attributeName"),
+ attribute_id=params.get("attributeId"),
attribute_value=params.get("attributeValue"),
dictionary_name=params.get("dictionaryName"),
dictionary_value=params.get("dictionaryValue"),
@@ -152,6 +154,7 @@ class DeviceAdministrationConditions(object):
("id", "id"),
("name", "name"),
("attributeName", "attribute_name"),
+ ("attributeId", "attribute_id"),
("attributeValue", "attribute_value"),
("dictionaryName", "dictionary_name"),
("dictionaryValue", "dictionary_value"),
diff --git a/ansible_collections/cisco/ise/plugins/action/device_administration_global_exception_rules.py b/ansible_collections/cisco/ise/plugins/action/device_administration_global_exception_rules.py
index 895c4c6e2..38718ced2 100644
--- a/ansible_collections/cisco/ise/plugins/action/device_administration_global_exception_rules.py
+++ b/ansible_collections/cisco/ise/plugins/action/device_administration_global_exception_rules.py
@@ -22,7 +22,6 @@ from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
ISESDK,
ise_argument_spec,
ise_compare_equality,
- get_dict_result,
)
from ansible_collections.cisco.ise.plugins.plugin_utils.exceptions import (
InconsistentParameters,
diff --git a/ansible_collections/cisco/ise/plugins/action/device_administration_local_exception_rules.py b/ansible_collections/cisco/ise/plugins/action/device_administration_local_exception_rules.py
index 570495d89..27f5b3401 100644
--- a/ansible_collections/cisco/ise/plugins/action/device_administration_local_exception_rules.py
+++ b/ansible_collections/cisco/ise/plugins/action/device_administration_local_exception_rules.py
@@ -22,7 +22,6 @@ from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
ISESDK,
ise_argument_spec,
ise_compare_equality,
- get_dict_result,
)
from ansible_collections.cisco.ise.plugins.plugin_utils.exceptions import (
InconsistentParameters,
diff --git a/ansible_collections/cisco/ise/plugins/action/device_administration_network_conditions.py b/ansible_collections/cisco/ise/plugins/action/device_administration_network_conditions.py
index 502b5b6c3..10bcdc558 100644
--- a/ansible_collections/cisco/ise/plugins/action/device_administration_network_conditions.py
+++ b/ansible_collections/cisco/ise/plugins/action/device_administration_network_conditions.py
@@ -38,7 +38,11 @@ argument_spec.update(dict(
id=dict(type="str"),
link=dict(type="dict"),
name=dict(type="str"),
- conditions=dict(type="list"),
+ deviceList=dict(type="list"),
+ cliDnisList=dict(type="list"),
+ ipAddrList=dict(type="list"),
+ macAddrList=dict(type="list"),
+ deviceGroupList=dict(type="list"),
))
required_if = [
@@ -59,7 +63,11 @@ class DeviceAdministrationNetworkConditions(object):
id=params.get("id"),
link=params.get("link"),
name=params.get("name"),
- conditions=params.get("conditions"),
+ device_list=params.get("deviceList"),
+ cli_dnis_list=params.get("cliDnisList"),
+ ip_addr_list=params.get("ipAddrList"),
+ mac_addr_list=params.get("macAddrList"),
+ device_group_list=params.get("deviceGroupList"),
)
def get_object_by_name(self, name):
@@ -124,7 +132,11 @@ class DeviceAdministrationNetworkConditions(object):
("id", "id"),
("link", "link"),
("name", "name"),
- ("conditions", "conditions"),
+ ("deviceList", "device_list"),
+ ("cliDnisList", "cli_dnis_list"),
+ ("ipAddrList", "ip_addr_list"),
+ ("macAddrList", "mac_addr_list"),
+ ("deviceGroupList", "device_group_list"),
]
# Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params
# If any does not have eq params, it requires update
diff --git a/ansible_collections/cisco/ise/plugins/action/device_administration_time_date_conditions.py b/ansible_collections/cisco/ise/plugins/action/device_administration_time_date_conditions.py
index 35431f36e..e0ffd4d73 100644
--- a/ansible_collections/cisco/ise/plugins/action/device_administration_time_date_conditions.py
+++ b/ansible_collections/cisco/ise/plugins/action/device_administration_time_date_conditions.py
@@ -40,6 +40,7 @@ argument_spec.update(dict(
id=dict(type="str"),
name=dict(type="str"),
attributeName=dict(type="str"),
+ attributeId=dict(type="str"),
attributeValue=dict(type="str"),
dictionaryName=dict(type="str"),
dictionaryValue=dict(type="str"),
@@ -73,6 +74,7 @@ class DeviceAdministrationTimeDateConditions(object):
id=params.get("id"),
name=params.get("name"),
attribute_name=params.get("attributeName"),
+ attribute_id=params.get("attributeId"),
attribute_value=params.get("attributeValue"),
dictionary_name=params.get("dictionaryName"),
dictionary_value=params.get("dictionaryValue"),
@@ -150,6 +152,7 @@ class DeviceAdministrationTimeDateConditions(object):
("id", "id"),
("name", "name"),
("attributeName", "attribute_name"),
+ ("attributeId", "attribute_id"),
("attributeValue", "attribute_value"),
("dictionaryName", "dictionary_name"),
("dictionaryValue", "dictionary_value"),
diff --git a/ansible_collections/cisco/ise/plugins/action/dictionary_references_info.py b/ansible_collections/cisco/ise/plugins/action/dictionary_references_info.py
new file mode 100644
index 000000000..4b4d92cbe
--- /dev/null
+++ b/ansible_collections/cisco/ise/plugins/action/dictionary_references_info.py
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2023, Cisco Systems
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+
+__metaclass__ = type
+from ansible.plugins.action import ActionBase
+
+try:
+ from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
+ AnsibleArgSpecValidator,
+ )
+except ImportError:
+ ANSIBLE_UTILS_IS_INSTALLED = False
+else:
+ ANSIBLE_UTILS_IS_INSTALLED = True
+from ansible.errors import AnsibleActionFail
+from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
+ ISESDK,
+ ise_argument_spec,
+)
+
+# Get common arguements specification
+argument_spec = ise_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __init__(self, *args, **kwargs):
+ if not ANSIBLE_UTILS_IS_INSTALLED:
+ raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
+ super(ActionModule, self).__init__(*args, **kwargs)
+ self._supports_async = False
+ self._supports_check_mode = True
+ self._result = None
+
+ # Checks the supplied parameters against the argument spec for this module
+ def _check_argspec(self):
+ aav = AnsibleArgSpecValidator(
+ data=self._task.args,
+ schema=dict(argument_spec=argument_spec),
+ schema_format="argspec",
+ schema_conditionals=dict(
+ required_if=required_if,
+ required_one_of=required_one_of,
+ mutually_exclusive=mutually_exclusive,
+ required_together=required_together,
+ ),
+ name=self._task.action,
+ )
+ valid, errors, self._task.args = aav.validate()
+ if not valid:
+ raise AnsibleActionFail(errors)
+
+ def get_object(self, params):
+ new_object = dict(
+ )
+ return new_object
+
+ def run(self, tmp=None, task_vars=None):
+ self._task.diff = False
+ self._result = super(ActionModule, self).run(tmp, task_vars)
+ self._result["changed"] = False
+ self._check_argspec()
+
+ self._result.update(dict(ise_response={}))
+
+ ise = ISESDK(params=self._task.args)
+
+ id = self._task.args.get("id")
+ name = self._task.args.get("name")
+ if not name and not id:
+ response = ise.exec(
+ family="edda",
+ function='get_edda_dictionary_references',
+ params=self.get_object(self._task.args)
+ ).response['response']
+ self._result.update(dict(ise_response=response))
+ self._result.update(ise.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/ise/plugins/action/endpoint.py b/ansible_collections/cisco/ise/plugins/action/endpoint.py
index b8526e704..5de00e6d8 100644
--- a/ansible_collections/cisco/ise/plugins/action/endpoint.py
+++ b/ansible_collections/cisco/ise/plugins/action/endpoint.py
@@ -31,6 +31,7 @@ argument_spec = ise_argument_spec()
# Add arguments specific for this module
argument_spec.update(dict(
state=dict(type="str", default="present", choices=["present", "absent"]),
+ name=dict(type="str"),
description=dict(type="str"),
mac=dict(type="str"),
profileId=dict(type="str"),
@@ -46,8 +47,8 @@ argument_spec.update(dict(
))
required_if = [
- ("state", "present", ["id", "mac"], True),
- ("state", "absent", ["id", "mac"], True),
+ ("state", "present", ["id", "name"], True),
+ ("state", "absent", ["id", "name"], True),
]
required_one_of = []
mutually_exclusive = []
@@ -58,6 +59,7 @@ class Endpoint(object):
def __init__(self, params, ise):
self.ise = ise
self.new_object = dict(
+ name=params.get("name"),
description=params.get("description"),
mac=params.get("mac"),
profile_id=params.get("profileId"),
@@ -123,10 +125,7 @@ class Endpoint(object):
result = False
prev_obj = None
id = self.new_object.get("id")
- name = self.new_object.get("mac")
- if name:
- name = re.sub("[-:.]", "", name).lower()
- self.new_object.update(dict(mac=name))
+ name = self.new_object.get("name")
if id:
prev_obj = self.get_object_by_id(id)
result = prev_obj is not None and isinstance(prev_obj, dict)
@@ -139,6 +138,7 @@ class Endpoint(object):
requested_obj = self.new_object
obj_params = [
+ ("name", "name"),
("description", "description"),
("mac", "mac"),
("profileId", "profile_id"),
@@ -168,7 +168,7 @@ class Endpoint(object):
def update(self):
id = self.new_object.get("id")
- name = self.new_object.get("mac")
+ name = self.new_object.get("name")
result = None
if not id:
id_ = self.get_object_by_name(name).get("id")
@@ -182,7 +182,7 @@ class Endpoint(object):
def delete(self):
id = self.new_object.get("id")
- name = self.new_object.get("mac")
+ name = self.new_object.get("name")
result = None
if not id:
id_ = self.get_object_by_name(name).get("id")
diff --git a/ansible_collections/cisco/ise/plugins/action/filter_policy.py b/ansible_collections/cisco/ise/plugins/action/filter_policy.py
index 3f4732053..d2a3ca73e 100644
--- a/ansible_collections/cisco/ise/plugins/action/filter_policy.py
+++ b/ansible_collections/cisco/ise/plugins/action/filter_policy.py
@@ -31,9 +31,6 @@ from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
ise_compare_equality,
get_dict_result,
)
-from ansible_collections.cisco.ise.plugins.plugin_utils.exceptions import (
- InconsistentParameters,
-)
# Get common arguments specification
argument_spec = ise_argument_spec()
diff --git a/ansible_collections/cisco/ise/plugins/action/mnt_session_active_count_info.py b/ansible_collections/cisco/ise/plugins/action/mnt_session_active_count_info.py
index c4c748317..643df1b6d 100644
--- a/ansible_collections/cisco/ise/plugins/action/mnt_session_active_count_info.py
+++ b/ansible_collections/cisco/ise/plugins/action/mnt_session_active_count_info.py
@@ -84,7 +84,7 @@ class ActionModule(ActionBase):
family="misc",
function='get_active_count',
params=self.get_object(self._task.args)
- ).response['count']
+ ).response['sessionCount']['count']
self._result.update(dict(ise_response=response))
self._result.update(ise.exit_json())
return self._result
diff --git a/ansible_collections/cisco/ise/plugins/action/network_access_authentication_rules.py b/ansible_collections/cisco/ise/plugins/action/network_access_authentication_rules.py
index 63e8d4bce..b8663b844 100644
--- a/ansible_collections/cisco/ise/plugins/action/network_access_authentication_rules.py
+++ b/ansible_collections/cisco/ise/plugins/action/network_access_authentication_rules.py
@@ -22,7 +22,6 @@ from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
ISESDK,
ise_argument_spec,
ise_compare_equality,
- get_dict_result,
)
from ansible_collections.cisco.ise.plugins.plugin_utils.exceptions import (
InconsistentParameters,
@@ -33,6 +32,7 @@ argument_spec = ise_argument_spec()
# Add arguments specific for this module
argument_spec.update(dict(
state=dict(type="str", default="present", choices=["present", "absent"]),
+ identitySourceId=dict(type="str"),
identitySourceName=dict(type="str"),
ifAuthFail=dict(type="str"),
ifProcessFail=dict(type="str"),
@@ -58,6 +58,7 @@ class NetworkAccessAuthenticationRules(object):
def __init__(self, params, ise):
self.ise = ise
self.new_object = dict(
+ identity_source_id=params.get("identitySourceId"),
identity_source_name=params.get("identitySourceName"),
if_auth_fail=params.get("ifAuthFail"),
if_process_fail=params.get("ifProcessFail"),
@@ -133,6 +134,7 @@ class NetworkAccessAuthenticationRules(object):
requested_obj = self.new_object
obj_params = [
+ ("identitySourceId", "identity_source_id"),
("identitySourceName", "identity_source_name"),
("ifAuthFail", "if_auth_fail"),
("ifProcessFail", "if_process_fail"),
diff --git a/ansible_collections/cisco/ise/plugins/action/network_access_authorization_rules.py b/ansible_collections/cisco/ise/plugins/action/network_access_authorization_rules.py
index 889963294..2b6ae8c21 100644
--- a/ansible_collections/cisco/ise/plugins/action/network_access_authorization_rules.py
+++ b/ansible_collections/cisco/ise/plugins/action/network_access_authorization_rules.py
@@ -21,9 +21,7 @@ from ansible.errors import AnsibleActionFail
from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
ISESDK,
ise_argument_spec,
- ise_compare_equality,
ise_compare_equality2,
- get_dict_result,
)
from ansible_collections.cisco.ise.plugins.plugin_utils.exceptions import (
InconsistentParameters,
diff --git a/ansible_collections/cisco/ise/plugins/action/network_access_conditions.py b/ansible_collections/cisco/ise/plugins/action/network_access_conditions.py
index a80689189..7ab7a5b7e 100644
--- a/ansible_collections/cisco/ise/plugins/action/network_access_conditions.py
+++ b/ansible_collections/cisco/ise/plugins/action/network_access_conditions.py
@@ -37,6 +37,7 @@ argument_spec.update(dict(
id=dict(type="str"),
name=dict(type="str"),
attributeName=dict(type="str"),
+ attributeId=dict(type="str"),
attributeValue=dict(type="str"),
dictionaryName=dict(type="str"),
dictionaryValue=dict(type="str"),
@@ -70,6 +71,7 @@ class NetworkAccessConditions(object):
id=params.get("id"),
name=params.get("name"),
attribute_name=params.get("attributeName"),
+ attribute_id=params.get("attributeId"),
attribute_value=params.get("attributeValue"),
dictionary_name=params.get("dictionaryName"),
dictionary_value=params.get("dictionaryValue"),
@@ -152,6 +154,7 @@ class NetworkAccessConditions(object):
("id", "id"),
("name", "name"),
("attributeName", "attribute_name"),
+ ("attributeId", "attribute_id"),
("attributeValue", "attribute_value"),
("dictionaryName", "dictionary_name"),
("dictionaryValue", "dictionary_value"),
diff --git a/ansible_collections/cisco/ise/plugins/action/network_access_global_exception_rules.py b/ansible_collections/cisco/ise/plugins/action/network_access_global_exception_rules.py
index b2d3e9bcd..b67519de4 100644
--- a/ansible_collections/cisco/ise/plugins/action/network_access_global_exception_rules.py
+++ b/ansible_collections/cisco/ise/plugins/action/network_access_global_exception_rules.py
@@ -22,7 +22,6 @@ from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
ISESDK,
ise_argument_spec,
ise_compare_equality,
- get_dict_result,
)
from ansible_collections.cisco.ise.plugins.plugin_utils.exceptions import (
InconsistentParameters,
diff --git a/ansible_collections/cisco/ise/plugins/action/network_access_local_exception_rules.py b/ansible_collections/cisco/ise/plugins/action/network_access_local_exception_rules.py
index 462fd6081..c5b3c4d86 100644
--- a/ansible_collections/cisco/ise/plugins/action/network_access_local_exception_rules.py
+++ b/ansible_collections/cisco/ise/plugins/action/network_access_local_exception_rules.py
@@ -22,7 +22,6 @@ from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
ISESDK,
ise_argument_spec,
ise_compare_equality,
- get_dict_result,
)
from ansible_collections.cisco.ise.plugins.plugin_utils.exceptions import (
InconsistentParameters,
diff --git a/ansible_collections/cisco/ise/plugins/action/network_access_time_date_conditions.py b/ansible_collections/cisco/ise/plugins/action/network_access_time_date_conditions.py
index 65957d072..23b46c263 100644
--- a/ansible_collections/cisco/ise/plugins/action/network_access_time_date_conditions.py
+++ b/ansible_collections/cisco/ise/plugins/action/network_access_time_date_conditions.py
@@ -40,6 +40,7 @@ argument_spec.update(dict(
id=dict(type="str"),
name=dict(type="str"),
attributeName=dict(type="str"),
+ attributeId=dict(type="str"),
attributeValue=dict(type="str"),
dictionaryName=dict(type="str"),
dictionaryValue=dict(type="str"),
@@ -73,6 +74,7 @@ class NetworkAccessTimeDateConditions(object):
id=params.get("id"),
name=params.get("name"),
attribute_name=params.get("attributeName"),
+ attribute_id=params.get("attributeId"),
attribute_value=params.get("attributeValue"),
dictionary_name=params.get("dictionaryName"),
dictionary_value=params.get("dictionaryValue"),
@@ -150,6 +152,7 @@ class NetworkAccessTimeDateConditions(object):
("id", "id"),
("name", "name"),
("attributeName", "attribute_name"),
+ ("attributeId", "attribute_id"),
("attributeValue", "attribute_value"),
("dictionaryName", "dictionary_name"),
("dictionaryValue", "dictionary_value"),
diff --git a/ansible_collections/cisco/ise/plugins/action/network_device_group.py b/ansible_collections/cisco/ise/plugins/action/network_device_group.py
index 8cd682e9c..d45ef371a 100644
--- a/ansible_collections/cisco/ise/plugins/action/network_device_group.py
+++ b/ansible_collections/cisco/ise/plugins/action/network_device_group.py
@@ -32,7 +32,7 @@ argument_spec.update(dict(
state=dict(type="str", default="present", choices=["present", "absent"]),
name=dict(type="str"),
description=dict(type="str"),
- othername=dict(type="str"),
+ ndgtype=dict(type="str"),
id=dict(type="str"),
))
@@ -51,7 +51,7 @@ class NetworkDeviceGroup(object):
self.new_object = dict(
name=params.get("name"),
description=params.get("description"),
- othername=params.get("othername"),
+ ndgtype=params.get("ndgtype"),
id=params.get("id"),
)
@@ -122,7 +122,7 @@ class NetworkDeviceGroup(object):
obj_params = [
("name", "name"),
("description", "description"),
- ("othername", "othername"),
+ ("ndgtype", "ndgtype"),
("id", "id"),
]
# Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params
diff --git a/ansible_collections/cisco/ise/plugins/action/node_primary_to_standalone.py b/ansible_collections/cisco/ise/plugins/action/node_primary_to_standalone.py
index af546b5ef..9d5364d4d 100644
--- a/ansible_collections/cisco/ise/plugins/action/node_primary_to_standalone.py
+++ b/ansible_collections/cisco/ise/plugins/action/node_primary_to_standalone.py
@@ -37,7 +37,7 @@ argument_spec.update(dict(
required_if = []
required_one_of = [
("hostname"),
-],
+]
mutually_exclusive = []
required_together = []
diff --git a/ansible_collections/cisco/ise/plugins/action/node_secondary_to_primary.py b/ansible_collections/cisco/ise/plugins/action/node_secondary_to_primary.py
index 9cbd890b9..386e2aada 100644
--- a/ansible_collections/cisco/ise/plugins/action/node_secondary_to_primary.py
+++ b/ansible_collections/cisco/ise/plugins/action/node_secondary_to_primary.py
@@ -37,7 +37,7 @@ argument_spec.update(dict(
required_if = []
required_one_of = [
("hostname"),
-],
+]
mutually_exclusive = []
required_together = []
diff --git a/ansible_collections/cisco/ise/plugins/action/node_services_profiler_probe_config.py b/ansible_collections/cisco/ise/plugins/action/node_services_profiler_probe_config.py
index 71f25d3d7..53a9a7920 100644
--- a/ansible_collections/cisco/ise/plugins/action/node_services_profiler_probe_config.py
+++ b/ansible_collections/cisco/ise/plugins/action/node_services_profiler_probe_config.py
@@ -21,7 +21,6 @@ from ansible.errors import AnsibleActionFail
from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
ISESDK,
ise_argument_spec,
- ise_compare_equality,
ise_compare_equality2,
get_dict_result,
)
diff --git a/ansible_collections/cisco/ise/plugins/action/node_standalone_to_primary.py b/ansible_collections/cisco/ise/plugins/action/node_standalone_to_primary.py
index def196c60..2a6dcb0b2 100644
--- a/ansible_collections/cisco/ise/plugins/action/node_standalone_to_primary.py
+++ b/ansible_collections/cisco/ise/plugins/action/node_standalone_to_primary.py
@@ -36,7 +36,7 @@ argument_spec.update(dict(
required_if = []
required_one_of = [
("hostname"),
-],
+]
mutually_exclusive = []
required_together = []
diff --git a/ansible_collections/cisco/ise/plugins/action/personas_check_standalone.py b/ansible_collections/cisco/ise/plugins/action/personas_check_standalone.py
index e6e6668b7..7e4007d03 100644
--- a/ansible_collections/cisco/ise/plugins/action/personas_check_standalone.py
+++ b/ansible_collections/cisco/ise/plugins/action/personas_check_standalone.py
@@ -18,8 +18,6 @@ except ImportError:
else:
ANSIBLE_UTILS_IS_INSTALLED = True
from ansible.errors import AnsibleActionFail
-from urllib.parse import quote
-import time
from ansible_collections.cisco.ise.plugins.plugin_utils.personas_utils import Node
argument_spec = dict(
diff --git a/ansible_collections/cisco/ise/plugins/action/personas_export_certs.py b/ansible_collections/cisco/ise/plugins/action/personas_export_certs.py
index a0a3e6d8a..8acba2dd2 100644
--- a/ansible_collections/cisco/ise/plugins/action/personas_export_certs.py
+++ b/ansible_collections/cisco/ise/plugins/action/personas_export_certs.py
@@ -18,8 +18,6 @@ except ImportError:
else:
ANSIBLE_UTILS_IS_INSTALLED = True
from ansible.errors import AnsibleActionFail
-from urllib.parse import quote
-import time
from ansible_collections.cisco.ise.plugins.plugin_utils.personas_utils import Node
argument_spec = dict(
diff --git a/ansible_collections/cisco/ise/plugins/action/personas_promote_primary.py b/ansible_collections/cisco/ise/plugins/action/personas_promote_primary.py
index 9de4ae5ae..8e7a1c2b5 100644
--- a/ansible_collections/cisco/ise/plugins/action/personas_promote_primary.py
+++ b/ansible_collections/cisco/ise/plugins/action/personas_promote_primary.py
@@ -18,8 +18,6 @@ except ImportError:
else:
ANSIBLE_UTILS_IS_INSTALLED = True
from ansible.errors import AnsibleActionFail
-from urllib.parse import quote
-import time
from ansible_collections.cisco.ise.plugins.plugin_utils.personas_utils import Node
argument_spec = dict(
diff --git a/ansible_collections/cisco/ise/plugins/action/personas_register_node.py b/ansible_collections/cisco/ise/plugins/action/personas_register_node.py
index 708551dd2..2a1b008f2 100644
--- a/ansible_collections/cisco/ise/plugins/action/personas_register_node.py
+++ b/ansible_collections/cisco/ise/plugins/action/personas_register_node.py
@@ -18,8 +18,6 @@ except ImportError:
else:
ANSIBLE_UTILS_IS_INSTALLED = True
from ansible.errors import AnsibleActionFail
-from urllib.parse import quote
-import time
from ansible_collections.cisco.ise.plugins.plugin_utils.personas_utils import Node
argument_spec = dict(
diff --git a/ansible_collections/cisco/ise/plugins/action/personas_update_roles_services.py b/ansible_collections/cisco/ise/plugins/action/personas_update_roles_services.py
index bca25ce3d..085271454 100644
--- a/ansible_collections/cisco/ise/plugins/action/personas_update_roles_services.py
+++ b/ansible_collections/cisco/ise/plugins/action/personas_update_roles_services.py
@@ -10,8 +10,6 @@ except ImportError:
else:
ANSIBLE_UTILS_IS_INSTALLED = True
from ansible.errors import AnsibleActionFail
-from urllib.parse import quote
-import time
from ansible_collections.cisco.ise.plugins.plugin_utils.personas_utils import Node
from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
ise_compare_equality,
@@ -97,7 +95,7 @@ class ActionModule(ActionBase):
try:
prev_obj = node.get_roles_services()
except Exception as e:
- AnsibleActionFail(e)
+ raise AnsibleActionFail(e)
if prev_obj:
if obj.requires_update(prev_obj, request_obj):
try:
diff --git a/ansible_collections/cisco/ise/plugins/action/rest_id_store.py b/ansible_collections/cisco/ise/plugins/action/rest_id_store.py
index 1e138018a..298223855 100644
--- a/ansible_collections/cisco/ise/plugins/action/rest_id_store.py
+++ b/ansible_collections/cisco/ise/plugins/action/rest_id_store.py
@@ -33,6 +33,7 @@ argument_spec.update(dict(
name=dict(type="str"),
description=dict(type="str"),
ersRestIDStoreAttributes=dict(type="dict"),
+ ersRestIDStoreUserAttributes=dict(type="dict"),
id=dict(type="str"),
))
@@ -52,6 +53,7 @@ class RestIdStore(object):
name=params.get("name"),
description=params.get("description"),
ers_rest_idstore_attributes=params.get("ersRestIDStoreAttributes"),
+ ers_rest_idstore_user_attributes=params.get("ersRestIDStoreUserAttributes"),
id=params.get("id"),
)
@@ -120,6 +122,7 @@ class RestIdStore(object):
("name", "name"),
("description", "description"),
("ersRestIDStoreAttributes", "ers_rest_idstore_attributes"),
+ ("ersRestIDStoreUserAttributes", "ers_rest_idstore_user_attributes"),
("id", "id"),
]
# Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params
@@ -129,6 +132,7 @@ class RestIdStore(object):
for (ise_param, ansible_param) in obj_params)
def create(self):
+ print(self.new_object)
result = self.ise.exec(
family="restid_store",
function="create_rest_id_store",
@@ -221,6 +225,7 @@ class ActionModule(ActionBase):
self._result.update(dict(ise_update_response=ise_update_response))
(obj_exists, updated_obj) = obj.exists()
response = updated_obj
+ ise.object_updated()
has_changed = None
has_changed = ise_update_response.get("UpdatedFieldsList").get("updatedField")
if (len(has_changed) == 0 or
diff --git a/ansible_collections/cisco/ise/plugins/action/trustsec_nbar_app.py b/ansible_collections/cisco/ise/plugins/action/subscriber.py
index 3cb7209b8..a3713078a 100644
--- a/ansible_collections/cisco/ise/plugins/action/trustsec_nbar_app.py
+++ b/ansible_collections/cisco/ise/plugins/action/subscriber.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (c) 2021, Cisco Systems
+# Copyright (c) 2023, Cisco Systems
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -33,42 +33,46 @@ argument_spec = ise_argument_spec()
# Add arguments specific for this module
argument_spec.update(dict(
state=dict(type="str", default="present", choices=["present", "absent"]),
- description=dict(type="str"),
- id=dict(type="str"),
- name=dict(type="str"),
- networkIdentities=dict(type="list"),
+ enabled=dict(type="bool"),
+ friendlyName=dict(type="str"),
+ identityGroups=dict(type="str"),
+ imeis=dict(type="str"),
+ imsi=dict(type="str"),
+ ki=dict(type="str"),
+ opc=dict(type="str"),
+ subscriberId=dict(type="str"),
))
-required_if = [
- ("state", "present", ["id", "name"], True),
- ("state", "absent", ["id", "name"], True),
-]
+required_if = []
required_one_of = []
mutually_exclusive = []
required_together = []
-class TrustsecNbarApp(object):
+class Subscriber(object):
def __init__(self, params, ise):
self.ise = ise
self.new_object = dict(
- description=params.get("description"),
- id=params.get("id"),
- name=params.get("name"),
- network_identities=params.get("networkIdentities"),
+ enabled=params.get("enabled"),
+ friendly_name=params.get("friendlyName"),
+ identity_groups=params.get("identityGroups"),
+ imeis=params.get("imeis"),
+ imsi=params.get("imsi"),
+ ki=params.get("ki"),
+ opc=params.get("opc"),
+ subscriber_id=params.get("subscriberId"),
)
def get_object_by_name(self, name):
# NOTICE: Get does not support/work for filter by name with EQ
result = None
gen_items_responses = self.ise.exec(
- family="nbar_app",
- function="get_nbar_apps_generator",
- params={"filter": "name.EQ.{name}".format(name=name)}
+ family="subscriber",
+ function="get_all_subscribers_generator"
)
try:
for items_response in gen_items_responses:
- items = items_response.response['response']
+ items = items_response.response.get('response', [])
result = get_dict_result(items, 'name', name)
if result:
return result
@@ -90,10 +94,10 @@ class TrustsecNbarApp(object):
def get_object_by_id(self, id):
try:
result = self.ise.exec(
- family="nbar_app",
- function="get_nbar_app_by_id",
+ family="subscriber",
+ function="get_subscriber_by_id",
handle_func_exception=False,
- params={"id": id}
+ params={"subscriber_id": id}
).response['response']
except (TypeError, AttributeError) as e:
self.ise.fail_json(
@@ -107,15 +111,13 @@ class TrustsecNbarApp(object):
)
except Exception:
result = None
- if isinstance(result, list) and len(result) > 0:
- return result[0]
return result
def exists(self):
id_exists = False
name_exists = False
prev_obj = None
- o_id = self.new_object.get("id")
+ o_id = self.new_object.get("subscriberId")
name = self.new_object.get("name")
if o_id:
prev_obj = self.get_object_by_id(o_id)
@@ -136,10 +138,14 @@ class TrustsecNbarApp(object):
requested_obj = self.new_object
obj_params = [
- ("description", "description"),
- ("id", "id"),
- ("name", "name"),
- ("networkIdentities", "network_identities"),
+ ("enabled", "enabled"),
+ ("friendlyName", "friendly_name"),
+ ("identityGroups", "identity_groups"),
+ ("imeis", "imeis"),
+ ("imsi", "imsi"),
+ ("ki", "ki"),
+ ("opc", "opc"),
+ ("subscriberId", "subscriber_id"),
]
# Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params
# If any does not have eq params, it requires update
@@ -149,8 +155,8 @@ class TrustsecNbarApp(object):
def create(self):
result = self.ise.exec(
- family="nbar_app",
- function="create_nbar_app",
+ family="subscriber",
+ function="create_subscriber",
params=self.new_object,
).response
return result
@@ -163,8 +169,8 @@ class TrustsecNbarApp(object):
id_ = self.get_object_by_name(name).get("id")
self.new_object.update(dict(id=id_))
result = self.ise.exec(
- family="nbar_app",
- function="update_nbar_app_by_id",
+ family="subscriber",
+ function="update_subscriber",
params=self.new_object
).response
return result
@@ -177,8 +183,8 @@ class TrustsecNbarApp(object):
id_ = self.get_object_by_name(name).get("id")
self.new_object.update(dict(id=id_))
result = self.ise.exec(
- family="nbar_app",
- function="delete_nbar_app_by_id",
+ family="subscriber",
+ function="delete_subscriber",
params=self.new_object
).response
return result
@@ -218,7 +224,7 @@ class ActionModule(ActionBase):
self._check_argspec()
ise = ISESDK(params=self._task.args)
- obj = TrustsecNbarApp(self._task.args, ise)
+ obj = Subscriber(self._task.args, ise)
state = self._task.args.get("state")
diff --git a/ansible_collections/cisco/ise/plugins/action/trustsec_sg_vn_mapping_bulk_create.py b/ansible_collections/cisco/ise/plugins/action/subscriber_bulk.py
index 349b4bc85..bd392306d 100644
--- a/ansible_collections/cisco/ise/plugins/action/trustsec_sg_vn_mapping_bulk_create.py
+++ b/ansible_collections/cisco/ise/plugins/action/subscriber_bulk.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (c) 2021, Cisco Systems
+# Copyright (c) 2023, Cisco Systems
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -27,7 +27,8 @@ from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
argument_spec = ise_argument_spec()
# Add arguments specific for this module
argument_spec.update(dict(
- payload=dict(type="list"),
+ ItemList=dict(type="list"),
+ operation=dict(type="str"),
))
required_if = []
@@ -65,7 +66,8 @@ class ActionModule(ActionBase):
def get_object(self, params):
new_object = dict(
- payload=params.get("payload"),
+ item_list=params.get("ItemList"),
+ operation=params.get("operation"),
)
return new_object
@@ -78,8 +80,8 @@ class ActionModule(ActionBase):
ise = ISESDK(params=self._task.args)
response = ise.exec(
- family="sg_vn_mapping",
- function="bulk_create_sg_vn_mappings",
+ family="subscriber",
+ function="bulk_subscriber_operation",
params=self.get_object(self._task.args),
).response
diff --git a/ansible_collections/cisco/ise/plugins/action/subscriber_imsi_info.py b/ansible_collections/cisco/ise/plugins/action/subscriber_imsi_info.py
new file mode 100644
index 000000000..f82cd0d6d
--- /dev/null
+++ b/ansible_collections/cisco/ise/plugins/action/subscriber_imsi_info.py
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2023, Cisco Systems
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+
+__metaclass__ = type
+from ansible.plugins.action import ActionBase
+
+try:
+ from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
+ AnsibleArgSpecValidator,
+ )
+except ImportError:
+ ANSIBLE_UTILS_IS_INSTALLED = False
+else:
+ ANSIBLE_UTILS_IS_INSTALLED = True
+from ansible.errors import AnsibleActionFail
+from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
+ ISESDK,
+ ise_argument_spec,
+)
+
+# Get common arguements specification
+argument_spec = ise_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ imsi=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __init__(self, *args, **kwargs):
+ if not ANSIBLE_UTILS_IS_INSTALLED:
+ raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
+ super(ActionModule, self).__init__(*args, **kwargs)
+ self._supports_async = False
+ self._supports_check_mode = True
+ self._result = None
+
+ # Checks the supplied parameters against the argument spec for this module
+ def _check_argspec(self):
+ aav = AnsibleArgSpecValidator(
+ data=self._task.args,
+ schema=dict(argument_spec=argument_spec),
+ schema_format="argspec",
+ schema_conditionals=dict(
+ required_if=required_if,
+ required_one_of=required_one_of,
+ mutually_exclusive=mutually_exclusive,
+ required_together=required_together,
+ ),
+ name=self._task.action,
+ )
+ valid, errors, self._task.args = aav.validate()
+ if not valid:
+ raise AnsibleActionFail(errors)
+
+ def get_object(self, params):
+ new_object = dict(
+ imsi=params.get("imsi"),
+ )
+ return new_object
+
+ def run(self, tmp=None, task_vars=None):
+ self._task.diff = False
+ self._result = super(ActionModule, self).run(tmp, task_vars)
+ self._result["changed"] = False
+ self._check_argspec()
+
+ self._result.update(dict(ise_response={}))
+
+ ise = ISESDK(params=self._task.args)
+
+ id = self._task.args.get("imsi")
+ name = self._task.args.get("name")
+ if id:
+ response = ise.exec(
+ family="subscriber",
+ function='get_subscriber_by_i_m_s_i',
+ params=self.get_object(self._task.args)
+ ).response['response']
+ self._result.update(dict(ise_response=response))
+ self._result.update(ise.exit_json())
+ return self._result
+ if not name and not id:
+ # NOTICE: Does not have a get all method or it is in another action
+ response = None
+ self._result.update(dict(ise_response=response))
+ self._result.update(ise.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/ise/plugins/action/trustsec_sg_vn_mapping_info.py b/ansible_collections/cisco/ise/plugins/action/subscriber_info.py
index 42820bc30..65d8cc69c 100644
--- a/ansible_collections/cisco/ise/plugins/action/trustsec_sg_vn_mapping_info.py
+++ b/ansible_collections/cisco/ise/plugins/action/subscriber_info.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (c) 2021, Cisco Systems
+# Copyright (c) 2023, Cisco Systems
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
@@ -29,11 +29,11 @@ argument_spec = ise_argument_spec()
argument_spec.update(dict(
page=dict(type="int"),
size=dict(type="int"),
+ filter=dict(type="str"),
+ filterType=dict(type="str"),
sort=dict(type="str"),
sortBy=dict(type="str"),
- filter=dict(type="list"),
- filterType=dict(type="str"),
- id=dict(type="str"),
+ subscriberId=dict(type="str"),
))
required_if = []
@@ -73,11 +73,11 @@ class ActionModule(ActionBase):
new_object = dict(
page=params.get("page"),
size=params.get("size"),
- sort=params.get("sort"),
- sort_by=params.get("sortBy"),
filter=params.get("filter"),
filter_type=params.get("filterType"),
- id=params.get("id"),
+ sort=params.get("sort"),
+ sort_by=params.get("sortBy"),
+ subscriber_id=params.get("subscriberId"),
)
return new_object
@@ -91,12 +91,12 @@ class ActionModule(ActionBase):
ise = ISESDK(params=self._task.args)
- id = self._task.args.get("id")
+ id = self._task.args.get("subscriberId")
name = self._task.args.get("name")
if id:
response = ise.exec(
- family="sg_vn_mapping",
- function='get_sg_vn_mapping_by_id',
+ family="subscriber",
+ function='get_subscriber_by_id',
params=self.get_object(self._task.args)
).response['response']
self._result.update(dict(ise_response=response))
@@ -105,8 +105,8 @@ class ActionModule(ActionBase):
if not name and not id:
responses = []
generator = ise.exec(
- family="sg_vn_mapping",
- function='get_sg_vn_mappings_generator',
+ family="subscriber",
+ function='get_all_subscribers_generator',
params=self.get_object(self._task.args),
)
try:
diff --git a/ansible_collections/cisco/ise/plugins/action/system_certificate.py b/ansible_collections/cisco/ise/plugins/action/system_certificate.py
index 0ca926288..3faae7fec 100644
--- a/ansible_collections/cisco/ise/plugins/action/system_certificate.py
+++ b/ansible_collections/cisco/ise/plugins/action/system_certificate.py
@@ -121,7 +121,7 @@ class SystemCertificate(object):
function="get_system_certificate_by_id",
params={"id": id, "host_name": host_name},
handle_func_exception=False,
- ).response
+ ).response['response']
except Exception as e:
result = None
return result
@@ -143,6 +143,18 @@ class SystemCertificate(object):
def requires_update(self, current_obj):
requested_obj = self.new_object
+ used_by_value = current_obj.get("usedBy")
+ if used_by_value is None or used_by_value.lower() == "not in use":
+ current_obj["eap"] = False
+ current_obj["pxgrid"] = False
+ current_obj["radius"] = False
+ current_obj["ims"] = False
+ else:
+ current_obj["eap"] = "eap" in used_by_value.lower()
+ current_obj["pxgrid"] = "pxgrid" in used_by_value.lower()
+ current_obj["radius"] = "radius" in used_by_value.lower()
+ current_obj["ims"] = "ims" in used_by_value.lower()
+
obj_params = [
("admin", "admin"),
("allowPortalTagTransferForSameSubject", "allow_portal_tag_transfer_for_same_subject"),
@@ -153,7 +165,7 @@ class SystemCertificate(object):
("expirationTTLPeriod", "expiration_ttl_period"),
("expirationTTLUnits", "expiration_ttl_units"),
("ims", "ims"),
- ("name", "name"),
+ ("friendlyName", "name"),
("portal", "portal"),
("portalGroupTag", "portal_group_tag"),
("pxgrid", "pxgrid"),
diff --git a/ansible_collections/cisco/ise/plugins/action/test_connector.py b/ansible_collections/cisco/ise/plugins/action/test_connector.py
new file mode 100644
index 000000000..f3a1b5797
--- /dev/null
+++ b/ansible_collections/cisco/ise/plugins/action/test_connector.py
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2023, Cisco Systems
+# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import absolute_import, division, print_function
+
+__metaclass__ = type
+from ansible.plugins.action import ActionBase
+
+try:
+ from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
+ AnsibleArgSpecValidator,
+ )
+except ImportError:
+ ANSIBLE_UTILS_IS_INSTALLED = False
+else:
+ ANSIBLE_UTILS_IS_INSTALLED = True
+from ansible.errors import AnsibleActionFail
+from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
+ ISESDK,
+ ise_argument_spec,
+)
+
+# Get common arguements specification
+argument_spec = ise_argument_spec()
+# Add arguments specific for this module
+argument_spec.update(dict(
+ authType=dict(type="str"),
+ authValues=dict(type="dict"),
+ connectorName=dict(type="str"),
+ responseParsing=dict(type="str"),
+ uniqueID=dict(type="str"),
+ url=dict(type="str"),
+))
+
+required_if = []
+required_one_of = []
+mutually_exclusive = []
+required_together = []
+
+
+class ActionModule(ActionBase):
+ def __init__(self, *args, **kwargs):
+ if not ANSIBLE_UTILS_IS_INSTALLED:
+ raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
+ super(ActionModule, self).__init__(*args, **kwargs)
+ self._supports_async = False
+ self._supports_check_mode = False
+ self._result = None
+
+ # Checks the supplied parameters against the argument spec for this module
+ def _check_argspec(self):
+ aav = AnsibleArgSpecValidator(
+ data=self._task.args,
+ schema=dict(argument_spec=argument_spec),
+ schema_format="argspec",
+ schema_conditionals=dict(
+ required_if=required_if,
+ required_one_of=required_one_of,
+ mutually_exclusive=mutually_exclusive,
+ required_together=required_together,
+ ),
+ name=self._task.action,
+ )
+ valid, errors, self._task.args = aav.validate()
+ if not valid:
+ raise AnsibleActionFail(errors)
+
+ def get_object(self, params):
+ new_object = dict(
+ auth_type=params.get("authType"),
+ auth_values=params.get("authValues"),
+ connector_name=params.get("connectorName"),
+ response_parsing=params.get("responseParsing"),
+ unique_id=params.get("uniqueID"),
+ url=params.get("url"),
+ )
+ return new_object
+
+ def run(self, tmp=None, task_vars=None):
+ self._task.diff = False
+ self._result = super(ActionModule, self).run(tmp, task_vars)
+ self._result["changed"] = False
+ self._check_argspec()
+
+ ise = ISESDK(params=self._task.args)
+
+ response = ise.exec(
+ family="edda",
+ function="test_connector",
+ params=self.get_object(self._task.args),
+ ).response
+
+ self._result.update(dict(ise_response=response))
+ self._result.update(ise.exit_json())
+ return self._result
diff --git a/ansible_collections/cisco/ise/plugins/action/trustsec_nbar_app_info.py b/ansible_collections/cisco/ise/plugins/action/trustsec_nbar_app_info.py
deleted file mode 100644
index e0390f20e..000000000
--- a/ansible_collections/cisco/ise/plugins/action/trustsec_nbar_app_info.py
+++ /dev/null
@@ -1,141 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# Copyright (c) 2021, Cisco Systems
-# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-from ansible.plugins.action import ActionBase
-
-try:
- from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
- AnsibleArgSpecValidator,
- )
-except ImportError:
- ANSIBLE_UTILS_IS_INSTALLED = False
-else:
- ANSIBLE_UTILS_IS_INSTALLED = True
-from ansible.errors import AnsibleActionFail
-from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
- ISESDK,
- ise_argument_spec,
-)
-
-# Get common arguements specification
-argument_spec = ise_argument_spec()
-# Add arguments specific for this module
-argument_spec.update(dict(
- page=dict(type="int"),
- size=dict(type="int"),
- sort=dict(type="str"),
- sortBy=dict(type="str"),
- filter=dict(type="list"),
- filterType=dict(type="str"),
- id=dict(type="str"),
-))
-
-required_if = []
-required_one_of = []
-mutually_exclusive = []
-required_together = []
-
-
-class ActionModule(ActionBase):
- def __init__(self, *args, **kwargs):
- if not ANSIBLE_UTILS_IS_INSTALLED:
- raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
- super(ActionModule, self).__init__(*args, **kwargs)
- self._supports_async = False
- self._supports_check_mode = True
- self._result = None
-
- # Checks the supplied parameters against the argument spec for this module
- def _check_argspec(self):
- aav = AnsibleArgSpecValidator(
- data=self._task.args,
- schema=dict(argument_spec=argument_spec),
- schema_format="argspec",
- schema_conditionals=dict(
- required_if=required_if,
- required_one_of=required_one_of,
- mutually_exclusive=mutually_exclusive,
- required_together=required_together,
- ),
- name=self._task.action,
- )
- valid, errors, self._task.args = aav.validate()
- if not valid:
- raise AnsibleActionFail(errors)
-
- def get_object(self, params):
- new_object = dict(
- page=params.get("page"),
- size=params.get("size"),
- sort=params.get("sort"),
- sort_by=params.get("sortBy"),
- filter=params.get("filter"),
- filter_type=params.get("filterType"),
- id=params.get("id"),
- )
- return new_object
-
- def run(self, tmp=None, task_vars=None):
- self._task.diff = False
- self._result = super(ActionModule, self).run(tmp, task_vars)
- self._result["changed"] = False
- self._check_argspec()
-
- self._result.update(dict(ise_response=[]))
-
- ise = ISESDK(params=self._task.args)
-
- id = self._task.args.get("id")
- name = self._task.args.get("name")
- if id:
- response = ise.exec(
- family="nbar_app",
- function='get_nbar_app_by_id',
- params=self.get_object(self._task.args)
- ).response['response']
- self._result.update(dict(ise_response=response))
- self._result.update(ise.exit_json())
- return self._result
- if not name and not id:
- responses = []
- generator = ise.exec(
- family="nbar_app",
- function='get_nbar_apps_generator',
- params=self.get_object(self._task.args),
- )
- try:
- for item in generator:
- tmp_response = item.response['response']
- if isinstance(tmp_response, list):
- responses += tmp_response
- else:
- responses.append(tmp_response)
- response = responses
- except (TypeError, AttributeError) as e:
- ise.fail_json(
- msg=(
- "An error occured when executing operation."
- " Check the configuration of your API Settings and API Gateway settings on your ISE server."
- " This collection assumes that the API Gateway, the ERS APIs and OpenAPIs are enabled."
- " You may want to enable the (ise_debug: True) argument."
- " The error was: {error}"
- ).format(error=e)
- )
- except Exception as e:
- ise.fail_json(
- msg=(
- "An error occured when executing operation."
- " The error was: {error}"
- " You may want to enable the (ise_debug: True) argument."
- ).format(error=e)
- )
-
- self._result.update(dict(ise_response=response))
- self._result.update(ise.exit_json())
- return self._result
diff --git a/ansible_collections/cisco/ise/plugins/action/trustsec_sg_vn_mapping.py b/ansible_collections/cisco/ise/plugins/action/trustsec_sg_vn_mapping.py
deleted file mode 100644
index f522e9296..000000000
--- a/ansible_collections/cisco/ise/plugins/action/trustsec_sg_vn_mapping.py
+++ /dev/null
@@ -1,267 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# Copyright (c) 2021, Cisco Systems
-# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-from ansible.plugins.action import ActionBase
-
-try:
- from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
- AnsibleArgSpecValidator,
- )
-except ImportError:
- ANSIBLE_UTILS_IS_INSTALLED = False
-else:
- ANSIBLE_UTILS_IS_INSTALLED = True
-from ansible.errors import AnsibleActionFail
-from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
- ISESDK,
- ise_argument_spec,
- ise_compare_equality,
- get_dict_result,
-)
-from ansible_collections.cisco.ise.plugins.plugin_utils.exceptions import (
- InconsistentParameters,
-)
-
-# Get common arguments specification
-argument_spec = ise_argument_spec()
-# Add arguments specific for this module
-argument_spec.update(dict(
- state=dict(type="str", default="present", choices=["present", "absent"]),
- id=dict(type="str"),
- lastUpdate=dict(type="str"),
- sgName=dict(type="str"),
- sgtId=dict(type="str"),
- vnId=dict(type="str"),
- vnName=dict(type="str"),
-))
-
-required_if = [
- ("state", "present", ["id", "sgName", "vnName"], True),
- ("state", "absent", ["id", "sgName", "vnName"], True),
-]
-required_one_of = []
-mutually_exclusive = []
-required_together = []
-
-
-class TrustsecSgVnMapping(object):
- def __init__(self, params, ise):
- self.ise = ise
- self.new_object = dict(
- id=params.get("id"),
- last_update=params.get("lastUpdate"),
- sg_name=params.get("sgName"),
- sgt_id=params.get("sgtId"),
- vn_id=params.get("vnId"),
- vn_name=params.get("vnName"),
- )
-
- def get_object_by_name(self, sg_name, vn_name):
- # NOTICE: Get does not support/work for filter by name with EQ
- result = None
- gen_items_responses = self.ise.exec(
- family="sg_vn_mapping",
- function="get_sg_vn_mappings_generator"
- )
- try:
- for items_response in gen_items_responses:
- items = items_response.response['response']
- for item in items:
- if isinstance(item, dict) and item.get('sgName') == sg_name and item.get('vnName') == vn_name:
- result = item
- break
- if result:
- return result
- except (TypeError, AttributeError) as e:
- self.ise.fail_json(
- msg=(
- "An error occured when executing operation."
- " Check the configuration of your API Settings and API Gateway settings on your ISE server."
- " This collection assumes that the API Gateway, the ERS APIs and OpenAPIs are enabled."
- " You may want to enable the (ise_debug: True) argument."
- " The error was: {error}"
- ).format(error=e)
- )
- except Exception:
- result = None
- return result
- return result
-
- def get_object_by_id(self, id):
- try:
- result = self.ise.exec(
- family="sg_vn_mapping",
- function="get_sg_vn_mapping_by_id",
- handle_func_exception=False,
- params={"id": id}
- ).response['response']
- except (TypeError, AttributeError) as e:
- self.ise.fail_json(
- msg=(
- "An error occured when executing operation."
- " Check the configuration of your API Settings and API Gateway settings on your ISE server."
- " This collection assumes that the API Gateway, the ERS APIs and OpenAPIs are enabled."
- " You may want to enable the (ise_debug: True) argument."
- " The error was: {error}"
- ).format(error=e)
- )
- except Exception:
- result = None
- if isinstance(result, list) and len(result) > 0:
- return result[0]
- return result
-
- def exists(self):
- id_exists = False
- name_exists = False
- prev_obj = None
- o_id = self.new_object.get("id")
- sg_name = self.new_object.get("sg_name")
- vn_name = self.new_object.get("vn_name")
- if o_id:
- prev_obj = self.get_object_by_id(o_id)
- id_exists = prev_obj is not None and isinstance(prev_obj, dict)
- if not id_exists and sg_name and vn_name:
- prev_obj = self.get_object_by_name(sg_name, vn_name)
- name_exists = prev_obj is not None and isinstance(prev_obj, dict)
- if name_exists:
- _id = prev_obj.get("id")
- if id_exists and name_exists and o_id != _id:
- raise InconsistentParameters("The 'id' and 'name' params don't refer to the same object")
- if _id:
- prev_obj = self.get_object_by_id(_id)
- it_exists = prev_obj is not None and isinstance(prev_obj, dict)
- return (it_exists, prev_obj)
-
- def requires_update(self, current_obj):
- requested_obj = self.new_object
-
- obj_params = [
- ("id", "id"),
- ("lastUpdate", "last_update"),
- ("sgName", "sg_name"),
- ("sgtId", "sgt_id"),
- ("vnId", "vn_id"),
- ("vnName", "vn_name"),
- ]
- # Method 1. Params present in request (Ansible) obj are the same as the current (ISE) params
- # If any does not have eq params, it requires update
- return any(not ise_compare_equality(current_obj.get(ise_param),
- requested_obj.get(ansible_param))
- for (ise_param, ansible_param) in obj_params)
-
- def create(self):
- result = self.ise.exec(
- family="sg_vn_mapping",
- function="create_sg_vn_mapping",
- params=self.new_object,
- ).response
- return result
-
- def update(self):
- id = self.new_object.get("id")
- sg_name = self.new_object.get("sg_name")
- vn_name = self.new_object.get("vn_name")
- result = None
- if not id:
- id_ = self.get_object_by_name(sg_name, vn_name).get("id")
- self.new_object.update(dict(id=id_))
- result = self.ise.exec(
- family="sg_vn_mapping",
- function="update_sg_vn_mapping_by_id",
- params=self.new_object
- ).response
- return result
-
- def delete(self):
- id = self.new_object.get("id")
- sg_name = self.new_object.get("sg_name")
- vn_name = self.new_object.get("vn_name")
- result = None
- if not id:
- id_ = self.get_object_by_name(sg_name, vn_name).get("id")
- self.new_object.update(dict(id=id_))
- result = self.ise.exec(
- family="sg_vn_mapping",
- function="delete_sg_vn_mapping_by_id",
- params=self.new_object
- ).response
- return result
-
-
-class ActionModule(ActionBase):
- def __init__(self, *args, **kwargs):
- if not ANSIBLE_UTILS_IS_INSTALLED:
- raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
- super(ActionModule, self).__init__(*args, **kwargs)
- self._supports_async = False
- self._supports_check_mode = False
- self._result = None
-
- # Checks the supplied parameters against the argument spec for this module
- def _check_argspec(self):
- aav = AnsibleArgSpecValidator(
- data=self._task.args,
- schema=dict(argument_spec=argument_spec),
- schema_format="argspec",
- schema_conditionals=dict(
- required_if=required_if,
- required_one_of=required_one_of,
- mutually_exclusive=mutually_exclusive,
- required_together=required_together,
- ),
- name=self._task.action,
- )
- valid, errors, self._task.args = aav.validate()
- if not valid:
- raise AnsibleActionFail(errors)
-
- def run(self, tmp=None, task_vars=None):
- self._task.diff = False
- self._result = super(ActionModule, self).run(tmp, task_vars)
- self._result["changed"] = False
- self._check_argspec()
-
- ise = ISESDK(params=self._task.args)
- obj = TrustsecSgVnMapping(self._task.args, ise)
-
- state = self._task.args.get("state")
-
- response = None
-
- if state == "present":
- (obj_exists, prev_obj) = obj.exists()
- if obj_exists:
- if obj.requires_update(prev_obj):
- ise_update_response = obj.update()
- self._result.update(dict(ise_update_response=ise_update_response))
- (obj_exists, updated_obj) = obj.exists()
- response = updated_obj
- ise.object_updated()
- else:
- response = prev_obj
- ise.object_already_present()
- else:
- ise_create_response = obj.create()
- (obj_exists, created_obj) = obj.exists()
- response = created_obj
- ise.object_created()
-
- elif state == "absent":
- (obj_exists, prev_obj) = obj.exists()
- if obj_exists:
- obj.delete()
- response = prev_obj
- ise.object_deleted()
- else:
- ise.object_already_absent()
-
- self._result.update(dict(ise_response=response))
- self._result.update(ise.exit_json())
- return self._result
diff --git a/ansible_collections/cisco/ise/plugins/action/trustsec_vn_bulk_delete.py b/ansible_collections/cisco/ise/plugins/action/trustsec_vn_bulk_delete.py
deleted file mode 100644
index d6aed5405..000000000
--- a/ansible_collections/cisco/ise/plugins/action/trustsec_vn_bulk_delete.py
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# Copyright (c) 2021, Cisco Systems
-# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-from ansible.plugins.action import ActionBase
-
-try:
- from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
- AnsibleArgSpecValidator,
- )
-except ImportError:
- ANSIBLE_UTILS_IS_INSTALLED = False
-else:
- ANSIBLE_UTILS_IS_INSTALLED = True
-from ansible.errors import AnsibleActionFail
-from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
- ISESDK,
- ise_argument_spec,
-)
-
-# Get common arguements specification
-argument_spec = ise_argument_spec()
-# Add arguments specific for this module
-argument_spec.update(dict(
- payload=dict(type="list"),
-))
-
-required_if = []
-required_one_of = []
-mutually_exclusive = []
-required_together = []
-
-
-class ActionModule(ActionBase):
- def __init__(self, *args, **kwargs):
- if not ANSIBLE_UTILS_IS_INSTALLED:
- raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
- super(ActionModule, self).__init__(*args, **kwargs)
- self._supports_async = False
- self._supports_check_mode = False
- self._result = None
-
- # Checks the supplied parameters against the argument spec for this module
- def _check_argspec(self):
- aav = AnsibleArgSpecValidator(
- data=self._task.args,
- schema=dict(argument_spec=argument_spec),
- schema_format="argspec",
- schema_conditionals=dict(
- required_if=required_if,
- required_one_of=required_one_of,
- mutually_exclusive=mutually_exclusive,
- required_together=required_together,
- ),
- name=self._task.action,
- )
- valid, errors, self._task.args = aav.validate()
- if not valid:
- raise AnsibleActionFail(errors)
-
- def get_object(self, params):
- new_object = dict(
- payload=params.get("payload"),
- )
- return new_object
-
- def run(self, tmp=None, task_vars=None):
- self._task.diff = False
- self._result = super(ActionModule, self).run(tmp, task_vars)
- self._result["changed"] = False
- self._check_argspec()
-
- ise = ISESDK(params=self._task.args)
-
- response = ise.exec(
- family="virtual_network",
- function="bulk_delete_virtual_networks",
- params=self.get_object(self._task.args),
- ).response
-
- self._result.update(dict(ise_response=response))
- self._result.update(ise.exit_json())
- return self._result
diff --git a/ansible_collections/cisco/ise/plugins/action/trustsec_vn_bulk_update.py b/ansible_collections/cisco/ise/plugins/action/trustsec_vn_bulk_update.py
deleted file mode 100644
index 4b37b3318..000000000
--- a/ansible_collections/cisco/ise/plugins/action/trustsec_vn_bulk_update.py
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# Copyright (c) 2021, Cisco Systems
-# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-from ansible.plugins.action import ActionBase
-
-try:
- from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
- AnsibleArgSpecValidator,
- )
-except ImportError:
- ANSIBLE_UTILS_IS_INSTALLED = False
-else:
- ANSIBLE_UTILS_IS_INSTALLED = True
-from ansible.errors import AnsibleActionFail
-from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
- ISESDK,
- ise_argument_spec,
-)
-
-# Get common arguements specification
-argument_spec = ise_argument_spec()
-# Add arguments specific for this module
-argument_spec.update(dict(
- payload=dict(type="list"),
-))
-
-required_if = []
-required_one_of = []
-mutually_exclusive = []
-required_together = []
-
-
-class ActionModule(ActionBase):
- def __init__(self, *args, **kwargs):
- if not ANSIBLE_UTILS_IS_INSTALLED:
- raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
- super(ActionModule, self).__init__(*args, **kwargs)
- self._supports_async = False
- self._supports_check_mode = False
- self._result = None
-
- # Checks the supplied parameters against the argument spec for this module
- def _check_argspec(self):
- aav = AnsibleArgSpecValidator(
- data=self._task.args,
- schema=dict(argument_spec=argument_spec),
- schema_format="argspec",
- schema_conditionals=dict(
- required_if=required_if,
- required_one_of=required_one_of,
- mutually_exclusive=mutually_exclusive,
- required_together=required_together,
- ),
- name=self._task.action,
- )
- valid, errors, self._task.args = aav.validate()
- if not valid:
- raise AnsibleActionFail(errors)
-
- def get_object(self, params):
- new_object = dict(
- payload=params.get("payload"),
- )
- return new_object
-
- def run(self, tmp=None, task_vars=None):
- self._task.diff = False
- self._result = super(ActionModule, self).run(tmp, task_vars)
- self._result["changed"] = False
- self._check_argspec()
-
- ise = ISESDK(params=self._task.args)
-
- response = ise.exec(
- family="virtual_network",
- function="bulk_update_virtual_networks",
- params=self.get_object(self._task.args),
- ).response
-
- self._result.update(dict(ise_response=response))
- self._result.update(ise.exit_json())
- return self._result
diff --git a/ansible_collections/cisco/ise/plugins/action/trustsec_vn_info.py b/ansible_collections/cisco/ise/plugins/action/trustsec_vn_info.py
deleted file mode 100644
index 0029067ea..000000000
--- a/ansible_collections/cisco/ise/plugins/action/trustsec_vn_info.py
+++ /dev/null
@@ -1,141 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# Copyright (c) 2021, Cisco Systems
-# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-from ansible.plugins.action import ActionBase
-
-try:
- from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
- AnsibleArgSpecValidator,
- )
-except ImportError:
- ANSIBLE_UTILS_IS_INSTALLED = False
-else:
- ANSIBLE_UTILS_IS_INSTALLED = True
-from ansible.errors import AnsibleActionFail
-from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
- ISESDK,
- ise_argument_spec,
-)
-
-# Get common arguements specification
-argument_spec = ise_argument_spec()
-# Add arguments specific for this module
-argument_spec.update(dict(
- page=dict(type="int"),
- size=dict(type="int"),
- sort=dict(type="str"),
- sortBy=dict(type="str"),
- filter=dict(type="list"),
- filterType=dict(type="str"),
- id=dict(type="str"),
-))
-
-required_if = []
-required_one_of = []
-mutually_exclusive = []
-required_together = []
-
-
-class ActionModule(ActionBase):
- def __init__(self, *args, **kwargs):
- if not ANSIBLE_UTILS_IS_INSTALLED:
- raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
- super(ActionModule, self).__init__(*args, **kwargs)
- self._supports_async = False
- self._supports_check_mode = True
- self._result = None
-
- # Checks the supplied parameters against the argument spec for this module
- def _check_argspec(self):
- aav = AnsibleArgSpecValidator(
- data=self._task.args,
- schema=dict(argument_spec=argument_spec),
- schema_format="argspec",
- schema_conditionals=dict(
- required_if=required_if,
- required_one_of=required_one_of,
- mutually_exclusive=mutually_exclusive,
- required_together=required_together,
- ),
- name=self._task.action,
- )
- valid, errors, self._task.args = aav.validate()
- if not valid:
- raise AnsibleActionFail(errors)
-
- def get_object(self, params):
- new_object = dict(
- page=params.get("page"),
- size=params.get("size"),
- sort=params.get("sort"),
- sort_by=params.get("sortBy"),
- filter=params.get("filter"),
- filter_type=params.get("filterType"),
- id=params.get("id"),
- )
- return new_object
-
- def run(self, tmp=None, task_vars=None):
- self._task.diff = False
- self._result = super(ActionModule, self).run(tmp, task_vars)
- self._result["changed"] = False
- self._check_argspec()
-
- self._result.update(dict(ise_response=[]))
-
- ise = ISESDK(params=self._task.args)
-
- id = self._task.args.get("id")
- name = self._task.args.get("name")
- if id:
- response = ise.exec(
- family="virtual_network",
- function='get_virtual_network_by_id',
- params=self.get_object(self._task.args)
- ).response['response']
- self._result.update(dict(ise_response=response))
- self._result.update(ise.exit_json())
- return self._result
- if not name and not id:
- responses = []
- generator = ise.exec(
- family="virtual_network",
- function='get_virtual_networks_generator',
- params=self.get_object(self._task.args),
- )
- try:
- for item in generator:
- tmp_response = item.response['response']
- if isinstance(tmp_response, list):
- responses += tmp_response
- else:
- responses.append(tmp_response)
- response = responses
- except (TypeError, AttributeError) as e:
- ise.fail_json(
- msg=(
- "An error occured when executing operation."
- " Check the configuration of your API Settings and API Gateway settings on your ISE server."
- " This collection assumes that the API Gateway, the ERS APIs and OpenAPIs are enabled."
- " You may want to enable the (ise_debug: True) argument."
- " The error was: {error}"
- ).format(error=e)
- )
- except Exception as e:
- ise.fail_json(
- msg=(
- "An error occured when executing operation."
- " The error was: {error}"
- " You may want to enable the (ise_debug: True) argument."
- ).format(error=e)
- )
-
- self._result.update(dict(ise_response=response))
- self._result.update(ise.exit_json())
- return self._result
diff --git a/ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping_bulk_create.py b/ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping_bulk_create.py
deleted file mode 100644
index 361916f3a..000000000
--- a/ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping_bulk_create.py
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# Copyright (c) 2021, Cisco Systems
-# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-from ansible.plugins.action import ActionBase
-
-try:
- from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
- AnsibleArgSpecValidator,
- )
-except ImportError:
- ANSIBLE_UTILS_IS_INSTALLED = False
-else:
- ANSIBLE_UTILS_IS_INSTALLED = True
-from ansible.errors import AnsibleActionFail
-from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
- ISESDK,
- ise_argument_spec,
-)
-
-# Get common arguements specification
-argument_spec = ise_argument_spec()
-# Add arguments specific for this module
-argument_spec.update(dict(
- payload=dict(type="list"),
-))
-
-required_if = []
-required_one_of = []
-mutually_exclusive = []
-required_together = []
-
-
-class ActionModule(ActionBase):
- def __init__(self, *args, **kwargs):
- if not ANSIBLE_UTILS_IS_INSTALLED:
- raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
- super(ActionModule, self).__init__(*args, **kwargs)
- self._supports_async = False
- self._supports_check_mode = False
- self._result = None
-
- # Checks the supplied parameters against the argument spec for this module
- def _check_argspec(self):
- aav = AnsibleArgSpecValidator(
- data=self._task.args,
- schema=dict(argument_spec=argument_spec),
- schema_format="argspec",
- schema_conditionals=dict(
- required_if=required_if,
- required_one_of=required_one_of,
- mutually_exclusive=mutually_exclusive,
- required_together=required_together,
- ),
- name=self._task.action,
- )
- valid, errors, self._task.args = aav.validate()
- if not valid:
- raise AnsibleActionFail(errors)
-
- def get_object(self, params):
- new_object = dict(
- payload=params.get("payload"),
- )
- return new_object
-
- def run(self, tmp=None, task_vars=None):
- self._task.diff = False
- self._result = super(ActionModule, self).run(tmp, task_vars)
- self._result["changed"] = False
- self._check_argspec()
-
- ise = ISESDK(params=self._task.args)
-
- response = ise.exec(
- family="vn_vlan_mapping",
- function="bulk_create_vn_vlan_mappings",
- params=self.get_object(self._task.args),
- ).response
-
- self._result.update(dict(ise_response=response))
- self._result.update(ise.exit_json())
- return self._result
diff --git a/ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping_bulk_delete.py b/ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping_bulk_delete.py
deleted file mode 100644
index 6cb9d9353..000000000
--- a/ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping_bulk_delete.py
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# Copyright (c) 2021, Cisco Systems
-# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-from ansible.plugins.action import ActionBase
-
-try:
- from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
- AnsibleArgSpecValidator,
- )
-except ImportError:
- ANSIBLE_UTILS_IS_INSTALLED = False
-else:
- ANSIBLE_UTILS_IS_INSTALLED = True
-from ansible.errors import AnsibleActionFail
-from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
- ISESDK,
- ise_argument_spec,
-)
-
-# Get common arguements specification
-argument_spec = ise_argument_spec()
-# Add arguments specific for this module
-argument_spec.update(dict(
- payload=dict(type="list"),
-))
-
-required_if = []
-required_one_of = []
-mutually_exclusive = []
-required_together = []
-
-
-class ActionModule(ActionBase):
- def __init__(self, *args, **kwargs):
- if not ANSIBLE_UTILS_IS_INSTALLED:
- raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
- super(ActionModule, self).__init__(*args, **kwargs)
- self._supports_async = False
- self._supports_check_mode = False
- self._result = None
-
- # Checks the supplied parameters against the argument spec for this module
- def _check_argspec(self):
- aav = AnsibleArgSpecValidator(
- data=self._task.args,
- schema=dict(argument_spec=argument_spec),
- schema_format="argspec",
- schema_conditionals=dict(
- required_if=required_if,
- required_one_of=required_one_of,
- mutually_exclusive=mutually_exclusive,
- required_together=required_together,
- ),
- name=self._task.action,
- )
- valid, errors, self._task.args = aav.validate()
- if not valid:
- raise AnsibleActionFail(errors)
-
- def get_object(self, params):
- new_object = dict(
- payload=params.get("payload"),
- )
- return new_object
-
- def run(self, tmp=None, task_vars=None):
- self._task.diff = False
- self._result = super(ActionModule, self).run(tmp, task_vars)
- self._result["changed"] = False
- self._check_argspec()
-
- ise = ISESDK(params=self._task.args)
-
- response = ise.exec(
- family="vn_vlan_mapping",
- function="bulk_delete_vn_vlan_mappings",
- params=self.get_object(self._task.args),
- ).response
-
- self._result.update(dict(ise_response=response))
- self._result.update(ise.exit_json())
- return self._result
diff --git a/ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping_bulk_update.py b/ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping_bulk_update.py
deleted file mode 100644
index fa6f11edd..000000000
--- a/ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping_bulk_update.py
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# Copyright (c) 2021, Cisco Systems
-# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-from ansible.plugins.action import ActionBase
-
-try:
- from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
- AnsibleArgSpecValidator,
- )
-except ImportError:
- ANSIBLE_UTILS_IS_INSTALLED = False
-else:
- ANSIBLE_UTILS_IS_INSTALLED = True
-from ansible.errors import AnsibleActionFail
-from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
- ISESDK,
- ise_argument_spec,
-)
-
-# Get common arguements specification
-argument_spec = ise_argument_spec()
-# Add arguments specific for this module
-argument_spec.update(dict(
- payload=dict(type="list"),
-))
-
-required_if = []
-required_one_of = []
-mutually_exclusive = []
-required_together = []
-
-
-class ActionModule(ActionBase):
- def __init__(self, *args, **kwargs):
- if not ANSIBLE_UTILS_IS_INSTALLED:
- raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
- super(ActionModule, self).__init__(*args, **kwargs)
- self._supports_async = False
- self._supports_check_mode = False
- self._result = None
-
- # Checks the supplied parameters against the argument spec for this module
- def _check_argspec(self):
- aav = AnsibleArgSpecValidator(
- data=self._task.args,
- schema=dict(argument_spec=argument_spec),
- schema_format="argspec",
- schema_conditionals=dict(
- required_if=required_if,
- required_one_of=required_one_of,
- mutually_exclusive=mutually_exclusive,
- required_together=required_together,
- ),
- name=self._task.action,
- )
- valid, errors, self._task.args = aav.validate()
- if not valid:
- raise AnsibleActionFail(errors)
-
- def get_object(self, params):
- new_object = dict(
- payload=params.get("payload"),
- )
- return new_object
-
- def run(self, tmp=None, task_vars=None):
- self._task.diff = False
- self._result = super(ActionModule, self).run(tmp, task_vars)
- self._result["changed"] = False
- self._check_argspec()
-
- ise = ISESDK(params=self._task.args)
-
- response = ise.exec(
- family="vn_vlan_mapping",
- function="bulk_update_vn_vlan_mappings",
- params=self.get_object(self._task.args),
- ).response
-
- self._result.update(dict(ise_response=response))
- self._result.update(ise.exit_json())
- return self._result
diff --git a/ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping_info.py b/ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping_info.py
deleted file mode 100644
index f99235f74..000000000
--- a/ansible_collections/cisco/ise/plugins/action/trustsec_vn_vlan_mapping_info.py
+++ /dev/null
@@ -1,141 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# Copyright (c) 2021, Cisco Systems
-# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-from ansible.plugins.action import ActionBase
-
-try:
- from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
- AnsibleArgSpecValidator,
- )
-except ImportError:
- ANSIBLE_UTILS_IS_INSTALLED = False
-else:
- ANSIBLE_UTILS_IS_INSTALLED = True
-from ansible.errors import AnsibleActionFail
-from ansible_collections.cisco.ise.plugins.plugin_utils.ise import (
- ISESDK,
- ise_argument_spec,
-)
-
-# Get common arguements specification
-argument_spec = ise_argument_spec()
-# Add arguments specific for this module
-argument_spec.update(dict(
- page=dict(type="int"),
- size=dict(type="int"),
- sort=dict(type="str"),
- sortBy=dict(type="str"),
- filter=dict(type="list"),
- filterType=dict(type="str"),
- id=dict(type="str"),
-))
-
-required_if = []
-required_one_of = []
-mutually_exclusive = []
-required_together = []
-
-
-class ActionModule(ActionBase):
- def __init__(self, *args, **kwargs):
- if not ANSIBLE_UTILS_IS_INSTALLED:
- raise AnsibleActionFail("ansible.utils is not installed. Execute 'ansible-galaxy collection install ansible.utils'")
- super(ActionModule, self).__init__(*args, **kwargs)
- self._supports_async = False
- self._supports_check_mode = True
- self._result = None
-
- # Checks the supplied parameters against the argument spec for this module
- def _check_argspec(self):
- aav = AnsibleArgSpecValidator(
- data=self._task.args,
- schema=dict(argument_spec=argument_spec),
- schema_format="argspec",
- schema_conditionals=dict(
- required_if=required_if,
- required_one_of=required_one_of,
- mutually_exclusive=mutually_exclusive,
- required_together=required_together,
- ),
- name=self._task.action,
- )
- valid, errors, self._task.args = aav.validate()
- if not valid:
- raise AnsibleActionFail(errors)
-
- def get_object(self, params):
- new_object = dict(
- page=params.get("page"),
- size=params.get("size"),
- sort=params.get("sort"),
- sort_by=params.get("sortBy"),
- filter=params.get("filter"),
- filter_type=params.get("filterType"),
- id=params.get("id"),
- )
- return new_object
-
- def run(self, tmp=None, task_vars=None):
- self._task.diff = False
- self._result = super(ActionModule, self).run(tmp, task_vars)
- self._result["changed"] = False
- self._check_argspec()
-
- self._result.update(dict(ise_response=[]))
-
- ise = ISESDK(params=self._task.args)
-
- id = self._task.args.get("id")
- name = self._task.args.get("name")
- if id:
- response = ise.exec(
- family="vn_vlan_mapping",
- function='get_vn_vlan_mapping_by_id',
- params=self.get_object(self._task.args)
- ).response['response']
- self._result.update(dict(ise_response=response))
- self._result.update(ise.exit_json())
- return self._result
- if not name and not id:
- responses = []
- generator = ise.exec(
- family="vn_vlan_mapping",
- function='get_vn_vlan_mappings_generator',
- params=self.get_object(self._task.args),
- )
- try:
- for item in generator:
- tmp_response = item.response['response']
- if isinstance(tmp_response, list):
- responses += tmp_response
- else:
- responses.append(tmp_response)
- response = responses
- except (TypeError, AttributeError) as e:
- ise.fail_json(
- msg=(
- "An error occured when executing operation."
- " Check the configuration of your API Settings and API Gateway settings on your ISE server."
- " This collection assumes that the API Gateway, the ERS APIs and OpenAPIs are enabled."
- " You may want to enable the (ise_debug: True) argument."
- " The error was: {error}"
- ).format(error=e)
- )
- except Exception as e:
- ise.fail_json(
- msg=(
- "An error occured when executing operation."
- " The error was: {error}"
- " You may want to enable the (ise_debug: True) argument."
- ).format(error=e)
- )
-
- self._result.update(dict(ise_response=response))
- self._result.update(ise.exit_json())
- return self._result