Example #1
0
    def _run_main(self, parsed_args, parsed_globals):
        master_dns = sshutils.validate_and_find_master_dns(
            session=self._session,
            parsed_globals=parsed_globals,
            cluster_id=parsed_args.cluster_id)

        key_file = parsed_args.key_pair_file
        sshutils.validate_scp_with_key_file(key_file)
        if (sshutils.check_command_key_format(key_file, ['cer', 'pem']) and
                (emrutils.which('scp') or emrutils.which('scp.exe'))):
            command = ['scp', '-r', '-o StrictHostKeyChecking=no', '-i',
                       parsed_args.key_pair_file, constants.SSH_USER + '@' +
                       master_dns + ':' + parsed_args.src]
        else:
            command = ['pscp', '-scp', '-r', '-i', parsed_args.key_pair_file,
                       constants.SSH_USER + '@' + master_dns + ':' +
                       parsed_args.src]

        if parsed_args.dest:
            command.append(parsed_args.dest)
        else:
            command.append(parsed_args.src.split('/')[-1])
        print(' '.join(command))
        rc = subprocess.call(command)
        return rc
Example #2
0
    def _run_main(self, parsed_args, parsed_globals):
        master_dns = emrutils.find_master_instance(
            self._session, parsed_globals,
            parsed_args.cluster_id)['PublicDnsName']
        if not master_dns:
            raise exceptions.MasterDNSNotAvailableError

        key_file = parsed_args.key_pair_file
        sshutils.validate_scp_with_key_file(key_file)
        if (sshutils.check_command_key_format(key_file, ['cer', 'pem'])
                and (emrutils.which('scp') or emrutils.which('scp.exe'))):
            command = [
                'scp', '-r', '-o StrictHostKeyChecking=no', '-i',
                parsed_args.key_pair_file,
                constants.SSH_USER + '@' + master_dns + ':' + parsed_args.src
            ]
        else:
            command = [
                'pscp', '-scp', '-r', '-i', parsed_args.key_pair_file,
                constants.SSH_USER + '@' + master_dns + ':' + parsed_args.src
            ]

        if parsed_args.dest:
            command.append(parsed_args.dest)
        else:
            command.append(parsed_args.src.split('/')[-1])
        print(' '.join(command))
        rc = subprocess.call(command)
        return rc
Example #3
0
    def _run_main_command(self, parsed_args, parsed_globals):
        master_dns = sshutils.validate_and_find_master_dns(
            session=self._session,
            parsed_globals=parsed_globals,
            cluster_id=parsed_args.cluster_id)

        key_file = parsed_args.key_pair_file
        sshutils.validate_scp_with_key_file(key_file)
        if (emrutils.which('scp') or emrutils.which('scp.exe')):
            command = [
                'scp', '-r', '-o StrictHostKeyChecking=no', '-i',
                parsed_args.key_pair_file,
                constants.SSH_USER + '@' + master_dns + ':' + parsed_args.src
            ]
        else:
            command = [
                'pscp', '-scp', '-r', '-i', parsed_args.key_pair_file,
                constants.SSH_USER + '@' + master_dns + ':' + parsed_args.src
            ]

        if parsed_args.dest:
            command.append(parsed_args.dest)
        else:
            command.append(parsed_args.src.split('/')[-1])
        print(' '.join(command))
        rc = subprocess.call(command)
        return rc
Example #4
0
    def _run_main(self, parsed_args, parsed_globals):
        master_dns = emrutils.find_master_instance(
            self._session, parsed_globals,
            parsed_args.cluster_id)['PublicDnsName']
        if not master_dns:
            raise exceptions.MasterDNSNotAvailableError

        key_file = parsed_args.key_pair_file
        sshutils.validate_scp_with_key_file(key_file)
        if (sshutils.check_command_key_format(key_file, ['cer', 'pem']) and
                (emrutils.which('scp') or emrutils.which('scp.exe'))):
            command = ['scp', '-r', '-o StrictHostKeyChecking=no', '-i',
                       parsed_args.key_pair_file, constants.SSH_USER + '@' +
                       master_dns + ':' + parsed_args.src]
        else:
            command = ['pscp', '-scp', '-r', '-i', parsed_args.key_pair_file,
                       constants.SSH_USER + '@' + master_dns + ':' +
                       parsed_args.src]

        if parsed_args.dest:
            command.append(parsed_args.dest)
        else:
            command.append(parsed_args.src.split('/')[-1])
        print(' '.join(command))
        rc = subprocess.call(command)
        return rc
Example #5
0
    def _run_main_command(self, parsed_args, parsed_globals):
        master_dns = sshutils.validate_and_find_master_dns(
            session=self._session,
            parsed_globals=parsed_globals,
            cluster_id=parsed_args.cluster_id)

        key_file = parsed_args.key_pair_file
        sshutils.validate_scp_with_key_file(key_file)
        if (sshutils.check_command_key_format(key_file, ['cer', 'pem'])
                and (emrutils.which('scp') or emrutils.which('scp.exe'))):
            command = [
                'scp', '-r', '-o StrictHostKeyChecking=no', '-i',
                parsed_args.key_pair_file, parsed_args.src,
                constants.SSH_USER + '@' + master_dns
            ]
        else:
            command = [
                'pscp', '-scp', '-r', '-i', parsed_args.key_pair_file,
                parsed_args.src, constants.SSH_USER + '@' + master_dns
            ]

        # if the instance is not terminated
        if parsed_args.dest:
            command[-1] = command[-1] + ":" + parsed_args.dest
        else:
            command[-1] = command[-1] + ":" + parsed_args.src.split('/')[-1]
        print(' '.join(command))
        rc = subprocess.call(command)
        return rc
Example #6
0
    def test_ssh_scp_key_file_format(self, emrutils):
        def which_side_effect(program):
            if program == 'ssh' or program == 'scp':
                return '/some/path'
        emrutils.which.side_effect = which_side_effect

        key_file1 = 'key.abc'
        sshutils.validate_ssh_with_key_file(key_file1)
        sshutils.validate_scp_with_key_file(key_file1)

        key_file2 = 'key'
        sshutils.validate_ssh_with_key_file(key_file2)
        sshutils.validate_scp_with_key_file(key_file2)
Example #7
0
    def test_ssh_scp_key_file_format(self, emrutils):
        def which_side_effect(program):
            if program == 'ssh' or program == 'scp':
                return '/some/path'

        emrutils.which.side_effect = which_side_effect

        key_file1 = 'key.abc'
        sshutils.validate_ssh_with_key_file(key_file1)
        sshutils.validate_scp_with_key_file(key_file1)

        key_file2 = 'key'
        sshutils.validate_ssh_with_key_file(key_file2)
        sshutils.validate_scp_with_key_file(key_file2)
Example #8
0
    def _run_main_command(self, parsed_args, parsed_globals):
        master_dns = sshutils.validate_and_find_master_dns(
            session=self._session,
            parsed_globals=parsed_globals,
            cluster_id=parsed_args.cluster_id)

        key_file = parsed_args.key_pair_file
        sshutils.validate_scp_with_key_file(key_file)
        if (emrutils.which('scp') or emrutils.which('scp.exe')):
            command = ['scp', '-r', '-o StrictHostKeyChecking=no',
                       '-i', parsed_args.key_pair_file, parsed_args.src,
                       constants.SSH_USER + '@' + master_dns]
        else:
            command = ['pscp', '-scp', '-r', '-i', parsed_args.key_pair_file,
                       parsed_args.src, constants.SSH_USER + '@' + master_dns]

        # if the instance is not terminated
        if parsed_args.dest:
            command[-1] = command[-1] + ":" + parsed_args.dest
        else:
            command[-1] = command[-1] + ":" + parsed_args.src.split('/')[-1]
        print(' '.join(command))
        rc = subprocess.call(command)
        return rc