Add properties for orgs and nets (#42085)

- Module utility now has orgs, nets, org_id, and net_id properties
- get_nets and get_orgs sets nets and orgs properties respectively
- Allows for storage of this data in the module. org_id and net_id aren’t set as I cannot guarantee that’s always desired.
This commit is contained in:
Kevin Breit 2018-07-03 03:23:12 -05:00 committed by Dag Wieers
parent 08ddd202fb
commit 05f7d64a98

View file

@ -56,6 +56,10 @@ class MerakiModule(object):
self.result = dict(changed=False) self.result = dict(changed=False)
self.headers = dict() self.headers = dict()
self.function = function self.function = function
self.orgs = None
self.nets = None
self.org_id = None
self.net_id = None
# normal output # normal output
self.existing = None self.existing = None
@ -153,7 +157,8 @@ class MerakiModule(object):
response = self.request('/organizations', method='GET') response = self.request('/organizations', method='GET')
if self.status != 200: if self.status != 200:
self.fail_json(msg='Organization lookup failed') self.fail_json(msg='Organization lookup failed')
return response self.orgs = self.request('/organizations', method='GET')
return self.orgs
def is_org_valid(self, data, org_name=None, org_id=None): def is_org_valid(self, data, org_name=None, org_id=None):
"""Checks whether a specific org exists and is duplicated. """Checks whether a specific org exists and is duplicated.
@ -200,7 +205,8 @@ class MerakiModule(object):
r = self.request(path, method='GET') r = self.request(path, method='GET')
if self.status != 200: if self.status != 200:
self.fail_json(msg='Network lookup failed') self.fail_json(msg='Network lookup failed')
return r self.nets = self.request(path, method='GET')
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.""" """Return network information about a particular network."""