Beispiel #1
0
    def hwaddr(self):
        """hwaddr attribute getter

        Returns a HWAddress object representing the hardware address of the
        device as reported by the kernel.
        """
        return hwaddress(self._nl_msg.get_attr("IFLA_ADDRESS"))
Beispiel #2
0
    def _create(self):
        domain_ctl = self._machine.get_domain_ctl()

        if self.orig_hwaddr:
            if self._machine.get_dev_by_hwaddr(self.orig_hwaddr):
                msg = "Device with hwaddr %s already exists" % self.orig_hwaddr
                raise DeviceError(msg)
        else:
            mac_pool = self._machine.get_mac_pool()
            while True:
                hwaddr = hwaddress(mac_pool.get_addr())
                if not self._machine.get_dev_by_hwaddr(hwaddr):
                    self.orig_hwaddr = hwaddr
                    break

        bridges = self._machine.get_network_bridges()
        if self.network in bridges:
            net_ctl = bridges[self.network]
        else:
            bridges[self.network] = net_ctl = VirtNetCtl()
            net_ctl.init()

        net_name = net_ctl.get_name()

        logging.info("Creating virtual device with hwaddr='%s' on machine %s",
                     self.orig_hwaddr, self._machine.get_id())

        domain_ctl.attach_interface(self.orig_hwaddr, net_name,
                                    self.virt_driver)
        # The sleep here is necessary, because udev sometimes renames the
        # newly created device
        sleep(1)
Beispiel #3
0
    def hwaddr(self, addr):
        """hwaddr attribute setter

        Args:
            addr -- an address accepted by the hwaddress factory method
        """
        addr = hwaddress(addr)
        self._update_attr(str(addr), "IFLA_ADDRESS")
        self._nl_link_sync("set")
Beispiel #4
0
 def ad_actor_system(self, val):
     val = hwaddress(val)
     self._set_linkinfo_data_attr("IFLA_BOND_AD_ACTOR_SYSTEM", val)
     self._nl_link_sync("set")
Beispiel #5
0
 def ad_actor_system(self):
     try:
         return hwaddress(
             self._get_linkinfo_data_attr("IFLA_BOND_AD_ACTOR_SYSTEM"))
     except:
         return None