Fix printing large output when getting hosts in debug mode
The `fuel node --json` cmd prints extremely large output already for a cluster of four nodes. That is why this cmd was replaced by the `fuel2 node list -f json` cmd that prints much less output. Change-Id: Iaa3ef9508ba7a7a203d4cc8d937aa763f7d8fc3d
This commit is contained in:
parent
a79e019cf3
commit
0036a5358c
@ -118,8 +118,6 @@ class AnsibleRunner(object):
|
||||
verbosity=100, check=False)
|
||||
|
||||
def _run_play(self, play_source):
|
||||
LOG.debug('Running play: %s', play_source)
|
||||
|
||||
host_list = play_source['hosts']
|
||||
|
||||
loader = dataloader.DataLoader()
|
||||
@ -154,8 +152,6 @@ class AnsibleRunner(object):
|
||||
if tqm is not None:
|
||||
tqm.cleanup()
|
||||
|
||||
LOG.debug('Execution result: %s', storage)
|
||||
|
||||
return storage
|
||||
|
||||
def run_playbook(self, playbook):
|
||||
@ -202,4 +198,6 @@ class AnsibleRunner(object):
|
||||
else AnsibleExecutionException)
|
||||
raise ek(msg)
|
||||
|
||||
LOG.debug('Execution result: %s' % result)
|
||||
|
||||
return result
|
||||
|
@ -459,11 +459,10 @@ class FuelManagement(cloud_management.CloudManagement):
|
||||
|
||||
def _get_cloud_hosts(self):
|
||||
if not self.cached_cloud_hosts:
|
||||
task = {'command': 'fuel node --json'}
|
||||
task = {'command': 'fuel2 node list -f json'}
|
||||
result = self.execute_on_master_node(task)
|
||||
for r in json.loads(result[0].payload['stdout']):
|
||||
self.cached_cloud_hosts.append(
|
||||
dict(ip=r['ip'], mac=r['mac'], fqdn=r['fqdn']))
|
||||
return json.loads(result[0].payload['stdout'])
|
||||
|
||||
return self.cached_cloud_hosts
|
||||
|
||||
def execute_on_master_node(self, task):
|
||||
@ -489,6 +488,7 @@ class FuelManagement(cloud_management.CloudManagement):
|
||||
|
||||
def _retrieve_hosts_fqdn(self):
|
||||
for host in self._get_cloud_hosts():
|
||||
host['fqdn'] = 'node-%s.domain.tld' % host['id']
|
||||
self.fqdn_to_hosts[host['fqdn']] = host
|
||||
|
||||
def get_nodes(self, fqdns=None):
|
||||
|
@ -27,10 +27,8 @@ class FuelManagementTestCase(test.TestCase):
|
||||
super(FuelManagementTestCase, self).setUp()
|
||||
|
||||
self.fake_ansible_result = fake.FakeAnsibleResult(
|
||||
payload={'stdout': '[{"ip": "10.0.0.2", "mac": "02", '
|
||||
'"fqdn": "node2.com"}, '
|
||||
'{"ip": "10.0.0.3", "mac": "03", '
|
||||
'"fqdn": "node3.com"}]'})
|
||||
payload={'stdout': '[{"ip": "10.0.0.2", "mac": "02", "id": "2"},'
|
||||
' {"ip": "10.0.0.3", "mac": "03", "id": "3"}]'})
|
||||
|
||||
@mock.patch('os_faults.ansible.executor.AnsibleRunner', autospec=True)
|
||||
def test_verify(self, mock_ansible_runner):
|
||||
@ -47,7 +45,7 @@ class FuelManagementTestCase(test.TestCase):
|
||||
fuel_managment.verify()
|
||||
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
mock.call(['fuel.local'], {'command': 'fuel2 node list -f json'}),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'], {'command': 'hostname'}),
|
||||
])
|
||||
|
||||
@ -62,13 +60,12 @@ class FuelManagementTestCase(test.TestCase):
|
||||
nodes = fuel_managment.get_nodes()
|
||||
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
mock.call(['fuel.local'], {'command': 'fuel2 node list -f json'}),
|
||||
])
|
||||
|
||||
self.assertEqual(nodes.hosts, [{'ip': '10.0.0.2', 'fqdn': 'node2.com',
|
||||
'mac': '02'},
|
||||
{'ip': '10.0.0.3', 'fqdn': 'node3.com',
|
||||
'mac': '03'}])
|
||||
self.assertEqual(nodes.hosts,
|
||||
[{'ip': '10.0.0.2', 'mac': '02', "id": "2"},
|
||||
{'ip': '10.0.0.3', 'mac': '03', "id": "3"}])
|
||||
|
||||
@mock.patch('os_faults.ansible.executor.AnsibleRunner', autospec=True)
|
||||
def test_execute_on_cloud(self, mock_ansible_runner):
|
||||
@ -87,7 +84,7 @@ class FuelManagementTestCase(test.TestCase):
|
||||
nodes.get_ips(), {'command': 'mycmd'}, raise_on_error=False)
|
||||
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
mock.call(['fuel.local'], {'command': 'fuel2 node list -f json'}),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'], {'command': 'mycmd'}, []),
|
||||
])
|
||||
|
||||
@ -103,10 +100,11 @@ class FuelManagementTestCase(test.TestCase):
|
||||
'address': 'fuel.local',
|
||||
'username': 'root',
|
||||
})
|
||||
nodes = fuel_managment.get_nodes(fqdns=['node3.com'])
|
||||
nodes = fuel_managment.get_nodes(fqdns=['node-3.domain.tld'])
|
||||
|
||||
self.assertEqual(nodes.hosts, [{'ip': '10.0.0.3', 'fqdn': 'node3.com',
|
||||
'mac': '03'}])
|
||||
self.assertEqual(nodes.hosts, [{'ip': '10.0.0.3',
|
||||
'mac': '03', 'id': '3',
|
||||
'fqdn': 'node-3.domain.tld'}])
|
||||
|
||||
@mock.patch('os_faults.ansible.executor.AnsibleRunner', autospec=True)
|
||||
@ddt.data(('keystone', fuel.KeystoneService),
|
||||
@ -138,9 +136,9 @@ class FuelManagementTestCase(test.TestCase):
|
||||
|
||||
nodes = service.get_nodes()
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
mock.call(['fuel.local'], {'command': 'fuel2 node list -f json'}),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
{'command': service_cls.GET_NODES_CMD}, []),
|
||||
])
|
||||
self.assertEqual(nodes.hosts, [{'ip': '10.0.0.3', 'fqdn': 'node3.com',
|
||||
'mac': '03'}])
|
||||
self.assertEqual(nodes.hosts, [{'ip': '10.0.0.3',
|
||||
'mac': '03', 'id': '3'}])
|
||||
|
@ -28,10 +28,8 @@ class FuelServiceTestCase(test.TestCase):
|
||||
super(FuelServiceTestCase, self).setUp()
|
||||
self.conf = {'address': 'fuel.local', 'username': 'root'}
|
||||
self.fake_ansible_result = fake.FakeAnsibleResult(
|
||||
payload={'stdout': '[{"ip": "10.0.0.2", "mac": "02", '
|
||||
'"fqdn": "node2.com"}, '
|
||||
'{"ip": "10.0.0.3", "mac": "03", '
|
||||
'"fqdn": "node3.com"}]'})
|
||||
payload={'stdout': '[{"ip": "10.0.0.2", "mac": "02", "id": "2"},'
|
||||
' {"ip": "10.0.0.3", "mac": "03", "id": "3"}]'})
|
||||
|
||||
@mock.patch('os_faults.ansible.executor.AnsibleRunner', autospec=True)
|
||||
@ddt.data(('keystone', fuel.KeystoneService),
|
||||
@ -68,7 +66,7 @@ class FuelServiceTestCase(test.TestCase):
|
||||
|
||||
service.kill()
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
mock.call(['fuel.local'], {'command': 'fuel2 node list -f json'}),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
{'command': service_cls.GET_NODES_CMD}, []),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
@ -110,7 +108,7 @@ class FuelServiceTestCase(test.TestCase):
|
||||
|
||||
service.freeze()
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
mock.call(['fuel.local'], {'command': 'fuel2 node list -f json'}),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
{'command': service_cls.GET_NODES_CMD}, []),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
@ -153,7 +151,7 @@ class FuelServiceTestCase(test.TestCase):
|
||||
delay_sec = 10
|
||||
service.freeze(nodes=None, sec=delay_sec)
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
mock.call(['fuel.local'], {'command': 'fuel2 node list -f json'}),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
{'command': service_cls.GET_NODES_CMD}, []),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
@ -196,7 +194,7 @@ class FuelServiceTestCase(test.TestCase):
|
||||
|
||||
service.unfreeze()
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
mock.call(['fuel.local'], {'command': 'fuel2 node list -f json'}),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
{'command': service_cls.GET_NODES_CMD}, []),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
@ -227,7 +225,7 @@ class FuelServiceTestCase(test.TestCase):
|
||||
|
||||
service.unplug()
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
mock.call(['fuel.local'], {'command': 'fuel2 node list -f json'}),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
{'command': service_cls.GET_NODES_CMD}, []),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
@ -259,7 +257,7 @@ class FuelServiceTestCase(test.TestCase):
|
||||
|
||||
service.plug()
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
mock.call(['fuel.local'], {'command': 'fuel2 node list -f json'}),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
{'command': service_cls.GET_NODES_CMD}, []),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
@ -300,7 +298,7 @@ class FuelServiceTestCase(test.TestCase):
|
||||
|
||||
service.restart()
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
mock.call(['fuel.local'], {'command': 'fuel2 node list -f json'}),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
{'command': service_cls.GET_NODES_CMD}, []),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
@ -330,7 +328,7 @@ class FuelServiceTestCase(test.TestCase):
|
||||
self.assertEqual('Task failed on some nodes', str(exception))
|
||||
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
mock.call(['fuel.local'], {'command': 'fuel2 node list -f json'}),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
{'command': service.GET_NODES_CMD}, []),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
@ -357,7 +355,7 @@ class FuelServiceTestCase(test.TestCase):
|
||||
self.assertEqual('Node collection is empty', str(exception))
|
||||
|
||||
ansible_runner_inst.execute.assert_has_calls([
|
||||
mock.call(['fuel.local'], {'command': 'fuel node --json'}),
|
||||
mock.call(['fuel.local'], {'command': 'fuel2 node list -f json'}),
|
||||
mock.call(['10.0.0.2', '10.0.0.3'],
|
||||
{'command': service.GET_NODES_CMD}, []),
|
||||
])
|
||||
|
Loading…
x
Reference in New Issue
Block a user