~ntt-pf-lab/nova/monkey_patch_notification

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/twisted/conch/client/options.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
 
2
# See LICENSE for details.
 
3
 
 
4
#
 
5
from twisted.conch.ssh.transport import SSHClientTransport, SSHCiphers
 
6
from twisted.python import usage
 
7
 
 
8
import sys
 
9
 
 
10
class ConchOptions(usage.Options):
 
11
 
 
12
    optParameters = [['user', 'l', None, 'Log in using this user name.'],
 
13
                     ['identity', 'i', None],
 
14
                     ['ciphers', 'c', None],
 
15
                     ['macs', 'm', None],
 
16
                     ['port', 'p', None, 'Connect to this port.  Server must be on the same port.'],
 
17
                     ['option', 'o', None, 'Ignored OpenSSH options'],
 
18
                     ['host-key-algorithms', '', None],
 
19
                     ['known-hosts', '', None, 'File to check for host keys'],
 
20
                     ['user-authentications', '', None, 'Types of user authentications to use.'],
 
21
                     ['logfile', '', None, 'File to log to, or - for stdout'],
 
22
                   ]
 
23
 
 
24
    optFlags = [['version', 'V', 'Display version number only.'],
 
25
                ['compress', 'C', 'Enable compression.'],
 
26
                ['log', 'v', 'Enable logging (defaults to stderr)'],
 
27
                ['nox11', 'x', 'Disable X11 connection forwarding (default)'],
 
28
                ['agent', 'A', 'Enable authentication agent forwarding'],
 
29
                ['noagent', 'a', 'Disable authentication agent forwarding (default)'],
 
30
                ['reconnect', 'r', 'Reconnect to the server if the connection is lost.'],
 
31
               ]
 
32
    zsh_altArgDescr = {"connection-usage":"Connection types to use"}
 
33
    #zsh_multiUse = ["foo", "bar"]
 
34
    zsh_mutuallyExclusive = [("agent", "noagent")]
 
35
    zsh_actions = {"user":"_users",
 
36
                   "ciphers":"_values -s , 'ciphers to choose from' %s" %
 
37
                       " ".join(SSHCiphers.cipherMap.keys()),
 
38
                   "macs":"_values -s , 'macs to choose from' %s" %
 
39
                       " ".join(SSHCiphers.macMap.keys()),
 
40
                   "host-key-algorithms":"_values -s , 'host key algorithms to choose from' %s" %
 
41
                       " ".join(SSHClientTransport.supportedPublicKeys),
 
42
                   #"user-authentications":"_values -s , 'user authentication types to choose from' %s" %
 
43
                   #    " ".join(???),
 
44
                   }
 
45
    #zsh_actionDescr = {"logfile":"log file name", "random":"random seed"}
 
46
    # user, host, or user@host completion similar to zsh's ssh completion
 
47
    zsh_extras = ['1:host | user@host:{_ssh;if compset -P "*@"; then _wanted hosts expl "remote host name" _ssh_hosts && ret=0 elif compset -S "@*"; then _wanted users expl "login name" _ssh_users -S "" && ret=0 else if (( $+opt_args[-l] )); then tmp=() else tmp=( "users:login name:_ssh_users -qS@" ) fi; _alternative "hosts:remote host name:_ssh_hosts" "$tmp[@]" && ret=0 fi}']
 
48
 
 
49
    def __init__(self, *args, **kw):
 
50
        usage.Options.__init__(self, *args, **kw)
 
51
        self.identitys = [] 
 
52
        self.conns = None
 
53
 
 
54
    def opt_identity(self, i):
 
55
        """Identity for public-key authentication"""
 
56
        self.identitys.append(i)
 
57
 
 
58
    def opt_ciphers(self, ciphers):
 
59
        "Select encryption algorithms"
 
60
        ciphers = ciphers.split(',')
 
61
        for cipher in ciphers:
 
62
            if not SSHCiphers.cipherMap.has_key(cipher):
 
63
                sys.exit("Unknown cipher type '%s'" % cipher)
 
64
        self['ciphers'] = ciphers
 
65
 
 
66
 
 
67
    def opt_macs(self, macs):
 
68
        "Specify MAC algorithms"
 
69
        macs = macs.split(',')
 
70
        for mac in macs:
 
71
            if not SSHCiphers.macMap.has_key(mac):
 
72
                sys.exit("Unknown mac type '%s'" % mac)
 
73
        self['macs'] = macs
 
74
 
 
75
    def opt_host_key_algorithms(self, hkas):
 
76
        "Select host key algorithms"
 
77
        hkas = hkas.split(',')
 
78
        for hka in hkas:
 
79
            if hka not in SSHClientTransport.supportedPublicKeys:
 
80
                sys.exit("Unknown host key type '%s'" % hka)
 
81
        self['host-key-algorithms'] = hkas
 
82
 
 
83
    def opt_user_authentications(self, uas):
 
84
        "Choose how to authenticate to the remote server"
 
85
        self['user-authentications'] = uas.split(',')
 
86
 
 
87
#    def opt_compress(self):
 
88
#        "Enable compression"
 
89
#        self.enableCompression = 1
 
90
#        SSHClientTransport.supportedCompressions[0:1] = ['zlib']