Misc s/func/certmaster/ replacements
[certmaster.git] / certmaster / overlord / cmd_modules / listminions.py
1 """
2 copyfile command line
3
4 Copyright 2007, Red Hat, Inc
5 see AUTHORS
6
7 This software may be freely redistributed under the terms of the GNU
8 general public license.
9
10 You should have received a copy of the GNU General Public License
11 along with this program; if not, write to the Free Software
12 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
13 """
14
15
16 import optparse
17 import os
18
19 from func.overlord import command
20 from func.overlord import client
21 DEFAULT_PORT = 51234
22
23 class ListMinions(client.command.Command):
24 name = "list_minions"
25 usage = "show known minions"
26
27 def addOptions(self):
28 self.parser.add_option("-v", "--verbose", dest="verbose",
29 action="store_true")
30
31 def handleOptions(self, options):
32 self.port = DEFAULT_PORT
33 if options.verbose:
34 self.verbose = self.options.verbose
35
36 def do(self, args):
37 self.server_spec = self.parentCommand.server_spec
38
39 client_obj = client.Client(self.server_spec,
40 port=self.port,
41 interactive=False,
42 verbose=self.options.verbose,
43 config=self.config)
44
45 servers = client_obj.servers
46 print servers
47 for server in servers:
48 # just cause I hate regex'es -akl
49 host = server.split(':')[-2]
50 host = host.split('/')[-1]
51 print host