Changeset 208797c for fedd/federation
- Timestamp:
- Aug 25, 2010 9:35:02 AM (14 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- 64e774d
- Parents:
- 88dbe63
- Location:
- fedd/federation
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/protogeni_access.py
r88dbe63 r208797c 15 15 16 16 from threading import Thread, Timer, Lock 17 from M2Crypto.SSL import SSLError18 17 19 18 from util import * … … 29 28 30 29 from access import access_base 31 from proxy_segment import proxy_segment 30 from protogeni_proxy import protogeni_proxy 31 from geniapi_proxy import geniapi_proxy 32 32 33 33 import topdl … … 41 41 fl = logging.getLogger("fedd.access") 42 42 fl.addHandler(nullHandler()) 43 44 class protogeni_proxy(proxy_segment):45 class ProtoGENIError(Exception):46 def __init__(self, op, code, output):47 Exception.__init__(self, output)48 self.op = op49 self.code = code50 self.output = output51 52 def __init__(self, log=None, keyfile=None, debug=False,53 ch_url=None, sa_url=None, cm_url=None):54 proxy_segment.__init__(self, log=log, keyfile=keyfile, debug=debug)55 56 self.ProtoGENIError = protogeni_proxy.ProtoGENIError57 self.ch_url = ch_url58 self.sa_url = sa_url59 self.cm_url = cm_url60 61 self.call_SetValue = service_caller('SetValue')62 63 self.debug_fail = ['Resolve']64 self.debug_response = {65 'RedeemTicket': ("XML blob1", "XML blob2"),66 'SliceStatus': { 'status': 'ready' },67 }68 69 70 def pg_call(self, url, method, params, context):71 max_retries = 572 retries = 073 74 s = service_caller(method, request_body_name="", strict=False)75 self.log.debug("Calling %s %s" % (url, method))76 if not self.debug:77 while retries < max_retries:78 r = s.call_xmlrpc_service(url, params, context=context)79 code = r.get('code', -1)80 if code == 0:81 # Success leaves the loop here82 return r.get('value', None)83 elif code == 14 and retries +1 < max_retries:84 # Busy resource85 retries+= 186 self.log.info("Resource busy, retrying in 30 secs")87 time.sleep(30)88 else:89 # NB: out of retries falls through to here90 raise self.ProtoGENIError(op=method,91 code=r.get('code', 'unknown'),92 output=r.get('output', 'No output'))93 else:94 if method in self.debug_fail:95 raise self.ProtoGENIError(op=method, code='unknown',96 output='No output')97 elif self.debug_response.has_key(method):98 return self.debug_response[method]99 else:100 return "%s XML blob" % method101 102 def clearinghouse_call(self, method, params, context):103 return self.pg_call(self.ch_url, method, params, context)104 105 def slice_authority_call(self, method, params, context):106 return self.pg_call(self.sa_url, method, params, context)107 108 def component_manager_call(self, method, params, context):109 return self.pg_call(self.cm_url, method, params, context)110 111 112 113 114 43 115 44 class access(access_base): … … 198 127 199 128 self.lookup_access = self.lookup_access_base 129 130 api = config.get("access", "api") or "protogeni" 131 if api == "protogeni": 132 self.api_proxy = protogeni_proxy 133 elif api == "geniapi": 134 self.api_proxy = geniapi_proxy 135 else: 136 self.log.debug("Unknown interface, using protogeni") 137 self.api_proxy = protogeni_proxy 200 138 201 139 self.call_SetValue = service_caller('SetValue') … … 978 916 'slice_urn': slice_urn, 979 917 } 980 sliver_cred, manifest= segment_commands.component_manager_call(918 rv = segment_commands.component_manager_call( 981 919 'CreateSliver', param, ctxt) 920 921 # the GENIAPI AM just hands back the manifest, bit the ProtoGENI 922 # API hands back a sliver credential. This just finds the format 923 # of choice. 924 if isinstance(rv, tuple): 925 manifest = rv[1] 926 else: 927 manifest = rv 982 928 except segment_commands.ProtoGENIError, e: 983 929 raise service_error(service_error.federant, … … 1004 950 r = segment_commands.component_manager_call( 1005 951 'SliverStatus', param, ctxt) 1006 status = r.get('status', 'changing') 952 # GENIAPI uses geni_status as the key, so check for both 953 status = r.get('status', r.get('geni_status','changing')) 1007 954 if status not in completed_states: 1008 955 if timeout is not None and time.time() > end: … … 1342 1289 % (self.staging_dir, ename), connInfo) 1343 1290 1344 segment_commands = protogeni_proxy(keyfile=ssh_key,1291 segment_commands = self.api_proxy(keyfile=ssh_key, 1345 1292 debug=self.create_debug, log=alloc_log, 1346 1293 ch_url = self.ch_url, sa_url=self.sa_url, … … 1423 1370 staging = None 1424 1371 1425 segment_commands = protogeni_proxy(keyfile=ssh_key,1372 segment_commands = self.api_proxy(keyfile=ssh_key, 1426 1373 debug=self.create_debug, ch_url = self.ch_url, 1427 1374 sa_url=self.sa_url, cm_url=self.cm_url) … … 1509 1456 # There's a ProtoGENI slice associated with the segment; renew it. 1510 1457 if name and scred and slice_urn: 1511 segment_commands = protogeni_proxy(log=self.log,1458 segment_commands = self.api_proxy(log=self.log, 1512 1459 debug=self.create_debug, keyfile=ssh_key, 1513 1460 cm_url = self.cm_url, sa_url = self.sa_url,
Note: See TracChangeset
for help on using the changeset viewer.