def get_agent_id(self):
     if self.bridge_mappings:
         mac = ip_lib.get_device_mac(list(self.bridge_mappings.values())[0])
     else:
         devices = ip_lib.IPWrapper().get_devices(True)
         if devices:
             mac = ip_lib.get_device_mac(devices[0].name)
         else:
             LOG.error(_LE("Unable to obtain MAC address for unique ID. " "Agent terminated!"))
             sys.exit(1)
     return "lb%s" % mac.replace(":", "")
Exemple #2
0
 def get_agent_id(self):
     if self.bridge_mappings:
         mac = ip_lib.get_device_mac(list(self.bridge_mappings.values())[0])
     else:
         devices = ip_lib.IPWrapper().get_devices(True)
         if devices:
             mac = ip_lib.get_device_mac(devices[0].name)
         else:
             LOG.error(
                 _LE("Unable to obtain MAC address for unique ID. "
                     "Agent terminated!"))
             sys.exit(1)
     return 'lb%s' % mac.replace(":", "")
Exemple #3
0
 def get_agent_id(self):
     if self.bridge_mappings:
         mac = ip_lib.get_device_mac(list(self.bridge_mappings.values())[0])
     else:
         devices = self.ip.get_devices(True)
         for device in devices:
             mac = ip_lib.get_device_mac(device.name)
             if mac:
                 break
         else:
             LOG.error("Unable to obtain MAC address for unique ID. "
                       "Agent terminated!")
             sys.exit(1)
     return 'lb%s' % mac.replace(":", "")
 def get_agent_id(self):
     if self.bridge_mappings:
         mac = ip_lib.get_device_mac(
             list(self.bridge_mappings.values())[0])
     else:
         devices = self.ip.get_devices(True)
         for device in devices:
             mac = ip_lib.get_device_mac(device.name)
             if mac:
                 break
         else:
             LOG.error("Unable to obtain MAC address for unique ID. "
                       "Agent terminated!")
             sys.exit(1)
     return 'lb%s' % mac.replace(":", "")
 def get_agent_id(self):
     devices = ip_lib.IPWrapper().get_devices(True)
     if devices:
         mac = ip_lib.get_device_mac(devices[0].name)
         return "macvtap%s" % mac.replace(":", "")
     else:
         LOG.error(_LE("Unable to obtain MAC address for unique ID. " "Agent terminated!"))
         sys.exit(1)
 def get_agent_id(self):
     devices = ip_lib.IPWrapper().get_devices(True)
     if devices:
         mac = ip_lib.get_device_mac(devices[0].name)
         return 'macvtap%s' % mac.replace(":", "")
     else:
         LOG.error("Unable to obtain MAC address for unique ID. "
                   "Agent terminated!")
         sys.exit(1)
 def get_agent_id(self):
     devices = ip_lib.IPWrapper().get_devices(True)
     for device in devices:
         mac = ip_lib.get_device_mac(device.name)
         if mac:
             return 'macvtap%s' % mac.replace(":", "")
     LOG.error("Unable to obtain MAC address for unique ID. "
               "Agent terminated!")
     sys.exit(1)
Exemple #8
0
    def test_get_device_mac(self):
        attr = self.generate_device_details()
        device = self.manage_device(attr)

        mac_address = ip_lib.get_device_mac(attr.name,
                                            namespace=attr.namespace)

        self.assertEqual(attr.mac_address, mac_address)

        device.link.delete()
Exemple #9
0
    def test_get_device_mac(self):
        attr = self.generate_device_details()
        device = self.manage_device(attr)

        mac_address = ip_lib.get_device_mac(attr.name,
                                            namespace=attr.namespace)

        self.assertEqual(attr.mac_address, mac_address)

        device.link.delete()
 def get_all_devices(self):
     devices = set()
     all_device_names = os.listdir(MACVTAP_FS)
     # Refresh the mac_device_name mapping
     self.mac_device_name_mappings = dict()
     for device_name in all_device_names:
         if device_name.startswith(constants.MACVTAP_DEVICE_PREFIX):
             mac = ip_lib.get_device_mac(device_name)
             self.mac_device_name_mappings[mac] = device_name
             devices.add(mac)
     return devices
 def get_all_devices(self):
     devices = set()
     all_device_names = os.listdir(MACVTAP_FS)
     # Refresh the mac_device_name mapping
     self.mac_device_name_mappings = dict()
     for device_name in all_device_names:
         if device_name.startswith(constants.MACVTAP_DEVICE_PREFIX):
             mac = ip_lib.get_device_mac(device_name)
             self.mac_device_name_mappings[mac] = device_name
             devices.add(mac)
     return devices
Exemple #12
0
    def test_get_device_mac_too_long_name(self):
        name = utils.get_rand_name(max_length=constants.DEVICE_NAME_MAX_LEN +
                                   5)
        attr = self.generate_device_details(name=name)
        device = self.manage_device(attr)

        mac_address = ip_lib.get_device_mac(attr.name,
                                            namespace=attr.namespace)

        self.assertEqual(attr.mac_address, mac_address)

        device.link.delete()
Exemple #13
0
    def test_get_device_mac_too_long_name(self):
        name = utils.get_rand_name(
            max_length=constants.DEVICE_NAME_MAX_LEN + 5)
        attr = self.generate_device_details(name=name)
        device = self.manage_device(attr)

        mac_address = ip_lib.get_device_mac(attr.name,
                                            namespace=attr.namespace)

        self.assertEqual(attr.mac_address, mac_address)

        device.link.delete()