def test_username_only_ssh(self):
        paramiko_runner = ParamikoRemoteScriptRunner('runner_1')

        paramiko_runner.runner_parameters = {
            'username': '******',
            'hosts': '127.0.0.1'
        }
        self.assertRaises(InvalidCredentialsException, paramiko_runner.pre_run)
Beispiel #2
0
    def test_username_invalid_private_key(self):
        paramiko_runner = ParamikoRemoteScriptRunner('runner_1')

        paramiko_runner.runner_parameters = {
            'username': '******',
            'hosts': '127.0.0.1',
            'private_key': 'invalid private key',
        }
        paramiko_runner.context = {}
        self.assertRaises(NoHostsConnectedToException, paramiko_runner.pre_run)
    def test_username_invalid_private_key(self):
        paramiko_runner = ParamikoRemoteScriptRunner('runner_1')

        paramiko_runner.runner_parameters = {
            'username': '******',
            'hosts': '127.0.0.1',
            'private_key': 'invalid private key',
        }
        paramiko_runner.context = {}
        self.assertRaises(NoHostsConnectedToException, paramiko_runner.pre_run)
 def test_cwd_used_correctly(self):
     remote_action = ParamikoRemoteScriptAction(
         'foo-script', bson.ObjectId(),
         script_local_path_abs='/home/stanley/shiz_storm.py',
         script_local_libs_path_abs=None,
         named_args={}, positional_args=['blank space'], env_vars={},
         on_behalf_user='******', user='******',
         private_key='---SOME RSA KEY---',
         remote_dir='/tmp', hosts=['127.0.0.1'], cwd='/test/cwd/'
     )
     paramiko_runner = ParamikoRemoteScriptRunner('runner_1')
     paramiko_runner._parallel_ssh_client = ParallelSSHClient(['127.0.0.1'], 'stanley')
     paramiko_runner._run_script_on_remote_host(remote_action)
     exp_cmd = "cd /test/cwd/ && /tmp/shiz_storm.py 'blank space'"
     ParallelSSHClient.run.assert_called_with(exp_cmd,
                                              timeout=None)
Beispiel #5
0
 def test_cwd_used_correctly(self):
     remote_action = ParamikoRemoteScriptAction(
         'foo-script',
         bson.ObjectId(),
         script_local_path_abs='/home/stanley/shiz_storm.py',
         script_local_libs_path_abs=None,
         named_args={},
         positional_args=['blank space'],
         env_vars={},
         on_behalf_user='******',
         user='******',
         private_key='---SOME RSA KEY---',
         remote_dir='/tmp',
         hosts=['127.0.0.1'],
         cwd='/test/cwd/')
     paramiko_runner = ParamikoRemoteScriptRunner('runner_1')
     paramiko_runner._parallel_ssh_client = ParallelSSHClient(['127.0.0.1'],
                                                              'stanley')
     paramiko_runner._run_script_on_remote_host(remote_action)
     exp_cmd = "cd /test/cwd/ && /tmp/shiz_storm.py 'blank space'"
     ParallelSSHClient.run.assert_called_with(exp_cmd, timeout=None)
Beispiel #6
0
    def test_top_level_error_is_correctly_reported(self):
        # Verify that a top-level error doesn't cause an exception to be thrown.
        # In a top-level error case, result dict doesn't contain entry per host
        paramiko_runner = ParamikoRemoteScriptRunner('runner_1')

        paramiko_runner.runner_parameters = {
            'username': '******',
            'hosts': '127.0.0.1'
        }
        paramiko_runner.action = ACTION_1
        paramiko_runner.liveaction_id = 'foo'
        paramiko_runner.entry_point = 'foo'
        paramiko_runner.context = {}
        paramiko_runner._cwd = '/tmp'
        paramiko_runner._copy_artifacts = Mock(side_effect=Exception('fail!'))
        status, result, _ = paramiko_runner.run(action_parameters={})

        self.assertEqual(status, LIVEACTION_STATUS_FAILED)
        self.assertEqual(result['failed'], True)
        self.assertEqual(result['succeeded'], False)
        self.assertTrue(
            'Failed copying content to remote boxes' in result['error'])
    def test_top_level_error_is_correctly_reported(self):
        # Verify that a top-level error doesn't cause an exception to be thrown.
        # In a top-level error case, result dict doesn't contain entry per host
        paramiko_runner = ParamikoRemoteScriptRunner('runner_1')

        paramiko_runner.runner_parameters = {
            'username': '******',
            'hosts': '127.0.0.1'
        }
        paramiko_runner.action = ACTION_1
        paramiko_runner.liveaction_id = 'foo'
        paramiko_runner.entry_point = 'foo'
        paramiko_runner.context = {}
        paramiko_runner._cwd = '/tmp'
        paramiko_runner._copy_artifacts = Mock(side_effect=Exception('fail!'))
        status, result, _ = paramiko_runner.run(action_parameters={})

        self.assertEqual(status, LIVEACTION_STATUS_FAILED)
        self.assertEqual(result['failed'], True)
        self.assertEqual(result['succeeded'], False)
        self.assertTrue('Failed copying content to remote boxes' in result['error'])
    def test_username_only_ssh(self):
        paramiko_runner = ParamikoRemoteScriptRunner('runner_1')

        paramiko_runner.runner_parameters = {'username': '******', 'hosts': '127.0.0.1'}
        self.assertRaises(InvalidCredentialsException, paramiko_runner.pre_run)