from sfa.util.sfaticket import SfaTicket
from sfa.util.debug import log
from sfa.plc.slices import Slices
+from sfa.trust.credential import Credential
import sfa.plc.peers as peers
from sfa.plc.network import *
from sfa.plc.api import SfaAPI
return slice_urns
-def get_rspec(api, xrn=None, origin_hrn=None):
+def get_rspec(api, creds, options):
+ # get slice's hrn from options
+ xrn = options.get('geni_slice_urn', None)
+ hrn, type = urn_to_hrn(xrn)
+
+ # get hrn of the original caller
+ origin_hrn = options.get('origin_hrn', None)
+ if not origin_hrn:
+ origin_hrn = Credential(string=creds[0]).get_gid_caller().get_hrn()
+
# look in cache first
if api.cache and not xrn:
rspec = api.cache.get('nodes')
if rspec:
return rspec
- hrn, type = urn_to_hrn(xrn)
network = Network(api)
if (hrn):
if network.get_slice(api, hrn):
return rspec
+
"""
Returns the request context required by sfatables. At some point, this
mechanism should be changed to refer to "contexts", which is the
from sfa.util.policy import Policy
from sfa.util.prefixTree import prefixTree
from sfa.util.sfaticket import *
+from sfa.trust.credential import Credential
from sfa.util.threadmanager import ThreadManager
import sfa.util.xmlrpcprotocol as xmlrpcprotocol
from sfa.util.debug import log
attrs = agg_ticket.get_attributes()
if not object_gid:
object_gid = agg_ticket.get_gid_object()
- print object_gid
rspecs.append(agg_ticket.get_rspec())
initscripts.extend(attrs.get('initscripts', []))
slivers.extend(attrs.get('slivers', []))
return slices
-def get_rspec(api, xrn=None, origin_hrn=None):
+def get_rspec(api, creds, options):
+ # get slice's hrn from options
+ xrn = options.get('geni_slice_urn', None)
+ hrn, type = urn_to_hrn(xrn)
+
+ # get hrn of the original caller
+ origin_hrn = options.get('origin_hrn', None)
+ if not origin_hrn:
+ origin_hrn = Credential(string=creds[0]).get_gid_caller().get_hrn()
+
# look in cache first
if api.cache and not xrn:
rspec = api.cache.get('nodes')
hrn, type = urn_to_hrn(xrn)
rspec = None
+ # XX
+ # XX TODO: Should try to use delegated credential first
+ # XX
cred = api.getCredential()
threads = ThreadManager()
+
for aggregate in api.aggregates:
- if aggregate not in [api.auth.client_cred.get_gid_caller().get_hrn()]:
+ if aggregate not in [api.auth.client_cred.get_gid_caller().get_hrn()]:
# get the rspec from the aggregate
server = api.aggregates[aggregate]
+ # XX
+ # XX TODO: switch to ProtoGeni spec in next release. Give other
+ # XX aggregtes a chacne to upgrade to this release before switching
+ # XX
+ # threads.run(server.ListResources, cred, options)
threads.run(server.get_resources, cred, xrn, origin_hrn)
+
results = threads.get_results()
# combine the rspecs into a single rspec
rspec.append(deepcopy(network))
for request in root.iterfind("./request"):
rspec.append(deepcopy(request))
-
+
+ print results
rspec = etree.tostring(rspec, xml_declaration=True, pretty_print=True)
# cache the result
if api.cache and not xrn: