X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fopenstack%2Fosxrn.py;h=e7d1d21d171459f822e72e307fec2a93d59cbe0b;hb=e81581343ef38c8b1644becb432c3f38eef56357;hp=ad82f22cfeec59c6c3290843f843b7b1d0fa97a6;hpb=45e7d08515e7713e8d057e3f958dd837f5a2a322;p=sfa.git diff --git a/sfa/openstack/osxrn.py b/sfa/openstack/osxrn.py index ad82f22c..e7d1d21d 100644 --- a/sfa/openstack/osxrn.py +++ b/sfa/openstack/osxrn.py @@ -3,16 +3,27 @@ from sfa.util.xrn import Xrn from sfa.util.config import Config def hrn_to_os_slicename(hrn): - return OSXrn(xrn=hrn, type='slice').get_slicename() + return OSXrn(xrn=hrn, type='slice').get_slicename() + + +def hrn_to_os_tenant_name(hrn): + return OSXrn(xrn=hrn, type='slice').get_tenant_name() + +def cleanup_name(name): + return name.replace(".", "_").replace("+", "_") class OSXrn(Xrn): - def __init__(self, name=None, type=None, **kwds): + def __init__(self, name=None, auth=None, **kwds): config = Config() if name is not None: - self.type = type - self.hrn = config.SFA_INTERFACE_HRN + "." + name + if 'type' in kwds: + self.type = kwds['type'] + if auth is not None: + self.hrn='.'.join([auth, cleanup_name(name)]) + else: + self.hrn = config.SFA_INTERFACE_HRN + "." + cleanup_name(name) self.hrn_to_urn() else: Xrn.__init__(self, **kwds) @@ -34,5 +45,11 @@ class OSXrn(Xrn): slicename = slicename.split(':')[0] slicename = re.sub('[\.]', '_', slicename) return slicename + + def get_tenant_name(self): + self._normalize() + tenant_name = self.hrn.replace('\.', '') + return tenant_name +