Beispiel #1
0
def ssh(ssh_plain_mode, ssh_command):
    logger = get_logger()
    ssh_path = spawn.find_executable('ssh')
    logger.debug('SSH executable path: {0}'.format(ssh_path or 'Not found'))
    if not ssh_path and platform.system() == 'Windows':
        msg = messages.SSH_WIN_NOT_FOUND
        raise CloudifyCliError(msg)
    elif not ssh_path:
        msg = messages.SSH_LINUX_NOT_FOUND
        raise CloudifyCliError(msg)
    else:
        command = [
            ssh_path, '{0}@{1}'.format(get_management_user(),
                                       get_management_server_ip())
        ]
        if get_global_verbosity():
            command.append('-v')
        if not ssh_plain_mode:
            command.extend(['-i', os.path.expanduser(get_management_key())])
        if ssh_command:
            command.extend(['--', ssh_command])
        logger.debug('executing command: {0}'.format(' '.join(command)))
        logger.info('Trying to connect...')
        from subprocess import call
        call(command)
Beispiel #2
0
def dev(args, task, tasks_file):
    management_ip = utils.get_management_server_ip()
    _execute(username=get_management_user(),
             key=get_management_key(),
             ip=management_ip,
             task=task,
             tasks_file=tasks_file,
             args=args)
Beispiel #3
0
def dev(args, task, tasks_file):
    management_ip = utils.get_management_server_ip()
    _execute(username=get_management_user(),
             key=get_management_key(),
             ip=management_ip,
             task=task,
             tasks_file=tasks_file,
             args=args)
Beispiel #4
0
def scp(local_path, path_on_manager, to_manager):
    scp_path = spawn.find_executable('scp')
    management_path = '{0}@{1}:{2}'.format(get_management_user(),
                                           get_management_server_ip(),
                                           path_on_manager)
    command = [scp_path, '-i', os.path.expanduser(get_management_key())]
    if to_manager:
        command += [local_path, management_path]
    else:
        command += [management_path, local_path]
    call(command)
Beispiel #5
0
def scp(local_path, path_on_manager, to_manager):
    scp_path = spawn.find_executable('scp')
    management_path = '{0}@{1}:{2}'.format(
        get_management_user(),
        get_management_server_ip(),
        path_on_manager
    )
    command = [scp_path, '-i', os.path.expanduser(get_management_key())]
    if to_manager:
        command += [local_path, management_path]
    else:
        command += [management_path, local_path]
    call(command)
def scp(local_path, path_on_manager, to_manager):
    from cloudify_cli.utils import get_management_user
    from cloudify_cli.utils import get_management_server_ip
    from cloudify_cli.utils import get_management_key

    scp_path = spawn.find_executable('scp')
    management_path = '{0}@{1}:{2}'.format(
        get_management_user(),
        get_management_server_ip(),
        path_on_manager
    )
    command = [scp_path, '-o', 'StrictHostKeyChecking=no',
               '-i', os.path.expanduser(get_management_key())]
    if to_manager:
        command += [local_path, management_path]
    else:
        command += [management_path, local_path]
    rc = call(command)
    if rc:
        raise RuntimeError('Scp failed with exit code: {0}'.format(rc))
Beispiel #7
0
def ssh(ssh_plain_mode, ssh_command):
    logger = get_logger()
    ssh_path = spawn.find_executable('ssh')
    logger.debug('SSH executable path: {0}'.format(ssh_path or 'Not found'))
    if not ssh_path and platform.system() == 'Windows':
        msg = messages.SSH_WIN_NOT_FOUND
        raise CloudifyCliError(msg)
    elif not ssh_path:
        msg = messages.SSH_LINUX_NOT_FOUND
        raise CloudifyCliError(msg)
    else:
        command = [ssh_path, '{0}@{1}'.format(get_management_user(),
                                              get_management_server_ip())]
        if get_global_verbosity():
            command.append('-v')
        if not ssh_plain_mode:
            command.extend(['-i', os.path.expanduser(get_management_key())])
        if ssh_command:
            command.extend(['--', ssh_command])
        logger.debug('executing command: {0}'.format(' '.join(command)))
        logger.info('Trying to connect...')
        from subprocess import call
        call(command)
import os, sys
from cloudify_cli.utils import (get_management_user, get_management_server_ip,
                                get_management_key)

command = 'ssh -n -o BatchMode=yes -i %s %s@%s true 2> /dev/null' % (
    get_management_key(), get_management_user(), get_management_server_ip())

command_result = os.system(command)
sys.exit(os.WEXITSTATUS(command_result))
import os, sys
from cloudify_cli.utils import (get_management_user,
                                get_management_server_ip,
                                get_management_key)


command = 'ssh -n -o BatchMode=yes -i %s %s@%s true 2> /dev/null' % (
    get_management_key(),
    get_management_user(),
    get_management_server_ip()
)

command_result = os.system(command)
sys.exit(os.WEXITSTATUS(command_result))
Beispiel #10
0
def _load_management_user(inputs):
    try:
        return inputs.get('ssh_user') or utils.get_management_user()
    except Exception:
        raise exceptions.CloudifyCliError('Manager user must be provided for '
                                          'the upgrade/rollback process')