blob: 753bc3ccdaa093d4bb711489460648ae945ae2f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#!/usr/bin/python
import Bcfg2.Options
import Bcfg2.Client.Proxy
class _ClientCmd(Bcfg2.Options.Subcommand):
pass
class Remove(_ClientCmd):
""" Remove the given client. """
options = [Bcfg2.Options.PositionalArgument(
'client',
help='Name of the client, that should be removed.')]
def run(self, setup):
proxy = Bcfg2.Client.Proxy.ComponentProxy()
proxy.Metadata.remove_client(setup.client)
class List(_ClientCmd):
""" List all clients. """
def run(self, setup):
proxy = Bcfg2.Client.Proxy.ComponentProxy()
for client in proxy.Metadata.list_clients():
print client
class ManageClients(Bcfg2.Options.CommandRegistry):
def __init__(self):
Bcfg2.Options.CommandRegistry.__init__(self)
self.register_commands(globals().values(), parent=_ClientCmd)
parser = Bcfg2.Options.get_parser(
description="Manage clients of a running Bcfg2 server",
components=[Bcfg2.Client.Proxy.ComponentProxy, self])
parser.add_options(self.subcommand_options)
parser.parse()
ManageClients().runcommand()
|