def _get_unit_number(self, mountpoint, unit_number): """Get a unit number for the device.""" mount_unit = volume_util.mountpoint_to_number(mountpoint) # Figure out the correct unit number if unit_number < mount_unit: new_unit_number = mount_unit else: new_unit_number = unit_number + 1 return new_unit_number
def attach_volume(self, connection_info, instance, mountpoint): """Attach volume storage to VM instance.""" instance_name = instance['name'] vm_ref = vm_util.get_vm_ref_from_name(self._session, instance_name) if vm_ref is None: raise exception.InstanceNotFound(instance_id=instance_name) # Attach Volume to VM LOG.debug( _("Attach_volume: %(connection_info)s, %(instance_name)s, " "%(mountpoint)s"), { 'connection_info': connection_info, 'instance_name': instance_name, 'mountpoint': mountpoint }) driver_type = connection_info['driver_volume_type'] if driver_type not in ['iscsi']: raise exception.VolumeDriverNotFound(driver_type=driver_type) data = connection_info['data'] mount_unit = volume_util.mountpoint_to_number(mountpoint) # Discover iSCSI Target device_name, uuid = self.discover_st(data) if device_name is None: raise volume_util.StorageError(_("Unable to find iSCSI Target")) # Get the vmdk file name that the VM is pointing to hardware_devices = self._session._call_method( vim_util, "get_dynamic_property", vm_ref, "VirtualMachine", "config.hardware.device") vmdk_file_path, controller_key, adapter_type, disk_type, unit_number \ = vm_util.get_vmdk_path_and_adapter_type(hardware_devices) # Figure out the correct unit number if unit_number < mount_unit: unit_number = mount_unit else: unit_number = unit_number + 1 self.attach_disk_to_vm(vm_ref, instance_name, adapter_type, disk_type="rdmp", controller_key=controller_key, unit_number=unit_number, device_name=device_name) LOG.info( _("Mountpoint %(mountpoint)s attached to " "instance %(instance_name)s"), { 'mountpoint': mountpoint, 'instance_name': instance_name })
def attach_volume(self, connection_info, instance, mountpoint): """Attach volume storage to VM instance.""" instance_name = instance["name"] vm_ref = vm_util.get_vm_ref_from_name(self._session, instance_name) if vm_ref is None: raise exception.InstanceNotFound(instance_id=instance_name) # Attach Volume to VM LOG.debug( _("Attach_volume: %(connection_info)s, %(instance_name)s, " "%(mountpoint)s"), {"connection_info": connection_info, "instance_name": instance_name, "mountpoint": mountpoint}, ) driver_type = connection_info["driver_volume_type"] if driver_type not in ["iscsi"]: raise exception.VolumeDriverNotFound(driver_type=driver_type) data = connection_info["data"] mount_unit = volume_util.mountpoint_to_number(mountpoint) # Discover iSCSI Target device_name, uuid = self.discover_st(data) if device_name is None: raise volume_util.StorageError(_("Unable to find iSCSI Target")) # Get the vmdk file name that the VM is pointing to hardware_devices = self._session._call_method( vim_util, "get_dynamic_property", vm_ref, "VirtualMachine", "config.hardware.device" ) vmdk_file_path, controller_key, adapter_type, disk_type, unit_number = vm_util.get_vmdk_path_and_adapter_type( hardware_devices ) # Figure out the correct unit number if unit_number < mount_unit: unit_number = mount_unit else: unit_number = unit_number + 1 self.attach_disk_to_vm( vm_ref, instance_name, adapter_type, disk_type="rdmp", controller_key=controller_key, unit_number=unit_number, device_name=device_name, ) LOG.info( _("Mountpoint %(mountpoint)s attached to " "instance %(instance_name)s"), {"mountpoint": mountpoint, "instance_name": instance_name}, )
def _attach_volume_iscsi(self, connection_info, instance, mountpoint): """Attach iscsi volume storage to VM instance.""" instance_name = instance['name'] vm_ref = vm_util.get_vm_ref(self._session, instance) # Attach Volume to VM LOG.debug(_("Attach_volume: %(connection_info)s, %(instance_name)s, " "%(mountpoint)s"), {'connection_info': connection_info, 'instance_name': instance_name, 'mountpoint': mountpoint}) data = connection_info['data'] mount_unit = volume_util.mountpoint_to_number(mountpoint) # Discover iSCSI Target device_name, uuid = self.discover_st(data) if device_name is None: raise volume_util.StorageError(_("Unable to find iSCSI Target")) # Get the vmdk file name that the VM is pointing to hardware_devices = self._session._call_method(vim_util, "get_dynamic_property", vm_ref, "VirtualMachine", "config.hardware.device") vmdk_file_path, controller_key, adapter_type, disk_type, unit_number \ = vm_util.get_vmdk_path_and_adapter_type(hardware_devices) # Figure out the correct unit number if unit_number < mount_unit: unit_number = mount_unit else: unit_number = unit_number + 1 self.attach_disk_to_vm(vm_ref, instance, adapter_type, 'rdmp', controller_key=controller_key, unit_number=unit_number, device_name=device_name) LOG.info(_("Mountpoint %(mountpoint)s attached to " "instance %(instance_name)s"), {'mountpoint': mountpoint, 'instance_name': instance_name})