def _get_one_interface(self, p_interface_name): """ Gather the information about a single interface given the interface name. Only UP interfaces return data, apparently, """ l_interface = NodeInterfaceData() l_interface.Name = p_interface_name # l_interface.Active = True l_interface.Key = 0 l_interface.UUID = toolUuid.create_uuid( ) # We need a way to persist the UUID instead of this l_interface.NodeInterfaceType = 'Other' l_afList = Interfaces()._find_addr_lists(p_interface_name) for l_afID in l_afList.keys(): l_v4 = [] l_v6 = [] l_afName = Interfaces()._find_addr_family_name(l_afID) if l_afName == 'AF_PACKET': l_interface.MacAddress = l_afList[l_afID] if l_afName == 'AF_INET': l_v4 = Interfaces()._get_address_list_INET(l_afList[l_afID]) l_interface.V4Address = l_v4 if l_afName == 'AF_INET6': l_v6 = Interfaces()._get_address_list_INET(l_afList[l_afID]) l_interface.V6Address = l_v6 return l_interface, l_v4, l_v6
def _read_one_interface_xml(p_interface_element): l_interface_obj = NodeInterfaceData() XmlConfigTools.read_base_object_xml(l_interface_obj, p_interface_element) l_interface_obj.MacAddress = PutGetXML.get_text_from_xml(p_interface_element, 'MacAddress') l_interface_obj.V4Address = PutGetXML.get_text_from_xml(p_interface_element, 'IPv4Address') l_interface_obj.V6Address = PutGetXML.get_text_from_xml(p_interface_element, 'IPv6Address') return l_interface_obj
def _get_one_interface(p_interface_name): """ Gather the information about a single interface given the interface name. Only UP interfaces return data, apparently, """ l_interface = NodeInterfaceData() l_interface.Name = p_interface_name l_interface.Active = True l_interface.Key = 0 l_interface.UUID = '123' l_interface.NodeInterfaceType = 'Other' # l_ifs = Interfaces._find_addr_lists(p_interface_name) # print(PrettyFormatAny.form(l_ifs, 'Ifs')) l_afList = Interfaces._find_addr_lists(p_interface_name) for l_afID in l_afList.iterkeys(): l_afName = Interfaces._find_addr_family_name(l_afID) # print('141 l_afID: {} {}'.format(l_afID, l_afName)) if l_afName == 'AF_PACKET': l_interface.MacAddress = l_afList[l_afID] if l_afName == 'AF_INET': l_interface.V4Address = Interfaces._get_address_list_INET(l_afList[l_afID]) if l_afName == 'AF_INET6': l_interface.V6Address = Interfaces._get_address_list_INET6(l_afList[l_afID]) # print('150 Jnterface {}'.format(PrettyFormatAny.form(l_interface, 'Interface', 150))) return l_interface