예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
파일: router.py 프로젝트: gocloudxyz/astara
    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))
예제 #4
0
    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))
예제 #5
0
    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
        )
예제 #6
0
    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
        )
예제 #7
0
    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)
예제 #8
0
    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)
예제 #9
0
    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)