Display hostname in the default formatter
Change-Id: If6021ee5449cf74159640fdcc3f248c9f99a4105
This commit is contained in:
parent
e795f6c841
commit
2aeb60434e
|
@ -60,6 +60,9 @@ class DefaultFormat(object):
|
|||
node=_utils.log_res(instance.node),
|
||||
state=instance.state.name)
|
||||
|
||||
if instance.hostname:
|
||||
_print('* Hostname: %(hostname)s', hostname=instance.hostname)
|
||||
|
||||
if instance.is_deployed:
|
||||
ips = instance.ip_addresses()
|
||||
if ips:
|
||||
|
|
|
@ -79,6 +79,7 @@ class TestDeploy(testtools.TestCase):
|
|||
instance.state = _instance.InstanceState.ACTIVE
|
||||
instance.is_deployed = True
|
||||
instance.ip_addresses.return_value = {'private': ['1.2.3.4']}
|
||||
instance.hostname = None
|
||||
|
||||
args = ['deploy', '--network', 'mynet', '--image', 'myimg',
|
||||
'--resource-class', 'compute']
|
||||
|
@ -133,6 +134,7 @@ class TestDeploy(testtools.TestCase):
|
|||
instance.node.name = None
|
||||
instance.node.id = '123'
|
||||
instance.state = _instance.InstanceState.ACTIVE
|
||||
instance.hostname = None
|
||||
|
||||
args = ['deploy', '--network', 'mynet', '--image', 'myimg',
|
||||
'--resource-class', 'compute']
|
||||
|
@ -148,6 +150,7 @@ class TestDeploy(testtools.TestCase):
|
|||
instance.node.name = None
|
||||
instance.node.id = '123'
|
||||
instance.state = _instance.InstanceState.DEPLOYING
|
||||
instance.hostname = None
|
||||
|
||||
args = ['deploy', '--network', 'mynet', '--image', 'myimg',
|
||||
'--resource-class', 'compute']
|
||||
|
@ -355,10 +358,25 @@ class TestDeploy(testtools.TestCase):
|
|||
self.assertFalse(mock_pr.return_value.provision_node.called)
|
||||
|
||||
def test_args_hostname(self, mock_pr):
|
||||
instance = mock_pr.return_value.provision_node.return_value
|
||||
instance.create_autospec(_instance.Instance)
|
||||
instance.is_deployed = True
|
||||
instance.node.name = None
|
||||
instance.node.id = '123'
|
||||
instance.state = _instance.InstanceState.ACTIVE
|
||||
instance.hostname = 'host'
|
||||
instance.ip_addresses.return_value = {'private': ['1.2.3.4']}
|
||||
|
||||
args = ['deploy', '--network', 'mynet', '--image', 'myimg',
|
||||
'--hostname', 'host', '--resource-class', 'compute']
|
||||
self._check(mock_pr, args, {}, {'hostname': 'host'})
|
||||
|
||||
self.mock_print.assert_has_calls([
|
||||
mock.call(mock.ANY, node='123', state='ACTIVE'),
|
||||
mock.call(mock.ANY, hostname='host'),
|
||||
mock.call(mock.ANY, ips='private=1.2.3.4')
|
||||
])
|
||||
|
||||
def test_args_with_candidates(self, mock_pr):
|
||||
args = ['deploy', '--network', 'mynet', '--image', 'myimg',
|
||||
'--candidate', 'node1', '--candidate', 'node2',
|
||||
|
@ -601,8 +619,10 @@ class TestShowWait(testtools.TestCase):
|
|||
|
||||
self.mock_print.assert_has_calls([
|
||||
mock.call(mock.ANY, node='name-1 (UUID 1)', state='ACTIVE'),
|
||||
mock.call(mock.ANY, hostname='hostname1'),
|
||||
mock.call(mock.ANY, ips='private=1.2.3.4'),
|
||||
mock.call(mock.ANY, node='name-2 (UUID 2)', state='DEPLOYING'),
|
||||
mock.call(mock.ANY, hostname='hostname2'),
|
||||
])
|
||||
mock_pr.return_value.show_instances.assert_called_once_with(
|
||||
['uuid1', 'hostname2'])
|
||||
|
@ -614,8 +634,10 @@ class TestShowWait(testtools.TestCase):
|
|||
|
||||
self.mock_print.assert_has_calls([
|
||||
mock.call(mock.ANY, node='name-1 (UUID 1)', state='ACTIVE'),
|
||||
mock.call(mock.ANY, hostname='hostname1'),
|
||||
mock.call(mock.ANY, ips='private=1.2.3.4'),
|
||||
mock.call(mock.ANY, node='name-2 (UUID 2)', state='DEPLOYING'),
|
||||
mock.call(mock.ANY, hostname='hostname2'),
|
||||
])
|
||||
mock_pr.return_value.list_instances.assert_called_once_with()
|
||||
|
||||
|
@ -627,8 +649,10 @@ class TestShowWait(testtools.TestCase):
|
|||
|
||||
self.mock_print.assert_has_calls([
|
||||
mock.call(mock.ANY, node='name-1 (UUID 1)', state='ACTIVE'),
|
||||
mock.call(mock.ANY, hostname='hostname1'),
|
||||
mock.call(mock.ANY, ips='private=1.2.3.4'),
|
||||
mock.call(mock.ANY, node='name-2 (UUID 2)', state='DEPLOYING'),
|
||||
mock.call(mock.ANY, hostname='hostname2'),
|
||||
])
|
||||
mock_pr.return_value.wait_for_provisioning.assert_called_once_with(
|
||||
['uuid1', 'hostname2'], timeout=None)
|
||||
|
@ -641,8 +665,10 @@ class TestShowWait(testtools.TestCase):
|
|||
|
||||
self.mock_print.assert_has_calls([
|
||||
mock.call(mock.ANY, node='name-1 (UUID 1)', state='ACTIVE'),
|
||||
mock.call(mock.ANY, hostname='hostname1'),
|
||||
mock.call(mock.ANY, ips='private=1.2.3.4'),
|
||||
mock.call(mock.ANY, node='name-2 (UUID 2)', state='DEPLOYING'),
|
||||
mock.call(mock.ANY, hostname='hostname2'),
|
||||
])
|
||||
mock_pr.return_value.wait_for_provisioning.assert_called_once_with(
|
||||
['uuid1', 'hostname2'], timeout=42)
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
Hostname is now displayed in the default format when displaying instances.
|
Loading…
Reference in New Issue