Пример #1
0
 def extract_primary_ip(self, host):
     if self.use_ipv4:
         return self.extract_primary_ip4(host)
     try:
         address = host["primary_ip"]["address"]
         return str(ip_interface(address).ip)
     except Exception:
         return
Пример #2
0
 def extract_addresses(self, interface):
     addresses = []
     id = interface["id"]
     for address in self.addresses_lookup.values():
         if "interface" in address and address["interface"]["id"] == id:
             temp = deepcopy(address)
             temp.pop("interface", None)
             addr = ip_interface(address["address"])
             temp["cidr"] = str(addr.with_prefixlen)
             temp["address"] = str(addr.ip)
             temp["netmask"] = str(addr.netmask)
             addresses.append(deepcopy(temp))
     return addresses
Пример #3
0
 def extract_primary_ip6(self, host):
     try:
         address = host["primary_ip6"]["address"]
         return str(ip_interface(address).ip)
     except Exception:
         return