Example #1
0
    def create(self,
               context,
               size,
               name,
               description,
               snapshot=None,
               image_id=None,
               volume_type=None,
               metadata=None,
               availability_zone=None,
               source_volume=None,
               scheduler_hints=None,
               backup_source_volume=None):
        def check_volume_az_zone(availability_zone):
            try:
                return self._valid_availabilty_zone(availability_zone)
            except exception.CinderException:
                LOG.exception(
                    _("Unable to query if %s is in the "
                      "availability zone set"), availability_zone)
                return False

        create_what = {
            'size': size,
            'name': name,
            'description': description,
            'snapshot': snapshot,
            'image_id': image_id,
            'volume_type': volume_type,
            'metadata': metadata,
            'availability_zone': availability_zone,
            'source_volume': source_volume,
            'scheduler_hints': scheduler_hints,
            'key_manager': self.key_manager,
            'backup_source_volume': backup_source_volume,
        }
        (flow, uuid) = create_volume.get_api_flow(self.scheduler_rpcapi,
                                                  self.volume_rpcapi, self.db,
                                                  self.image_service,
                                                  check_volume_az_zone,
                                                  create_what)

        assert flow, _('Create volume flow not retrieved')
        flow.run(context)
        if flow.state != states.SUCCESS:
            raise exception.CinderException(
                _("Failed to successfully complete"
                  " create volume workflow"))

        # Extract the volume information from the task uuid that was specified
        # to produce said information.
        volume = None
        try:
            volume = flow.results[uuid]['volume']
        except KeyError:
            pass

        # Raise an error, nobody provided it??
        assert volume, _('Expected volume result not found')
        return volume
Example #2
0
File: api.py Project: pdmars/cinder
    def create(
        self,
        context,
        size,
        name,
        description,
        snapshot=None,
        image_id=None,
        volume_type=None,
        metadata=None,
        availability_zone=None,
        source_volume=None,
        scheduler_hints=None,
        backup_source_volume=None,
    ):
        def check_volume_az_zone(availability_zone):
            try:
                return self._valid_availability_zone(availability_zone)
            except exception.CinderException:
                LOG.exception(_("Unable to query if %s is in the " "availability zone set"), availability_zone)
                return False

        create_what = {
            "context": context,
            "raw_size": size,
            "name": name,
            "description": description,
            "snapshot": snapshot,
            "image_id": image_id,
            "raw_volume_type": volume_type,
            "metadata": metadata,
            "raw_availability_zone": availability_zone,
            "source_volume": source_volume,
            "scheduler_hints": scheduler_hints,
            "key_manager": self.key_manager,
            "backup_source_volume": backup_source_volume,
        }

        try:
            flow_engine = create_volume.get_api_flow(
                self.scheduler_rpcapi,
                self.volume_rpcapi,
                self.db,
                self.image_service,
                check_volume_az_zone,
                create_what,
            )
        except Exception:
            LOG.exception(_("Failed to create api volume flow"))
            raise exception.CinderException(_("Failed to create api volume flow"))

        flow_engine.run()
        volume = flow_engine.storage.fetch("volume")
        return volume
Example #3
0
    def create(self, context, size, name, description, snapshot=None,
               image_id=None, volume_type=None, metadata=None,
               availability_zone=None, source_volume=None,
               scheduler_hints=None, backup_source_volume=None):

        def check_volume_az_zone(availability_zone):
            try:
                return self._valid_availabilty_zone(availability_zone)
            except exception.CinderException:
                LOG.exception(_("Unable to query if %s is in the "
                                "availability zone set"), availability_zone)
                return False

        create_what = {
            'size': size,
            'name': name,
            'description': description,
            'snapshot': snapshot,
            'image_id': image_id,
            'volume_type': volume_type,
            'metadata': metadata,
            'availability_zone': availability_zone,
            'source_volume': source_volume,
            'scheduler_hints': scheduler_hints,
            'key_manager': self.key_manager,
            'backup_source_volume': backup_source_volume,
        }
        (flow, uuid) = create_volume.get_api_flow(self.scheduler_rpcapi,
                                                  self.volume_rpcapi,
                                                  self.db,
                                                  self.image_service,
                                                  check_volume_az_zone,
                                                  create_what)

        assert flow, _('Create volume flow not retrieved')
        flow.run(context)
        if flow.state != states.SUCCESS:
            raise exception.CinderException(_("Failed to successfully complete"
                                              " create volume workflow"))

        # Extract the volume information from the task uuid that was specified
        # to produce said information.
        volume = None
        try:
            volume = flow.results[uuid]['volume']
        except KeyError:
            pass

        # Raise an error, nobody provided it??
        assert volume, _('Expected volume result not found')
        return volume
Example #4
0
    def create(self,
               context,
               size,
               name,
               description,
               snapshot=None,
               image_id=None,
               volume_type=None,
               metadata=None,
               availability_zone=None,
               source_volume=None,
               scheduler_hints=None,
               backup_source_volume=None):
        def check_volume_az_zone(availability_zone):
            try:
                return self._valid_availability_zone(availability_zone)
            except exception.CinderException:
                LOG.exception(
                    _("Unable to query if %s is in the "
                      "availability zone set"), availability_zone)
                return False

        create_what = {
            'context': context,
            'raw_size': size,
            'name': name,
            'description': description,
            'snapshot': snapshot,
            'image_id': image_id,
            'raw_volume_type': volume_type,
            'metadata': metadata,
            'raw_availability_zone': availability_zone,
            'source_volume': source_volume,
            'scheduler_hints': scheduler_hints,
            'key_manager': self.key_manager,
            'backup_source_volume': backup_source_volume,
        }

        try:
            flow_engine = create_volume.get_api_flow(
                self.scheduler_rpcapi, self.volume_rpcapi, self.db,
                self.image_service, check_volume_az_zone, create_what)
        except Exception:
            raise exception.CinderException(
                _("Failed to create api volume flow"))

        flow_engine.run()
        volume = flow_engine.storage.fetch('volume')
        return volume
Example #5
0
    def create(self, context, size, name, description, snapshot=None,
               image_id=None, volume_type=None, metadata=None,
               availability_zone=None, source_volume=None,
               scheduler_hints=None, backup_source_volume=None):

        def check_volume_az_zone(availability_zone):
            try:
                return self._valid_availability_zone(availability_zone)
            except exception.CinderException:
                LOG.exception(_("Unable to query if %s is in the "
                                "availability zone set"), availability_zone)
                return False

        create_what = {
            'context': context,
            'raw_size': size,
            'name': name,
            'description': description,
            'snapshot': snapshot,
            'image_id': image_id,
            'raw_volume_type': volume_type,
            'metadata': metadata,
            'raw_availability_zone': availability_zone,
            'source_volume': source_volume,
            'scheduler_hints': scheduler_hints,
            'key_manager': self.key_manager,
            'backup_source_volume': backup_source_volume,
        }

        try:
            flow_engine = create_volume.get_api_flow(self.scheduler_rpcapi,
                                                     self.volume_rpcapi,
                                                     self.db,
                                                     self.image_service,
                                                     check_volume_az_zone,
                                                     create_what)
        except Exception:
            LOG.exception(_("Failed to create api volume flow"))
            raise exception.CinderException(
                _("Failed to create api volume flow"))

        flow_engine.run()
        volume = flow_engine.storage.fetch('volume')
        return volume