X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fplanetlab%2Fpldriver.py;h=2afcf8cfbf6c912e0c812f39f25e75a50006d483;hb=33c77f0907d42cfb0d0b5a046489b77aa8bfcae1;hp=0fb4fc37e07a82122eea7695e2c364d89de4a3e2;hpb=8a8c1cf266637f8477e480debe46cb4d866c4f9e;p=sfa.git diff --git a/sfa/planetlab/pldriver.py b/sfa/planetlab/pldriver.py index 0fb4fc37..2afcf8cf 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.planetlab.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: @@ -570,6 +577,10 @@ class PlDriver (Driver): 'testbed':self.testbed_name(), 'geni_request_rspec_versions': request_rspec_versions, 'geni_ad_rspec_versions': ad_rspec_versions, + 'geni_single_allocation': False, # Accept operations that act on as subse +t of slivers in a given state + 'geni_allocate': 'geni_many', # Multiple slivers can exist and be incrementally added, including those which connect or overlap in some way. + 'geni_best_effort': 'true', } def list_slices (self, creds, options): @@ -604,6 +615,14 @@ 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') + + # Adding geni_available to caching key + if options.get('geni_available'): + version_string = version_string + "_" + str(options.get('geni_available')) # look in cache first if cached_requested and self.cache and not slice_hrn: @@ -647,7 +666,7 @@ class PlDriver (Driver): persons = self.shell.GetPersons(slice['person_ids'], ['key_ids']) key_ids = [key_id for person in persons for key_id in person['key_ids']] person_keys = self.shell.GetKeys(key_ids) - keys = [key['key'] for key in keys] + keys = [key['key'] for key in person_keys] user.update({'urn': slice_urn, 'login': slice['name'], @@ -721,15 +740,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['start_time'] = lease.get('start_time') + requested_lease['duration'] = lease.get('duration') + 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.