diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2007-12-31 11:21:10 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2007-12-31 11:21:10 +0000 |
commit | ef5051726a3aa1f0192bd8d99c5c5b1ee9f067af (patch) | |
tree | 57bf0854d95c18cced379921657f746ad5faab04 /src/lib/Client | |
parent | 104a1e27cee2d5524460d26c83d3e920cd88b2e9 (diff) | |
download | bcfg2-ef5051726a3aa1f0192bd8d99c5c5b1ee9f067af.tar.gz bcfg2-ef5051726a3aa1f0192bd8d99c5c5b1ee9f067af.tar.bz2 bcfg2-ef5051726a3aa1f0192bd8d99c5c5b1ee9f067af.zip |
Switch over to more Options usage and complete tests (everything appears to work now)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4142 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Client')
-rw-r--r-- | src/lib/Client/Proxy.py | 64 |
1 files changed, 45 insertions, 19 deletions
diff --git a/src/lib/Client/Proxy.py b/src/lib/Client/Proxy.py index 8e34a0fb5..d148748e2 100644 --- a/src/lib/Client/Proxy.py +++ b/src/lib/Client/Proxy.py @@ -6,7 +6,6 @@ from Bcfg2.tlslite.integration.XMLRPCTransport import XMLRPCTransport from Bcfg2.tlslite.integration.HTTPTLSConnection import HTTPTLSConnection from Bcfg2.tlslite.TLSConnection import TLSConnection import Bcfg2.tlslite.errors -from Bcfg2.Settings import settings #FIXME need to reimplement _binadaddress support for XMLRPCTransport @@ -47,39 +46,66 @@ class CobaltComponentError(Exception): class SafeProxy: '''Wrapper for proxy''' - + _retries = 4 _authinfo = () + _components = {} def __init__(self, component, args={}): self.component = component self.log = logging.getLogger(component) - password = settings.COMMUNICATION_PASSWORD - if args['password']: + if args.has_key('server'): + # processing from command line args + self._components[component] = args['server'] + else: + if args.has_key('setup'): + # processing from specified config file + _cfpath = args['setup'] + else: + _cfpath = '/etc/bcfg2.conf' + self._cfile = ConfigParser.ConfigParser() + self._cfile.read([_cfpath]) + try: + self._components = self._cfile._sections['components'] + except: + self.log.error("%s doesn't contain a valid components section" % (_cfpath)) + raise SystemExit, 1 + if args.has_key('password'): + # get passwd from cmdline password = args['password'] - - user = settings.COMMUNICATION_USER - if args['user']: + else: + try: + password = self._cfile.get('communication', 'password') + except: + self.log.error("%s doesn't contain a valid password" % (_cfpath)) + raise SystemExit, 1 + if args.has_key('user'): user = args['user'] + else: + try: + user = self._cfile.get('communication', 'user') + except: + user = 'root' self._authinfo = (user, password) - self.fingerprint = False - if args['fingerprint']: + if args.has_key('fingerprint'): self.fingerprint = args['fingerprint'] + else: + self.fingerprint = False - address = settings.COMPONENTS_BCFG2 - if args['server']: + _bindaddress = "" + try: + _bindaddress = self._cfile.get('communication', 'bindaddress') + except: + pass + + if args.has_key('server'): address = args['server'] - - # NOT USED - #_bindaddress = "" - #try: - # _bindaddress = self._cfile.get('communication', 'bindaddress') - #except: - # pass + else: + address = self.__get_location(component) + try: - # NOT USED # if _bindaddress != "": # self.log.info("Binding client to address %s" % _bindaddress) # self.proxy = xmlrpclib.ServerProxy(address, transport=Bcfg2SafeTransport()) |