From: Josh Karlin Date: Wed, 6 Oct 2010 17:47:49 +0000 (-0400) Subject: merged namespace X-Git-Tag: sfa-1.0-2~7^2 X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=commitdiff_plain;h=eababa96fb603cdd552bc03091813544b099befd;hp=-c merged namespace --- eababa96fb603cdd552bc03091813544b099befd diff --combined sfa/managers/aggregate_manager_pl.py index ff11270a,c0e9d9eb..ae4215a8 --- a/sfa/managers/aggregate_manager_pl.py +++ b/sfa/managers/aggregate_manager_pl.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 index 041a5625,173de194..a3c7c1a0 --- a/sfa/plc/slices.py +++ b/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 = {} @@@ -185,9 -183,8 +184,9 @@@ 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: @@@ -240,7 -237,8 +239,7 @@@ 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 index 89a9903d,b920f00d..93186c96 --- a/sfa/util/namespace.py +++ b/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)