-def delete_slice(api, xrn, origin_hrn=None):
- credential = api.getCredential()
- aggregates = Aggregates(api)
- for aggregate in aggregates:
- success = False
- # request hash is optional so lets try the call without it
- try:
- aggregates[aggregate].delete_slice(credential, xrn, origin_hrn)
- success = True
- except:
- print >> log, "%s" % (traceback.format_exc())
- print >> log, "Error calling delete slice at aggregate %s" % aggregate
- return 1
+# we have specialized xmlrpclib.ServerProxy to remember the input url
+# OTOH it's not clear if we're only dealing with XMLRPCServerProxy instances
+def get_serverproxy_url (server):
+ try:
+ return server.url
+ except:
+ sfa_logger().warning("GetVersion, falling back to xmlrpclib.ServerProxy internals")
+ return server._ServerProxy__host + server._ServerProxy__handler
+
+def GetVersion(api):
+ # peers explicitly in aggregates.xml
+ peers =dict ([ (peername,get_serverproxy_url(v)) for (peername,v) in api.aggregates.iteritems()
+ if peername != api.hrn])
+ xrn=Xrn (api.hrn)
+ supported_rspecs = [dict(pg_rspec_version), dict(sfa_rspec_version)]
+ version_more = {'interface':'slicemgr',
+ 'hrn' : xrn.get_hrn(),
+ 'urn' : xrn.get_urn(),
+ 'peers': peers,
+ 'request_rspec_versions': supported_rspecs,
+ 'ad_rspec_versions': supported_rspecs,
+ 'default_ad_rspec': dict(sfa_rspec_version)
+ }
+ sm_version=version_core(version_more)
+ # local aggregate if present needs to have localhost resolved
+ 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'])
+ return sm_version
+
+def CreateSliver(api, xrn, creds, rspec_str, users, call_id):
+
+ def _CreateSliver(aggregate, 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.
+ # The Aggregate's verion info is cached
+ server = api.aggregates[aggregate]
+ # get cached aggregate version
+ aggregate_version_key = 'version_'+ aggregate
+ aggregate_version = api.cache.get(aggregate_version_key)
+ if not aggregate_version:
+ # get current aggregate version anc cache it for 24 hours
+ aggregate_version = server.GetVersion()
+ api.cache.add(aggregate_version_key, aggregate_version, 60 * 60 * 24)
+
+ if 'sfa' not in aggregate_version and 'geni_api' in aggregate_version:
+ # sfa aggregtes support both sfa and pg rspecs, no need to convert
+ # if aggregate supports sfa rspecs. othewise convert to pg rspec
+ rspec = RSpecConverter.to_pg_rspec(rspec)