netspecs = spec.getDictsByTagName('NetSpec')
for netspec in netspecs:
net_hrn = netspec['name']
- resources = {'start_time': start_time, 'end_time': end_time, 'networks': netspec}
+ resources = {'start_time': start_time, 'end_time': end_time, 'networks': {'NetSpec' : netspec}}
resourceDict = {'RSpec': resources}
tempspec.parseDict(resourceDict)
rspecs[net_hrn] = tempspec.toxml()
-
+
#print "rspecs:", rspecs.keys()
#print "aggregates:", aggregates.keys()
# send each rspec to the appropriate aggregate/sm
for netspec in netspecs:
net_hrn = netspec['name']
resources = {'start_time': 0, 'end_time': 0 ,
- 'network': netspec}
+ 'network': {'NetSpec' : netspec}}
resourceDict = {'RSpec': resources}
temp_rspec.parseDict(resourceDict)
rspecs[net_hrn] = temp_rspec.toxml()
credential = api.getCredential()
tickets = {}
for net_hrn in rspecs:
- net_urn = urn_to_hrn(net_hrn, 'authority')
+ net_urn = urn_to_hrn(net_hrn)
try:
# if we are directly connected to the aggregate then we can just
# send them the request. if not, then we may be connected to an sm
else:
# lets forward this rspec to a sm that knows about the network
for agg in aggregates:
- network_found = aggregates[agg].get_aggregates(credential, )net_urn
+ network_found = aggregates[agg].get_aggregates(credential, net_urn)
if network_found:
ticket = aggregates[aggregate].get_ticket(credential, \
slice_hrn, rspecs[net_hrn], origin_hrn)
# create a new ticket
new_ticket = SfaTicket(subject = slice_hrn)
new_ticket.set_gid_caller(api.auth.client_gid)
+ new_ticket.set_issuer(key=api.key, subject=api.hrn)
tmp_rspec = RSpec()
networks = []
- valid_data = {}
+ valid_data = {
+ 'timestamp': int(time.time()),
+ 'initscripts': [],
+ 'slivers': []
+ }
# merge data from aggregate ticket into new ticket
for agg_ticket in tickets.values():
+ # get data from this ticket
agg_ticket = SfaTicket(string=agg_ticket)
+ attributes = agg_ticket.get_attributes()
+ if attributes.get('initscripts', []) != None:
+ valid_data['initscripts'].extend(attributes.get('initscripts', []))
+ if attributes.get('slivers', []) != None:
+ valid_data['slivers'].extend(attributes.get('slivers', []))
+
+ # set the object gid
object_gid = agg_ticket.get_gid_object()
new_ticket.set_gid_object(object_gid)
- new_ticket.set_issuer(key=api.key, subject=api.hrn)
new_ticket.set_pubkey(object_gid.get_pubkey())
-
- #new_ticket.set_attributes(data)
+
+ # build the rspec
tmp_rspec.parseString(agg_ticket.get_rspec())
networks.extend([{'NetSpec': tmp_rspec.getDictsByTagName('NetSpec')}])
#new_ticket.set_parent(api.auth.hierarchy.get_auth_ticket(auth_hrn))
+ new_ticket.set_attributes(valid_data)
resources = {'networks': networks, 'start_time': 0, 'duration': 0}
resourceDict = {'RSpec': resources}
tmp_rspec.parseDict(resourceDict)
new_ticket.set_rspec(tmp_rspec.toxml())
-
new_ticket.encode()
new_ticket.sign()
return new_ticket.save_to_string(save_parents=True)
from sfa.plc.nodes import Nodes
nodes = Nodes(api, origin_hrn=origin_hrn)
- if hrn:
+ if xrn:
rspec = nodes.get_rspec(xrn)
else:
nodes.refresh()
return the basic information needed in a dict.
"""
def fetch_context(slice_hrn, user_hrn, contexts):
- slice_hrn = urn_to_hrn(slice_xrn)[0]
- user_hrn = urn_to_hrn(user_xrn)[0]
+ #slice_hrn = urn_to_hrn(slice_xrn)[0]
+ #user_hrn = urn_to_hrn(user_xrn)[0]
base_context = {'sfa':{'user':{'hrn':user_hrn}}}
return base_context