!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__))
|
dir_name = os.path.dirname(os.path.realpath(__file__))
|
||||||
package_dir = os.path.join(dir_name, "./../../")
|
package_dir = os.path.join(dir_name, "./../../")
|
||||||
host_file = os.path.normpath(os.path.join(package_dir, "..", "hosts"))
|
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):
|
if not os.path.exists(host_file) or not os.path.isfile(host_file):
|
||||||
raise Exception(ErrorCode.GAUSS_522["GAUSS_52200"] % host_file)
|
raise Exception(ErrorCode.GAUSS_522["GAUSS_52200"] % host_file)
|
||||||
|
@ -687,6 +687,7 @@ General options:
|
|||||||
self.retry_register_other_ssh_agent()
|
self.retry_register_other_ssh_agent()
|
||||||
self.verifyTrust()
|
self.verifyTrust()
|
||||||
self.set_user_ssh_crontab(result)
|
self.set_user_ssh_crontab(result)
|
||||||
|
self.delete_tmp_file()
|
||||||
self.logger.log("Successfully created SSH trust.")
|
self.logger.log("Successfully created SSH trust.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.logExit(str(e))
|
self.logger.logExit(str(e))
|
||||||
@ -1158,12 +1159,8 @@ General options:
|
|||||||
input : contents
|
input : contents
|
||||||
output: NA
|
output: NA
|
||||||
"""
|
"""
|
||||||
if os.getuid() == 0:
|
|
||||||
return
|
|
||||||
# write hosts file
|
# write hosts file
|
||||||
current_path = os.path.dirname(os.path.realpath(__file__))
|
hosts_file = "/tmp/gs_sshexkey_hosts"
|
||||||
package_dir = os.path.normpath(os.path.join(current_path, "../"))
|
|
||||||
hosts_file = os.path.normpath(os.path.join(package_dir, "hosts"))
|
|
||||||
if os.path.exists(hosts_file):
|
if os.path.exists(hosts_file):
|
||||||
FileUtil.removeFile(hosts_file)
|
FileUtil.removeFile(hosts_file)
|
||||||
FileUtil.createFile(hosts_file)
|
FileUtil.createFile(hosts_file)
|
||||||
@ -1172,6 +1169,15 @@ General options:
|
|||||||
FileUtil.changeMode(DefaultValue.FILE_MODE, hosts_file, cmd_type="shell")
|
FileUtil.changeMode(DefaultValue.FILE_MODE, hosts_file, cmd_type="shell")
|
||||||
FileUtil.changeOwner(self.user, 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):
|
def write_hostname_to_list(self, ip_hostname):
|
||||||
"""
|
"""
|
||||||
function: Add hostname to the list
|
function: Add hostname to the list
|
||||||
|
@ -912,7 +912,7 @@ class PostUninstallImpl:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise Exception(str(e))
|
raise Exception(str(e))
|
||||||
|
|
||||||
def delet_root_mutual_trust(self, local_host, path):
|
def delet_root_mutual_trust(self, local_host):
|
||||||
"""
|
"""
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
@ -948,6 +948,8 @@ class PostUninstallImpl:
|
|||||||
|
|
||||||
# delete remote root mutual trust
|
# delete remote root mutual trust
|
||||||
kill_remote_ssh_agent_cmd = DefaultValue.killInstProcessCmd("ssh-agent", True)
|
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)
|
self.sshTool.getSshStatusOutput(cmd % kill_remote_ssh_agent_cmd, host_list, gp_path=path)
|
||||||
# delete local root mutual trust
|
# delete local root mutual trust
|
||||||
CmdExecutor.execCommandLocally(cmd % kill_ssh_agent_cmd)
|
CmdExecutor.execCommandLocally(cmd % kill_ssh_agent_cmd)
|
||||||
@ -981,8 +983,7 @@ class PostUninstallImpl:
|
|||||||
os_profile = self.mpprcFile
|
os_profile = self.mpprcFile
|
||||||
else:
|
else:
|
||||||
os_profile = ClusterConstants.ETC_PROFILE
|
os_profile = ClusterConstants.ETC_PROFILE
|
||||||
path = EnvUtil.get_env_param(source_file=os_profile,
|
|
||||||
env_param="UNPACKPATH")
|
|
||||||
self.createTrustForRoot()
|
self.createTrustForRoot()
|
||||||
self.cleanGphomeScript()
|
self.cleanGphomeScript()
|
||||||
self.checkLogFilePath()
|
self.checkLogFilePath()
|
||||||
@ -996,10 +997,10 @@ class PostUninstallImpl:
|
|||||||
self.logger.log("Successfully cleaned environment.")
|
self.logger.log("Successfully cleaned environment.")
|
||||||
if os.path.exists(self.gauss_om_path):
|
if os.path.exists(self.gauss_om_path):
|
||||||
self.cleanOthernodesBackupScript()
|
self.cleanOthernodesBackupScript()
|
||||||
self.delet_root_mutual_trust(local_host, path)
|
self.delet_root_mutual_trust(local_host)
|
||||||
self.cleanLocalBackupScript()
|
self.cleanLocalBackupScript()
|
||||||
else:
|
else:
|
||||||
self.delet_root_mutual_trust(local_host, path)
|
self.delet_root_mutual_trust(local_host)
|
||||||
self.logger.log("clean over.")
|
self.logger.log("clean over.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.logExit(str(e))
|
self.logger.logExit(str(e))
|
||||||
|
@ -2725,7 +2725,7 @@ Common options:
|
|||||||
package_path = get_package_path()
|
package_path = get_package_path()
|
||||||
om_backup_path = os.path.dirname(package_path)
|
om_backup_path = os.path.dirname(package_path)
|
||||||
check_backup_path = os.path.join("/home", self.user, "gauss_om")
|
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
|
return
|
||||||
|
|
||||||
self.logger.log("Backup om scripts.")
|
self.logger.log("Backup om scripts.")
|
||||||
@ -2743,6 +2743,7 @@ Common options:
|
|||||||
cmd = "cp -rf %s/hosts %s" % (self.clusterToolPath, dest_path)
|
cmd = "cp -rf %s/hosts %s" % (self.clusterToolPath, dest_path)
|
||||||
CmdExecutor.execCommandLocally(cmd)
|
CmdExecutor.execCommandLocally(cmd)
|
||||||
|
|
||||||
|
if self.current_user_root:
|
||||||
# cp cgroup to /home/user/gauss_om/script
|
# cp cgroup to /home/user/gauss_om/script
|
||||||
self.logger.debug("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_lib_dir = os.path.join(dest_path, "lib")
|
||||||
|
@ -483,6 +483,10 @@ class Postuninstall(LocalBaseOM):
|
|||||||
# mkdir gauss_om dir
|
# mkdir gauss_om dir
|
||||||
gaussom_lib_dir = "/home/%s/gauss_om/lib/" % self.user
|
gaussom_lib_dir = "/home/%s/gauss_om/lib/" % self.user
|
||||||
gaussom_bin_dir = "/home/%s/gauss_om/bin/" % 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
|
# 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)
|
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)
|
(status, output) = subprocess.getstatusoutput(cmd)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user