X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fplc%2Fslices.py;h=e6164442d7e6876b74863af807f34fae9f5ed59f;hb=10c8efa8217ba42dea14cd82441a7d733c0a86c9;hp=70ace8a66cf76e6ca987a0b83f1822911be8e8f1;hpb=0f7b97bc15361cf22b62187e82ee08e0447f584c;p=sfa.git diff --git a/sfa/plc/slices.py b/sfa/plc/slices.py index 70ace8a6..e6164442 100644 --- a/sfa/plc/slices.py +++ b/sfa/plc/slices.py @@ -25,7 +25,7 @@ class Slices(SimpleStorage): rspec_to_slice_tag = {'max_rate':'net_max_rate'} - def __init__(self, api, ttl = .5, caller_cred=None): + def __init__(self, api, ttl = .5, origin_hrn=None): self.api = api self.ttl = ttl self.threshold = None @@ -36,7 +36,7 @@ class Slices(SimpleStorage): SimpleStorage.__init__(self, self.slices_file) self.policy = Policy(self.api) self.load() - self.caller_cred=caller_cred + self.origin_hrn=origin_hrn def get_slivers(self, hrn, node=None): @@ -274,14 +274,14 @@ class Slices(SimpleStorage): def delete_slice_smgr(self, hrn): credential = self.api.getCredential() - caller_cred = self.caller_cred + origin_hrn = self.origin_hrn aggregates = Aggregates(self.api) for aggregate in aggregates: success = False # request hash is optional so lets try the call without it try: request_hash=None - aggregates[aggregate].delete_slice(credential, hrn, request_hash, caller_cred) + aggregates[aggregate].delete_slice(credential, hrn, request_hash, origin_hrn) success = True except: print >> log, "%s" % (traceback.format_exc()) @@ -292,7 +292,7 @@ class Slices(SimpleStorage): try: arg_list = [credential, hrn] request_hash = self.api.key.compute_hash(arg_list) - aggregates[aggregate].delete_slice(credential, hrn, request_hash, caller_cred) + aggregates[aggregate].delete_slice(credential, hrn, request_hash, origin_hrn) success = True except: print >> log, "%s" % (traceback.format_exc()) @@ -373,7 +373,7 @@ class Slices(SimpleStorage): slicename = hrn_to_pl_slicename(slice_hrn) parts = slicename.split("_") login_base = parts[0] - slices = self.api.plshell.GetSlices(self.api.plauth, [slicename], ['slice_id', 'node_ids', 'site_id']) + slices = self.api.plshell.GetSlices(self.api.plauth, [slicename]) if not slices: slice_fields = {} slice_keys = ['name', 'url', 'description'] @@ -404,6 +404,8 @@ class Slices(SimpleStorage): slice = slices[0] slice_id = slice['slice_id'] site_id = slice['site_id'] + #the slice is alredy on the remote agg. Let us update(e.g. expires field) it with the latest info. + self.sync_slice(slice, slice_record, peer) slice['peer_slice_id'] = slice_record['pointer'] self.verify_persons(registry, credential, slice_record, site_id, remote_site_id, peer, sfa_peer) @@ -601,7 +603,7 @@ class Slices(SimpleStorage): rspecs[net_hrn] = tempspec.toxml() # send each rspec to the appropriate aggregate/sm - caller_cred = self.caller_cred + origin_hrn = self.origin_hrn for net_hrn in rspecs: try: # if we are directly connected to the aggregate then we can just send them the rspec @@ -611,19 +613,19 @@ class Slices(SimpleStorage): if net_hrn in [self.api.hrn]: try: request_hash = None - aggregates[net_hrn].create_slice(credential, hrn, rspec, request_hash, caller_cred) + aggregates[net_hrn].create_slice(credential, hrn, rspec, request_hash, origin_hrn) except: arg_list = [credential,hrn,rspec] request_hash = self.api.key.compute_hash(arg_list) - aggregates[net_hrn].create_slice(credential, hrn, rspec, request_hash, caller_cred) + aggregates[net_hrn].create_slice(credential, hrn, rspec, request_hash, origin_hrn) else: try: request_hash = None - aggregates[net_hrn].create_slice(credential, hrn, rspecs[net_hrn], request_hash, caller_cred) + aggregates[net_hrn].create_slice(credential, hrn, rspecs[net_hrn], request_hash, origin_hrn) except: arg_list = [credential,hrn,rspecs[net_hrn]] request_hash = self.api.key.compute_hash(arg_list) - aggregates[net_hrn].create_slice(credential, hrn, rspecs[net_hrn], request_hash, caller_cred) + aggregates[net_hrn].create_slice(credential, hrn, rspecs[net_hrn], request_hash, origin_hrn) else: # lets forward this rspec to a sm that knows about the network arg_list = [credential, net_hrn] @@ -636,11 +638,11 @@ class Slices(SimpleStorage): if network_networks: try: request_hash = None - aggregates[aggregate].create_slice(credential, hrn, rspecs[net_hrn], request_hash, caller_cred) + aggregates[aggregate].create_slice(credential, hrn, rspecs[net_hrn], request_hash, origin_hrn) except: arg_list = [credential, hrn, rspecs[net_hrn]] request_hash = self.api.key.compute_hash(arg_list) - aggregates[aggregate].create_slice(credential, hrn, rspecs[net_hrn], request_hash, caller_cred) + aggregates[aggregate].create_slice(credential, hrn, rspecs[net_hrn], request_hash, origin_hrn) except: print >> log, "Error creating slice %(hrn)s at aggregate %(net_hrn)s" % locals() @@ -701,3 +703,11 @@ class Slices(SimpleStorage): except: aggregates[aggregate].stop_slice(credential, hrn, request_hash) + def sync_slice(self, old_record, new_record, peer): + if old_record['expires'] != new_record['expires']: + if peer: + self.api.plshell.UnBindObjectFromPeer(self.api.plauth, 'slice', old_record['slice_id'], peer) + self.api.plshell.UpdateSlice(self.api.plauth, old_record['slice_id'], {'expires' : new_record['expires']}) + if peer: + self.api.plshell.BindObjectToPeer(self.api.plauth, 'slice', old_record['slice_id'], peer, old_record['peer_slice_id']) + return 1