X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fplanetlab%2Fplxrn.py;h=a8461b53cf5fbfa8225c8f52104702691461ac76;hb=f41d4566c5db5ac9b36a5a86ded828197fe3b1fd;hp=6d57dccb129e72ae05fe6b2ff9fcca8b8e5f8888;hpb=2ac2da4b770f57bede8e9a9ee65142242fdf05a3;p=sfa.git diff --git a/sfa/planetlab/plxrn.py b/sfa/planetlab/plxrn.py index 6d57dccb..a8461b53 100644 --- a/sfa/planetlab/plxrn.py +++ b/sfa/planetlab/plxrn.py @@ -1,6 +1,6 @@ # specialized Xrn class for PlanetLab import re -from sfa.util.xrn import Xrn +from sfa.util.xrn import Xrn, get_authority # temporary helper functions to use this module instead of namespace def hostname_to_hrn (auth, login_base, hostname): @@ -21,6 +21,22 @@ def hrn_to_pl_authname (hrn): def xrn_to_hostname(hrn): return Xrn.unescape(PlXrn(xrn=hrn, type='node').get_leaf()) +# helpers to handle external objects created via fedaration +def xrn_to_ext_slicename (xrn): + slice_hrn=PlXrn(xrn=xrn,type='slice').get_hrn() + site_hrn = get_authority(slice_hrn) + login_base = '8'.join(site_hrn.split('.')) + slice_name = '_'.join([login_base, slice_hrn.split('.')[-1]]) + return slice_name + +def hrn_to_ext_loginbase (hrn): + site_hrn = get_authority(hrn) + login_base = '8'.join(site_hrn.split('.'))[:20] + return login_base + +def top_auth (hrn): + return hrn.split('.')[0] + class PlXrn (Xrn): @staticmethod @@ -76,7 +92,10 @@ class PlXrn (Xrn): def pl_login_base (self): self._normalize() - base = self.authority[-1] + if self.type and self.type.startswith('authority'): + base = self.leaf + else: + base = self.authority[-1] # Fix up names of GENI Federates base = base.lower()