Skip to content

Commit 5cc9d43

Browse files
author
Kevin Corbin
committed
add ability to get interfaces by specifying node
1 parent 2186edc commit 5cc9d43

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

acitoolkit/aciphysobject.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2531,6 +2531,9 @@ def get(cls, session, pod_parent=None, node=None, module=None, port=None):
25312531
If the pod, node, module and port are specified, then only that
25322532
specific interface is read.
25332533
2534+
If the pod and node are specified, then only those interfaces are
2535+
read
2536+
25342537
:param session: the instance of Session used for APIC communication
25352538
:param pod_parent: Linecard instance to limit interfaces or pod\
25362539
number (optional)
@@ -2558,9 +2561,14 @@ def get(cls, session, pod_parent=None, node=None, module=None, port=None):
25582561
if not isinstance(pod_parent, str):
25592562
raise TypeError(('When specifying a specific port, the pod '
25602563
'must be identified by a string'))
2564+
# Handle case where only node is specified
2565+
elif node:
2566+
if not isinstance(pod_parent, str):
2567+
raise TypeError(('When specifying a specific node, the pod '
2568+
'must be identified by a string'))
25612569
else:
25622570
if pod_parent:
2563-
if not isinstance(pod_parent, cls._get_parent_class()):
2571+
if not isinstance(pod_parent, str):
25642572
raise TypeError('Interface parent must be a {0} object'.format(cls._get_parent_class()))
25652573

25662574
cdp_policies = Interface._get_discoveryprot_policies(session, 'cdp')
@@ -2570,6 +2578,12 @@ def get(cls, session, pod_parent=None, node=None, module=None, port=None):
25702578
dist_name = 'topology/pod-{0}/node-{1}/sys/phys-[eth{2}/{3}]'.format(pod_parent, node, module, port)
25712579
interface_query_url = ('/api/mo/' + dist_name + '.json?query-target=self')
25722580
eth_query_url = ('/api/mo/' + dist_name + '/phys.json?query-target=self')
2581+
# add the case where we return all of the ports of a given node
2582+
elif node:
2583+
dist_name = 'topology/pod-1/node-{0}/sys'.format(node)
2584+
interface_query_url = ('/api/mo/' + dist_name + '.json?query-target=children&target-subtree-class=l1PhysIf')
2585+
eth_query_url = ('/api/mo/' + dist_name + '.json?query-target=subtree&target-subtree-class=ethpmPhysIf')
2586+
25732587
else:
25742588
interface_query_url = '/api/node/class/l1PhysIf.json?query-target=self'
25752589
eth_query_url = '/api/node/class/ethpmPhysIf.json?query-target=self'

0 commit comments

Comments
 (0)