def test_interface_to_port(self): # TODO test with create port is False results = open(self.PATH + 'hls_snmp.xml').read() results_set = ResultSet.parse_result(results) services = parse_lookup_service_result(results_set) for psservice in services: for data in psservice['data']: port = interface_to_port(data.subject.contents) self.assertIsInstance(port, Port)
def extract_interface(ifaddress, ifname, ipaddress, hostname): """ Reads interface object from user input data. If the interface has existing matching port it will be returned instead. @returns: None, L{periscope.topology.models.Port}, or L{psapi.protocol.Interface} """ if not ifaddress and not ifname and not ipaddress and not hostname: return None interface = Interface(ifAddress=ifaddress, ifName=ifname, ipAddress=ipaddress, hostName=hostname) port = interface_to_port(interface, False) if port: return port else: return interface