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)
1  2 
sfa/managers/aggregate_manager_pl.py
sfa/plc/slices.py
sfa/util/namespace.py

@@@ -15,7 -15,6 +15,6 @@@ from sfa.util.record import SfaRecor
  from sfa.util.policy import Policy
  from sfa.util.record import *
  from sfa.util.sfaticket import SfaTicket
- from sfa.util.debug import log
  from sfa.plc.slices import Slices
  from sfa.trust.credential import Credential
  import sfa.plc.peers as peers
@@@ -38,10 -37,9 +37,10 @@@ def __get_registry_objects(slice_xrn, c
  
      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 = {}
@@@ -61,7 -59,7 +60,7 @@@
          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
diff --combined sfa/plc/slices.py
@@@ -14,7 -14,6 +14,6 @@@ from sfa.util.faults import 
  from sfa.util.record import SfaRecord
  from sfa.util.policy import Policy
  from sfa.util.prefixTree import prefixTree
- from sfa.util.debug import log
  
  MAXINT =  2L**31-1
  
@@@ -171,10 -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 = {}            
                  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:
              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
diff --combined sfa/util/namespace.py
@@@ -19,9 -19,9 +19,9 @@@ def get_authority(xrn)
  def hrn_to_pl_slicename(hrn):
      # remove any escaped no alpah numeric characters
      #hrn = re.sub('\\\[^a-zA-Z0-9]', '', hrn)
-     # remove any escaped '.' (i.e. '\.')      
-     hrn = hrn.replace('\\.', '')    
-     parts = hrn.split(".")  
+     # remove any escaped '.' (i.e. '\.')
+     hrn = hrn.replace('\\.', '')
+     parts = hrn.split(".")
      return parts[-2] + "_" + parts[-1]
  
  # assuming hrn is the hrn of an authority, return the plc authority name
@@@ -85,7 -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)