From bf3dd19ae0644107116fe690fa86333b20021f76 Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Fri, 28 Mar 2008 17:06:10 -0400 Subject: move command.py:BaseCommand() to it's own module, base_command.py update the cmd_modules/* classes accordingly also cleanup some imports in the cmd_modules/* classes --- func/overlord/base_command.py | 31 +++++++++++++++++++++++++++++++ func/overlord/cmd_modules/call.py | 6 +++--- func/overlord/cmd_modules/check.py | 5 ++--- func/overlord/cmd_modules/copyfile.py | 6 +++--- func/overlord/cmd_modules/listminions.py | 5 ++--- func/overlord/cmd_modules/ping.py | 4 ++-- func/overlord/cmd_modules/show.py | 11 +++++------ func/overlord/command.py | 20 -------------------- 8 files changed, 48 insertions(+), 40 deletions(-) create mode 100644 func/overlord/base_command.py (limited to 'func') diff --git a/func/overlord/base_command.py b/func/overlord/base_command.py new file mode 100644 index 0000000..d2f9a9f --- /dev/null +++ b/func/overlord/base_command.py @@ -0,0 +1,31 @@ +#!/usr/bin/python +""" +Copyright 2008, Red Hat, Inc +Adrian Likins +also see AUTHORS + +This software may be freely redistributed under the terms of the GNU +general public license. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" + +import command +import client + +DEFAULT_PORT = 51234 +class BaseCommand(command.Command): + """ wrapper class for commands with some convience functions, namely + getOverlord() for getting a overlord client api handle""" + + interactive = False + verbose=0 + port=DEFAULT_PORT + def getOverlord(self): + self.overlord_obj = client.Overlord(self.server_spec, + port=self.port, + interactive=self.interactive, + verbose=self.verbose, + config=self.config) diff --git a/func/overlord/cmd_modules/call.py b/func/overlord/cmd_modules/call.py index dda57eb..d3e5fba 100644 --- a/func/overlord/cmd_modules/call.py +++ b/func/overlord/cmd_modules/call.py @@ -17,12 +17,12 @@ import optparse import pprint import xmlrpclib -from func.overlord import command from func.overlord import client +from func.overlord import base_command DEFAULT_FORKS = 1 -class Call(client.command.BaseCommand): +class Call(base_command.BaseCommand): name = "call" usage = "call module method name arg1 arg2..." def addOptions(self): @@ -51,7 +51,7 @@ class Call(client.command.BaseCommand): def parse(self, argv): self.argv = argv - return command.BaseCommand.parse(self, argv) + return base_command.BaseCommand.parse(self, argv) def format_return(self, data): diff --git a/func/overlord/cmd_modules/check.py b/func/overlord/cmd_modules/check.py index 93f5523..18bcd52 100644 --- a/func/overlord/cmd_modules/check.py +++ b/func/overlord/cmd_modules/check.py @@ -18,15 +18,14 @@ import optparse import os import urllib2 -from func.overlord import command -from func.overlord import client +from func.overlord import base_command from func import utils from func.minion import sub_process from func.config import read_config from certmaster.commonconfig import MinionConfig -class CheckAction(client.command.BaseCommand): +class CheckAction(base_command.BaseCommand): name = "check" usage = "check func for possible setup problems" diff --git a/func/overlord/cmd_modules/copyfile.py b/func/overlord/cmd_modules/copyfile.py index 1371b6d..63341f2 100644 --- a/func/overlord/cmd_modules/copyfile.py +++ b/func/overlord/cmd_modules/copyfile.py @@ -19,11 +19,11 @@ import pprint import stat import xmlrpclib -from func.overlord import command +from func.overlord import base_command from func.overlord import client -class CopyFile(client.command.BaseCommand): +class CopyFile(base_command.BaseCommand): name = "copyfile" usage = "copy a file to a client" @@ -42,7 +42,7 @@ class CopyFile(client.command.BaseCommand): self.verbose = self.options.verbose def do(self, args): - self.server_spec = self.parentClass.server_spec + self.server_spec = self.parentCommand.server_spec self.getOverlord() try: diff --git a/func/overlord/cmd_modules/listminions.py b/func/overlord/cmd_modules/listminions.py index f5a62c8..6e9c657 100644 --- a/func/overlord/cmd_modules/listminions.py +++ b/func/overlord/cmd_modules/listminions.py @@ -17,10 +17,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. import optparse import os -from func.overlord import command -from func.overlord import client +from func.overlord import base_command -class ListMinions(client.command.BaseCommand): +class ListMinions(base_command.BaseCommand): name = "list_minions" usage = "show known minions" diff --git a/func/overlord/cmd_modules/ping.py b/func/overlord/cmd_modules/ping.py index 3a0e6ac..ef866ae 100644 --- a/func/overlord/cmd_modules/ping.py +++ b/func/overlord/cmd_modules/ping.py @@ -19,11 +19,11 @@ import pprint import stat import xmlrpclib -from func.overlord import command +from func.overlord import base_command from func.overlord import client -class Ping(client.command.BaseCommand): +class Ping(base_command.BaseCommand): name = "ping" usage = "see what func minions are up/accessible" diff --git a/func/overlord/cmd_modules/show.py b/func/overlord/cmd_modules/show.py index 5c4875f..0e42759 100644 --- a/func/overlord/cmd_modules/show.py +++ b/func/overlord/cmd_modules/show.py @@ -17,11 +17,10 @@ import optparse import pprint import xmlrpclib -from func.overlord import command -from func.overlord import client +from func.overlord import base_command -class ShowHardware(client.command.BaseCommand): +class ShowHardware(base_command.BaseCommand): name = "hardware" usage = "show hardware details" @@ -37,7 +36,7 @@ class ShowHardware(client.command.BaseCommand): def parse(self, argv): self.argv = argv - return command.Command.parse(self,argv) + return base_command.BaseCommand.parse(self,argv) def do(self,args): @@ -62,7 +61,7 @@ class ShowHardware(client.command.BaseCommand): print minion_data[arg] -class Show(client.command.BaseCommand): +class Show(base_command.BaseCommand): name = "show" usage = "various simple report stuff" subCommandClasses = [ShowHardware] @@ -79,7 +78,7 @@ class Show(client.command.BaseCommand): def parse(self, argv): self.argv = argv - return command.Command.parse(self, argv) + return base_command.BaseCommand.parse(self, argv) def do(self, args): diff --git a/func/overlord/command.py b/func/overlord/command.py index 0fd0c7a..537bec5 100644 --- a/func/overlord/command.py +++ b/func/overlord/command.py @@ -289,23 +289,3 @@ class Command: c = c.parentCommand return c -DEFAULT_PORT = 51234 -class BaseCommand(Command): - """ wrapper class for commands with some convience functions, namely - getOverlord() for getting a overlord client api handle""" - - interactive = False - verbose=0 - port=DEFAULT_PORT - def getOverlord(self): - if not getattr(self, "server_spec"): - self.server_spec = self.parentCommand.server_spec - - - self.overlord_obj = client.Overlord(self.server_spec, - port=self.port, - interactive=self.interactive, - verbose=self.verbose, - config=self.config) - - -- cgit