- def delete(self, slice_urns, options={}):
+ def delete(self, slice_urns, options=None):
"""
Deletes the lease associated with the slice hrn and the credentials
if the slice belongs to iotlab. Answer to DeleteSliver.
.. note:: creds are unused, and are not used either in the dummy driver
delete_sliver .
"""
+ if options is None: options={}
# collect sliver ids so we can update sliver allocation states after
# we remove the slivers.
aggregate = IotlabAggregate(self)
'geni_ad_rspec_versions': ad_rspec_versions}
# first 2 args are None in case of resource discovery
- def list_resources (self, version=None, options={}):
+ def list_resources (self, version=None, options=None):
+ if options is None: options={}
aggregate = IotlabAggregate(self)
rspec = aggregate.list_resources(version=version, options=options)
return rspec
- def describe(self, urns, version, options={}):
+ def describe(self, urns, version, options=None):
+ if options is None: options={}
aggregate = IotlabAggregate(self)
return aggregate.describe(urns, version=version, options=options)
- def status (self, urns, options={}):
+ def status (self, urns, options=None):
+ if options is None: options={}
aggregate = IotlabAggregate(self)
desc = aggregate.describe(urns, version='GENI 3')
status = {'geni_urn': desc['geni_urn'],
return status
- def allocate (self, urn, rspec_string, expiration, options={}):
+ def allocate (self, urn, rspec_string, expiration, options=None):
+ if options is None: options={}
xrn = Xrn(urn)
aggregate = IotlabAggregate(self)
peer = slices.get_peer(xrn.get_hrn())
sfa_peer = slices.get_sfa_peer(xrn.get_hrn())
+ caller_hrn = options.get('actual_caller_hrn', [])
+ caller_xrn = Xrn(caller_hrn)
+ caller_urn = caller_xrn.get_urn()
+
+ logger.debug("IOTLABDRIVER.PY :: Allocate caller = %s" % (caller_urn))
slice_record = {}
users = options.get('geni_users', [])
-
sfa_users = options.get('sfa_users', [])
+
if sfa_users:
- # XXX Always empty ??? no slice_record in the Allocate call
- #slice_record = sfa_users[0].get('slice_record', [])
- user_xrn = Xrn(sfa_users[0]['urn'])
- user_hrn = user_xrn.get_hrn()
-
- slice_record = sfa_users[0].get('slice_record', {})
- slice_record['user'] = {'keys': users[0]['keys'],
- 'email': users[0]['email'],
+ user = None
+ # Looking for the user who actually called the Allocate function in the list of users of the slice
+ for u in sfa_users:
+ if 'urn' in u and u['urn'] == caller_urn:
+ user = u
+ logger.debug("user = %s" % u)
+ # If we find the user in the list we use it, else we take the 1st in the list as before
+ if user:
+ user_hrn = caller_hrn
+ else:
+ user = sfa_users[0]
+ # XXX Always empty ??? no slice_record in the Allocate call
+ #slice_record = sfa_users[0].get('slice_record', [])
+ user_xrn = Xrn(sfa_users[0]['urn'])
+ user_hrn = user_xrn.get_hrn()
+
+ slice_record = user.get('slice_record', {})
+ slice_record['user'] = {'keys': user['keys'],
+ 'email': user['email'],
'hrn': user_hrn}
slice_record['authority'] = xrn.get_authority_hrn()
return aggregate.describe([xrn.get_urn()], version=rspec.version)
- def provision(self, urns, options={}):
+ def provision(self, urns, options=None):
+ if options is None: options={}
# update users
slices = IotlabSlices(self)
aggregate = IotlabAggregate(self)