OLD | NEW |
1 # | 1 # |
2 # Copyright 2007 Google Inc. Released under the GPL v2 | 2 # Copyright 2007 Google Inc. Released under the GPL v2 |
3 | 3 |
4 """ | 4 """ |
5 This module defines the SSHHost class. | 5 This module defines the SSHHost class. |
6 | 6 |
7 Implementation details: | 7 Implementation details: |
8 You should import the "hosts" package instead of importing each type of host. | 8 You should import the "hosts" package instead of importing each type of host. |
9 | 9 |
10 SSHHost: a remote machine with a ssh access | 10 SSHHost: a remote machine with a ssh access |
(...skipping 20 matching lines...) Expand all Loading... |
31 boot strap monitoring are available. If the machine does not have a | 31 boot strap monitoring are available. If the machine does not have a |
32 serial console available then ordinary SSH-based commands will | 32 serial console available then ordinary SSH-based commands will |
33 still be available, but attempts to use extensions such as | 33 still be available, but attempts to use extensions such as |
34 console logging or hard reset will fail silently. | 34 console logging or hard reset will fail silently. |
35 | 35 |
36 Implementation details: | 36 Implementation details: |
37 This is a leaf class in an abstract class hierarchy, it must | 37 This is a leaf class in an abstract class hierarchy, it must |
38 implement the unimplemented methods in parent classes. | 38 implement the unimplemented methods in parent classes. |
39 """ | 39 """ |
40 | 40 |
41 def _initialize(self, hostname, user="root", port=22, password="", | 41 def _initialize(self, hostname, *args, **dargs): |
42 *args, **dargs): | |
43 """ | 42 """ |
44 Construct a SSHHost object | 43 Construct a SSHHost object |
45 | 44 |
46 Args: | 45 Args: |
47 hostname: network hostname or address of remote machine | 46 hostname: network hostname or address of remote machine |
48 """ | 47 """ |
49 super(SSHHost, self)._initialize(hostname=hostname, user=user, | 48 super(SSHHost, self)._initialize(hostname=hostname, *args, **dargs) |
50 port=port, password=password, | |
51 *args, **dargs) | |
52 self.setup_ssh() | 49 self.setup_ssh() |
53 | 50 |
54 | 51 |
55 def ssh_command(self, connect_timeout=30, options='', alive_interval=300): | 52 def ssh_command(self, connect_timeout=30, options='', alive_interval=300): |
56 """ | 53 """ |
57 Construct an ssh command with proper args for this host. | 54 Construct an ssh command with proper args for this host. |
58 """ | 55 """ |
59 options = "%s %s" % (options, self.master_ssh_option) | 56 options = "%s %s" % (options, self.master_ssh_option) |
60 base_cmd = abstract_ssh.make_ssh_command(user=self.user, port=self.port, | 57 base_cmd = abstract_ssh.make_ssh_command(user=self.user, port=self.port, |
61 opts=options, | 58 opts=options, |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 except: | 236 except: |
240 pass | 237 pass |
241 | 238 |
242 | 239 |
243 def setup_ssh(self): | 240 def setup_ssh(self): |
244 if self.password: | 241 if self.password: |
245 try: | 242 try: |
246 self.ssh_ping() | 243 self.ssh_ping() |
247 except error.AutoservSshPingHostError: | 244 except error.AutoservSshPingHostError: |
248 self.setup_ssh_key() | 245 self.setup_ssh_key() |
OLD | NEW |