X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fopenstack%2Fosxrn.py;h=e7d1d21d171459f822e72e307fec2a93d59cbe0b;hb=e81581343ef38c8b1644becb432c3f38eef56357;hp=830ee9acd49d396c5bf9b4e8d07c822923ea0ee7;hpb=1d0ab72103c2198f46640464da4338a7dd6f6475;p=sfa.git diff --git a/sfa/openstack/osxrn.py b/sfa/openstack/osxrn.py index 830ee9ac..e7d1d21d 100644 --- a/sfa/openstack/osxrn.py +++ b/sfa/openstack/osxrn.py @@ -5,16 +5,21 @@ from sfa.util.config import Config def hrn_to_os_slicename(hrn): 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, auth=None, **kwds): + def __init__(self, name=None, auth=None, **kwds): config = Config() if name is not None: - self.type = type + if 'type' in kwds: + self.type = kwds['type'] if auth is not None: self.hrn='.'.join([auth, cleanup_name(name)]) else: @@ -40,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 +