Index: fedd/federation/protogeni_access.py
===================================================================
--- fedd/federation/protogeni_access.py	(revision 88dbe6330de24f2673a50c961f1651c0f63d0338)
+++ fedd/federation/protogeni_access.py	(revision 208797c18a36ab60d41373d4305eb6da39360f64)
@@ -15,5 +15,4 @@
 
 from threading import Thread, Timer, Lock
-from M2Crypto.SSL import SSLError
 
 from util import *
@@ -29,5 +28,6 @@
 
 from access import access_base
-from proxy_segment import proxy_segment
+from protogeni_proxy import protogeni_proxy
+from geniapi_proxy import geniapi_proxy
 
 import topdl
@@ -41,75 +41,4 @@
 fl = logging.getLogger("fedd.access")
 fl.addHandler(nullHandler())
-
-class protogeni_proxy(proxy_segment):
-    class ProtoGENIError(Exception): 
-	def __init__(self, op, code, output):
-	    Exception.__init__(self, output)
-	    self.op = op
-	    self.code = code
-	    self.output = output
-
-    def __init__(self, log=None, keyfile=None, debug=False, 
-	    ch_url=None, sa_url=None, cm_url=None):
-	proxy_segment.__init__(self, log=log, keyfile=keyfile, debug=debug)
-
-	self.ProtoGENIError = protogeni_proxy.ProtoGENIError
-	self.ch_url = ch_url
-	self.sa_url = sa_url
-	self.cm_url = cm_url
-
-	self.call_SetValue = service_caller('SetValue')
-
-	self.debug_fail = ['Resolve']
-	self.debug_response = {
-		'RedeemTicket': ("XML blob1", "XML blob2"),
-		'SliceStatus': { 'status': 'ready' },
-	    }
-
-
-    def pg_call(self, url, method, params, context):
-	max_retries = 5
-	retries = 0
-
-	s = service_caller(method, request_body_name="", strict=False)
-	self.log.debug("Calling %s %s" % (url, method))
-	if not self.debug:
-	    while retries < max_retries:
-		r = s.call_xmlrpc_service(url, params, context=context)
-		code = r.get('code', -1)
-		if code == 0:
-		    # Success leaves the loop here
-		    return r.get('value', None)
-		elif code == 14 and retries +1 < max_retries:
-		    # Busy resource
-		    retries+= 1
-		    self.log.info("Resource busy, retrying in 30 secs")
-		    time.sleep(30)
-		else:
-		    # NB: out of retries falls through to here
-		    raise self.ProtoGENIError(op=method, 
-			    code=r.get('code', 'unknown'), 
-			    output=r.get('output', 'No output'))
-	else:
-	    if method in self.debug_fail:
-		raise self.ProtoGENIError(op=method, code='unknown',
-			output='No output')
-	    elif self.debug_response.has_key(method):
-		return self.debug_response[method]
-	    else:
-		return "%s XML blob" % method
-
-    def clearinghouse_call(self, method, params, context):
-	return self.pg_call(self.ch_url, method, params, context)
-
-    def slice_authority_call(self, method, params, context):
-	return self.pg_call(self.sa_url, method, params, context)
-
-    def component_manager_call(self, method, params, context):
-	return self.pg_call(self.cm_url, method, params, context)
-
-
-
-
 
 class access(access_base):
@@ -198,4 +127,13 @@
 
 	self.lookup_access = self.lookup_access_base
+
+	api = config.get("access", "api") or "protogeni"
+	if api == "protogeni":
+	    self.api_proxy = protogeni_proxy
+	elif api == "geniapi":
+	    self.api_proxy = geniapi_proxy
+	else:
+	    self.log.debug("Unknown interface, using protogeni")
+	    self.api_proxy = protogeni_proxy
 
 	self.call_SetValue = service_caller('SetValue')
@@ -978,6 +916,14 @@
 		    'slice_urn': slice_urn,
 		    }
-	    sliver_cred, manifest = segment_commands.component_manager_call(
+	    rv = segment_commands.component_manager_call(
 		    'CreateSliver', param, ctxt)
+
+	    # the GENIAPI AM just hands back the manifest, bit the ProtoGENI
+	    # API hands back a sliver credential.  This just finds the format
+	    # of choice.
+	    if isinstance(rv, tuple):
+		manifest = rv[1]
+	    else:
+		manifest = rv
 	except segment_commands.ProtoGENIError, e:
 	    raise service_error(service_error.federant,
@@ -1004,5 +950,6 @@
 		r = segment_commands.component_manager_call(
 			'SliverStatus', param, ctxt)
-		status = r.get('status', 'changing')
+		# GENIAPI uses geni_status as the key, so check for both
+		status = r.get('status', r.get('geni_status','changing'))
 		if status not in completed_states:
 		    if timeout is not None and time.time() > end:
@@ -1342,5 +1289,5 @@
 		    % (self.staging_dir, ename), connInfo)
 
-	    segment_commands = protogeni_proxy(keyfile=ssh_key,
+	    segment_commands = self.api_proxy(keyfile=ssh_key,
 		    debug=self.create_debug, log=alloc_log,
 		    ch_url = self.ch_url, sa_url=self.sa_url,
@@ -1423,5 +1370,5 @@
 	    staging = None
 
-	segment_commands = protogeni_proxy(keyfile=ssh_key,
+	segment_commands = self.api_proxy(keyfile=ssh_key,
 		debug=self.create_debug, ch_url = self.ch_url,
 		sa_url=self.sa_url, cm_url=self.cm_url)
@@ -1509,5 +1456,5 @@
 	    # There's a ProtoGENI slice associated with the segment; renew it.
 	    if name and scred and slice_urn:
-		segment_commands = protogeni_proxy(log=self.log, 
+		segment_commands = self.api_proxy(log=self.log, 
 			debug=self.create_debug, keyfile=ssh_key,
 			cm_url = self.cm_url, sa_url = self.sa_url,
