def _on_success(self): """Do some useful job if upgrade was done successfully. """ # Remove saved version files for all upgrades # # NOTE(eli): It solves several problems: # # 1. user runs upgrade 5.0 -> 5.1 which fails # upgrade system saves version which we upgrade # from in file working_dir/5.1/version.yaml. # Then user runs upgrade 5.0 -> 5.0.1 which # successfully upgraded. Then user runs again # upgrade 5.0.1 -> 5.1, but there is saved file # working_dir/5.1/version.yaml which contains # 5.0 version, and upgrade system thinks that # it's upgrading from 5.0 version, as result # it tries to make database dump from wrong # version of container. # # 2. without this hack user can run upgrade # second time and loose his data, this hack # prevents this case because before upgrade # checker will use current version instead # of saved version to determine version which # we run upgrade from. for version_file in glob.glob(self._config.version_files_mask): utils.remove(version_file) self._setup_update_repos()
def _on_success(self): """Do some useful job if upgrade was done successfully. """ # Remove saved version files for all upgrades # # NOTE(eli): It solves several problems: # # 1. user runs upgrade 5.0 -> 5.1 which fails # upgrade system saves version which we upgrade # from in file working_dir/5.1/version.yaml. # Then user runs upgrade 5.0 -> 5.0.1 which # successfully upgraded. Then user runs again # upgrade 5.0.1 -> 5.1, but there is saved file # working_dir/5.1/version.yaml which contains # 5.0 version, and upgrade system thinks that # it's upgrading from 5.0 version, as result # it tries to make database dump from wrong # version of container. # # 2. without this hack user can run upgrade # second time and loose his data, this hack # prevents this case because before upgrade # checker will use current version instead # of saved version to determine version which # we run upgrade from. for version_file in glob.glob(self._config.version_files_mask): utils.remove(version_file)
def on_success(self): """Remove saved version files for all upgrades NOTE(eli): It solves several problems: 1. user runs upgrade 5.0 -> 5.1 which fails upgrade system saves version which we upgrade from in file working_dir/5.1/version.yaml. Then user runs upgrade 5.0 -> 5.0.1 which successfully upgraded. Then user runs again upgrade 5.0.1 -> 5.1, but there is saved file working_dir/5.1/version.yaml which contains 5.0 version, and upgrade system thinks that it's upgrading from 5.0 version, as result it tries to make database dump from wrong version of container. 2. without this hack user can run upgrade second time and loose his data, this hack prevents this case because before upgrade checker will use current version instead of saved version to determine version which we run upgrade from. """ for version_file in glob.glob(self.config.version_files_mask): utils.remove(version_file)
def remove_repos(self): sources = glob.glob(self.host_system_config['repos']['src']) for source in sources: destination = os.path.join( self.host_system_config['repos']['dst'], os.path.basename(source)) utils.remove(destination)
def save_astute_keys(self): """Copy any astute generated keys.""" container_name = self.make_container_name('astute', self.from_version) utils.remove(self.config.astute_keys_path) try: utils.exec_cmd('docker cp {0}:{1} {2}'.format( container_name, self.config.astute_container_keys_path, self.config.working_directory)) except errors.ExecutedErrorNonZeroExitCode as exc: # If there was error, mostly it's because of error # # Error: Could not find the file /var/lib/astute # in container fuel-core-5.0-astute # # It means that user didn't run deployment on his # env, because this directory is created by orchestrator # during the first deployment. # Also it can fail if there was no running container # in both case we should create empty directory to copy # it in after container creation section logger.debug( 'Cannot copy astute keys, creating empty directory ' '%s: %s', self.config.astute_keys_path, exc) if not utils.file_exists(self.config.astute_keys_path): os.mkdir(self.config.astute_keys_path)
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 remove_repos(self): logger.info('Removing repositories...') sources = glob.glob(self.config.openstack['repos']['src']) for source in sources: destination = os.path.join(self.config.openstack['repos']['dst'], os.path.basename(source)) utils.remove(destination)
def remove_puppets(self): logger.info('Removing puppet manifests...') sources = glob.glob(self.config.openstack['puppets']['src']) for source in sources: destination = os.path.join(self.config.openstack['puppets']['dst'], os.path.basename(source)) utils.remove(destination)
def remove_puppets(self): logger.info('Removing puppet manifests...') sources = glob.glob(self.config.openstack['puppets']['src']) for source in sources: destination = os.path.join( self.config.openstack['puppets']['dst'], os.path.basename(source)) utils.remove(destination)
def remove_repos(self): logger.info('Removing repositories...') sources = glob.glob(self.config.openstack['repos']['src']) for source in sources: destination = os.path.join( self.config.openstack['repos']['dst'], os.path.basename(source)) utils.remove(destination)
def undo(self): # destination should be a path/to/file in case source was a file destination = self._to if not os.path.isdir(self._from) and os.path.isdir(self._to): basename = os.path.basename(self._from) destination = os.path.join(self._to, basename) # do nothing if destination doesn't exist remove(destination, ignore_errors=True)
def remove_versions(self): """Copy openstack release versions""" logger.info('Copy openstack release versions...') release_versions_cfg = self.config.openstack['release_versions'] versions = glob.glob(release_versions_cfg['src']) for version_file in versions: dst = os.path.join( release_versions_cfg['dst'], os.path.basename(version_file)) utils.remove(dst)
def remove_versions(self): """Copy openstack release versions """ logger.info('Copy openstack release versions...') release_versions_cfg = self.config.openstack['release_versions'] versions = glob.glob(release_versions_cfg['src']) for version_file in versions: dst = os.path.join(release_versions_cfg['dst'], os.path.basename(version_file)) utils.remove(dst)
def test_remove_dir(self, remove_mock, _, __): utils.remove('path') remove_mock.assert_called_once_with('path', ignore_errors=True)
def test_remove_file_does_not_exist(self, remove_mock, _, __): utils.remove('path') self.method_was_not_called(remove_mock)
def test_remove_link_to_dir(self, remove_mock, _, __, ___): utils.remove('path') remove_mock.assert_called_once_with('path')
def test_remove_file(self, remove_mock, _, __): utils.remove('path') remove_mock.assert_called_once_with('path')
def undo(self): remove(self._to)
def remove_new_configs(self): """Remove new version of configs from the filesystem. """ utils.remove(self.supervisor_config_dir)