def _migrate_volume_prep(self): admin_ctx = context.get_admin_context() # create volume's current host and the destination host db.service_create(admin_ctx, {"host": "test", "topic": CONF.volume_topic, "created_at": timeutils.utcnow()}) db.service_create(admin_ctx, {"host": "test2", "topic": CONF.volume_topic, "created_at": timeutils.utcnow()}) # current status is available volume = self._create_volume(admin_ctx) return volume
def _migrate_volume_prep(self): # create volume's current host and the destination host db.service_create(self.ctx, {"host": "test", "topic": constants.VOLUME_TOPIC, "created_at": timeutils.utcnow()}) db.service_create( self.ctx, {"host": "test2", "topic": constants.VOLUME_TOPIC, "created_at": timeutils.utcnow()} ) # current status is available volume = self._create_volume(self.ctx) return volume
def test_cluster_get_services(self): """Test services is properly populated on non empty cluster.""" # We create another cluster to see we do the selection correctly self._create_populated_cluster(2, name="cluster2") # We create our cluster with 2 up nodes and 1 down cluster, svcs = self._create_populated_cluster(3, 1) # Add a deleted service to the cluster db.service_create(self.ctxt, {"cluster_name": cluster.name, "deleted": True}) db_cluster = db.cluster_get(self.ctxt, name=cluster.name, get_services=True) self.assertEqual(3, len(db_cluster.services)) self.assertSetEqual({svc.id for svc in svcs}, {svc.id for svc in db_cluster.services})
def _migrate_volume_prep(self): # create volume's current host and the destination host db.service_create(self.ctx, {'host': 'test', 'topic': constants.VOLUME_TOPIC, 'created_at': timeutils.utcnow()}) db.service_create(self.ctx, {'host': 'test2', 'topic': constants.VOLUME_TOPIC, 'created_at': timeutils.utcnow()}) # current status is available volume = self._create_volume(self.ctx) return volume
def _migrate_volume_prep(self): # create volume's current host and the destination host db.service_create(self.ctx, {'host': 'test', 'topic': CONF.volume_topic, 'created_at': timeutils.utcnow()}) db.service_create(self.ctx, {'host': 'test2', 'topic': CONF.volume_topic, 'created_at': timeutils.utcnow()}) # current status is available volume = self._create_volume(self.ctx) return volume
def _migrate_volume_prep(self): admin_ctx = context.get_admin_context() # create volume's current host and the destination host db.service_create(admin_ctx, {'host': 'test', 'topic': CONF.volume_topic, 'created_at': timeutils.utcnow()}) db.service_create(admin_ctx, {'host': 'test2', 'topic': CONF.volume_topic, 'created_at': timeutils.utcnow()}) volume = self._create_volume(admin_ctx) return volume
def test_cluster_get_services(self): """Test services is properly populated on non empty cluster.""" # We create another cluster to see we do the selection correctly utils.create_populated_cluster(self.ctxt, 2, name='cluster2') # We create our cluster with 2 up nodes and 1 down cluster, svcs = utils.create_populated_cluster(self.ctxt, 3, 1) # Add a deleted service to the cluster db.service_create(self.ctxt, {'cluster_name': cluster.name, 'deleted': True}) db_cluster = db.cluster_get(self.ctxt, name=cluster.name, get_services=True) self.assertEqual(3, len(db_cluster.services)) self.assertSetEqual({svc.id for svc in svcs}, {svc.id for svc in db_cluster.services})
def create(self): if self.obj_attr_is_set('id'): raise exception.ObjectActionError(action='create', reason=_('already created')) updates = self.cinder_obj_get_changes() db_service = db.service_create(self._context, updates) self._from_db_object(self._context, self, db_service)
def setUp(self): super(TestCleanableManager, self).setUp() self.user_id = fake_constants.USER_ID self.project_id = fake_constants.PROJECT_ID self.context = context.RequestContext(self.user_id, self.project_id, is_admin=True) self.service = db.service_create(self.context, {})
def _migrate_volume_prep(self): admin_ctx = context.get_admin_context() # create volume's current host and the destination host db.service_create( admin_ctx, { 'host': 'test', 'topic': CONF.volume_topic, 'created_at': timeutils.utcnow() }) db.service_create( admin_ctx, { 'host': 'test2', 'topic': CONF.volume_topic, 'created_at': timeutils.utcnow() }) volume = self._create_volume(admin_ctx) return volume
def test_worker_get_all(self): """Test basic get_all method.""" self._create_workers(1) service = db.service_create(self.ctxt, {}) workers = self._create_workers(3, service_id=service.id) db_workers = db.worker_get_all(self.ctxt, service_id=service.id) self._assertEqualListsOfObjects(workers, db_workers)
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 "cluster" in updates: raise exception.ObjectActionError(action="create", reason=_("cluster assigned")) db_service = db.service_create(self._context, updates) self._from_db_object(self._context, self, db_service)
def _create_service_ref(self, context): zone = FLAGS.storage_availability_zone service_ref = db.service_create(context, {'host': self.host, 'binary': self.binary, 'topic': self.topic, 'report_count': 0, 'availability_zone': zone}) self.service_id = service_ref['id']
def _migrate_volume_prep(self): admin_ctx = context.get_admin_context() # create volume's current host and the destination host db.service_create(admin_ctx, {'host': 'test', 'topic': CONF.volume_topic, 'created_at': timeutils.utcnow()}) db.service_create(admin_ctx, {'host': 'test2', 'topic': CONF.volume_topic, 'created_at': timeutils.utcnow()}) # current status is available volume = db.volume_create(admin_ctx, {'status': 'available', 'host': 'test', 'provider_location': '', 'attach_status': ''}) return volume
def _create_service_ref(self, context): zone = CONF.storage_availability_zone service_ref = db.service_create(context, {'host': self.host, 'binary': self.binary, 'topic': self.topic, 'report_count': 0, 'availability_zone': zone}) self.service_id = service_ref['id']
def create_service(ctxt, values=None): values = values or {} v = default_service_values() v.update(values) service = db.service_create(ctxt, v) # We need to read the contents from the DB if we have set updated_at # or created_at fields if 'updated_at' in values or 'created_at' in values: service = db.service_get(ctxt, service.id) return service
def test_create_svc_exists_upgrade_cluster(self, is_upgrading_mock): """Test that we update cluster_name field when cfg has changed.""" # Create the service in the DB db_svc = db.service_create(context.get_admin_context(), {'host': self.host, 'binary': self.binary, 'topic': self.topic, 'cluster_name': None}) cluster_name = 'cluster' app = service.Service.create(host=self.host, binary=self.binary, cluster=cluster_name, topic=self.topic) self._check_app(app, cluster_name, svc_id=db_svc.id)
def test_create_svc_exists_upgrade_cluster(self): """Test that we update cluster_name field when cfg has changed.""" # Create the service in the DB db_svc = db.service_create(context.get_admin_context(), {'host': self.host, 'binary': self.binary, 'topic': self.topic, 'cluster_name': None}) cluster_name = 'cluster' app = service.Service.create(host=self.host, binary=self.binary, cluster=cluster_name, topic=self.topic) self._check_app(app, cluster_name, svc_id=db_svc.id, added_to_cluster=cluster_name)
def test_create_svc_exists_not_upgrade_cluster(self, is_upgrading_mock): """Test we don't update cluster_name on cfg change when upgrading.""" # Create the service in the DB db_svc = db.service_create(context.get_admin_context(), {'host': self.host, 'binary': self.binary, 'topic': self.topic, 'cluster': None}) cluster_name = 'cluster' app = service.Service.create(host=self.host, binary=self.binary, cluster=cluster_name, topic=self.topic) self._check_app(app, cluster_name, cluster_exists=False, is_upgrading=True, svc_id=db_svc.id)
def _create_populated_cluster(self, num_services, num_down_svcs=0, **values): """Helper method that creates a cluster with up and down services.""" up_time = timeutils.utcnow() down_time = up_time - datetime.timedelta(seconds=CONF.service_down_time + 1) cluster = self._create_cluster(**values) svcs = [ db.service_create( self.ctxt, {"cluster_name": cluster.name, "updated_at": down_time if i < num_down_svcs else up_time} ) for i in range(num_services) ] return cluster, svcs
def _create_service_ref(self, context): zone = FLAGS.node_availability_zone service_ref = db.service_create( context, { "host": self.host, "binary": self.binary, "topic": self.topic, "report_count": 0, "availability_zone": zone, }, ) self.service_id = service_ref["id"]
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 'cluster' in updates: raise exception.ObjectActionError( action='create', reason=_('cluster assigned')) if 'uuid' not in updates: updates['uuid'] = uuidutils.generate_uuid() self.uuid = updates['uuid'] db_service = db.service_create(self._context, updates) self._from_db_object(self._context, self, db_service)
def create_populated_cluster(ctxt, num_services, num_down_svcs=0, **values): """Helper method that creates a cluster with up and down services.""" up_time = timeutils.utcnow() down_time = (up_time - datetime.timedelta(seconds=CONF.service_down_time + 1)) cluster = create_cluster(ctxt, **values) svcs = [ db.service_create( ctxt, {'cluster_name': cluster.name, 'host': 'host' + str(i), 'updated_at': down_time if i < num_down_svcs else up_time}) for i in range(num_services) ] return cluster, svcs
def test_create_svc_exists_not_upgrade_cluster(self, is_upgrading_mock): """Test we don't update cluster_name on cfg change when upgrading.""" # Create the service in the DB db_svc = db.service_create( context.get_admin_context(), { 'host': self.host, 'binary': self.binary, 'topic': self.topic, 'cluster': None }) cluster_name = 'cluster' app = service.Service.create(host=self.host, binary=self.binary, cluster=cluster_name, topic=self.topic) self._check_app(app, cluster_name, cluster_exists=False, is_upgrading=True, svc_id=db_svc.id)
def _create_service(self, **values): values.setdefault('uuid', self.uuid()) db.service_create(self.context, values)
def _create_service(self, values): v = self._get_base_values() v.update(values) return db.service_create(self.ctxt, v)