Filter APIs out from services list
API services records are a special case (unlike RPC services they do not report their state regularly) and must not be exposed out of Compute API. Closes-Bug: #1543625 Change-Id: Icadd380ea1ff75f0cca433b68441ac5dad0ead53
This commit is contained in:
@@ -34,6 +34,8 @@ class ServiceController(object):
|
||||
self.ext_mgr = ext_mgr
|
||||
|
||||
def _get_services(self, req):
|
||||
api_services = ('nova-osapi_compute', 'nova-ec2', 'nova-metadata')
|
||||
|
||||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
|
||||
@@ -41,8 +43,11 @@ class ServiceController(object):
|
||||
# permission checks
|
||||
nova_context.require_admin_context(context)
|
||||
|
||||
services = self.host_api.service_get_all(
|
||||
context, set_zones=True)
|
||||
services = [
|
||||
s
|
||||
for s in self.host_api.service_get_all(context, set_zones=True)
|
||||
if s['binary'] not in api_services
|
||||
]
|
||||
|
||||
host = ''
|
||||
if 'host' in req.GET:
|
||||
|
||||
@@ -39,9 +39,16 @@ class ServiceController(wsgi.Controller):
|
||||
"disable-log-reason": self._disable_log_reason}
|
||||
|
||||
def _get_services(self, req):
|
||||
api_services = ('nova-osapi_compute', 'nova-ec2', 'nova-metadata')
|
||||
|
||||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
_services = self.host_api.service_get_all(context, set_zones=True)
|
||||
|
||||
_services = [
|
||||
s
|
||||
for s in self.host_api.service_get_all(context, set_zones=True)
|
||||
if s['binary'] not in api_services
|
||||
]
|
||||
|
||||
host = ''
|
||||
if 'host' in req.GET:
|
||||
|
||||
@@ -84,6 +84,29 @@ fake_services_list = [
|
||||
last_seen_up=datetime.datetime(2012, 9, 18, 8, 3, 38),
|
||||
forced_down=False,
|
||||
disabled_reason='test4'),
|
||||
# NOTE(rpodolyaka): API services are special case and must be filtered out
|
||||
dict(test_service.fake_service,
|
||||
binary='nova-osapi_compute',
|
||||
host='host2',
|
||||
id=5,
|
||||
disabled=False,
|
||||
topic=None,
|
||||
updated_at=None,
|
||||
created_at=datetime.datetime(2012, 9, 18, 2, 46, 28),
|
||||
last_seen_up=None,
|
||||
forced_down=False,
|
||||
disabled_reason=None),
|
||||
dict(test_service.fake_service,
|
||||
binary='nova-metadata',
|
||||
host='host2',
|
||||
id=6,
|
||||
disabled=False,
|
||||
topic=None,
|
||||
updated_at=None,
|
||||
created_at=datetime.datetime(2012, 9, 18, 2, 46, 28),
|
||||
last_seen_up=None,
|
||||
forced_down=False,
|
||||
disabled_reason=None),
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user