Solved second use case of bug #890822 bug/890822
Change-Id: If8ac4dd7540400b38a65fcb0419beab70ff55029
This commit is contained in:
@@ -22,12 +22,22 @@ def processHost(param, process_args=None):
|
||||
raise ParamProcessingError(str(ex))
|
||||
|
||||
def processSSHKey(param, process_args=None):
|
||||
"""
|
||||
Generates SSH key if given key in param doesn't exist. In case param
|
||||
is an empty string it generates default SSH key ($HOME/.ssh/id_rsa).
|
||||
"""
|
||||
def create_key(path):
|
||||
local = ScriptRunner()
|
||||
# create new ssh key
|
||||
local.append('ssh-keygen -f %s -N ""' % path)
|
||||
local.execute()
|
||||
|
||||
if not param:
|
||||
key_file = '%s/.ssh/id_rsa' % os.environ["HOME"]
|
||||
param = '%s.pub' % key_file
|
||||
if not os.path.isfile(param):
|
||||
local = ScriptRunner()
|
||||
# create new ssh key
|
||||
local.append('ssh-keygen -f %s -N ""' % key_file)
|
||||
local.execute()
|
||||
create_key(key_file)
|
||||
elif not os.path.isfile(param):
|
||||
key_file = param.endswith('.pub') and param[:-4] or param
|
||||
create_key(key_file)
|
||||
return param
|
||||
|
||||
Reference in New Issue
Block a user