def pre_rolling_restart(self, env): import params env.set_params(params) if params.version and compare_versions(format_hdp_stack_version(params.version), '2.2.0.0') >= 0: upgrade.backup_data() Execute(format("hdp-select set knox-server {version}"))
def pre_upgrade_restart(self, env, upgrade_type=None): import params env.set_params(params) if params.version and compare_versions(format_hdp_stack_version(params.version), '2.2.0.0') >= 0: absolute_backup_dir = None if params.upgrade_direction and params.upgrade_direction == Direction.UPGRADE: Logger.info("Backing up directories. Initial conf folder: %s" % os.path.realpath(params.knox_conf_dir)) # This will backup the contents of the conf directory into /tmp/knox-upgrade-backup/knox-conf-backup.tar absolute_backup_dir = upgrade.backup_data() # conf-select will change the symlink to the conf folder. conf_select.select(params.stack_name, "knox", params.version) hdp_select.select("knox-server", params.version) # Extract the tar of the old conf folder into the new conf directory if absolute_backup_dir is not None and params.upgrade_direction and params.upgrade_direction == Direction.UPGRADE: conf_tar_source_path = os.path.join(absolute_backup_dir, upgrade.BACKUP_CONF_ARCHIVE) if os.path.exists(conf_tar_source_path): extract_dir = os.path.realpath(params.knox_conf_dir) conf_tar_dest_path = os.path.join(extract_dir, upgrade.BACKUP_CONF_ARCHIVE) Logger.info("Copying %s into %s file." % (upgrade.BACKUP_CONF_ARCHIVE, conf_tar_dest_path)) Execute(('cp', conf_tar_source_path, conf_tar_dest_path), sudo = True, ) tar_archive.untar_archive(conf_tar_source_path, extract_dir) File(conf_tar_dest_path, action = "delete", )
def pre_rolling_restart(self, env): import params env.set_params(params) if params.version and compare_versions(format_hdp_stack_version(params.version), '2.2.0.0') >= 0: absolute_backup_dir = None if params.upgrade_direction and params.upgrade_direction == Direction.UPGRADE: Logger.info("Backing up directories. Initial conf folder: %s" % os.path.realpath(params.knox_conf_dir)) # This will backup the contents of the conf directory into /tmp/knox-upgrade-backup/knox-conf-backup.tar absolute_backup_dir = upgrade.backup_data() # conf-select will change the symlink to the conf folder. conf_select.select(params.stack_name, "knox", params.version) hdp_select.select("knox-server", params.version) # Extract the tar of the old conf folder into the new conf directory if absolute_backup_dir is not None and params.upgrade_direction and params.upgrade_direction == Direction.UPGRADE: conf_tar_source_path = os.path.join(absolute_backup_dir, upgrade.BACKUP_CONF_ARCHIVE) if os.path.exists(conf_tar_source_path): extract_dir = os.path.realpath(params.knox_conf_dir) conf_tar_dest_path = os.path.join(extract_dir, upgrade.BACKUP_CONF_ARCHIVE) Logger.info("Copying %s into %s file." % (upgrade.BACKUP_CONF_ARCHIVE, conf_tar_dest_path)) Execute(('cp', conf_tar_source_path, conf_tar_dest_path), sudo = True, ) tar_archive.untar_archive(conf_tar_source_path, extract_dir) File(conf_tar_dest_path, action = "delete", )
def pre_upgrade_restart(self, env, upgrade_type=None): import params env.set_params(params) # backup the data directory to /tmp/knox-upgrade-backup/knox-data-backup.tar just in case # something happens; Knox is interesting in that they re-generate missing files like # keystores which can cause side effects if the upgrade goes wrong if params.upgrade_direction and params.upgrade_direction == Direction.UPGRADE: absolute_backup_dir = upgrade.backup_data() Logger.info("Knox data was successfully backed up to {0}".format( absolute_backup_dir)) install_knox() # seed the new Knox data directory with the keystores of yesteryear if params.upgrade_direction == Direction.UPGRADE: upgrade.seed_current_data_directory()
def pre_rolling_restart(self, env): import params env.set_params(params) if params.version and compare_versions( format_hdp_stack_version(params.version), '2.2.0.0') >= 0: absolute_backup_dir = None if params.upgrade_direction and params.upgrade_direction == Direction.UPGRADE: Logger.info("Backing up directories. Initial conf folder: %s" % os.path.realpath(params.knox_conf_dir)) # This will backup the contents of the conf directory into /tmp/knox-upgrade-backup/knox-conf-backup.tar absolute_backup_dir = upgrade.backup_data() # conf-select will change the symlink to the conf folder. conf_select.select(params.stack_name, "knox", params.version) hdp_select.select("knox-server", params.version) # Extract the tar of the old conf folder into the new conf directory if absolute_backup_dir is not None and params.upgrade_direction and params.upgrade_direction == Direction.UPGRADE: conf_tar_source_path = os.path.join( absolute_backup_dir, upgrade.BACKUP_CONF_ARCHIVE) if os.path.exists(conf_tar_source_path): extract_dir = os.path.realpath(params.knox_conf_dir) conf_tar_dest_path = os.path.join( extract_dir, upgrade.BACKUP_CONF_ARCHIVE) Logger.info( "Copying %s into %s file." % (upgrade.BACKUP_CONF_ARCHIVE, conf_tar_dest_path)) Execute("cp %s %s" % (conf_tar_source_path, conf_tar_dest_path)) tarball = None try: tarball = tarfile.open(conf_tar_source_path, "r") Logger.info("Extracting %s into %s directory." % (upgrade.BACKUP_CONF_ARCHIVE, extract_dir)) tarball.extractall(extract_dir) Logger.info("Deleting temporary tar at %s" % conf_tar_dest_path) Execute("rm %s" % (conf_tar_dest_path)) finally: if tarball: tarball.close()
def pre_upgrade_restart(self, env, upgrade_type=None): import params env.set_params(params) # backup the data directory to /tmp/knox-upgrade-backup/knox-data-backup.tar just in case # something happens; Knox is interesting in that they re-generate missing files like # keystores which can cause side effects if the upgrade goes wrong if params.upgrade_direction and params.upgrade_direction == Direction.UPGRADE: absolute_backup_dir = upgrade.backup_data() Logger.info("Knox data was successfully backed up to {0}".format(absolute_backup_dir)) # <conf-selector-tool> will change the symlink to the conf folder. conf_select.select(params.stack_name, "knox", params.version) stack_select.select("knox-server", params.version) # seed the new Knox data directory with the keystores of yesteryear if params.upgrade_direction == Direction.UPGRADE: upgrade.seed_current_data_directory()
def pre_upgrade_restart(self, env, upgrade_type=None): import params env.set_params(params) if params.version and compare_versions( format_stack_version(params.version), '4.0.0.0') >= 0: absolute_backup_dir = None if params.upgrade_direction and params.upgrade_direction == Direction.UPGRADE: Logger.info("Backing up directories. Initial conf folder: %s" % os.path.realpath(params.knox_conf_dir)) # This will backup the contents of the conf directory into /tmp/knox-upgrade-backup/knox-conf-backup.tar absolute_backup_dir = upgrade.backup_data() # conf-select will change the symlink to the conf folder. stack_select.select_packages(params.version) # Extract the tar of the old conf folder into the new conf directory if absolute_backup_dir is not None and params.upgrade_direction and params.upgrade_direction == Direction.UPGRADE: conf_tar_source_path = os.path.join( absolute_backup_dir, upgrade.BACKUP_CONF_ARCHIVE) data_tar_source_path = os.path.join( absolute_backup_dir, upgrade.BACKUP_DATA_ARCHIVE) if os.path.exists(conf_tar_source_path): extract_dir = os.path.realpath(params.knox_conf_dir) conf_tar_dest_path = os.path.join( extract_dir, upgrade.BACKUP_CONF_ARCHIVE) Logger.info( "Copying %s into %s file." % (upgrade.BACKUP_CONF_ARCHIVE, conf_tar_dest_path)) Execute( ('cp', conf_tar_source_path, conf_tar_dest_path), sudo=True, ) tar_archive.untar_archive(conf_tar_source_path, extract_dir) File( conf_tar_dest_path, action="delete", ) extract_dir = os.path.realpath(params.knox_data_dir + "-" + params.version + "/security") if not os.path.exists(extract_dir): Directory(extract_dir, owner=params.knox_user, group=params.knox_group, create_parents=True) data_tar_dest_path = os.path.join( extract_dir, upgrade.BACKUP_DATA_ARCHIVE) Logger.info("Copying %s into %s file." % (upgrade.BACKUP_DATA_ARCHIVE, data_tar_dest_path + "/security")) Execute( ('cp', data_tar_source_path, data_tar_dest_path), sudo=True, ) tar_archive.untar_archive(data_tar_source_path, extract_dir) File( data_tar_dest_path, action="delete", ) populate_topology_template = format( 'cp /usr/iop/{version}/etc/knox/conf.dist/topologies/* {knox_conf_dir}/topologies' ) Logger.info( "Prepare to populate topologies template via command: {0}" .format(populate_topology_template)) Execute(populate_topology_template)