Exemple #1
0
    def get_address(self, index=0, *args):
        """
        Return the address of the guest through ovirt node tcpdump cache.

        :param index: Name or index of the NIC whose address is requested.
        :return: IP address of NIC.
        :raise VMIPAddressMissingError: If no IP address is found for the the
                NIC's MAC address
        """
        nic = self.virtnet[index]
        if nic.nettype == 'bridge':
            mac = self.get_mac_address()
            ip = self.address_cache.get(mac)
            # TODO: Verify MAC-IP address mapping on remote ovirt node
            if not ip:
                raise virt_vm.VMIPAddressMissingError(mac)
            return ip
        else:
            raise ValueError("Ovirt only support bridge nettype now.")
Exemple #2
0
    def get_address(self, index=0, *args):
        """
        Return the address of the guest through ovirt node tcpdump cache.

        :param index: Name or index of the NIC whose address is requested.
        :return: IP address of NIC.
        :raise VMIPAddressMissingError: If no IP address is found for the the
                NIC's MAC address
        """
        def is_ip_reachable(ipaddr):
            res, _ = ping(ipaddr, timeout=5)
            return res == 0

        nic = self.virtnet[index]
        if nic.nettype == 'bridge':
            mac = self.get_mac_address()
            for mac_i in mac:
                ip = self.address_cache.get(mac_i)
                if ip and is_ip_reachable(ip):
                    return ip
            # TODO: Verify MAC-IP address mapping on remote ovirt node
            raise virt_vm.VMIPAddressMissingError(mac)
        else:
            raise ValueError("Ovirt only support bridge nettype now.")