X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fplanetlab%2Fplxrn.py;h=a8461b53cf5fbfa8225c8f52104702691461ac76;hb=f41d4566c5db5ac9b36a5a86ded828197fe3b1fd;hp=22e94181695c32f031da6162aed33a8dc3a32985;hpb=bc77b3e1ce73d7f748d9cc978472dba246034d74;p=sfa.git diff --git a/sfa/planetlab/plxrn.py b/sfa/planetlab/plxrn.py index 22e94181..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