merged namespace
authorJosh Karlin <jkarlin@bbn.com>
Wed, 6 Oct 2010 17:47:49 +0000 (13:47 -0400)
committerJosh Karlin <jkarlin@bbn.com>
Wed, 6 Oct 2010 17:47:49 +0000 (13:47 -0400)
sfa/managers/aggregate_manager_pl.py
sfa/plc/slices.py
sfa/util/namespace.py

index c0e9d9e..ae4215a 100644 (file)
@@ -37,9 +37,10 @@ def __get_registry_objects(slice_xrn, creds, users):
 
     if users:
         # dont allow special characters in the site login base
-        only_alphanumeric = re.compile('[^a-zA-Z0-9]+')
-        login_base = only_alphanumeric.sub('', hrn_auth[:20]).lower()
-  
+        #only_alphanumeric = re.compile('[^a-zA-Z0-9]+')
+        #login_base = only_alphanumeric.sub('', hrn_auth[:20]).lower()
+        slicename = hrn_to_pl_slicename(hrn)
+        login_base = slicename.split('_')[0]
         reg_objects = {}
 
         site = {}
@@ -59,7 +60,7 @@ def __get_registry_objects(slice_xrn, creds, users):
         slice = {}
         slice['expires'] = int(time.mktime(Credential(string=creds[0]).get_lifetime().timetuple()))
         slice['hrn'] = hrn
-        slice['name'] = site['login_base'] + "_" +  get_leaf(hrn)
+        slice['name'] = hrn_to_pl_slicename(hrn)
         slice['url'] = hrn
         slice['description'] = hrn
         slice['pointer'] = 0
index 173de19..a3c7c1a 100644 (file)
@@ -170,9 +170,10 @@ class Slices:
     def verify_site(self, registry, credential, slice_hrn, peer, sfa_peer, reg_objects=None):
         authority = get_authority(slice_hrn)
         authority_urn = hrn_to_urn(authority, 'authority')
-        
+        login_base = None
         if reg_objects:
             site = reg_objects['site']
+            login_base = site['login_base']
         else:
             site_records = registry.Resolve(authority_urn, [credential])
             site = {}            
@@ -183,8 +184,9 @@ class Slices:
                 raise RecordNotFound(authority)
             
         remote_site_id = site.pop('site_id')    
-                
-        login_base = get_leaf(authority)
+        
+        if login_base is None:
+            login_base = get_leaf(authority)
         sites = self.api.plshell.GetSites(self.api.plauth, login_base)
 
         if not sites:
@@ -237,8 +239,7 @@ class Slices:
             for key in slice_keys:
                 if key in slice_record and slice_record[key]:
                     slice_fields[key] = slice_record[key]
-
-            # add the slice  
+            # add the slice                          
             slice_id = self.api.plshell.AddSlice(self.api.plauth, slice_fields)
             slice = slice_fields
             slice['slice_id'] = slice_id
index b920f00..93186c9 100644 (file)
@@ -85,7 +85,7 @@ def urn_to_hrn(urn):
     # 2. escape '.'            # '.' exists in protogeni object names and are not delimiters
     # 3. replace ':' with '.'  # ':' is the urn hierarchy delimiter
     # 4. join list elements using '.' 
-    hrn = '.'.join([part.replace('.', '\.').replace(':', '.') for part in hrn_parts if part]) 
+    hrn = '.'.join([part.replace('.', '\\.').replace(':', '.') for part in hrn_parts if part]) 
     
     return str(hrn), str(type)