Skip to content

Commit

Permalink
2.18.3:
Browse files Browse the repository at this point in the history
    changes:
      bugfixes:
        - Ansible utils requirements updated.
        - cisco.meraki.networks_switch_stacks delete stack not working, fixing path parameters.
        - cisco.meraki.networks_clients_info - incorrect API endpoint, fixing info module.
  • Loading branch information
fmunozmiranda committed Oct 16, 2024
1 parent c1f789c commit 5ee9ff4
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Other versions of this collection have support for previous Cisco Meraki version
| Cisco Meraki version | Ansible "cisco.meraki" version | Python "DashboardAPI" version |
|--------------------------|------------------------------|-------------------------------|
| 1.33.0 | 2.17.0 |1.33.0 |
| 1.44.1 | 2.18.2 |1.44.1 |
| 1.44.1 | 2.18.3 |1.44.1 |

*Notes*:

Expand Down
8 changes: 7 additions & 1 deletion changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1074,4 +1074,10 @@ releases:
2.18.2:
changes:
minor_changes:
- Include networks_appliance_traffic_shaping_custom_performance_classes_info plugin.
- Include networks_appliance_traffic_shaping_custom_performance_classes_info plugin.
2.18.3:
changes:
bugfixes:
- Ansible utils requirements updated.
- cisco.meraki.networks_switch_stacks delete stack not working, fixing path parameters.
- cisco.meraki.networks_clients_info - incorrect API endpoint, fixing info module.
4 changes: 2 additions & 2 deletions galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: cisco
name: meraki
version: 2.18.2
version: 2.18.3
readme: README.md
authors:
- Francisco Muñoz <[email protected]>
Expand All @@ -18,7 +18,7 @@ tags:
- networking
- sdn
dependencies:
ansible.utils: ">=2.0.0,<5.0"
ansible.utils: ">=2.0.0,<6.0"
build_ignore:
- docs/_build/
repository: https://github.com/meraki/dashboard-api-ansible
Expand Down
34 changes: 33 additions & 1 deletion playbooks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,36 @@

# - name: Show result
# ansible.builtin.debug:
# msg: "{{ result }}"
# msg: "{{ result }}"

# - name: Create
# cisco.meraki.networks_switch_stacks:
# state: present
# meraki_suppress_logging: false
# name: A cool stack
# networkId: "{{network_id}}"
# serials:
# - QBSB-BNH2-KDXJ

- name: Get all networks _clients
cisco.meraki.networks_clients_info:
# t0: string
meraki_suppress_logging: false
timespan: 1
perPage: 3
# startingAfter: string
# endingBefore: string
# statuses: []
# ip: string
# ip6: string
# ip6Local: string
# mac: string
# os: string
# pskGroup: string
# description: string
# vlan: string
# recentDeviceConnections: []
networkId: L_828099381482771185
total_pages: -1
direction: next
register: result
84 changes: 80 additions & 4 deletions plugins/action/networks_clients_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@
# Add arguments specific for this module
argument_spec.update(dict(
networkId=dict(type="str"),
t0=dict(type="str"),
timespan=dict(type="float"),
perPage=dict(type="int"),
total_pages=dict(type="int"),
direction=dict(type="str"),
startingAfter=dict(type="str"),
endingBefore=dict(type="str"),
statuses=dict(type="list"),
ip=dict(type="str"),
ip6=dict(type="str"),
ip6Local=dict(type="str"),
mac=dict(type="str"),
os=dict(type="str"),
pskGroup=dict(type="str"),
description=dict(type="str"),
vlan=dict(type="str"),
recentDeviceConnections=dict(type="list"),
clientId=dict(type="str"),
))

Expand Down Expand Up @@ -73,6 +90,63 @@ def get_object(self, params):
"clientId")
return new_object

def get_all(self, params):
new_object = {}
if params.get("networkId") is not None:
new_object["networkId"] = params.get(
"networkId")
if params.get("t0") is not None:
new_object["t0"] = params.get(
"t0")
if params.get("timespan") is not None:
new_object["timespan"] = params.get(
"timespan")
if params.get("perPage") is not None:
new_object["perPage"] = params.get(
"perPage")
new_object['total_pages'] = params.get(
"total_pages") or 1
new_object['direction'] = params.get(
"direction") or "next"
if params.get("startingAfter") is not None:
new_object["startingAfter"] = params.get(
"startingAfter")
if params.get("endingBefore") is not None:
new_object["endingBefore"] = params.get(
"endingBefore")
if params.get("statuses") is not None:
new_object["statuses"] = params.get(
"statuses")
if params.get("ip") is not None:
new_object["ip"] = params.get(
"ip")
if params.get("ip6") is not None:
new_object["ip6"] = params.get(
"ip6")
if params.get("ip6Local") is not None:
new_object["ip6Local"] = params.get(
"ip6Local")
if params.get("mac") is not None:
new_object["mac"] = params.get(
"mac")
if params.get("os") is not None:
new_object["os"] = params.get(
"os")
if params.get("pskGroup") is not None:
new_object["pskGroup"] = params.get(
"pskGroup")
if params.get("description") is not None:
new_object["description"] = params.get(
"description")
if params.get("vlan") is not None:
new_object["vlan"] = params.get(
"vlan")
if params.get("recentDeviceConnections") is not None:
new_object["recentDeviceConnections"] = params.get(
"recentDeviceConnections")

return new_object

def run(self, tmp=None, task_vars=None):
self._task.diff = False
self._result = super(ActionModule, self).run(tmp, task_vars)
Expand All @@ -94,9 +168,11 @@ def run(self, tmp=None, task_vars=None):
self._result.update(meraki.exit_json())
return self._result
if not id:
# NOTE: Does not have a get all method or it is in another action
response = None
meraki.object_modify_result(changed=False, result="Module does not have get all, check arguments of module")
response = meraki.exec_meraki(
family="networks",
function='getNetworkClients',
params=self.get_all(self._task.args),
)
self._result.update(dict(meraki_response=response))
self._result.update(meraki.exit_json())
return self._result
return self._result
6 changes: 3 additions & 3 deletions plugins/action/networks_switch_stacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def exists(self):
name_exists = prev_obj is not None and isinstance(prev_obj, dict)
if name_exists:
_id = prev_obj.get("id")
_id = _id or prev_obj.get("switchStackId")
_id = _id or prev_obj.get("switchStackId") or prev_obj.get("switch_stack_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")
Expand Down Expand Up @@ -188,15 +188,15 @@ def create(self):

def delete(self):
id = self.new_object.get("id")
id = id or self.new_object.get("switchStackId")
id = id or self.new_object.get("switchStackId") or self.new_object.get("switch_stack_id")
name = self.new_object.get("name")
result = None
if not id:
prev_obj_name = self.get_object_by_name(name)
id_ = None
if prev_obj_name:
id_ = prev_obj_name.get("id")
id_ = id_ or prev_obj_name.get("switchStackId")
id_ = id_ or prev_obj_name.get("switchStackId") or prev_obj_name.get("switch_stack_id")
if id_:
self.new_object.update(dict(switchstackid=id_))
result = self.meraki.exec_meraki(
Expand Down
125 changes: 125 additions & 0 deletions plugins/modules/networks_clients_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
module: networks_clients_info
short_description: Information module for networks _clients
description:
- Get all networks _clients.
- Get networks _clients by id.
- List the clients that have used this network in the timespan.
- >
Return the client associated with the given identifier. Clients can be identified by a client key or either the
MAC or IP depending on whether the network uses Track-by-IP.
version_added: '2.16.0'
extends_documentation_fragment:
- cisco.meraki.module_info
- cisco.meraki.module_info_pagination
author: Francisco Munoz (@fmunoz)
options:
headers:
Expand All @@ -25,6 +28,79 @@
description:
- NetworkId path parameter. Network ID.
type: str
t0:
description:
- T0 query parameter. The beginning of the timespan for the data. The maximum lookback period is 31 days from today.
type: str
timespan:
description:
- >
Timespan query parameter. The timespan for which the information will be fetched. If specifying timespan, do
not specify parameter t0. The value must be in seconds and be less than or equal to 31 days. The default is
1 day.
type: float
perPage:
description:
- PerPage query parameter. The number of entries per page returned. Acceptable range is 3 - 1000. Default is 10.
type: int
startingAfter:
description:
- >
StartingAfter query parameter. A token used by the server to indicate the start of the page. Often this is a
timestamp or an ID but it is not limited to those. This parameter should not be defined by client
applications. The link for the first, last, prev, or next page in the HTTP Link header should define it.
type: str
endingBefore:
description:
- >
EndingBefore query parameter. A token used by the server to indicate the end of the page. Often this is a
timestamp or an ID but it is not limited to those. This parameter should not be defined by client
applications. The link for the first, last, prev, or next page in the HTTP Link header should define it.
type: str
statuses:
description:
- Statuses query parameter. Filters clients based on status. Can be one of 'Online' or 'Offline'.
elements: str
type: list
ip:
description:
- Ip query parameter. Filters clients based on a partial or full match for the ip address field.
type: str
ip6:
description:
- Ip6 query parameter. Filters clients based on a partial or full match for the ip6 address field.
type: str
ip6Local:
description:
- Ip6Local query parameter. Filters clients based on a partial or full match for the ip6Local address field.
type: str
mac:
description:
- Mac query parameter. Filters clients based on a partial or full match for the mac address field.
type: str
os:
description:
- Os query parameter. Filters clients based on a partial or full match for the os (operating system) field.
type: str
pskGroup:
description:
- PskGroup query parameter. Filters clients based on partial or full match for the iPSK name field.
type: str
description:
description:
- Description query parameter. Filters clients based on a partial or full match for the description field.
type: str
vlan:
description:
- Vlan query parameter. Filters clients based on the full match for the VLAN field.
type: str
recentDeviceConnections:
description:
- >
RecentDeviceConnections query parameter. Filters clients based on recent connection type. Can be one of
'Wired' or 'Wireless'.
elements: str
type: list
clientId:
description:
- ClientId path parameter. Client ID.
Expand All @@ -36,15 +112,63 @@
- name: Cisco Meraki documentation for networks getNetworkClient
description: Complete reference of the getNetworkClient API.
link: https://developer.cisco.com/meraki/api-v1/#!get-network-client
- name: Cisco Meraki documentation for networks getNetworkClients
description: Complete reference of the getNetworkClients API.
link: https://developer.cisco.com/meraki/api-v1/#!get-network-clients
notes:
- SDK Method used are
networks.Networks.get_network_client,
networks.Networks.get_network_clients,
- Paths used are
get /networks/{networkId}/clients,
get /networks/{networkId}/clients/{clientId},
"""

EXAMPLES = r"""
- name: Get all networks _clients
cisco.meraki.networks_clients_info:
meraki_api_key: "{{meraki_api_key}}"
meraki_base_url: "{{meraki_base_url}}"
meraki_single_request_timeout: "{{meraki_single_request_timeout}}"
meraki_certificate_path: "{{meraki_certificate_path}}"
meraki_requests_proxy: "{{meraki_requests_proxy}}"
meraki_wait_on_rate_limit: "{{meraki_wait_on_rate_limit}}"
meraki_nginx_429_retry_wait_time: "{{meraki_nginx_429_retry_wait_time}}"
meraki_action_batch_retry_wait_time: "{{meraki_action_batch_retry_wait_time}}"
meraki_retry_4xx_error: "{{meraki_retry_4xx_error}}"
meraki_retry_4xx_error_wait_time: "{{meraki_retry_4xx_error_wait_time}}"
meraki_maximum_retries: "{{meraki_maximum_retries}}"
meraki_output_log: "{{meraki_output_log}}"
meraki_log_file_prefix: "{{meraki_log_file_prefix}}"
meraki_log_path: "{{meraki_log_path}}"
meraki_print_console: "{{meraki_print_console}}"
meraki_suppress_logging: "{{meraki_suppress_logging}}"
meraki_simulate: "{{meraki_simulate}}"
meraki_be_geo_id: "{{meraki_be_geo_id}}"
meraki_caller: "{{meraki_caller}}"
meraki_use_iterator_for_get_pages: "{{meraki_use_iterator_for_get_pages}}"
meraki_inherit_logging_config: "{{meraki_inherit_logging_config}}"
t0: string
timespan: 0
perPage: 0
startingAfter: string
endingBefore: string
statuses: []
ip: string
ip6: string
ip6Local: string
mac: string
os: string
pskGroup: string
description: string
vlan: string
recentDeviceConnections: []
networkId: string
total_pages: -1
direction: next
register: result
- name: Get networks _clients by id
cisco.meraki.networks_clients_info:
meraki_api_key: "{{meraki_api_key}}"
Expand All @@ -65,6 +189,7 @@
meraki_suppress_logging: "{{meraki_suppress_logging}}"
meraki_simulate: "{{meraki_simulate}}"
meraki_be_geo_id: "{{meraki_be_geo_id}}"
meraki_caller: "{{meraki_caller}}"
meraki_use_iterator_for_get_pages: "{{meraki_use_iterator_for_get_pages}}"
meraki_inherit_logging_config: "{{meraki_inherit_logging_config}}"
networkId: string
Expand Down

1 comment on commit 5ee9ff4

@fmunozmiranda
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#67

Please sign in to comment.