Skip to content

Commit

Permalink
Added ability to only get info for a single switch node and added dyn…
Browse files Browse the repository at this point in the history
…amic load balancing attribute to switch
  • Loading branch information
Edsall committed Mar 31, 2015
1 parent e34b97c commit 5734447
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions acitoolkit/aciphysobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,7 @@ def __init__(self, pod=None, node=None, name=None, role=None, parent=None):
self.vpc_info = None
self.v4_proxy_ip = None
self.mac_proxy_ip = None
self.dynamic_load_balancing = None

logging.debug('Creating %s %s', self.__class__.__name__, 'pod-' +
str(self.pod) + '/node-' + str(self.node))
Expand Down Expand Up @@ -1044,7 +1045,11 @@ def get(session, parent=None, node_id=None):
if parent:
if not isinstance(parent, Pod) and not isinstance(parent, str):
raise TypeError('An instance of Pod class or string is required to specify pod')

else:
if isinstance(parent, Pod):
pod_id = parent.pod
else:
pod_id = parent
if node_id:
if not isinstance(node_id, str):
raise TypeError('The node_id must be a string such as "101".')
Expand All @@ -1054,8 +1059,10 @@ def get(session, parent=None, node_id=None):

if node_id :
# this can be enhanced to get a specific node
node_query_url = ('/api/node/class/fabricNode.json?'
'query-target=self')
node_dn = 'topology/pod-{0}/node-{1}'.format(pod_id, node_id)
node_query_url = '/api/mo/'+node_dn+ '.json?query-target=self'
# node_query_url = ('/api/node/class/fabricNode.json?'
# 'query-target=self')
else :
node_query_url = ('/api/node/class/fabricNode.json?'
'query-target=self')
Expand All @@ -1073,7 +1080,7 @@ def get(session, parent=None, node_id=None):
node._session = session
node._populate_from_attributes(apic_node['fabricNode']['attributes'])
node._get_topsystem_info()

# check for pod match if specified
pod_match = False
if parent:
Expand Down Expand Up @@ -1276,6 +1283,27 @@ def _get_topsystem_info(self):
if slot['eqptSupCSlot']['attributes']['operSt']=='inserted' :
self.num_sup_modules +=1

# get dynamic load balancing config
mo_query_url = '/api/mo/' + self.dn + '/sys.json?query-target=subtree&target-subtree-class=topoctrlLbP'
ret = self._session.get(mo_query_url)
lb_data = ret.json()['imdata']
self.dynamic_load_balancing_mode = 'unknown'

for lb_info in lb_data:
if 'topoctrlLbP' in lb_info:
self.dynamic_load_balancing_mode = lb_info['topoctrlLbP']['attributes']['dlbMode']

# get dynamic load balancing config
mo_query_url = '/api/mo/' + self.dn + '/sys.json?query-target=subtree&target-subtree-class=topoVxlanP'
ret = self._session.get(mo_query_url)
data = ret.json()['imdata']
self.ivxlan_udp_port = 'unknown'

for info in data:
if 'topoctrlVxlanP' in info:
self.ivxlan_udp_port = info['topoctrVxlanP']['attributes']['udpPort']




def populate_children(self, deep=False):
Expand Down

0 comments on commit 5734447

Please sign in to comment.