def searchMacEp(session, mac, ip): EPs = [] MAC = mac.translate(None, ',.-:').lower() if ip: try: clsQuery = session.md.lookupByClass('fvCEp', subtree='full', subtreeClassFilter='fvCEp,fvRsCEpToPathEp,fvIp,fvRsHyper,fvRsToNic,fvRsToVm', propFilter='and(eq(fvCEp.mac, "{}")eq(fvCEp.ip, "{}"))'.format(MAC, ip)) except ValueError as e: sys.exit() else: try: clsQuery = session.md.lookupByClass('fvCEp', subtree='full', subtreeClassFilter='fvCEp,fvRsCEpToPathEp,fvIp,fvRsHyper,fvRsToNic,fvRsToVm', propFilter='eq(fvCEp.mac, "{}")'.format(MAC)) except ValueError as e: sys.exit() for obj in clsQuery: EP = {} EP['mac'] = obj.mac EP['ip'] = obj.ip EP['encap'] = obj.encap if session.debug_flag: printJSON(obj, pretty=True) for child in obj.children: if child.__class__.__name__ == 'RsCEpToPathEp': node, port, vpc = cli_lib.getNodePort(str(child.tDn)) EP['node'] = node EP['port'] = port EP['vpc'] = vpc EPs.append(EP) return EPs
def searchIpEp(session, ip): if cli_lib.if_ip(ip): EPs = [] clsQuery = session.md.lookupByClass('fvCEp', subtree='full', subtreeInclude='required', subtreeClassFilter='fvIp', subtreePropFilter='eq(fvIp.addr, "{}")'.format(ip)) for obj in clsQuery: EP = searchMacEp(session, obj.mac, ip) EPs = EPs + EP return EPs else: EPs = [] print ('Wildcard search by IP: {}'.format(ip)) clsQuery = session.md.lookupByClass('fvIp', propFilter='and(wcard(fvIp.rn, "{}"))'.format(ip), ) for obj in clsQuery: EP = {} try: dnQuery = session.md.lookupByDn(obj.parentDn) nodeInfo = session.md.lookupByClass('fvRsCEpToPathEp', parentDn=obj.parentDn) except ValueError as e: continue for node in nodeInfo: if session.debug_flag: printJSON(obj, pretty=True) printJSON(dnQuery, pretty=True) printJSON(node, pretty=True) EP = {} EP['ip'] = dnQuery.ip EP['mac'] = dnQuery.mac EP['encap'] = dnQuery.encap node, port, vpc = cli_lib.getNodePort(str(node.tDn)) EP['node'] = node EP['port'] = port EP['vpc'] = vpc EPs.append(EP) return EPs
def print_json(self, verbose_flag=None, pretty=False): printJSON(self.obj, pretty=pretty) if verbose_flag and len(self.epgs) > 0: for epg in self.epgs: printJSON(epg.obj, pretty=True) if verbose_flag and len(self.ppgs) > 0: for ppg in self.ppgs: printJSON(ppg.obj, pretty=True)
def print_json(self, verbose_flag=None, pretty=False): printJSON(self.obj, pretty=pretty)
def print_json(self, verbose_flag=None, pretty=False): printJSON(self.obj, pretty=pretty) if verbose_flag and len(self.ports) > 0: for port in self.ports: port.print_json()
def print_json(self, verbose_flag=None, pretty=False): if self.physObj: printJSON(self.physObj, pretty=pretty) if self.logicalObj: printJSON(self.logicalObj, pretty=pretty)
def print_json(self, verbose_flag=None, pretty=False): printJSON(self.obj, pretty=pretty) if verbose_flag: for ep in self.eps: ep.pp(verbose_flag=verbose_flag, json_flag=True, pretty=pretty)
def print_json(self, verbose_flag=None): printJSON(self.obj, pretty=True)