Misc s/func/certmaster/ replacements
[certmaster.git] / certmaster / overlord / cmd_modules / ping.py
1 """
2 copyfile command line
3
4 Copyright 2007, Red Hat, Inc
5 Michael DeHaan <mdehaan@redhat.com>
6 also see AUTHORS
7
8 This software may be freely redistributed under the terms of the GNU
9 general public license.
10
11 You should have received a copy of the GNU General Public License
12 along with this program; if not, write to the Free Software
13 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
14 """
15
16 import optparse
17 import os
18 import pprint
19 import stat
20 import xmlrpclib
21
22 from func.overlord import command
23 from func.overlord import client
24
25 # FIXME: this really should not be in each sub module.
26 DEFAULT_PORT = 51234
27
28
29 class Ping(client.command.Command):
30 name = "ping"
31 usage = "see what func minions are up/accessible"
32
33 def addOptions(self):
34 """
35 Not too many options for you! (Seriously, it's a simple command ... func "*" ping)
36 """
37 # FIXME: verbose and port should be added globally to all sub modules
38 self.parser.add_option("-v", "--verbose", dest="verbose",
39 action="store_true")
40 self.parser.add_option("-p", "--port", dest="port",
41 default=DEFAULT_PORT)
42
43 def handleOptions(self, options):
44 """
45 Nothing to do here...
46 """
47 pass
48
49 def do(self, args):
50 self.server_spec = self.parentCommand.server_spec
51
52 # because this is mainly an interactive command, expand the server list and make seperate connections.
53 # to make things look more speedy.
54
55 servers = client.expand_servers(self.server_spec, port=self.options.port, noglobs=None,
56 verbose=self.options.verbose, just_fqdns=True)
57
58 for server in servers:
59
60 client_obj = client.Client(server,port=self.options.port,interactive=False,
61 verbose=self.options.verbose,config=self.config, noglobs=True)
62
63 results = client_obj.run("test", "ping", [])
64 if results == 1:
65 print "[ ok ... ] %s" % server
66 else:
67 print "[ FAILED ] %s" % server
68
69 return 1