示例#1
0
    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'))
示例#2
0
    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'))
示例#3
0
    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'))
示例#4
0
    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)

        connection_data = connection_info['data']
        dev_number = volume_utils.get_device_number(mountpoint)

        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']

        LOG.debug(connection_info)
        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'))