from types import StringTypes
from collections import defaultdict
-
+import sys
from sfa.util.xrn import get_leaf, get_authority, urn_to_hrn
from sfa.util.plxrn import hrn_to_pl_slicename
from sfa.util.policy import Policy
# slice belongs to out local plc or a myplc peer. We will assume it
# is a local site, unless we find out otherwise
peer = None
-
+ print>>sys.stderr, " \r\n \r\n \t slices.py get_peer slice_authority "
# get this slice's authority (site)
slice_authority = get_authority(hrn)
# get this site's authority (sfa root authority or sub authority)
site_authority = get_authority(slice_authority).lower()
-
+ print>>sys.stderr, " \r\n \r\n \t slices.py get_peer slice_authority %s site_authority %s" %(slice_authority,site_authority)
# check if we are already peered with this site_authority, if so
- peers = self.api.driver.GetPeers({}, ['peer_id', 'peername', 'shortname', 'hrn_root'])
- for peer_record in peers:
- names = [name.lower() for name in peer_record.values() if isinstance(name, StringTypes)]
- if site_authority in names:
- peer = peer_record
+ #peers = self.api.driver.GetPeers({}, ['peer_id', 'peername', 'shortname', 'hrn_root'])
+ #for peer_record in peers:
+ #names = [name.lower() for name in peer_record.values() if isinstance(name, StringTypes)]
+ #if site_authority in names:
+ #peer = peer_record
return peer
return site
def verify_slice(self, slice_hrn, slice_record, peer, sfa_peer):
- slicename = hrn_to_pl_slicename(slice_hrn)
- parts = slicename.split("_")
+ #slicename = hrn_to_pl_slicename(slice_hrn)
+ parts = hrn_to_pl_slicename(slice_hrn).split("_")
login_base = parts[0]
+ slicename = slice_hrn
slices = self.api.driver.GetSlices([slicename])
+ print>>sys.stderr, " \r\n \r\rn Slices.py verify_slice slicename %s slices %s slice_record %s"%(slicename ,slices, slice_record)
if not slices:
slice = {'name': slicename,
'url': slice_record.get('url', slice_hrn),
# unbind from peer so we can modify if necessary. Will bind back later
self.api.driver.UnBindObjectFromPeer('slice', slice['slice_id'], peer['shortname'])
#Update existing record (e.g. expires field) it with the latest info.
- if slice_record and slice['expires'] != slice_record['expires']:
- self.api.driver.UpdateSlice( slice['slice_id'], {'expires' : slice_record['expires']})
+ #if slice_record and slice['expires'] != slice_record['expires']:
+ #self.api.driver.UpdateSlice( slice['slice_id'], {'expires' : slice_record['expires']})
return slice