'Attempts to launch an interactive shell by first trying the system\'s
ssh client. If the system does not have the ssh command it falls back
to a pure-python ssh shell.'

def shell(self, user=None, forward_x11=False, forward_agent=False, pseudo_tty=False, command=None):

    if (self.update() != 'running'):
        try:
            alias = self.alias
        except exception.BaseException:
            alias = None
        label = 'instance'
        if (alias == 'master'):
            label = 'master'
            alias = 'node'
        elif alias:
            label = 'node'
        instance_id = (alias or self.id)
        raise exception.InstanceNotRunning(instance_id, self.state, label=label)
    user = (user or self.user)
    if utils.has_required(['ssh']):
        log.debug('Using    native    OpenSSH    client')
        sshopts = ('-i    %s' % self.key_location)
        if forward_x11:
            sshopts += '    -Y'
        if forward_agent:
            sshopts += '    -A'
        if pseudo_tty:
            sshopts += '    -t'
        ssh_cmd = (static.SSH_TEMPLATE % dict(opts=sshopts, user=user, host=self.addr))
        if command:
            command = ("'source    /etc/profile    &&    %s'" % command)
            ssh_cmd = '    '.join([ssh_cmd, command])
        log.debug(('ssh_cmd:    %s' % ssh_cmd))
        return subprocess.call(ssh_cmd, shell=True)
    else:
        log.debug('Using    Pure-Python    SSH    client')
        if forward_x11:
            log.warn('X11    Forwarding    not    available    in    Python    SSH    client')
        if forward_agent:
            log.warn(('Authentication    agent    forwarding    not    available    in    ' + 'Python    SSH    client'))
        if pseudo_tty:
            log.warn(('Pseudo-tty    allocation    is    not    available    in    ' + 'Python    SSH    client'))
        if command:
            orig_user = self.ssh.get_current_user()
            self.ssh.switch_user(user)
            self.ssh.execute(command, silent=False)
            self.ssh.switch_user(orig_user)
            return self.ssh.get_last_status()
        self.ssh.interactive_shell(user=user)
