def create_consistencygroup(self, context, topic, group_id, request_spec_list=None, filter_properties_list=None): self._wait_for_scheduler() try: self.driver.schedule_create_consistencygroup( context, group_id, request_spec_list, filter_properties_list) except exception.NoValidHost: msg = (_("Could not find a host for consistency group " "%(group_id)s.") % {'group_id': group_id}) LOG.error(msg) db.consistencygroup_update(context, group_id, {'status': 'error'}) except Exception: with excutils.save_and_reraise_exception(): LOG.exception(_LE("Failed to create consistency group " "%(group_id)s."), {'group_id': group_id}) db.consistencygroup_update(context, group_id, {'status': 'error'})
def create_consistencygroup(ctxt, host='test_host@fakedrv#fakepool', name='test_cg', description='this is a test cg', status=fields.ConsistencyGroupStatus.AVAILABLE, availability_zone='fake_az', volume_type_id=None, cgsnapshot_id=None, source_cgid=None, **kwargs): """Create a consistencygroup object in the DB.""" cg = objects.ConsistencyGroup(ctxt) cg.host = host cg.user_id = ctxt.user_id or fake.USER_ID cg.project_id = ctxt.project_id or fake.PROJECT_ID cg.status = status cg.name = name cg.description = description cg.availability_zone = availability_zone if volume_type_id: cg.volume_type_id = volume_type_id cg.cgsnapshot_id = cgsnapshot_id cg.source_cgid = source_cgid new_id = kwargs.pop('id', None) cg.update(kwargs) cg.create() if new_id and new_id != cg.id: db.consistencygroup_update(ctxt, cg.id, {'id': new_id}) cg = objects.ConsistencyGroup.get_by_id(ctxt, new_id) return cg
def create_consistencygroup(self, context, topic, group_id, request_spec_list=None, filter_properties_list=None): self._wait_for_scheduler() try: self.driver.schedule_create_consistencygroup( context, group_id, request_spec_list, filter_properties_list) except exception.NoValidHost: msg = (_("Could not find a host for consistency group " "%(group_id)s.") % { 'group_id': group_id }) LOG.error(msg) db.consistencygroup_update(context, group_id, {'status': 'error'}) except Exception: with excutils.save_and_reraise_exception(): LOG.exception( _LE("Failed to create consistency group " "%(group_id)s."), {'group_id': group_id}) db.consistencygroup_update(context, group_id, {'status': 'error'})
def save(self): updates = self.cinder_obj_get_changes() if updates: if "cgsnapshots" in updates: raise exception.ObjectActionError(action="save", reason=_("cgsnapshots changed")) if "volumes" in updates: raise exception.ObjectActionError(action="save", reason=_("volumes changed")) db.consistencygroup_update(self._context, self.id, updates) self.obj_reset_changes()
def save(self): updates = self.cinder_obj_get_changes() if updates: if 'cgsnapshots' in updates: raise exception.ObjectActionError( action='save', reason=_('cgsnapshots changed')) if 'volumes' in updates: raise exception.ObjectActionError( action='save', reason=_('volumes changed')) db.consistencygroup_update(self._context, self.id, updates) self.obj_reset_changes()
def group_update_db(context, group_id, host): """Set the host and the scheduled_at field of a consistencygroup. :returns: A Consistencygroup with the updated fields set properly. """ now = timeutils.utcnow() values = {'host': host, 'updated_at': now} return db.consistencygroup_update(context, group_id, values)
def save(self): updates = self.cinder_obj_get_changes() if updates: db.consistencygroup_update(self._context, self.id, updates) self.obj_reset_changes()