def connect_volume(self, connection_data, dev_number, instance_name, vm_ref): if 'name_label' not in connection_data: label = 'tempSR-%s' % connection_data['volume_id'] else: label = connection_data['name_label'] del connection_data['name_label'] if 'name_description' not in connection_data: desc = 'Disk-for:%s' % instance_name else: desc = connection_data['name_description'] sr_params = {} if u'sr_uuid' not in connection_data: sr_params = volume_utils.parse_volume_info(connection_data) uuid = "FA15E-D15C-" + str(sr_params['id']) sr_params['sr_type'] = 'iscsi' else: uuid = connection_data['sr_uuid'] for k in connection_data['introduce_sr_keys']: sr_params[k] = connection_data[k] sr_params['name_description'] = desc # Introduce SR try: sr_ref = self.introduce_sr(uuid, label, sr_params) LOG.debug(_('Introduced %(label)s as %(sr_ref)s.') % locals()) except self._session.XenAPI.Failure, exc: LOG.exception(exc) raise volume_utils.StorageError( _('Unable to introduce Storage Repository'))
def create_volume_for_sm(self, volume, sr_uuid): LOG.debug("Creating volume for Storage Manager") sm_vol_rec = {} try: sr_ref = self._session.call_xenapi("SR.get_by_uuid", sr_uuid) except self._session.XenAPI.Failure, exc: LOG.exception(exc) raise volume_utils.StorageError(_('Unable to get SR using uuid'))
def connect_volume(self, connection_data, dev_number, instance_name, vm_ref): description = 'Disk-for:%s' % instance_name uuid, label, sr_params = volume_utils.parse_sr_info( connection_data, description) # Introduce SR try: sr_ref = self.introduce_sr(uuid, label, sr_params) LOG.debug(_('Introduced %(label)s as %(sr_ref)s.') % locals()) except self._session.XenAPI.Failure, exc: LOG.exception(exc) raise volume_utils.StorageError( _('Unable to introduce Storage Repository'))
def attach_volume(self, connection_info, instance_name, mountpoint): """Attach volume storage to VM instance""" # Before we start, check that the VM exists vm_ref = vm_utils.lookup(self._session, instance_name) if vm_ref is None: raise exception.InstanceNotFound(instance_id=instance_name) # NOTE: No Resource Pool concept so far LOG.debug( _("Attach_volume: %(connection_info)s, %(instance_name)s," " %(mountpoint)s") % locals()) driver_type = connection_info['driver_volume_type'] if driver_type not in ['iscsi', 'xensm']: raise exception.VolumeDriverNotFound(driver_type=driver_type) data = connection_info['data'] if 'name_label' not in data: label = 'tempSR-%s' % data['volume_id'] else: label = data['name_label'] del data['name_label'] if 'name_description' not in data: desc = 'Disk-for:%s' % instance_name else: desc = data['name_description'] LOG.debug(connection_info) sr_params = {} if u'sr_uuid' not in data: sr_params = volume_utils.parse_volume_info(connection_info, mountpoint) uuid = "FA15E-D15C-" + str(sr_params['id']) sr_params['sr_type'] = 'iscsi' else: uuid = data['sr_uuid'] for k in data['introduce_sr_keys']: sr_params[k] = data[k] sr_params['name_description'] = desc # Introduce SR try: sr_ref = self.introduce_sr(uuid, label, sr_params) LOG.debug(_('Introduced %(label)s as %(sr_ref)s.') % locals()) except self._session.XenAPI.Failure, exc: LOG.exception(exc) raise volume_utils.StorageError( _('Unable to introduce Storage Repository'))