Meraki module utility - get_net() downloads networks if data isn't provided (#41423)
* Enable get_net() to download nets if data isn't provided - Currently, get_net() requires data to be passed to it - PR enables get_net() to download all networks if data isn't passed - Slightly simpler code - Best practice is to download nets early in execution * Apply fixes related to get_net() * Removed extra code from the rebase
This commit is contained in:
parent
eeada86554
commit
ca5f9aab1e
2 changed files with 12 additions and 15 deletions
|
@ -211,20 +211,17 @@ class MerakiModule(object):
|
||||||
self.nets.append(t)
|
self.nets.append(t)
|
||||||
return self.nets
|
return self.nets
|
||||||
|
|
||||||
def get_net(self, org_name, net_name, data=None):
|
# def get_net(self, org_name, net_name, data=None):
|
||||||
"""Return network information about a particular network."""
|
# path = self.construct_path('get_all', function='network', org_id=org_id)
|
||||||
# TODO: Allow method to download data on its own
|
# r = self.request(path, method='GET')
|
||||||
# if not data:
|
# return r
|
||||||
# org_id = self.get_org_id(org_name)
|
|
||||||
# path = '/organizations/{org_id}/networks/{net_id}'.format(
|
def get_net(self, org_name, net_name, org_id=None, data=None):
|
||||||
# org_id=org_id,
|
''' Return network information '''
|
||||||
# net_id=self.get_net_id(
|
if not data:
|
||||||
# org_name=org_name,
|
if not org_id:
|
||||||
# net_name=net_name,
|
org_id = self.get_org_id(org_name)
|
||||||
# data=data)
|
data = self.get_nets(org_id=org_id)
|
||||||
# )
|
|
||||||
# return json.loads(self.request('GET', path))
|
|
||||||
# else:
|
|
||||||
for n in data:
|
for n in data:
|
||||||
if n['name'] == net_name:
|
if n['name'] == net_name:
|
||||||
return n
|
return n
|
||||||
|
|
|
@ -206,7 +206,7 @@ def main():
|
||||||
elif meraki.params['net_name'] or meraki.params['net_id'] is not None:
|
elif meraki.params['net_name'] or meraki.params['net_id'] is not None:
|
||||||
meraki.result['data'] = meraki.get_net(meraki.params['org_name'],
|
meraki.result['data'] = meraki.get_net(meraki.params['org_name'],
|
||||||
meraki.params['net_name'],
|
meraki.params['net_name'],
|
||||||
nets
|
data=nets
|
||||||
)
|
)
|
||||||
elif meraki.params['state'] == 'present':
|
elif meraki.params['state'] == 'present':
|
||||||
if meraki.params['net_name']: # FIXME: Idempotency check is ugly here, improve
|
if meraki.params['net_name']: # FIXME: Idempotency check is ugly here, improve
|
||||||
|
|
Loading…
Reference in a new issue