Esempio n. 1
0
 def test_get_bdms_to_connect(self):
     root_bdm = {'device_name': 'vda', 'boot_index': 0}
     bdms = [root_bdm,
             {'device_name': 'vdb', 'boot_index': 1},
             {'device_name': 'vdc', 'boot_index': -1},
             {'device_name': 'vde', 'boot_index': None},
             {'device_name': 'vdd'}]
     self.assertNotIn(root_bdm, block_device.get_bdms_to_connect(bdms,
                                             exclude_root_mapping=True))
     self.assertIn(root_bdm, block_device.get_bdms_to_connect(bdms))
Esempio n. 2
0
 def test_get_bdms_to_connect(self):
     root_bdm = {'device_name': 'vda', 'boot_index': 0}
     bdms = [root_bdm,
             {'device_name': 'vdb', 'boot_index': 1},
             {'device_name': 'vdc', 'boot_index': -1},
             {'device_name': 'vde', 'boot_index': None},
             {'device_name': 'vdd'}]
     self.assertNotIn(root_bdm, block_device.get_bdms_to_connect(bdms,
                                             exclude_root_mapping=True))
     self.assertIn(root_bdm, block_device.get_bdms_to_connect(bdms))
Esempio n. 3
0
 def test_get_bdms_to_connect(self):
     root_bdm = {"device_name": "vda", "boot_index": 0}
     bdms = [
         root_bdm,
         {"device_name": "vdb", "boot_index": 1},
         {"device_name": "vdc", "boot_index": -1},
         {"device_name": "vde", "boot_index": None},
         {"device_name": "vdd"},
     ]
     self.assertNotIn(root_bdm, block_device.get_bdms_to_connect(bdms, exclude_root_mapping=True))
     self.assertIn(root_bdm, block_device.get_bdms_to_connect(bdms))
Esempio n. 4
0
    def _get_guest_storage_config(self, context, block_device_info,
                                  reboot=False):
        devices = []
        block_device_mapping = driver.block_device_info_get_mapping(
            block_device_info)

        LOG.info(_LI('block_device_mapping %s'), block_device_mapping)
        for vol in block_device.get_bdms_to_connect(block_device_mapping):
            connection_info = vol['connection_info']
            info = {'dev': vol['mount_device']}
            self._connect_volume(connection_info, info)
            device_path = connection_info['data'].get('device_path')
            if device_path:
                real_path = os.path.realpath(device_path)
                devices.append(real_path + ':' + vol['mount_device'])
            bdm = objects.BlockDeviceMapping.get_by_volume_id(
                context, connection_info['data']['volume_id'])
            driver_bdm = driver_block_device.DriverVolumeBlockDevice(bdm)
            driver_bdm['connection_info'] = connection_info
            driver_bdm.save()
        return devices