def showTopologies(self): """ Description Show the NGPF configuration: Topology Groups, Device Groups, Mac Addreseses, VLAN ID, IPv4, IPv6, protocol sessions. """ queryData = {'from': '/', 'nodes': [{'node': 'topology', 'properties': ['name', 'status', 'vports', 'ports'], 'where': []}, {'node': 'deviceGroup', 'properties': ['name', 'status'], 'where': []}, {'node': 'networkGroup','properties': ['name', 'multiplier'], 'where': []}, {'node': 'ethernet', 'properties': ['name', 'status', 'sessionStatus', 'enableVlans', 'mac'], 'where': []}, {'node': 'vlan', 'properties': ['name', 'vlanId', 'priority'], 'where': []}, {'node': 'ipv4', 'properties': ['name', 'status', 'sessionStatus', 'address', 'gatewayIp', 'prefix'], 'where': []}, {'node': 'ipv6', 'properties': ['name', 'status', 'sessionStatus', 'address', 'gatewayIp', 'prefix'], 'where': []}, {'node': 'bgpIpv4Peer', 'properties': ['name', 'status', 'sessionStatus', 'dutIp', 'type', 'localIpv4Ver2', 'localAs2Bytes', 'holdTimer', 'flap', 'uptimeInSec', 'downtimeInSec'], 'where': []}, {'node': 'bgpIpv6Peer', 'properties': ['name', 'status', 'sessionStatus'], 'where': []}, {'node': 'ospfv2', 'properties': ['name', 'status', 'sessionStatus'], 'where': []}, {'node': 'ospfv3', 'properties': ['name', 'status', 'sessionStatus'], 'where': []}, {'node': 'igmpHost', 'properties': ['name', 'status', 'sessionStatus'], 'where': []}, {'node': 'igmpQuerier', 'properties': ['name', 'status', 'sessionStatus'], 'where': []}, {'node': 'vxlan', 'properties': ['name', 'status', 'sessionStatus'], 'where': []}, ] } queryResponse = self.ixnObj.query(data=queryData, silentMode=True) self.ixnObj.logInfo('', timestamp=False) for topology in queryResponse.json()['result'][0]['topology']: self.ixnObj.logInfo('TopologyGroup: {0} Name: {1}'.format(topology['id'], topology['name']), timestamp=False) self.ixnObj.logInfo(' Status: {0}'.format(topology['status']), timestamp=False) buildNumber = float(self.ixnObj.getIxNetworkVersion()[:3]) if buildNumber >= 8.5: vportObjList = topology['ports'] else: vportObjList = topology['vports'] for vportObj in vportObjList: vportResponse = self.ixnObj.get(self.ixnObj.httpHeader+vportObj, silentMode=True) self.ixnObj.logInfo(' VportId: {0} Name: {1} AssignedTo: {2} State: {3}'.format(vportResponse.json()['id'], vportResponse.json()['name'], vportResponse.json()['assignedTo'], vportResponse.json()['state']), timestamp=False) self.ixnObj.logInfo('\n', end='', timestamp=False) for deviceGroup in topology['deviceGroup']: self.ixnObj.logInfo(' DeviceGroup:{0} Name:{1}'.format(deviceGroup['id'], deviceGroup['name']), timestamp=False) self.ixnObj.logInfo('\tStatus: {0}'.format(deviceGroup['status']), end='\n\n', timestamp=False) for ethernet in deviceGroup['ethernet']: ethernetObj = ethernet['href'] ethernetSessionStatus = self.getSessionStatus(ethernetObj) self.ixnObj.logInfo('\tEthernet:{0} Name:{1}'.format(ethernet['id'], ethernet['name']), timestamp=False) self.ixnObj.logInfo('\t Status: {0}'.format(ethernet['status']), timestamp=False) enableVlansResponse = self.ixnObj.get(self.ixnObj.httpHeader+ethernet['enableVlans'], silentMode=True) enableVlansMultivalue = enableVlansResponse.json()['links'][0]['href'] enableVlansValues = self.getMultivalueValues(enableVlansMultivalue, silentMode=True)[0] self.ixnObj.logInfo('\t Vlan enabled: %s\n' % enableVlansValues, timestamp=False) if ethernet['ipv6'] == []: ethernet['ipv6'].insert(0, None) for mac,vlan,ipv4,ipv6 in zip(ethernet['mac'], ethernet['vlan'], ethernet['ipv4'], ethernet['ipv6']): ipv4Obj = ipv4['href'] ipv4SessionStatus = self.getSessionStatus(ipv4Obj) self.ixnObj.logInfo('\tIPv4:{0} Status: {1}'.format(ipv4['id'], ipv4['status']), timestamp=False) macResponse = self.ixnObj.get(self.ixnObj.httpHeader+ethernet['mac'], silentMode=True) macAddress = self.getMultivalueValues(macResponse.json()['links'][0]['href'], silentMode=True) vlanResponse = self.ixnObj.get(self.ixnObj.httpHeader+vlan['vlanId'], silentMode=True) vlanId = self.getMultivalueValues(vlanResponse.json()['links'][0]['href'], silentMode=True) priorityResponse = self.ixnObj.get(self.ixnObj.httpHeader+vlan['priority'], silentMode=True) vlanPriority = self.getMultivalueValues(priorityResponse.json()['links'][0]['href'], silentMode=True) ipResponse = self.ixnObj.get(self.ixnObj.httpHeader+ipv4['address'], silentMode=True) ipAddress = self.getMultivalueValues(ipResponse.json()['links'][0]['href'], silentMode=True) gatewayResponse = self.ixnObj.get(self.ixnObj.httpHeader+ipv4['gatewayIp'], silentMode=True) gateway = self.getMultivalueValues(gatewayResponse.json()['links'][0]['href'], silentMode=True) prefixResponse = self.ixnObj.get(self.ixnObj.httpHeader+ipv4['prefix'], silentMode=True) prefix = self.getMultivalueValues(prefixResponse.json()['links'][0]['href'], silentMode=True) index = 1 self.ixnObj.logInfo('\t {0:8} {1:14} {2:7} {3:9} {4:12} {5:16} {6:12} {7:7} {8:7}'.format('Index', 'MacAddress', 'VlanId', 'VlanPri', 'EthSession', 'IPv4Address', 'Gateway', 'Prefix', 'Ipv4Session'), timestamp=False) self.ixnObj.logInfo('\t {0}'.format('-'*104), timestamp=False) for mac,vlanId,vlanPriority,ethSession,ip,gateway,prefix,ipv4Session in zip(macAddress, vlanId, vlanPriority, ethernetSessionStatus, ipAddress, gateway, prefix, ipv4SessionStatus): self.ixnObj.logInfo('\t {0:^5} {1:18} {2:^6} {3:^9} {4:13} {5:<15} {6:<13} {7:6} {8:7}'.format(index, mac, vlanId, vlanPriority, ethSession, ip, gateway, prefix, ipv4Session), timestamp=False) index += 1 # IPv6 if None not in ethernet['ipv6']: ipResponse = self.ixnObj.get(self.ixnObj.httpHeader+ipv6['address'], silentMode=True) gatewayResponse = self.ixnObj.get(self.ixnObj.httpHeader+ipv6['gatewayIp'], silentMode=True) prefixResponse = self.ixnObj.get(self.ixnObj.httpHeader+ipv6['prefix'], silentMode=True) self.ixnObj.logInfo('\tIPv6:{0} Status: {1}'.format(ipv6['id'], ipv6['status']), timestamp=False) self.ixnObj.logInfo('\t {0:8} {1:14} {2:7} {3:9} {4:12} {5:19} {6:18} {7:7} {8:7}'.format('Index', 'MacAddress', 'VlanId', 'VlanPri', 'EthSession', 'IPv6Address', 'Gateway', 'Prefix', 'Ipv6Session'), timestamp=False) self.ixnObj.logInfo('\t %s' % '-'*113) for mac,vlanId,vlanPriority,ethSession,ip,gateway,prefix,ipv4Session in zip(macResponse.json()['values'], vlanResponse.json()['values'], priorityResponse.json()['values'], ethernet['sessionStatus'], ipResponse.json()['values'], gatewayResponse.json()['values'], prefixResponse.json()['values'], ipv6['sessionStatus']): self.ixnObj.logInfo('\t {0:^5} {1:18} {2:^6} {3:^9} {4:13} {5:<15} {6:<13} {7:8} {8:7}'.format(index, mac, vlanId, vlanPriority, ethSession, ip, gateway, prefix, ipv4Session), timestamp=False) index += 1 self.ixnObj.logInfo('\n', end='', timestamp=False) if ipv4['bgpIpv4Peer'] != []: for bgpIpv4Peer in ipv4['bgpIpv4Peer']: bgpIpv4PeerHref = bgpIpv4Peer['href'] bgpIpv4PeerSessionStatus = self.getSessionStatus(bgpIpv4PeerHref) self.ixnObj.logInfo('\tBGPIpv4Peer:{0} Name:{1}'.format(bgpIpv4Peer['id'], bgpIpv4Peer['name'], bgpIpv4Peer['status']), timestamp=False) dutIpResponse = self.ixnObj.get(self.ixnObj.httpHeader+bgpIpv4Peer['dutIp'], silentMode=True) dutIp = self.getMultivalueValues(dutIpResponse.json()['links'][0]['href'], silentMode=True) typeResponse = self.ixnObj.get(self.ixnObj.httpHeader+bgpIpv4Peer['type'], silentMode=True) typeMultivalue = typeResponse.json()['links'][0]['href'] bgpType = self.getMultivalueValues(typeMultivalue, silentMode=True) localAs2BytesResponse = self.ixnObj.get(self.ixnObj.httpHeader+bgpIpv4Peer['localAs2Bytes'], silentMode=True) localAs2BytesMultivalue = localAs2BytesResponse.json()['links'][0]['href'] localAs2Bytes = self.getMultivalueValues(localAs2BytesMultivalue, silentMode=True) flapResponse = self.ixnObj.get(self.ixnObj.httpHeader+bgpIpv4Peer['flap'], silentMode=True) flap = self.getMultivalueValues(flapResponse.json()['links'][0]['href'], silentMode=True) uptimeResponse = self.ixnObj.get(self.ixnObj.httpHeader+bgpIpv4Peer['uptimeInSec'], silentMode=True) uptime = self.getMultivalueValues(uptimeResponse.json()['links'][0]['href'], silentMode=True) downtimeResponse = self.ixnObj.get(self.ixnObj.httpHeader+bgpIpv4Peer['downtimeInSec'], silentMode=True) downtime = self.getMultivalueValues(downtimeResponse.json()['links'][0]['href'], silentMode=True) self.ixnObj.logInfo('\t Type: {0} localAs2Bytes: {1}'.format(bgpType[0], localAs2Bytes[0]), timestamp=False) self.ixnObj.logInfo('\t Status: {0}'.format(bgpIpv4Peer['status']), timestamp=False) index = 1 for dutIp,bgpSession,flap,uptime,downtime in zip(dutIp, bgpIpv4PeerSessionStatus, flap, uptime, downtime): self.ixnObj.logInfo('\t\t{0}: DutIp:{1} SessionStatus:{2} Flap:{3} upTime:{4} downTime:{5}'.format(index, dutIp, bgpSession, flap, uptime, downtime), timestamp=False) index += 1 for ospfv2 in ipv4['ospfv2']: self.ixnObj.logInfo('\t OSPFv2:{0} Name:{1}'.format(ospfv2['id'], ospfv2['name'], ospfv2['status']), timestamp=False) self.ixnObj.logInfo('\t\tStatus: {0}'.format(ospfv2['status']), end='\n\n', timestamp=False) for igmpHost in ipv4['igmpHost']: self.ixnObj.logInfo('\t igmpHost:{0} Name:{1}'.format(igmpHost['id'], igmpHost['name'], igmpHost['status']), timestamp=False) self.ixnObj.logInfo('\t\tStatus: {0}'.format(igmpHost['status']), end='\n\n', timestamp=False) for igmpQuerier in ipv4['igmpQuerier']: self.ixnObj.logInfo('\t igmpQuerier:{0} Name:{1}'.format(igmpQuerier['id'], igmpQuerier['name'], igmpQuerier['status']), timestamp=False) self.ixnObj.logInfo('\t\tStatus: {0}'.format(igmpQuerier['status']), end='\n\n', timestamp=False) for vxlan in ipv4['vxlan']: self.ixnObj.logInfo('\t vxlan:{0} Name:{1}'.format(vxlan['id'], vxlan['name'], vxlan['status']), timestamp=False) self.ixnObj.logInfo('\tStatus: {0}'.format(vxlan['status']), end='\n\n, timestamp=False') for networkGroup in deviceGroup['networkGroup']: self.ixnObj.logInfo('\n\tNetworkGroup:{0} Name:{1}'.format(networkGroup['id'], networkGroup['name']), timestamp=False) self.ixnObj.logInfo('\t Multiplier: {0}'.format(networkGroup['multiplier']), timestamp=False) response = self.ixnObj.get(self.ixnObj.httpHeader+networkGroup['href']+'/ipv4PrefixPools', silentMode=True) prefixPoolHref = response.json()[0]['links'][0]['href'] response = self.ixnObj.get(self.ixnObj.httpHeader+response.json()[0]['networkAddress'], silentMode=True) startingAddressMultivalue = response.json()['links'][0]['href'] startingAddress = self.getMultivalueValues(startingAddressMultivalue, silentMode=True)[0] endingAddress = self.getMultivalueValues(startingAddressMultivalue, silentMode=True)[-1] prefixPoolResponse = self.ixnObj.get(self.ixnObj.httpHeader+prefixPoolHref, silentMode=True) self.ixnObj.logInfo('\t StartingAddress:{0} EndingAddress:{1} Prefix:{2}'.format(startingAddress, endingAddress, response.json()['formatLength']), timestamp=False) if None not in ethernet['ipv6']: for ipv6 in ethernet['ipv6']: self.ixnObj.logInfo('\t IPv6:{0} Name:{1}'.format(ipv6['id'], ipv6['name']), timestamp=False) for bgpIpv6Peer in ipv6['bgpIpv6Peer']: self.ixnObj.logInfo('\t BGPIpv6Peer:{0} Name:{1}'.format(bgpIpv6Peer['id'], bgpIpv6Peer['name']), timestamp=False) for ospfv3 in ipv6['ospfv3']: self.ixnObj.logInfo('\t OSPFv3:{0} Name:{1}'.format(ospfv3['id'], ospfv3['name']), timestamp=False) for mldHost in ipv6['mldHost']: self.ixnObj.logInfo('\t mldHost:{0} Name:{1}'.format(mldHost['id'], mldHost['name']), timestamp=False) for mldQuerier in ipv6['mldQuerier']: self.ixnObj.logInfo('\t mldQuerier:{0} Name:{1}'.format(mldQuerier['id'], mldQuerier['name']), timestamp=False) self.ixnObj.logInfo('\n', timestamp=False)