Beispiel #1
0
 def create(self):
     if self.obj_attr_is_set('id'):
         raise exception.ObjectActionError(action='create',
                                           reason=_('already created'))
     updates = self.smaug_obj_get_changes()
     db_service = db.service_create(self._context, updates)
     self._from_db_object(self._context, self, db_service)
Beispiel #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')
Beispiel #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})
     self.service_id = service_ref['id']
Beispiel #4
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')
Beispiel #5
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)
Beispiel #6
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')
Beispiel #7
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)
Beispiel #8
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')
Beispiel #9
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')
Beispiel #10
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')