示例#1
0
    def save(self):
        updates = self.waterfall_obj_get_changes()
        if updates:
            if 'consistencygroup' in updates:
                raise exception.ObjectActionError(
                    action='save', reason=_('consistencygroup changed'))
            if 'glance_metadata' in updates:
                raise exception.ObjectActionError(
                    action='save', reason=_('glance_metadata changed'))
            if 'snapshots' in updates:
                raise exception.ObjectActionError(
                    action='save', reason=_('snapshots changed'))
            if 'metadata' in updates:
                # Metadata items that are not specified in the
                # self.metadata will be deleted
                metadata = updates.pop('metadata', None)
                self.metadata = db.workflow_metadata_update(
                    self._context, self.id, metadata, True)
            if self._context.is_admin and 'admin_metadata' in updates:
                metadata = updates.pop('admin_metadata', None)
                self.admin_metadata = db.workflow_admin_metadata_update(
                    self._context, self.id, metadata, True)

            db.workflow_update(self._context, self.id, updates)
            self.obj_reset_changes()
示例#2
0
 def save(self):
     updates = self.waterfall_obj_get_changes()
     if updates:
         if 'consistencygroup' in updates:
             raise exception.ObjectActionError(
                 action='save', reason=_('consistencygroup changed'))
         if 'snapshots' in updates:
             raise exception.ObjectActionError(
                 action='save', reason=_('snapshots changed'))
         db.cgsnapshot_update(self._context, self.id, updates)
         self.obj_reset_changes()
示例#3
0
    def create(self):
        if self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='create',
                                              reason=_('already_created'))
        updates = self.waterfall_obj_get_changes()

        if 'consistencygroup' in updates:
            raise exception.ObjectActionError(
                action='create', reason=_('consistencygroup assigned'))

        db_cgsnapshots = db.cgsnapshot_create(self._context, updates)
        self._from_db_object(self._context, self, db_cgsnapshots)
示例#4
0
    def create(self):
        if self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='create',
                                              reason=_('already created'))
        updates = self.waterfall_obj_get_changes()

        if 'workflow' in updates:
            raise exception.ObjectActionError(action='create',
                                              reason=_('workflow assigned'))
        if 'cgsnapshot' in updates:
            raise exception.ObjectActionError(action='create',
                                              reason=_('cgsnapshot assigned'))

        db_snapshot = db.snapshot_create(self._context, updates)
        self._from_db_object(self._context, self, db_snapshot)
示例#5
0
 def create(self):
     if self.obj_attr_is_set('id'):
         raise exception.ObjectActionError(action='create',
                                           reason=_('already created'))
     updates = self.waterfall_obj_get_changes()
     db_service = db.service_create(self._context, updates)
     self._from_db_object(self._context, self, db_service)
示例#6
0
 def create(self):
     if self.obj_attr_is_set('id'):
         raise exception.ObjectActionError(action='create',
                                           reason=_('already created'))
     db_workflow_type = workflow_types.create(self._context, self.name,
                                              self.extra_specs,
                                              self.is_public, self.projects,
                                              self.description)
     self._from_db_object(self._context, self, db_workflow_type)
示例#7
0
    def save(self):
        updates = self.waterfall_obj_get_changes()
        if updates:
            if 'workflow' in updates:
                raise exception.ObjectActionError(action='save',
                                                  reason=_('workflow changed'))
            if 'cgsnapshot' in updates:
                raise exception.ObjectActionError(
                    action='save', reason=_('cgsnapshot changed'))

            if 'metadata' in updates:
                # Metadata items that are not specified in the
                # self.metadata will be deleted
                metadata = updates.pop('metadata', None)
                self.metadata = db.snapshot_metadata_update(
                    self._context, self.id, metadata, True)

            db.snapshot_update(self._context, self.id, updates)

        self.obj_reset_changes()
示例#8
0
    def obj_load_attr(self, attrname):
        if attrname not in self.OPTIONAL_FIELDS:
            raise exception.ObjectActionError(
                action='obj_load_attr',
                reason=_('attribute %s not lazy-loadable') % attrname)
        if not self._context:
            raise exception.OrphanedObjectError(method='obj_load_attr',
                                                objtype=self.obj_name())

        if attrname == 'metadata':
            self.metadata = db.workflow_metadata_get(self._context, self.id)
        elif attrname == 'admin_metadata':
            self.admin_metadata = {}
            if self._context.is_admin:
                self.admin_metadata = db.workflow_admin_metadata_get(
                    self._context, self.id)
        elif attrname == 'glance_metadata':
            try:
                # NOTE(dulek): We're using alias here to have conversion from
                # list to dict done there.
                self.workflow_glance_metadata = db.workflow_glance_metadata_get(
                    self._context, self.id)
            except exception.GlanceMetadataNotFound:
                # NOTE(dulek): DB API raises when workflow has no
                # glance_metadata. Silencing this because at this level no
                # metadata is a completely valid result.
                self.glance_metadata = {}
        elif attrname == 'workflow_type':
            # If the workflow doesn't have workflow_type, WorkflowType.get_by_id
            # would trigger a db call which raise WorkflowTypeNotFound exception.
            self.workflow_type = (objects.WorkflowType.get_by_id(
                self._context, self.workflow_type_id)
                                  if self.workflow_type_id else None)
        elif attrname == 'workflow_attachment':
            attachments = objects.WorkflowAttachmentList.get_all_by_workflow_id(
                self._context, self.id)
            self.workflow_attachment = attachments
        elif attrname == 'consistencygroup':
            consistencygroup = objects.ConsistencyGroup.get_by_id(
                self._context, self.consistencygroup_id)
            self.consistencygroup = consistencygroup
        elif attrname == 'snapshots':
            self.snapshots = objects.SnapshotList.get_all_for_workflow(
                self._context, self.id)

        self.obj_reset_changes(fields=[attrname])
示例#9
0
    def obj_load_attr(self, attrname):
        if attrname not in OPTIONAL_FIELDS:
            raise exception.ObjectActionError(
                action='obj_load_attr',
                reason=_('attribute %s not lazy-loadable') % attrname)
        if not self._context:
            raise exception.OrphanedObjectError(method='obj_load_attr',
                                                objtype=self.obj_name())

        if attrname == 'consistencygroup':
            self.consistencygroup = objects.ConsistencyGroup.get_by_id(
                self._context, self.consistencygroup_id)

        if attrname == 'snapshots':
            self.snapshots = objects.SnapshotList.get_all_for_cgsnapshot(
                self._context, self.id)

        self.obj_reset_changes(fields=[attrname])
示例#10
0
    def obj_load_attr(self, attrname):
        if attrname not in OPTIONAL_FIELDS:
            raise exception.ObjectActionError(
                action='obj_load_attr',
                reason=_('attribute %s not lazy-loadable') % attrname)
        if not self._context:
            raise exception.OrphanedObjectError(method='obj_load_attr',
                                                objtype=self.obj_name())

        if attrname == 'cgsnapshots':
            self.cgsnapshots = objects.CGSnapshotList.get_all_by_group(
                self._context, self.id)

        if attrname == 'workflows':
            self.workflows = objects.WorkflowList.get_all_by_group(
                self._context, self.id)

        self.obj_reset_changes(fields=[attrname])