Merge "Fix display of availability-zone for manila-manage command"

This commit is contained in:
Jenkins 2015-10-01 15:29:29 +00:00 committed by Gerrit Code Review
commit 57ca688176
2 changed files with 17 additions and 11 deletions

View File

@ -189,14 +189,15 @@ class HostCommands(object):
ctxt = context.get_admin_context()
services = db.service_get_all(ctxt)
if zone:
services = [s for s in services if s['availability_zone'] == zone]
services = [
s for s in services if s['availability_zone']['name'] == zone]
hosts = []
for srv in services:
if not [h for h in hosts if h['host'] == srv['host']]:
hosts.append(srv)
for h in hosts:
print("%-25s\t%-15s" % (h['host'], h['availability_zone']))
print("%-25s\t%-15s" % (h['host'], h['availability_zone']['name']))
class DbCommands(object):
@ -332,9 +333,14 @@ class ServiceCommands(object):
status = 'enabled'
if svc['disabled']:
status = 'disabled'
print(print_format % (svc['binary'], svc['host'].partition('.')[0],
svc['availability_zone'], status, art,
svc['updated_at']))
print(print_format % (
svc['binary'],
svc['host'].partition('.')[0],
svc['availability_zone']['name'],
status,
art,
svc['updated_at'],
))
CATEGORIES = {

View File

@ -166,11 +166,11 @@ class ManilaCmdManageTestCase(test.TestCase):
def test_list(self, print_mock):
serv_1 = {
'host': 'fake_host1',
'availability_zone': 'avail_zone1',
'availability_zone': {'name': 'avail_zone1'},
}
serv_2 = {
'host': 'fake_host2',
'availability_zone': 'avail_zone2',
'availability_zone': {'name': 'avail_zone2'},
}
self.mock_object(db, 'service_get_all',
mock.Mock(return_value=[serv_1, serv_2]))
@ -188,11 +188,11 @@ class ManilaCmdManageTestCase(test.TestCase):
def test_list_zone_is_none(self, print_mock):
serv_1 = {
'host': 'fake_host1',
'availability_zone': 'avail_zone1',
'availability_zone': {'name': 'avail_zone1'},
}
serv_2 = {
'host': 'fake_host2',
'availability_zone': 'avail_zone2',
'availability_zone': {'name': 'avail_zone2'},
}
self.mock_object(db, 'service_get_all',
mock.Mock(return_value=[serv_1, serv_2]))
@ -292,7 +292,7 @@ class ManilaCmdManageTestCase(test.TestCase):
get_admin_context.return_value = ctxt
service = {'binary': 'manila-binary',
'host': 'fake-host.fake-domain',
'availability_zone': 'fake-zone',
'availability_zone': {'name': 'fake-zone'},
'updated_at': '2014-06-30 11:22:33',
'disabled': False}
service_get_all.return_value = [service]
@ -307,7 +307,7 @@ class ManilaCmdManageTestCase(test.TestCase):
'Updated At')
service_format = format % (service['binary'],
service['host'].partition('.')[0],
service['availability_zone'],
service['availability_zone']['name'],
'enabled',
':-)',
service['updated_at'])