def create(self): if self.obj_attr_is_set('id'): raise exception.ObjectActionError(action='create', reason=_('already_created')) updates = self.cinder_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)
def _create_cgsnapshot( name="test_cgsnapshot", description="this is a test cgsnapshot", consistencygroup_id="1", status="creating" ): """Create a cgsnapshot object.""" cgsnapshot = {} cgsnapshot["user_id"] = "fake" cgsnapshot["project_id"] = "fake" cgsnapshot["consistencygroup_id"] = consistencygroup_id cgsnapshot["name"] = name cgsnapshot["description"] = description cgsnapshot["status"] = status return db.cgsnapshot_create(context.get_admin_context(), cgsnapshot)["id"]
def _create_cgsnapshot(name='test_cgsnapshot', description='this is a test cgsnapshot', consistencygroup_id='1', status='creating'): """Create a cgsnapshot object.""" cgsnapshot = {} cgsnapshot['user_id'] = 'fake' cgsnapshot['project_id'] = 'fake' cgsnapshot['consistencygroup_id'] = consistencygroup_id cgsnapshot['name'] = name cgsnapshot['description'] = description cgsnapshot['status'] = status return db.cgsnapshot_create(context.get_admin_context(), cgsnapshot)['id']
def _create_cgsnapshot( name='test_cgsnapshot', description='this is a test cgsnapshot', consistencygroup_id='1', status='creating'): """Create a cgsnapshot object.""" cgsnapshot = {} cgsnapshot['user_id'] = 'fake' cgsnapshot['project_id'] = 'fake' cgsnapshot['consistencygroup_id'] = consistencygroup_id cgsnapshot['name'] = name cgsnapshot['description'] = description cgsnapshot['status'] = status return db.cgsnapshot_create(context.get_admin_context(), cgsnapshot)['id']
def create_cgsnapshot(ctxt, name='test_cgsnap', description='this is a test cgsnap', status='available', consistencygroup_id=None, **kwargs): """Create a cgsnapshot object in the DB.""" cgsnap = {} cgsnap['user_id'] = ctxt.user_id cgsnap['project_id'] = ctxt.project_id cgsnap['status'] = status cgsnap['name'] = name cgsnap['description'] = description cgsnap['consistencygroup_id'] = consistencygroup_id for key in kwargs: cgsnap[key] = kwargs[key] return db.cgsnapshot_create(ctxt, cgsnap)
def create_cgsnapshot( ctxt, name="test_cgsnap", description="this is a test cgsnap", status="available", consistencygroup_id=None, **kwargs ): """Create a cgsnapshot object in the DB.""" cgsnap = {} cgsnap["user_id"] = ctxt.user_id cgsnap["project_id"] = ctxt.project_id cgsnap["status"] = status cgsnap["name"] = name cgsnap["description"] = description cgsnap["consistencygroup_id"] = consistencygroup_id for key in kwargs: cgsnap[key] = kwargs[key] return db.cgsnapshot_create(ctxt, cgsnap)
def create_cgsnapshot(ctxt, consistencygroup_id, name='test_cgsnapshot', description='this is a test cgsnapshot', status='creating', recursive_create_if_needed=True, return_vo=True, **kwargs): """Create a cgsnapshot object in the DB.""" values = { 'user_id': ctxt.user_id or fake.USER_ID, 'project_id': ctxt.project_id or fake.PROJECT_ID, 'status': status, 'name': name, 'description': description, 'consistencygroup_id': consistencygroup_id} values.update(kwargs) if recursive_create_if_needed and consistencygroup_id: create_cg = False try: objects.ConsistencyGroup.get_by_id(ctxt, consistencygroup_id) create_vol = not db.volume_get_all_by_group( ctxt, consistencygroup_id) except exception.ConsistencyGroupNotFound: create_cg = True create_vol = True if create_cg: create_consistencygroup(ctxt, id=consistencygroup_id) if create_vol: create_volume(ctxt, consistencygroup_id=consistencygroup_id) cgsnap = db.cgsnapshot_create(ctxt, values) if not return_vo: return cgsnap return objects.CGSnapshot.get_by_id(ctxt, cgsnap.id)