Example #1
0
    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)
 def run(self):
     # save dhcrelay.conf to versioned folder
     copy_file(self._save_from, self._save_to)
     # remove dhcrelay.conf from global supervisor scope
     remove(self._save_from)
     # stop dhcrelay in supervisord, otherwise it will be re-ran
     # automatically
     safe_exec_cmd('supervisorctl stop dhcrelay_monitor')
Example #3
0
 def run(self):
     # save dhcrelay.conf to versioned folder
     copy_file(self._save_from, self._save_to)
     # remove dhcrelay.conf from global supervisor scope
     remove(self._save_from)
     # stop dhcrelay in supervisord, otherwise it will be re-ran
     # automatically
     safe_exec_cmd('supervisorctl stop dhcrelay_monitor')
    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)
Example #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)
    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)
    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)
Example #8
0
    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)
    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)
    def test_copy_file_do_not_overwrite(self, copy_mock, _, __):
        from_path = '/from_path.txt'
        to_path = '/to_path.txt'

        utils.copy_file(from_path, to_path, overwrite=False)
        self.method_was_not_called(copy_mock)
    def test_copy_file_to_dir(self, copy_mock, _):
        from_path = '/from_path.txt'
        to_path = '/to_path'

        utils.copy_file(from_path, to_path)
        copy_mock.assert_called_once_with(from_path, '/to_path/from_path.txt')
Example #12
0
    def test_copy_file_do_not_overwrite(self, copy_mock, _, __):
        from_path = '/from_path.txt'
        to_path = '/to_path.txt'

        utils.copy_file(from_path, to_path, overwrite=False)
        self.method_was_not_called(copy_mock)
Example #13
0
    def test_copy_file_to_dir(self, copy_mock, _):
        from_path = '/from_path.txt'
        to_path = '/to_path'

        utils.copy_file(from_path, to_path)
        copy_mock.assert_called_once_with(from_path, '/to_path/from_path.txt')