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() ctxt = context.get_admin_context()
services = db.service_get_all(ctxt) services = db.service_get_all(ctxt)
if zone: 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 = [] hosts = []
for srv in services: for srv in services:
if not [h for h in hosts if h['host'] == srv['host']]: if not [h for h in hosts if h['host'] == srv['host']]:
hosts.append(srv) hosts.append(srv)
for h in hosts: 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): class DbCommands(object):
@ -332,9 +333,14 @@ class ServiceCommands(object):
status = 'enabled' status = 'enabled'
if svc['disabled']: if svc['disabled']:
status = 'disabled' status = 'disabled'
print(print_format % (svc['binary'], svc['host'].partition('.')[0], print(print_format % (
svc['availability_zone'], status, art, svc['binary'],
svc['updated_at'])) svc['host'].partition('.')[0],
svc['availability_zone']['name'],
status,
art,
svc['updated_at'],
))
CATEGORIES = { CATEGORIES = {

View File

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