!13 优化sshexkey功能

Merge pull request !13 from zhangxubo/sshtool
This commit is contained in:
opengauss-bot 2021-01-04 14:47:24 +08:00 committed by Gitee
commit 4069bed656
2 changed files with 23 additions and 16 deletions

View File

@ -165,9 +165,11 @@ Usage:
General options:
-f Host file containing the IP address of nodes.
-h Host ip list. Separate multiple nodes with commas(,).
-l Path of log file.
--skip-hostname-set Whether to skip hostname setting.
(The default value is set.)
-W Password of nodes.
-?, --help Show help information for this utility,
and exit the command line mode.
-V, --version Show version information.
@ -188,10 +190,14 @@ General options:
if ("hostfile" in paraDict.keys()):
self.hostFile = paraDict.get("hostfile")
if ("nodename" in paraDict.keys()):
self.hostList = paraDict.get("nodename")
if ("logFile" in paraDict.keys()):
self.logFile = paraDict.get("logFile")
if ("skipHostnameSet" in paraDict.keys()):
self.skipHostnameSet = paraDict.get("skipHostnameSet")
if ("passwords" in paraDict.keys()):
self.passwd = paraDict.get("passwords")
def checkParameter(self):
"""
@ -200,23 +206,24 @@ General options:
output: NA
"""
# check required parameters
if (self.hostFile == ""):
self.usage()
GaussLog.exitWithError(ErrorCode.GAUSS_500["GAUSS_50001"]
% 'f' + ".")
if (not os.path.exists(self.hostFile)):
GaussLog.exitWithError(ErrorCode.GAUSS_502["GAUSS_50201"]
% self.hostFile)
if (not os.path.isabs(self.hostFile)):
GaussLog.exitWithError(ErrorCode.GAUSS_502["GAUSS_50213"]
% self.hostFile)
if len(self.hostList) == 0:
if (self.hostFile == ""):
self.usage()
GaussLog.exitWithError(ErrorCode.GAUSS_500["GAUSS_50001"]
% 'f' + ".")
if (not os.path.exists(self.hostFile)):
GaussLog.exitWithError(ErrorCode.GAUSS_502["GAUSS_50201"]
% self.hostFile)
if (not os.path.isabs(self.hostFile)):
GaussLog.exitWithError(ErrorCode.GAUSS_502["GAUSS_50213"]
% self.hostFile)
# read host file to hostList
self.readHostFile()
# read host file to hostList
self.readHostFile()
if (self.hostList == []):
GaussLog.exitWithError(ErrorCode.GAUSS_500["GAUSS_50004"]
% 'f' + " It cannot be empty.")
if (self.hostList == []):
GaussLog.exitWithError(ErrorCode.GAUSS_500["GAUSS_50004"]
% 'f' + " It cannot be empty.")
# check logfile
if (self.logFile != ""):

View File

@ -79,7 +79,7 @@ gs_check = ["-?", "--help", "-V", "--version", "-e:", "-i:",
"--ShrinkNodes=", "--nodegroup-name=",
"--skip-root-items", "--set"]
gs_sshexkey = ["-?", "--help", "-V", "--version",
"-f:", "--skip-hostname-set", "-l:"]
"-f:", "--skip-hostname-set", "-l:", "-h:", "-W:"]
gs_backup = ["-?", "--help", "-V", "--version", "--backup-dir=",
"--parameter", "--force",
"--binary", "--all", "-l:", "-h:", "-t:", "-X:"]