Merge "objects: add Service.get_by_uuid method"
This commit is contained in:
@@ -130,7 +130,8 @@ class Service(base.NovaPersistentObject, base.NovaObject,
|
||||
# Version 1.19: Added get_minimum_version()
|
||||
# Version 1.20: Added get_minimum_version_multi()
|
||||
# Version 1.21: Added uuid
|
||||
VERSION = '1.21'
|
||||
# Version 1.22: Added get_by_uuid()
|
||||
VERSION = '1.22'
|
||||
|
||||
fields = {
|
||||
'id': fields.IntegerField(read_only=True),
|
||||
@@ -266,6 +267,11 @@ class Service(base.NovaPersistentObject, base.NovaObject,
|
||||
db_service = db.service_get(context, service_id)
|
||||
return cls._from_db_object(context, cls(), db_service)
|
||||
|
||||
@base.remotable_classmethod
|
||||
def get_by_uuid(cls, context, service_uuid):
|
||||
db_service = db.service_get_by_uuid(context, service_uuid)
|
||||
return cls._from_db_object(context, cls(), db_service)
|
||||
|
||||
@base.remotable_classmethod
|
||||
def get_by_host_and_topic(cls, context, host, topic):
|
||||
db_service = db.service_get_by_host_and_topic(context, host, topic)
|
||||
|
@@ -1157,7 +1157,7 @@ object_data = {
|
||||
'SecurityGroupList': '1.0-dc8bbea01ba09a2edb6e5233eae85cbc',
|
||||
'SecurityGroupRule': '1.1-ae1da17b79970012e8536f88cb3c6b29',
|
||||
'SecurityGroupRuleList': '1.2-0005c47fcd0fb78dd6d7fd32a1409f5b',
|
||||
'Service': '1.21-4ff88e4cd40f3b3ce923805f29d84ee0',
|
||||
'Service': '1.22-8a740459ab9bf258a19c8fcb875c2d9a',
|
||||
'ServiceList': '1.19-5325bce13eebcbf22edc9678285270cc',
|
||||
'TaskLog': '1.0-78b0534366f29aa3eebb01860fbe18fe',
|
||||
'TaskLogList': '1.0-cc8cce1af8a283b9d28b55fcd682e777',
|
||||
|
@@ -99,6 +99,10 @@ class _TestServiceObject(object):
|
||||
def test_get_by_id(self):
|
||||
self._test_query('service_get', 'get_by_id', 123)
|
||||
|
||||
def test_get_by_uuid(self):
|
||||
self._test_query('service_get_by_uuid', 'get_by_uuid',
|
||||
uuidsentinel.service_uuid)
|
||||
|
||||
def test_get_by_host_and_topic(self):
|
||||
self._test_query('service_get_by_host_and_topic',
|
||||
'get_by_host_and_topic', 'fake-host', 'fake-topic')
|
||||
|
Reference in New Issue
Block a user