Skip to content
Snippets Groups Projects
Commit 91572be9 authored by Robert Latta's avatar Robert Latta
Browse files

added bundle(e.g. ae10) interface is a member of

parent c99e4212
Branches
Tags
No related merge requests found
...@@ -213,12 +213,16 @@ def list_interfaces(netconf_config): ...@@ -213,12 +213,16 @@ def list_interfaces(netconf_config):
assert name is not None, "expected interface 'name' child element" assert name is not None, "expected interface 'name' child element"
ifc = { ifc = {
'name': name.text, 'name': name.text,
'description': '' 'description': '',
'bundle': []
} }
description = e.find('description') description = e.find('description')
if description is not None: if description is not None:
ifc['description'] = description.text ifc['description'] = description.text
for b in i.iterfind(".//bundle"):
ifc['bundle'].append(b.text)
ifc['ipv4'] = e.xpath('./family/inet/address/name/text()') ifc['ipv4'] = e.xpath('./family/inet/address/name/text()')
ifc['ipv6'] = e.xpath('./family/inet6/address/name/text()') ifc['ipv6'] = e.xpath('./family/inet6/address/name/text()')
......
...@@ -337,10 +337,23 @@ def refresh_juniper_interface_list(hostname, netconf): ...@@ -337,10 +337,23 @@ def refresh_juniper_interface_list(hostname, netconf):
for k in r.keys('netconf-interfaces:%s:*' % hostname): for k in r.keys('netconf-interfaces:%s:*' % hostname):
r.delete(k) r.delete(k)
for k in r.keys('netconf-interface-bundles:%s:*' % hostname):
r.delete(k)
all_bundles = defaultdict(list)
for ifc in juniper.list_interfaces(netconf): for ifc in juniper.list_interfaces(netconf):
bundles = ifc.get('bundle', None)
for bundle in bundles:
if bundle:
all_bundles[bundle].append(ifc['name'])
r.set( r.set(
'netconf-interfaces:%s:%s' % (hostname, ifc['name']), 'netconf-interfaces:%s:%s' % (hostname, ifc['name']),
json.dumps(ifc)) json.dumps(ifc))
for k, v in all_bundles.items():
r.set(
'netconf-interface-bundles:%s:%s' % (hostname, k),
json.dumps(v))
@app.task(base=InventoryTask, bind=True) @app.task(base=InventoryTask, bind=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment