Beispiel #1
0
    def delete(self, arqs=None, instance=None):
        """Delete one or more ARQS.

        The request can be either one of these two forms:
            DELETE /v2/accelerator_requests?arqs=uuid1,uuid2,...
            DELETE /v2/accelerator_requests?instance=uuid

        The second form is idempotent, i.e., it would have the same effect
        if called repeatedly with the same instance UUID. In other words,
        it would not raise an error on the second and later attempts even if
        the first one has deleted the ARQs. Whereas the first form is not
        idempotent: if one or more of the ARQs do not exist, it would raise
        an error. Nova uses the second form: so repeated calls do not cause
        issues.

        :param arq: List of ARQ UUIDs
        :param instance: UUID of instance whose ARQs need to be deleted
        """
        context = pecan.request.context
        if (arqs and instance) or ((not arqs) and (not instance)):
            raise exception.ObjectActionError(
                action='delete',
                reason='Provide either an ARQ uuid list or an instance UUID')
        elif arqs:
            LOG.info("[arqs] delete. arqs=(%s)", arqs)
            arqlist = arqs.split(',')
            objects.ExtARQ.delete_by_uuid(context, arqlist)
        else:  # instance is not None
            LOG.info("[arqs] delete. instance=(%s)", instance)
            objects.ExtARQ.delete_by_instance(context, instance)
Beispiel #2
0
    def create(self, context):
        """Create a Device Profile record in the DB."""
        # TODO() validate with a JSON schema
        if 'name' not in self:
            raise exception.ObjectActionError(action='create',
                                              reason='name is required')

        values = self.obj_get_changes()
        self._to_profile_json(values)

        db_devprof = self.dbapi.device_profile_create(context, values)
        self._from_db_object(self, db_devprof)
Beispiel #3
0
    def create(self, context):
        """Create a Deployable record in the DB."""
        if 'uuid' not in self:
            raise exception.ObjectActionError(action='create',
                                              reason='uuid is required')

        if self.parent_uuid is None:
            self.root_uuid = self.uuid
        else:
            self.root_uuid = self._get_parent_root_uuid()

        values = self.obj_get_changes()
        db_dep = self.dbapi.deployable_create(context, values)
        self._from_db_object(self, db_dep)
Beispiel #4
0
    def create(self, context, device_profile_id=None):
        """Create an ExtARQ record in the DB."""
        if 'device_profile' not in self.arq and not device_profile_id:
            raise exception.ObjectActionError(
                action='create', reason='Device profile is required in ARQ')
        self.arq.state = constants.ARQINITIAL
        self.substate = constants.ARQINITIAL
        values = self.obj_get_changes()
        arq_obj = values.pop('arq', None)
        if arq_obj is not None:
            values.update(arq_obj.as_dict())

        # Pass devprof id to db layer, to avoid repeated queries
        if device_profile_id is not None:
            values['device_profile_id'] = device_profile_id

        db_extarq = self.dbapi.extarq_create(context, values)
        self._from_db_object(self, db_extarq)
        return self
Beispiel #5
0
    def delete(self, arqs=None, instance=None):
        """Delete one or more ARQS.

        The request can be either one of these two forms:
            DELETE /v2/accelerator_requests?arqs=uuid1,uuid2,...
            DELETE /v2/accelerator_requests?instance=uuid

        :param arq: List of ARQ UUIDs
        :param instance: UUID of instance whose ARQs need to be deleted
        """
        context = pecan.request.context
        if (arqs and instance) or ((not arqs) and (not instance)):
            raise exception.ObjectActionError(
                action='delete',
                reason='Provide either an ARQ uuid list or an instance UUID')
        elif arqs:
            LOG.info("[arqs] delete. arqs=(%s)", arqs)
            arqlist = arqs.split(',')
            objects.ExtARQ.delete_by_uuid(context, arqlist)
        else:  # instance is not None
            LOG.info("[arqs] delete. instance=(%s)", instance)
            objects.ExtARQ.delete_by_instance(context, instance)