fix aggregate status
[sfa.git] / sfa / openstack / osxrn.py
index 830ee9a..e7d1d21 100644 (file)
@@ -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
+