Coverage for plugins/modules/meraki_mx_uplink.py : 66%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
#!/usr/bin/python # -*- coding: utf-8 -*-
# Copyright: (c) 2019, Kevin Breit (@kbreit) <kevin.breit@kevinbreit.net> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community' }
--- module: meraki_mx_uplink short_description: Manage uplinks on Meraki MX appliances version_added: "2.9" description: - Configure and query information about uplinks on Meraki MX appliances. notes: - Some of the options are likely only used for developers within Meraki. options: state: description: - Specifies whether object should be queried, created/modified, or removed. choices: [absent, present, query] default: query type: str org_name: description: - Name of organization associated to a network. type: str org_id: description: - ID of organization associated to a network. type: str net_name: description: - Name of network which VLAN is in or should be in. aliases: [network] type: str net_id: description: - ID of network which VLAN is in or should be in. type: str wan1: description: - Configuration of WAN1 uplink type: dict suboptions: bandwidth_limits: description: - Structure for configuring bandwidth limits type: dict suboptions: limit_up: description: - Maximum upload speed for interface type: int limit_down: description: - Maximum download speed for interface type: int wan2: description: - Configuration of WAN2 uplink type: dict suboptions: bandwidth_limits: description: - Structure for configuring bandwidth limits type: dict suboptions: limit_up: description: - Maximum upload speed for interface type: int limit_down: description: - Maximum download speed for interface type: int cellular: description: - Configuration of cellular uplink type: dict suboptions: bandwidth_limits: description: - Structure for configuring bandwidth limits type: dict suboptions: limit_up: description: - Maximum upload speed for interface type: int limit_down: description: - Maximum download speed for interface type: int author: - Kevin Breit (@kbreit) extends_documentation_fragment: meraki '''
- name: Set MX uplink settings meraki_mx_uplink: auth_key: '{{auth_key}}' state: present org_name: '{{test_org_name}}' net_name: '{{test_net_name}} - Uplink' wan1: bandwidth_limits: limit_down: 1000000 limit_up: 1000 cellular: bandwidth_limits: limit_down: 0 limit_up: 0 delegate_to: localhost
- name: Query MX uplink settings meraki_mx_uplink: auth_key: '{{auth_key}}' state: query org_name: '{{test_org_name}}' net_name: '{{test_net_name}} - Uplink' delegate_to: localhost
'''
data: description: Information about the organization which was created or modified returned: success type: complex contains: wan1: description: WAN1 interface returned: success type: complex contains: bandwidth_limits: description: Structure for uplink bandwidth limits returned: success type: complex contains: limit_up: description: Upload bandwidth limit returned: success type: int limit_down: description: Download bandwidth limit returned: success type: int wan2: description: WAN2 interface returned: success type: complex contains: bandwidth_limits: description: Structure for uplink bandwidth limits returned: success type: complex contains: limit_up: description: Upload bandwidth limit returned: success type: int limit_down: description: Download bandwidth limit returned: success type: int cellular: description: cellular interface returned: success type: complex contains: bandwidth_limits: description: Structure for uplink bandwidth limits returned: success type: complex contains: limit_up: description: Upload bandwidth limit returned: success type: int limit_down: description: Download bandwidth limit returned: success type: int '''
from ansible.module_utils.network.meraki.meraki import MerakiModule, meraki_argument_spec
INT_NAMES = ('wan1', 'wan2', 'cellular')
return data
'limit_down': data['bandwidthLimits'][interface]['limitDown'], } } # return snake_dict_to_camel_dict(new_struct) return new_struct
def main(): # define the available arguments/parameters that a user can pass to # the module
limit_down=dict(type='int'), )
interface_arg_spec = dict(bandwidth_limits=dict(type='dict', default=None, options=bandwidth_arg_spec), )
net_name=dict(type='str', aliases=['network']), net_id=dict(type='str'), wan1=dict(type='dict', default=None, options=interface_arg_spec), wan2=dict(type='dict', default=None, options=interface_arg_spec), cellular=dict(type='dict', default=None, options=interface_arg_spec), )
# the AnsibleModule object will be our abstraction working with Ansible # this includes instantiation, a couple of common attr would be the # args/params passed to the execution, as well as if the module # supports check mode supports_check_mode=True, ) meraki = MerakiModule(module, function='mx_uplink')
meraki.params['follow_redirects'] = 'all'
meraki.url_catalog['update_bw'] = update_bw_url
payload = dict()
if org_id is None: if net_id is None: net_id = meraki.get_net_id(net_name=meraki.params['net_name'], data=nets)
path = meraki.construct_path('get_all', net_id=net_id) 'limitDown': meraki.params[interface]['bandwidth_limits']['limit_down'], } clean_custom_format(meraki_struct_to_custom_format(payload))) 'after': diff[1], } formatted_response = clean_custom_format(meraki_struct_to_custom_format(response)) 'after': diff[1], } else:
# in the event of a successful module execution, you will want to # simple AnsibleModule.exit_json(), passing the key/value results
main() |