예제 #1
0
 def create(self):
     if self.obj_attr_is_set('id'):
         raise exception.ObjectActionError(action='create',
                                           reason=_('already created'))
     updates = self.sgservice_obj_get_changes()
     db_service = db.service_create(self._context, updates)
     self._from_db_object(self._context, self, db_service)
예제 #2
0
 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')
예제 #3
0
 def _create_service_ref(self, context):
     service_ref = db.service_create(
         context, {'host': self.host,
                   'binary': self.binary,
                   'topic': self.topic,
                   'report_count': 0,
                   'availability_zone': CONF.availability_zone}
     )
     self.service_id = service_ref['id']
예제 #4
0
 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)
예제 #5
0
    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')
예제 #6
0
 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')