Fix network upload in CLI

Fix network upload due to API update.

Change-Id: I8b8c013fe9689423304168c2050264fe67f5f124
Closes-Bug: #1508423
This commit is contained in:
Alexander Saprykin
2015-10-21 15:29:16 +02:00
parent 8ea3b64d21
commit 2a1b048cc4
2 changed files with 13 additions and 21 deletions

View File

@@ -54,17 +54,8 @@ class NetworkAction(Action):
directory=params.dir,
serializer=self.serializer
)
task_result = env.set_network_data(network_data)
if task_result['status'] == 'error':
print(
"Error uploading configuration: {0}".format(
task_result['message']
)
)
else:
print(
"Network configuration uploaded."
)
env.set_network_data(network_data)
print("Network configuration uploaded.")
def verify(self, params):
"""To verify network configuration from some directory

View File

@@ -37,9 +37,8 @@ NETWORK_CONFIG_OK_OUTPUT = {
}
NETWORK_CONFIG_ERROR_OUTPUT = {
'status': 'error',
'message': 'Some error',
'progress': 100,
'errors': [],
}
@@ -70,11 +69,13 @@ class TestNetworkActions(base.UnitTestCase):
self.m_request.get('/api/v1/clusters/1/', json=ENV_OUTPUT)
self.m_request.put(
'/api/v1/clusters/1/network_configuration/neutron',
json=NETWORK_CONFIG_ERROR_OUTPUT)
with patch('sys.stdout') as fake_out:
self.execute(['fuel', 'network', '--env', '1', '--upload', 'smth'])
call_args = fake_out.write.call_args_list[0]
self.assertIn('Error uploading configuration', call_args[0][0])
self.assertIn(
NETWORK_CONFIG_ERROR_OUTPUT['message'], call_args[0][0]
)
status_code=400, json=NETWORK_CONFIG_ERROR_OUTPUT)
with patch("sys.stderr") as m_stderr:
self.assertRaises(
SystemExit, self.execute,
['fuel', 'network', '--env', '1', '--upload', 'smth'])
self.assertIn("400 Client Error", m_stderr.write.call_args[0][0])
self.assertIn(NETWORK_CONFIG_ERROR_OUTPUT['message'],
m_stderr.write.call_args[0][0])