diff options
-rwxr-xr-x | clients | 38 |
1 files changed, 32 insertions, 6 deletions
@@ -2,10 +2,36 @@ import Bcfg2.Options import Bcfg2.Client.Proxy -parser = Bcfg2.Options.get_parser( - components=[Bcfg2.Client.Proxy.ComponentProxy]) -parser.parse() -proxy = Bcfg2.Client.Proxy.ComponentProxy() -for client in proxy.Metadata.list_clients(): - print client +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() |