#import sfa.plc.peers as peers
from sfa.util.version import version_core
from sfa.util.callids import Callids
#import sfa.plc.peers as peers
from sfa.util.version import version_core
from sfa.util.callids import Callids
def _call_id_supported(api, server):
"""
Returns true if server support the optional call_id arg, false otherwise.
"""
def _call_id_supported(api, server):
"""
Returns true if server support the optional call_id arg, false otherwise.
"""
- peers =dict ([ (peername,get_serverproxy_url(v)) for (peername,v) in myapi.aggregates.iteritems()
- if peername != myapi.hrn])
+ peers =dict ([ (peername,get_serverproxy_url(v)) for (peername,v) in api.aggregates.iteritems()
+ if peername != api.hrn])
if rspec_version.content_type in ['*', 'request']:
request_rspec_versions.append(rspec_version.to_dict())
default_rspec_version = version_manager.get_version("sfa 1").to_dict()
if rspec_version.content_type in ['*', 'request']:
request_rspec_versions.append(rspec_version.to_dict())
default_rspec_version = version_manager.get_version("sfa 1").to_dict()
- if myapi.hrn in myapi.aggregates:
- local_am_url=get_serverproxy_url(myapi.aggregates[myapi.hrn])
- sm_version['peers'][myapi.hrn]=local_am_url.replace('localhost',sm_version['hostname'])
+ if api.hrn in api.aggregates:
+ local_am_url=get_serverproxy_url(api.aggregates[api.hrn])
+ sm_version['peers'][api.hrn]=local_am_url.replace('localhost',sm_version['hostname'])
-def CreateSliver(myapi, xrn, creds, rspec_str, users, call_id):
+def CreateSliver(api, xrn, creds, rspec_str, users, call_id):
version_manager = VersionManager()
def _CreateSliver(aggregate, server, xrn, credential, rspec, users, call_id):
version_manager = VersionManager()
def _CreateSliver(aggregate, server, xrn, credential, rspec, users, call_id):
# Need to call GetVersion at an aggregate to determine the supported
# rspec type/format beofre calling CreateSliver at an Aggregate.
print>>sys.stderr, " \r\n SLICE MANAGERSLAB _CreateSliver server "
# Need to call GetVersion at an aggregate to determine the supported
# rspec type/format beofre calling CreateSliver at an Aggregate.
print>>sys.stderr, " \r\n SLICE MANAGERSLAB _CreateSliver server "
# sfa aggregtes support both sfa and pg rspecs, no need to convert
# if aggregate supports sfa rspecs. otherwise convert to pg rspec
rspec = RSpec(RSpecConverter.to_pg_rspec(rspec, 'request'))
# sfa aggregtes support both sfa and pg rspecs, no need to convert
# if aggregate supports sfa rspecs. otherwise convert to pg rspec
rspec = RSpec(RSpecConverter.to_pg_rspec(rspec, 'request'))
rspec = rspec.toxml()
requested_users = sfa_to_pg_users_arg(users)
args = [xrn, credential, rspec, requested_users]
rspec = rspec.toxml()
requested_users = sfa_to_pg_users_arg(users)
args = [xrn, credential, rspec, requested_users]
args.append(call_id)
rspec = server.CreateSliver(*args)
return {"aggregate": aggregate, "rspec": rspec, "elapsed": time.time()-tStart, "status": "success"}
args.append(call_id)
rspec = server.CreateSliver(*args)
return {"aggregate": aggregate, "rspec": rspec, "elapsed": time.time()-tStart, "status": "success"}
- print>>sys.stderr, " \r\n \r\n \t\t =======SLICE MANAGER _CreateSliver myapi aggregates %s \t caller_hrn %s myapi.hrn %s" %(myapi.aggregates, caller_hrn, myapi.hrn)
- for aggregate in myapi.aggregates:
+ print>>sys.stderr, " \r\n \r\n \t\t =======SLICE MANAGER _CreateSliver api aggregates %s \t caller_hrn %s api.hrn %s" %(api.aggregates, caller_hrn, api.hrn)
+ for aggregate in api.aggregates:
- interface = myapi.aggregates[aggregate]
- print>>sys.stderr, " \r\n \r\n \t\t =======SLICE MANAGER _CreateSliver aggregate %s interface %s" %(myapi.aggregates[aggregate],interface)
- server = myapi.get_server(interface, credential)
+ interface = api.aggregates[aggregate]
+ print>>sys.stderr, " \r\n \r\n \t\t =======SLICE MANAGER _CreateSliver aggregate %s interface %s" %(api.aggregates[aggregate],interface)
+ server = api.get_server(interface, credential)
if server is None:
print>>sys.stderr, " \r\n \r\n \t\t =======SLICE MANAGER _CreateSliver NOSERVERS "
# Just send entire RSpec to each aggregate
if server is None:
print>>sys.stderr, " \r\n \r\n \t\t =======SLICE MANAGER _CreateSliver NOSERVERS "
# Just send entire RSpec to each aggregate
caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
# attempt to use delegated credential first
caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
# attempt to use delegated credential first
threads.run(server.RenewSliver, xrn, [credential], expiration_time, call_id)
# 'and' the results
return reduce (lambda x,y: x and y, threads.get_results() , True)
threads.run(server.RenewSliver, xrn, [credential], expiration_time, call_id)
# 'and' the results
return reduce (lambda x,y: x and y, threads.get_results() , True)
caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
# attempt to use delegated credential first
caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
# attempt to use delegated credential first
threads = ThreadManager()
for (aggregate, aggregate_rspec) in aggregate_rspecs.iteritems():
# prevent infinite loop. Dont send request back to caller
# unless the caller is the aggregate's SM
threads = ThreadManager()
for (aggregate, aggregate_rspec) in aggregate_rspecs.iteritems():
# prevent infinite loop. Dont send request back to caller
# unless the caller is the aggregate's SM
else:
net_urn = hrn_to_urn(aggregate, 'authority')
# we may have a peer that knows about this aggregate
else:
net_urn = hrn_to_urn(aggregate, 'authority')
# we may have a peer that knows about this aggregate
- for agg in myapi.aggregates:
- target_aggs = myapi.aggregates[agg].get_aggregates(credential, net_urn)
+ for agg in api.aggregates:
+ target_aggs = api.aggregates[agg].get_aggregates(credential, net_urn)
if not target_aggs or not 'hrn' in target_aggs[0]:
continue
# send the request to this address
url = target_aggs[0]['url']
if not target_aggs or not 'hrn' in target_aggs[0]:
continue
# send the request to this address
url = target_aggs[0]['url']
- ticket.set_gid_caller(myapi.auth.client_gid)
- ticket.set_issuer(key=myapi.key, subject=myapi.hrn)
+ ticket.set_gid_caller(api.auth.client_gid)
+ ticket.set_issuer(key=api.key, subject=api.hrn)
if Callids().already_handled(call_id): return ""
(hrn, type) = urn_to_hrn(xrn)
# get the callers hrn
if Callids().already_handled(call_id): return ""
(hrn, type) = urn_to_hrn(xrn)
# get the callers hrn
caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
# attempt to use delegated credential first
caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
# attempt to use delegated credential first
threads.run(server.DeleteSliver, xrn, credential, call_id)
threads.get_results()
return 1
threads.run(server.DeleteSliver, xrn, credential, call_id)
threads.get_results()
return 1
caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
# attempt to use delegated credential first
caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
# attempt to use delegated credential first
caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
# attempt to use delegated credential first
caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
# attempt to use delegated credential first
caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
# attempt to use delegated credential first
caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
# attempt to use delegated credential first
- if caching and myapi.cache:
- myapi.cache.add('slices', slices)
+ if caching and api.cache:
+ api.cache.add('slices', slices)
etree.SubElement(stats_tag, "aggregate", name=str(aggname), elapsed=str(elapsed), status=str(status))
except Exception, e:
etree.SubElement(stats_tag, "aggregate", name=str(aggname), elapsed=str(elapsed), status=str(status))
except Exception, e:
# force ProtoGENI aggregates to give us a v2 RSpec
if 'sfa' not in version.keys():
my_opts['rspec_version'] = version_manager.get_version('ProtoGENI 2').to_dict()
rspec = server.ListResources(*args)
return {"aggregate": aggregate, "rspec": rspec, "elapsed": time.time()-tStart, "status": "success"}
except Exception, e:
# force ProtoGENI aggregates to give us a v2 RSpec
if 'sfa' not in version.keys():
my_opts['rspec_version'] = version_manager.get_version('ProtoGENI 2').to_dict()
rspec = server.ListResources(*args)
return {"aggregate": aggregate, "rspec": rspec, "elapsed": time.time()-tStart, "status": "success"}
except Exception, e:
return {"aggregate": aggregate, "elapsed": time.time()-tStart, "status": "exception"}
if Callids().already_handled(call_id): return ""
return {"aggregate": aggregate, "elapsed": time.time()-tStart, "status": "exception"}
if Callids().already_handled(call_id): return ""
caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
# attempt to use delegated credential first
caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
# attempt to use delegated credential first
- interface = myapi.aggregates[aggregate]
- server = myapi.get_server(interface, cred)
+ interface = api.aggregates[aggregate]
+ server = api.get_server(interface, cred)
threads.run(_ListResources, aggregate, server, [cred], options, call_id)
threads.run(_ListResources, aggregate, server, [cred], options, call_id)
- if caching and myapi.cache and not xrn:
- myapi.cache.add(version_string, rspec.toxml())
+ if caching and api.cache and not xrn:
+ api.cache.add(version_string, rspec.toxml())
-#def ListResources(myapi, creds, options, call_id):
+#def ListResources(api, creds, options, call_id):
#xrn = options.get('geni_slice_urn', '')
#(hrn, type) = urn_to_hrn(xrn)
#print >>sys.stderr, " SM_ListResources xrn " , xrn
#xrn = options.get('geni_slice_urn', '')
#(hrn, type) = urn_to_hrn(xrn)
#print >>sys.stderr, " SM_ListResources xrn " , xrn
- ##print >>sys.stderr, " SM ListResources myapi.__dict__ " , myapi.__dict__.keys()
- ##print >>sys.stderr, " SM ListResources dir(myapi)" , dir(myapi)
+ ##print >>sys.stderr, " SM ListResources api.__dict__ " , api.__dict__.keys()
+ ##print >>sys.stderr, " SM ListResources dir(api)" , dir(api)
#print >>sys.stderr, " \r\n avant RspecVersion \r\n \r\n"
## get the rspec's return format from options
#rspec_version = RSpecVersion(options.get('rspec_version'))
#print >>sys.stderr, " \r\n avant RspecVersion \r\n \r\n"
## get the rspec's return format from options
#rspec_version = RSpecVersion(options.get('rspec_version'))
- #if caching and myapi.cache and not xrn:
- #print>>sys.stderr," \r\n caching %s and myapi.cache %s and not xrn %s"%(caching , myapi.cache,xrn)
- #rspec = myapi.cache.get(version_string)
+ #if caching and api.cache and not xrn:
+ #print>>sys.stderr," \r\n caching %s and api.cache %s and not xrn %s"%(caching , api.cache,xrn)
+ #rspec = api.cache.get(version_string)
#caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
#print >>sys.stderr, " \r\n SM ListResources get the callers caller_hrn hrn %s "%(caller_hrn)
## attempt to use delegated credential first
#caller_hrn = Credential(string=valid_cred).get_gid_caller().get_hrn()
#print >>sys.stderr, " \r\n SM ListResources get the callers caller_hrn hrn %s "%(caller_hrn)
## attempt to use delegated credential first
- #print >>sys.stderr, " \r\n SM ListResources get the callers myapi.aggregates %s "%(myapi.aggregates)
- #for aggregate in myapi.aggregates:
+ #print >>sys.stderr, " \r\n SM ListResources get the callers api.aggregates %s "%(api.aggregates)
+ #for aggregate in api.aggregates:
## prevent infinite loop. Dont send request back to caller
## unless the caller is the aggregate's SM
## prevent infinite loop. Dont send request back to caller
## unless the caller is the aggregate's SM
#print >>sys.stderr, " Slice Mgr ListResources, server" ,server
#my_opts = copy(options)
#my_opts['geni_compressed'] = False
#print >>sys.stderr, " Slice Mgr ListResources, server" ,server
#my_opts = copy(options)
#my_opts['geni_compressed'] = False
- #if caching and myapi.cache and not xrn:
- #myapi.cache.add(version_string, rspec.toxml())
+ #if caching and api.cache and not xrn:
+ #api.cache.add(version_string, rspec.toxml())
def SliverStatus(api, slice_xrn, creds, call_id):
if Callids().already_handled(call_id): return {}
# attempt to use delegated credential first
def SliverStatus(api, slice_xrn, creds, call_id):
if Callids().already_handled(call_id): return {}
# attempt to use delegated credential first
threads.run (server.SliverStatus, slice_xrn, credential, call_id)
results = threads.get_results()
threads.run (server.SliverStatus, slice_xrn, credential, call_id)
results = threads.get_results()