def test_get_hard_disks(self, mock_list_hdds): mock_list_hdds.return_value = ( 'UUID: uuid_disk_1\n\n' 'UUID: uuid_disk_2\n\n' ) response = vhdutils.get_hard_disks() self.assertEqual({"uuid_disk_1": {}, "uuid_disk_2": {}}, response)
def _check_disk(self, disk_file, base_disk): try: vhdutils.check_disk_uuid(disk_file) disk_info = vhdutils.disk_info(disk_file) parent_uuid = disk_info[constants.VHD_PARENT_UUID] if not parent_uuid: return except vbox_exc.VBoxException: parent_uuid = None registered_hdds = vhdutils.get_hard_disks() if parent_uuid not in registered_hdds: parent_info = vhdutils.disk_info(base_disk) self._vbox_manage.set_disk_parent_uuid( disk_file, parent_info[constants.VHD_UUID])
def _check_disk(self, disk_file, base_disk): try: vhdutils.check_disk_uuid(disk_file) disk_info = vhdutils.disk_info(disk_file) parent_uuid = disk_info[constants.VHD_PARENT_UUID] if not parent_uuid: return except vbox_exc.VBoxException: parent_uuid = None registered_hdds = vhdutils.get_hard_disks() if parent_uuid not in registered_hdds: parent_info = vhdutils.disk_info(base_disk) self._vbox_manage.set_disk_parent_uuid( disk_file, parent_info[constants.VHD_UUID])
def volume_uuid(connection_info): """Returm the volume uuid if is already registered.""" data = connection_info['data'] target_lun = str(data['target_lun']) target_iqn = data['target_iqn'] target_portal = data['target_portal'].split(':')[0] registered_hdds = vhdutils.get_hard_disks() for uuid, disk in registered_hdds.items(): if '|' not in disk[constants.VHD_PATH]: continue disk_info = disk[constants.VHD_PATH].split('|') for target_info in (target_lun, target_iqn, target_portal): if target_info not in disk_info: break else: return uuid return None
def volume_uuid(connection_info): """Returm the volume uuid if is already registered.""" data = connection_info['data'] target_lun = str(data['target_lun']) target_iqn = data['target_iqn'] target_portal = data['target_portal'].split(':')[0] registered_hdds = vhdutils.get_hard_disks() for uuid, disk in registered_hdds.items(): if '|' not in disk[constants.VHD_PATH]: continue disk_info = disk[constants.VHD_PATH].split('|') for target_info in (target_lun, target_iqn, target_portal): if target_info not in disk_info: break else: return uuid return None
def init_host(self): """Initialize anything that is necessary for the driver to function, including catching up with currently running VM's on the given host. """ # Update the Hypervisor internal database. # Remove all the inaccessible virtual hard disk which # not exist anymore. hdds = vhdutils.get_hard_disks() for uuid, disk in hdds.items(): state = disk[constants.VHD_STATE] if not state == constants.VHD_STATE_INACCESSIBLE: continue # Check if the disk is still exists disk_file = disk.get(constants.VHD_PATH) if disk_file and not os.path.exists(disk_file): # Remove the disk from hypervisor LOG.info(i18n._LI("Remove inaccessible disk: %(disk)s"), {"disk": disk}) manage.VBoxManage.close_medium(constants.MEDIUM_DISK, uuid)
def init_host(self): """Initialize anything that is necessary for the driver to function, including catching up with currently running VM's on the given host. """ # Update the Hypervisor internal database. # Remove all the inaccessible virtual hard disk which # not exist anymore. hdds = vhdutils.get_hard_disks() for uuid, disk in hdds.items(): state = disk[constants.VHD_STATE] if not state == constants.VHD_STATE_INACCESSIBLE: continue # Check if the disk is still exists disk_file = disk.get(constants.VHD_PATH) if disk_file and not os.path.exists(disk_file): # Remove the disk from hypervisor LOG.info(i18n._LI("Remove inaccessible disk: %(disk)s"), {"disk": disk}) manage.VBoxManage.close_medium(constants.MEDIUM_DISK, uuid)
def test_get_hard_disks(self, mock_list_hdds): mock_list_hdds.return_value = ('UUID: uuid_disk_1\n\n' 'UUID: uuid_disk_2\n\n') response = vhdutils.get_hard_disks() self.assertEqual({"uuid_disk_1": {}, "uuid_disk_2": {}}, response)