def update_config(self, management_address, config): """Updates appliance configuration This is responsible for pushing configuration to the managed appliance """ self.log.info(_('Updating config for %s'), self.name) astara_client.update_config(management_address, self.mgt_port, config)
def update_config(self, management_address, config): """Updates appliance configuration This is responsible for pushing configuration to the managed appliance """ self.log.info(_('Updating config for %s'), self.name) start_time = timeutils.utcnow() astara_client.update_config( management_address, self.mgt_port, config) delta = timeutils.delta_seconds(start_time, timeutils.utcnow()) self.log.info(_('Config updated for %s after %s seconds'), self.name, round(delta, 2))
def test_update_config_failure(self): config = {'foo': 'bar'} self.mock_put.return_value.status_code = 500 self.mock_put.return_value.text = 'error_text' with self.assertRaises(Exception): astara_client.update_config('fe80::2', 5000, config) self.mock_put.assert_called_once_with( 'http://[fe80::2]:5000/v1/system/config', data=b'{"foo": "bar"}', headers={'Content-type': 'application/json'}, timeout=90 )
def test_update_config_failure(self): config = {'foo': 'bar'} self.mock_put.return_value.status_code = 500 self.mock_put.return_value.text = 'error_text' with self.assertRaises(Exception): astara_client.update_config('fe80::2', 5000, config) self.mock_put.assert_called_once_with( 'http://[fe80::2]:5000/v1/system/config', data='{"foo": "bar"}', headers={'Content-type': 'application/json'}, timeout=90 )
def test_update_config(self): config = {'foo': 'bar'} self.mock_put.return_value.status_code = 200 self.mock_put.return_value.json.return_value = config resp = astara_client.update_config('fe80::2', 5000, config) self.mock_put.assert_called_once_with( 'http://[fe80::2]:5000/v1/system/config', data=b'{"foo": "bar"}', headers={'Content-type': 'application/json'}, timeout=90) self.assertEqual(resp, config)
def test_update_config(self): config = {'foo': 'bar'} self.mock_put.return_value.status_code = 200 self.mock_put.return_value.json.return_value = config resp = astara_client.update_config('fe80::2', 5000, config) self.mock_put.assert_called_once_with( 'http://[fe80::2]:5000/v1/system/config', data='{"foo": "bar"}', headers={'Content-type': 'application/json'}, timeout=90) self.assertEqual(resp, config)
def test_update_config_with_custom_config(self): config = {'foo': 'bar'} self.mock_put.return_value.status_code = 200 self.mock_put.return_value.json.return_value = config with mock.patch.object(astara_client.cfg, 'CONF') as cfg: cfg.config_timeout = 5 resp = astara_client.update_config('fe80::2', 5000, config) self.mock_put.assert_called_once_with( 'http://[fe80::2]:5000/v1/system/config', data=b'{"foo": "bar"}', headers={'Content-type': 'application/json'}, timeout=5) self.assertEqual(config, resp)