!849 fix gs_sshexkey和gs_postuninstall bug
Merge pull request !849 from liuheng/fix19
This commit is contained in:
commit
d749e0ac52
@ -971,6 +971,12 @@ class FileUtil(object):
|
||||
dir_name = os.path.dirname(os.path.realpath(__file__))
|
||||
package_dir = os.path.join(dir_name, "./../../")
|
||||
host_file = os.path.normpath(os.path.join(package_dir, "..", "hosts"))
|
||||
if host_file and os.path.exists(host_file) and os.path.isfile(host_file):
|
||||
return host_file
|
||||
|
||||
tmp_hosts_file = "/tmp/gs_sshexkey_hosts"
|
||||
if os.path.exists(tmp_hosts_file):
|
||||
host_file = tmp_hosts_file
|
||||
|
||||
if not os.path.exists(host_file) or not os.path.isfile(host_file):
|
||||
raise Exception(ErrorCode.GAUSS_522["GAUSS_52200"] % host_file)
|
||||
|
@ -687,6 +687,7 @@ General options:
|
||||
self.retry_register_other_ssh_agent()
|
||||
self.verifyTrust()
|
||||
self.set_user_ssh_crontab(result)
|
||||
self.delete_tmp_file()
|
||||
self.logger.log("Successfully created SSH trust.")
|
||||
except Exception as e:
|
||||
self.logger.logExit(str(e))
|
||||
@ -1158,12 +1159,8 @@ General options:
|
||||
input : contents
|
||||
output: NA
|
||||
"""
|
||||
if os.getuid() == 0:
|
||||
return
|
||||
# write hosts file
|
||||
current_path = os.path.dirname(os.path.realpath(__file__))
|
||||
package_dir = os.path.normpath(os.path.join(current_path, "../"))
|
||||
hosts_file = os.path.normpath(os.path.join(package_dir, "hosts"))
|
||||
hosts_file = "/tmp/gs_sshexkey_hosts"
|
||||
if os.path.exists(hosts_file):
|
||||
FileUtil.removeFile(hosts_file)
|
||||
FileUtil.createFile(hosts_file)
|
||||
@ -1172,6 +1169,15 @@ General options:
|
||||
FileUtil.changeMode(DefaultValue.FILE_MODE, hosts_file, cmd_type="shell")
|
||||
FileUtil.changeOwner(self.user, hosts_file, cmd_type="shell")
|
||||
|
||||
def delete_tmp_file(self):
|
||||
"""
|
||||
function: Delete tmp file
|
||||
input : NA
|
||||
output: NA
|
||||
"""
|
||||
hosts_file = "/tmp/gs_sshexkey_hosts"
|
||||
FileUtil.removeFile(hosts_file)
|
||||
|
||||
def write_hostname_to_list(self, ip_hostname):
|
||||
"""
|
||||
function: Add hostname to the list
|
||||
|
@ -912,7 +912,7 @@ class PostUninstallImpl:
|
||||
except Exception as e:
|
||||
raise Exception(str(e))
|
||||
|
||||
def delet_root_mutual_trust(self, local_host, path):
|
||||
def delet_root_mutual_trust(self, local_host):
|
||||
"""
|
||||
:return:
|
||||
"""
|
||||
@ -948,6 +948,8 @@ class PostUninstallImpl:
|
||||
|
||||
# delete remote root mutual trust
|
||||
kill_remote_ssh_agent_cmd = DefaultValue.killInstProcessCmd("ssh-agent", True)
|
||||
current_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
path = os.path.join(current_dir, "../../../")
|
||||
self.sshTool.getSshStatusOutput(cmd % kill_remote_ssh_agent_cmd, host_list, gp_path=path)
|
||||
# delete local root mutual trust
|
||||
CmdExecutor.execCommandLocally(cmd % kill_ssh_agent_cmd)
|
||||
@ -981,8 +983,7 @@ class PostUninstallImpl:
|
||||
os_profile = self.mpprcFile
|
||||
else:
|
||||
os_profile = ClusterConstants.ETC_PROFILE
|
||||
path = EnvUtil.get_env_param(source_file=os_profile,
|
||||
env_param="UNPACKPATH")
|
||||
|
||||
self.createTrustForRoot()
|
||||
self.cleanGphomeScript()
|
||||
self.checkLogFilePath()
|
||||
@ -996,10 +997,10 @@ class PostUninstallImpl:
|
||||
self.logger.log("Successfully cleaned environment.")
|
||||
if os.path.exists(self.gauss_om_path):
|
||||
self.cleanOthernodesBackupScript()
|
||||
self.delet_root_mutual_trust(local_host, path)
|
||||
self.delet_root_mutual_trust(local_host)
|
||||
self.cleanLocalBackupScript()
|
||||
else:
|
||||
self.delet_root_mutual_trust(local_host, path)
|
||||
self.delet_root_mutual_trust(local_host)
|
||||
self.logger.log("clean over.")
|
||||
except Exception as e:
|
||||
self.logger.logExit(str(e))
|
||||
|
@ -2725,7 +2725,7 @@ Common options:
|
||||
package_path = get_package_path()
|
||||
om_backup_path = os.path.dirname(package_path)
|
||||
check_backup_path = os.path.join("/home", self.user, "gauss_om")
|
||||
if om_backup_path == check_backup_path or not self.current_user_root:
|
||||
if om_backup_path == check_backup_path:
|
||||
return
|
||||
|
||||
self.logger.log("Backup om scripts.")
|
||||
@ -2743,16 +2743,17 @@ Common options:
|
||||
cmd = "cp -rf %s/hosts %s" % (self.clusterToolPath, dest_path)
|
||||
CmdExecutor.execCommandLocally(cmd)
|
||||
|
||||
# cp cgroup to /home/user/gauss_om/script
|
||||
self.logger.debug("cp cgroup to /home/user/gauss_om/script.")
|
||||
backup_lib_dir = os.path.join(dest_path, "lib")
|
||||
backup_bin_dir = os.path.join(dest_path, "bin")
|
||||
FileUtil.createDirectory(backup_lib_dir, mode=DefaultValue.KEY_DIRECTORY_MODE)
|
||||
FileUtil.createDirectory(backup_bin_dir, mode=DefaultValue.KEY_DIRECTORY_MODE)
|
||||
libcgroup_dir = os.path.realpath("%s/libcgroup/lib/libcgroup.so*" % package_path)
|
||||
cgroup_exe_dir = os.path.realpath("%s/libcgroup/bin/gs_cgroup" % package_path)
|
||||
cp_cmd = "cp -rf %s %s; cp -rf %s %s" % (libcgroup_dir, backup_lib_dir, cgroup_exe_dir, backup_bin_dir)
|
||||
CmdExecutor.execCommandLocally(cp_cmd)
|
||||
if self.current_user_root:
|
||||
# cp cgroup to /home/user/gauss_om/script
|
||||
self.logger.debug("cp cgroup to /home/user/gauss_om/script.")
|
||||
backup_lib_dir = os.path.join(dest_path, "lib")
|
||||
backup_bin_dir = os.path.join(dest_path, "bin")
|
||||
FileUtil.createDirectory(backup_lib_dir, mode=DefaultValue.KEY_DIRECTORY_MODE)
|
||||
FileUtil.createDirectory(backup_bin_dir, mode=DefaultValue.KEY_DIRECTORY_MODE)
|
||||
libcgroup_dir = os.path.realpath("%s/libcgroup/lib/libcgroup.so*" % package_path)
|
||||
cgroup_exe_dir = os.path.realpath("%s/libcgroup/bin/gs_cgroup" % package_path)
|
||||
cp_cmd = "cp -rf %s %s; cp -rf %s %s" % (libcgroup_dir, backup_lib_dir, cgroup_exe_dir, backup_bin_dir)
|
||||
CmdExecutor.execCommandLocally(cp_cmd)
|
||||
|
||||
# cp $GPHOME script lib to /home/user/gauss_om/
|
||||
cmd = ("cp -rf %s/script %s/lib %s/version.cfg %s"
|
||||
|
@ -483,6 +483,10 @@ class Postuninstall(LocalBaseOM):
|
||||
# mkdir gauss_om dir
|
||||
gaussom_lib_dir = "/home/%s/gauss_om/lib/" % self.user
|
||||
gaussom_bin_dir = "/home/%s/gauss_om/bin/" % self.user
|
||||
|
||||
if not os.path.exists(gaussom_bin_dir) or not os.path.exists(gaussom_lib_dir) or \
|
||||
len(os.listdir(gaussom_bin_dir)) == 0 or len(os.listdir(gaussom_lib_dir)) == 0:
|
||||
return
|
||||
# delete cgroup
|
||||
cmd = "export LD_LIBRARY_PATH=%s:\$LD_LIBRARY_PATH && %s/gs_cgroup -d -U %s" % (gaussom_lib_dir, gaussom_bin_dir, self.user)
|
||||
(status, output) = subprocess.getstatusoutput(cmd)
|
||||
|
Loading…
x
Reference in New Issue
Block a user