Fix std.ssh "password" parameter
Fixes the bug where calling std.ssh action without "password" input was resulting in error. Closes-bug: #1756272 Change-Id: I5f7af13326933658014a9c42c495d779bec7f14f
This commit is contained in:
parent
7167e4b71a
commit
f5c0be6ee9
@ -1077,11 +1077,10 @@ Input parameters:
|
||||
- **username** - User name to authenticate on the host. *Required*.
|
||||
- **password** - User password to to authenticate on the host. *Optional*.
|
||||
- **private_key_filename** - Private key file name which will be used for
|
||||
authentication on remote host.
|
||||
|
||||
All private keys should be on executor host in **<home-user-directory>/.ssh/**.
|
||||
**<home-user-directory>** should refer to user directory under which service is
|
||||
running. *Optional*.
|
||||
authentication on remote host. All private keys should be on the executor
|
||||
host in **<home-user-directory>/.ssh** directory or absolute path of
|
||||
the key should be provided. The file needs to be accessible
|
||||
for the user account running the executor. *Optional*.
|
||||
|
||||
**NOTE**: Authentication using key pairs is supported, key should be
|
||||
on Mistral Executor server machine.
|
||||
|
@ -347,7 +347,7 @@ class SSHAction(actions.Action):
|
||||
return ssh_utils.execute_command
|
||||
|
||||
def __init__(self, cmd, host, username,
|
||||
password=None, private_key_filename=None):
|
||||
password="", private_key_filename=None):
|
||||
super(SSHAction, self).__init__()
|
||||
|
||||
self.cmd = cmd
|
||||
@ -396,8 +396,7 @@ class SSHAction(actions.Action):
|
||||
return raise_exc(parent_exc=e)
|
||||
|
||||
def test(self, context):
|
||||
# TODO(rakhmerov): Implement.
|
||||
return None
|
||||
return json.dumps(self.params)
|
||||
|
||||
|
||||
class SSHProxiedAction(SSHAction):
|
||||
|
36
mistral/tests/unit/actions/test_std_ssh_action.py
Normal file
36
mistral/tests/unit/actions/test_std_ssh_action.py
Normal file
@ -0,0 +1,36 @@
|
||||
# Copyright 2018 Nokia Networks.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
from mistral.actions import std_actions as std
|
||||
from mistral.tests.unit import base
|
||||
|
||||
|
||||
class SSHActionTest(base.BaseTest):
|
||||
|
||||
def test_default_inputs(self):
|
||||
cmd = "echo -n ok"
|
||||
host = "localhost"
|
||||
username = "mistral"
|
||||
action = std.SSHAction(cmd, host, username)
|
||||
mock_ctx = None
|
||||
|
||||
stdout = action.test(mock_ctx)
|
||||
params = json.loads(stdout)
|
||||
|
||||
self.assertEqual("", params['password'], "Password does not match.")
|
||||
self.assertIsNone(
|
||||
params['private_key_filename'],
|
||||
"private_key_filename is not None.")
|
Loading…
x
Reference in New Issue
Block a user