Address nits from service create/destroy notification review
This adds two things from the review of change I955d98f9fd4b121f98e172e5ab30eb668a24006d: 1. A utility method to convert a service binary to a valid notification source. 2. Adds a comment in the functional test reminding us that we're using the latest microversion which is how we get the service uuid from the REST API. Change-Id: If67b4e07d608f323c1154f7f379d4eb849e46fbf
This commit is contained in:
parent
8e793a6c6f
commit
fe535cbaa0
|
@ -162,11 +162,7 @@ class NotificationPublisher(NotificationObject):
|
|||
|
||||
@classmethod
|
||||
def from_service_obj(cls, service):
|
||||
# nova-osapi_compute binary name needs to be translated to nova-api
|
||||
# notification source enum value.
|
||||
source = ("nova-api"
|
||||
if service.binary == "nova-osapi_compute"
|
||||
else service.binary)
|
||||
source = fields.NotificationSource.get_source_by_binary(service.binary)
|
||||
return cls(host=service.host, source=source)
|
||||
|
||||
|
||||
|
|
|
@ -809,6 +809,12 @@ class NotificationSource(BaseNovaEnum):
|
|||
ALL = (API, COMPUTE, CONDUCTOR, SCHEDULER,
|
||||
NETWORK, CONSOLEAUTH, CELLS, CONSOLE, METADATA)
|
||||
|
||||
@staticmethod
|
||||
def get_source_by_binary(binary):
|
||||
# nova-osapi_compute binary name needs to be translated to nova-api
|
||||
# notification source enum value.
|
||||
return "nova-api" if binary == "nova-osapi_compute" else binary
|
||||
|
||||
|
||||
class NotificationAction(BaseNovaEnum):
|
||||
UPDATE = 'update'
|
||||
|
|
|
@ -151,6 +151,8 @@ class TestServiceNotificationSample(TestServiceNotificationBase):
|
|||
|
||||
def test_service_destroy(self):
|
||||
self.compute2 = self.start_service('compute', host='host2')
|
||||
# This test runs with the latest microversion by default so we get the
|
||||
# service uuid back from the REST API.
|
||||
compute2_service_id = self.admin_api.get_services(
|
||||
host=self.compute2.host, binary='nova-compute')[0]['id']
|
||||
self.admin_api.api_delete('os-services/%s' % compute2_service_id)
|
||||
|
|
|
@ -736,3 +736,13 @@ class TestSchemaGeneration(test.NoDBTestCase):
|
|||
expected = {'type': ['string'], 'pattern': '[a-z]+[0-9]+',
|
||||
'readonly': False}
|
||||
self.assertEqual(expected, field.get_schema())
|
||||
|
||||
|
||||
class TestNotificationSource(test.NoDBTestCase):
|
||||
def test_get_source_by_binary(self):
|
||||
self.assertEqual('nova-api',
|
||||
fields.NotificationSource.get_source_by_binary(
|
||||
'nova-osapi_compute'))
|
||||
self.assertEqual('nova-metadata',
|
||||
fields.NotificationSource.get_source_by_binary(
|
||||
'nova-metadata'))
|
||||
|
|
Loading…
Reference in New Issue