1 from sfa.util.faults import *
2 from sfa.util.namespace import *
3 from sfa.util.method import Method
4 from sfa.util.parameter import Parameter
5 from sfa.trust.credential import Credential
6 from dateutil.parser import parse
8 class RenewSliver(Method):
10 Renews the resources in a sliver, extending the lifetime of the slice.
11 @param slice_urn (string) URN of slice to renew
12 @param credentials ([string]) of credentials
13 @param expiration_time (string) requested time of expiration
16 interfaces = ['aggregate', 'slicemgr']
18 Parameter(str, "Slice URN"),
19 Parameter(type([str]), "List of credentials"),
20 Parameter(str, "Expiration time in RFC 3339 format")
22 returns = Parameter(bool, "Success or Failure")
24 def call(self, slice_xrn, creds, expiration_time):
25 hrn, type = urn_to_hrn(slice_xrn)
27 self.api.logger.info("interface: %s\ttarget-hrn: %s\tcaller-creds: %s\tmethod-name: %s"%(self.api.interface, hrn, creds, self.name))
29 # Find the valid credentials
30 valid_creds = self.api.auth.checkCredentials(creds, 'renewsliver', hrn)
32 # Validate that the time does not go beyond the credential's expiration time
33 requested_time = parse(expiration_time)
34 if requested_time > Credential(string=valid_creds[0]).get_expiration():
35 raise InsufficientRights('SliverStatus: Credential expires before requested expiration time')
37 manager = self.api.get_interface_manager()
38 manager.renew_slice(self.api, slice_xrn, valid_creds, requested_time)