X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fplanetlab%2Fpldriver.py;h=7835a1dd6e53ab9e9d28d454a24dbcf07027c56e;hb=1db1a879ffde8991aa95dd80142d555551655e88;hp=b73fcf7dcf531860de8874ef3dfc03bdd11907be;hpb=0f90da7f05fbe3d07e56790c10f6ecc877b33754;p=sfa.git diff --git a/sfa/planetlab/pldriver.py b/sfa/planetlab/pldriver.py index b73fcf7d..7835a1dd 100644 --- a/sfa/planetlab/pldriver.py +++ b/sfa/planetlab/pldriver.py @@ -27,7 +27,7 @@ from sfa.planetlab.plshell import PlShell import sfa.planetlab.peers as peers from sfa.planetlab.plaggregate import PlAggregate from sfa.planetlab.plslices import PlSlices -from sfa.util.plxrn import PlXrn, slicename_to_hrn, hostname_to_hrn, hrn_to_pl_slicename +from sfa.planetlab.plxrn import PlXrn, slicename_to_hrn, hostname_to_hrn, hrn_to_pl_slicename, xrn_to_hostname def list_to_dict(recs, key): @@ -71,6 +71,9 @@ class PlDriver (Driver): if type == 'authority': sites = self.shell.GetSites([pl_record['login_base']]) if not sites: + # xxx when a site gets registered through SFA we need to set its max_slices + if 'max_slices' not in pl_record: + pl_record['max_slices']=2 pointer = self.shell.AddSite(pl_record) else: pointer = sites[0]['site_id'] @@ -157,6 +160,10 @@ class PlDriver (Driver): 'password', 'phone', 'url', 'bio', 'accepted_aup', 'enabled']: update_fields[key] = all_fields[key] + # when updating a user, we always get a 'email' field at this point + # this is because 'email' is a native field in the RegUser object... + if 'email' in update_fields and not update_fields['email']: + del update_fields['email'] self.shell.UpdatePerson(pointer, update_fields) if new_key: @@ -604,6 +611,10 @@ class PlDriver (Driver): #panos adding the info option to the caching key (can be improved) if options.get('info'): version_string = version_string + "_"+options.get('info', 'default') + + # Adding the list_leases option to the caching key + if options.get('list_leases'): + version_string = version_string + "_"+options.get('list_leases', 'default') # look in cache first if cached_requested and self.cache and not slice_hrn: @@ -721,15 +732,31 @@ class PlDriver (Driver): for node in rspec.version.get_nodes_with_slivers(): hostname = None if node.get('component_name'): - hostname = node.get('component_name') + hostname = node.get('component_name').strip() elif node.get('component_id'): - hostname = xrn_to_hostname(node.get('component_id')) + hostname = xrn_to_hostname(node.get('component_id').strip()) if hostname: requested_slivers.append(hostname) nodes = slices.verify_slice_nodes(slice, requested_slivers, peer) # add/remove links links slices.verify_slice_links(slice, rspec.version.get_link_requests(), nodes) + + # add/remove leases + requested_leases = [] + kept_leases = [] + for lease in rspec.version.get_leases(): + requested_lease = {} + if not lease.get('lease_id'): + requested_lease['hostname'] = xrn_to_hostname(lease.get('component_id').strip()) + requested_lease['t_from'] = lease.get('t_from') + requested_lease['t_until'] = lease.get('t_until') + else: + kept_leases.append(int(lease['lease_id'])) + if requested_lease.get('hostname'): + requested_leases.append(requested_lease) + + leases = slices.verify_slice_leases(slice, requested_leases, kept_leases, peer) # handle MyPLC peer association. # only used by plc and ple.