def create(self): if self.obj_attr_is_set('id'): raise exception.ObjectActionError(action='create', reason=_('already created')) updates = self.karbor_obj_get_changes() db_service = db.service_create(self._context, updates) self._from_db_object(self._context, self, db_service)
def test_services_create(self): service_ref = db.service_create(self.ctxt, {'host': 'hosttest', 'binary': 'binarytest', 'topic': 'topictest', 'report_count': 0}) self.assertEqual(service_ref['host'], 'hosttest')
def _create_service_ref(self, context): service_ref = db.service_create(context, {'host': self.host, 'binary': self.binary, 'topic': self.topic, 'report_count': 0}) self.service_id = service_ref['id']
def test_services_create(self): service_ref = db.service_create( self.ctxt, { 'host': 'hosttest', 'binary': 'binarytest', 'topic': 'topictest', 'report_count': 0 }) self.assertEqual('hosttest', service_ref['host'])
def test_service_destroy(self): service_ref = db.service_create(self.ctxt, {'host': 'hosttest2', 'binary': 'binarytest2', 'topic': 'topictest2', 'report_count': 0}) service_id = service_ref['id'] db.service_destroy(self.ctxt, service_id) self.assertRaises(exception.ServiceNotFound, db.service_get, self.ctxt, service_id)
def test_service_destroy(self): service_ref = db.service_create( self.ctxt, { 'host': 'hosttest2', 'binary': 'binarytest2', 'topic': 'topictest2', 'report_count': 0 }) service_id = service_ref['id'] db.service_destroy(self.ctxt, service_id) self.assertRaises(exception.ServiceNotFound, db.service_get, self.ctxt, service_id)
def test_service_get_by_host_and_topic(self): service_ref = db.service_create(self.ctxt, {'host': 'hosttest5', 'binary': 'binarytest5', 'topic': 'topictest5', 'report_count': 0}) service_get_ref = db.service_get_by_host_and_topic(self.ctxt, 'hosttest5', 'topictest5') self.assertEqual(service_ref['host'], 'hosttest5') self.assertEqual(service_get_ref['host'], 'hosttest5')
def test_service_get_by_host_and_topic(self): service_ref = db.service_create( self.ctxt, { 'host': 'hosttest5', 'binary': 'binarytest5', 'topic': 'topictest5', 'report_count': 0 }) service_get_ref = db.service_get_by_host_and_topic( self.ctxt, 'hosttest5', 'topictest5') self.assertEqual('hosttest5', service_ref['host']) self.assertEqual('hosttest5', service_get_ref['host'])
def test_service_update(self): service_ref = db.service_create(self.ctxt, {'host': 'hosttest3', 'binary': 'binarytest3', 'topic': 'topictest3', 'report_count': 0}) service_id = service_ref['id'] service_update_ref = db.service_update(self.ctxt, service_id, {'host': 'hosttest4', 'binary': 'binarytest4', 'topic': 'topictest4', 'report_count': 0}) self.assertEqual(service_ref['host'], 'hosttest3') self.assertEqual(service_update_ref['host'], 'hosttest4')
def test_service_update(self): service_ref = db.service_create( self.ctxt, { 'host': 'hosttest3', 'binary': 'binarytest3', 'topic': 'topictest3', 'report_count': 0 }) service_id = service_ref['id'] service_update_ref = db.service_update( self.ctxt, service_id, { 'host': 'hosttest4', 'binary': 'binarytest4', 'topic': 'topictest4', 'report_count': 0 }) self.assertEqual('hosttest3', service_ref['host']) self.assertEqual('hosttest4', service_update_ref['host'])