return self.driver.status (urns, options=options)
- def Allocate(self, api, xrn, creds, rspec_string, options):
+ def Allocate(self, api, xrn, creds, rspec_string, expiration, options):
"""
Allocate resources as described in a request RSpec argument
to a slice with the named URN.
"""
call_id = options.get('call_id')
if Callids().already_handled(call_id): return ""
- return self.driver.allocate(xrn, rspec_string, options)
+ return self.driver.allocate(xrn, rspec_string, expiration, options)
def Provision(self, api, xrns, creds, options):
"""
from sfa.util.faults import SfaInvalidArgument, InvalidRSpec, SfatablesRejected
+from sfa.util.sfatime import datetime_to_string
from sfa.util.xrn import Xrn
from sfa.util.method import Method
from sfa.util.sfatablesRuntime import run_sfatables
# Find the valid credentials
valid_creds = self.api.auth.checkCredentials(creds, 'createsliver', xrn.get_hrn())
+ # use the expiration from the first valid credential to determine when
+ # the slivers should expire.
+ expiration = datetime_to_string(Credential(cred=valid_creds[0]).expiration)
# make sure request is not empty
slivers = RSpec(rspec).version.get_nodes_with_slivers()
if not slivers:
raise SfatablesRejected(slice_xrn)
- result = self.api.manager.Allocate(self.api, xrn.get_urn(), creds, rspec, options)
+ result = self.api.manager.Allocate(self.api, xrn.get_urn(), creds, rspec, expiration, options)
return result
'geni_slivers': desc['geni_slivers']}
return status
- def allocate (self, urn, rspec_string, options={}):
+ def allocate (self, urn, rspec_string, expiration, options={}):
xrn = Xrn(urn)
aggregate = OSAggregate(self)
'geni_slivers': desc['geni_slivers']}
return status
- def allocate (self, urn, rspec_string, options={}):
+ def allocate (self, urn, rspec_string, expiration, options={}):
xrn = Xrn(urn)
aggregate = PlAggregate(self)
slices = PlSlices(self)
# ensure site record exists
site = slices.verify_site(xrn.hrn, slice_record, peer, sfa_peer, options=options)
# ensure slice record exists
- slice = slices.verify_slice(xrn.hrn, slice_record, peer, sfa_peer, options=options)
+ slice = slices.verify_slice(xrn.hrn, slice_record, peer, sfa_peer, expiration=expiration, options=options)
# ensure person records exists
persons = slices.verify_persons(xrn.hrn, slice, users, peer, sfa_peer, options=options)
# ensure slice attributes exists
return site
- def verify_slice(self, slice_hrn, slice_record, peer, sfa_peer, options={}):
+ def verify_slice(self, slice_hrn, slice_record, peer, sfa_peer, expiration, options={}):
slicename = hrn_to_pl_slicename(slice_hrn)
parts = slicename.split("_")
login_base = parts[0]
slices = self.driver.shell.GetSlices([slicename])
+ expires = int(datetime_to_epoch(utcparse(expiration)))
if not slices:
slice = {'name': slicename,
'url': 'No Url',
slice['node_ids'] = []
slice['person_ids'] = []
if peer and slice_record:
- slice['peer_slice_id'] = slice_record.get('slice_id', None)
+ slice['peer_slice_id'] = slice_record.get('slice_id', None)
+ # set the expiration
+ self.driver.shell.UpdateSlice(slice['slice_id'], {'expires': expires})
else:
slice = slices[0]
if peer and slice_record:
slice['peer_slice_id'] = slice_record.get('slice_id', None)
# unbind from peer so we can modify if necessary. Will bind back later
self.driver.shell.UnBindObjectFromPeer('slice', slice['slice_id'], peer['shortname'])
- #Update existing record (e.g. expires field) it with the latest info.
- if slice_record and slice_record.get('expires'):
- requested_expires = int(datetime_to_epoch(utcparse(slice_record['expires'])))
- if requested_expires and slice['expires'] != requested_expires:
- self.driver.shell.UpdateSlice( slice['slice_id'], {'expires' : requested_expires})
+
+ #Update expiration if necessary
+ if slice['expires'] != expires:
+ self.driver.shell.UpdateSlice( slice['slice_id'], {'expires' : expires})
return slice