コード例 #1
0
ファイル: base.py プロジェクト: isuzdal/fuel-upgrade
    def update_astute_config(self, defaults=None, overwrites=None):
        """Update astute config and backup old one

        Read astute.yaml config file, update it with new config,
        copy old file to backup location and save new astute.yaml.
        """
        # NOTE(ikalnitsky): we need to re-read astute.yaml in order protect
        # us from loosing some useful injection of another hook
        astute_config = copy.deepcopy(defaults or {})
        astute_config = utils.dict_merge(
            astute_config,
            read_yaml_config(self.config.current_fuel_astute_path))
        astute_config = utils.dict_merge(
            astute_config,
            overwrites or {})

        # NOTE(eli): Just save file for backup in case
        # if user wants to restore it manually
        utils.copy_file(
            self.config.current_fuel_astute_path,
            '{0}_{1}'.format(self.config.current_fuel_astute_path,
                             self.config.from_version),
            overwrite=False)

        utils.save_as_yaml(self.config.current_fuel_astute_path, astute_config)
コード例 #2
0
    def test_save_as_yaml(self, yaml_mock):
        path = '/tmp/path'
        data = {'a': 'b'}
        mock_open = self.mock_open('')
        with mock.patch('__builtin__.open', mock_open):
            utils.save_as_yaml(path, data)

        yaml_mock.dump.assert_called_once_with(data, default_flow_style=False)
コード例 #3
0
ファイル: test_utils.py プロジェクト: koder-ua/nailgun-fcert
    def test_save_as_yaml(self, yaml_mock):
        path = '/tmp/path'
        data = {'a': 'b'}
        mock_open = self.mock_open('')
        with mock.patch('__builtin__.open', mock_open):
            utils.save_as_yaml(path, data)

        yaml_mock.dump.assert_called_once_with(data, default_flow_style=False)
コード例 #4
0
    def run(self):
        """Adds default credentials to config file
        """
        astute_config = deepcopy(self.credentials)
        astute_config.update(self.config.astute)

        # NOTE(eli): Just save file for backup in case
        # if user wants to restore it manually
        utils.copy_file(
            self.config.current_fuel_astute_path,
            '{0}_{1}'.format(self.config.current_fuel_astute_path,
                             self.config.from_version),
            overwrite=False)

        utils.save_as_yaml(self.config.current_fuel_astute_path, astute_config)
コード例 #5
0
    def run(self):
        """Adds default credentials to config file
        """
        # NOTE(ikalnitsky): we need to re-read astute.yaml in order protect
        # us from loosing some useful injection of another hook
        astute_config = deepcopy(self.credentials)
        astute_config.update(
            read_yaml_config(self.config.current_fuel_astute_path))

        # NOTE(eli): Just save file for backup in case
        # if user wants to restore it manually
        utils.copy_file(self.config.current_fuel_astute_path,
                        '{0}_{1}'.format(self.config.current_fuel_astute_path,
                                         self.config.from_version),
                        overwrite=False)

        utils.save_as_yaml(self.config.current_fuel_astute_path, astute_config)
コード例 #6
0
    def run(self):
        """Adds default credentials to config file
        """
        # NOTE(ikalnitsky): we need to re-read astute.yaml in order protect
        # us from loosing some useful injection of another hook
        astute_config = deepcopy(self.credentials)
        astute_config.update(
            read_yaml_config(self.config.current_fuel_astute_path))

        # NOTE(eli): Just save file for backup in case
        # if user wants to restore it manually
        utils.copy_file(
            self.config.current_fuel_astute_path,
            '{0}_{1}'.format(self.config.current_fuel_astute_path,
                             self.config.from_version),
            overwrite=False)

        utils.save_as_yaml(self.config.current_fuel_astute_path, astute_config)
コード例 #7
0
    def run(self):
        """Replaces config file with current DNS domain
        """
        # NOTE(ikalnitsky): we need to re-read astute.yaml in order protect
        # us from loosing some useful injection of another hook
        astute_config = read_yaml_config(self.config.current_fuel_astute_path)
        hostname, sep, realdomain = os.uname()[1].partition('.')

        astute_config['DNS_DOMAIN'] = realdomain
        astute_config['DNS_SEARCH'] = realdomain

        # NOTE(mattymo): Just save file for backup in case
        # if user wants to restore it manually
        utils.copy_file(self.config.current_fuel_astute_path,
                        '{0}_{1}'.format(self.config.current_fuel_astute_path,
                                         self.config.from_version),
                        overwrite=False)

        utils.save_as_yaml(self.config.current_fuel_astute_path, astute_config)
コード例 #8
0
ファイル: base.py プロジェクト: toby82/fuel-web
    def update_astute_config(self, defaults=None, overwrites=None):
        """Read astute.yaml config file, update it with new config,
        copy old file to backup location and save new astute.yaml.
        """
        # NOTE(ikalnitsky): we need to re-read astute.yaml in order protect
        # us from loosing some useful injection of another hook
        astute_config = copy.deepcopy(defaults or {})
        astute_config = utils.dict_merge(
            astute_config,
            read_yaml_config(self.config.current_fuel_astute_path))
        astute_config = utils.dict_merge(astute_config, overwrites or {})

        # NOTE(eli): Just save file for backup in case
        # if user wants to restore it manually
        utils.copy_file(self.config.current_fuel_astute_path,
                        '{0}_{1}'.format(self.config.current_fuel_astute_path,
                                         self.config.from_version),
                        overwrite=False)

        utils.save_as_yaml(self.config.current_fuel_astute_path, astute_config)
コード例 #9
0
    def run(self):
        """Replaces config file with current DNS domain
        """
        # NOTE(ikalnitsky): we need to re-read astute.yaml in order protect
        # us from loosing some useful injection of another hook
        astute_config = read_yaml_config(self.config.current_fuel_astute_path)
        hostname, sep, realdomain = os.uname()[1].partition('.')

        astute_config['DNS_DOMAIN'] = realdomain
        astute_config['DNS_SEARCH'] = realdomain

        # NOTE(mattymo): Just save file for backup in case
        # if user wants to restore it manually
        utils.copy_file(
            self.config.current_fuel_astute_path,
            '{0}_{1}'.format(self.config.current_fuel_astute_path,
                             self.config.from_version),
            overwrite=False)

        utils.save_as_yaml(self.config.current_fuel_astute_path, astute_config)