summaryrefslogtreecommitdiffstats
path: root/src/lib/Client/Proxy.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Client/Proxy.py')
-rw-r--r--src/lib/Client/Proxy.py64
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())