Last change
on this file since 7017 was
7017,
checked in by rwilson, 14 years ago
|
Improved reporting.
|
-
Property svn:executable set to
*
|
File size:
1.6 KB
|
Line | |
---|
1 | #!/bin/env python |
---|
2 | |
---|
3 | '''Testlet to check that can ssh to each subordinate node of the cluster.''' |
---|
4 | |
---|
5 | import os |
---|
6 | import time |
---|
7 | import test_utils as util |
---|
8 | |
---|
9 | name = 'Test of compute-node accessibility via ssh' |
---|
10 | |
---|
11 | def test(logfile): |
---|
12 | result = True |
---|
13 | |
---|
14 | (cluster, domain) = util.get_hostname() |
---|
15 | |
---|
16 | # get python to run |
---|
17 | python_env_var = os.getenv('PYTHON') |
---|
18 | |
---|
19 | # get cluster-specific information |
---|
20 | cluster_dict = util.get_cluster_info(cluster) |
---|
21 | if cluster_dict is None: |
---|
22 | util.log_print_nl(logfile, 'Sorry, you must be on one of these clusters:') |
---|
23 | for name in Cluster_Info: |
---|
24 | util.log_print_nl(logfile, '\t%s' % name) |
---|
25 | util.log_print_nl(logfile, 'You are on the %s machine.' % cluster) |
---|
26 | return False |
---|
27 | |
---|
28 | # get max width of the compute node names |
---|
29 | width = len(cluster_dict['node_stem']) + len(str(cluster_dict['num_nodes'])) |
---|
30 | |
---|
31 | # test each node |
---|
32 | for node_num in range(cluster_dict['num_nodes']): |
---|
33 | node_name = cluster_dict['node_stem'] % node_num |
---|
34 | util.log_print(logfile, "Testing: %s" % node_name.ljust(width+2)) |
---|
35 | (_, fd) = os.popen4('ssh %s exit' % node_name) |
---|
36 | data = fd.read() |
---|
37 | status = fd.close() |
---|
38 | #if status is None: |
---|
39 | if len(data) == 0: |
---|
40 | util.log_print_nl(logfile, 'OK') |
---|
41 | else: |
---|
42 | util.log_print(logfile, data) |
---|
43 | result = False |
---|
44 | |
---|
45 | return result |
---|
46 | |
---|
47 | |
---|
48 | if __name__ == '__main__': |
---|
49 | import sys |
---|
50 | |
---|
51 | logfile = 'test.log' |
---|
52 | if len(sys.argv) > 1: |
---|
53 | logfile = sys.argv[1] |
---|
54 | |
---|
55 | try: |
---|
56 | os.remove(logfile) |
---|
57 | except: |
---|
58 | pass |
---|
59 | |
---|
60 | if not test(logfile): |
---|
61 | sys.exit(10) |
---|
62 | |
---|
63 | sys.exit(0) |
---|
Note: See
TracBrowser
for help on using the repository browser.