<s> import datetime <EOL> from openflow . optin_manager . sfa . util . faults import InsufficientRights <EOL> from openflow . optin_manager . sfa . util . xrn import urn_to_hrn <EOL> from openflow . optin_manager . sfa . util . method import Method <EOL> from openflow . optin_manager . sfa . util . openflow . optin_manager . sfa . ime import utcparse <EOL> from openflow . optin_manager . sfa . trust . credential import Credential <EOL> from openflow . optin_manager . sfa . util . parameter import Parameter <EOL> class RenewSliver ( Method ) : <EOL> """<STR_LIT>""" <EOL> interfaces = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> accepts = [ <EOL> Parameter ( str , "<STR_LIT>" ) , <EOL> Parameter ( type ( [ str ] ) , "<STR_LIT>" ) , <EOL> Parameter ( str , "<STR_LIT>" ) , <EOL> Parameter ( dict , "<STR_LIT>" ) , <EOL> ] <EOL> returns = Parameter ( bool , "<STR_LIT>" ) <EOL> def call ( self , slice_xrn , creds , expiration_time , options ) : <EOL> ( hrn , type ) = urn_to_hrn ( slice_xrn ) <EOL> self . api . logger . info ( "<STR_LIT>" % ( self . api . interface , hrn , creds , self . name ) ) <EOL> valid_creds = self . api . auth . checkCredentials ( creds , '<STR_LIT>' , hrn ) <EOL> requested_time = utcparse ( expiration_time ) <EOL> max_renew_days = int ( self . api . config . SFA_MAX_SLICE_RENEW ) <EOL> if requested_time > Credential ( string = valid_creds [ <NUM_LIT:0> ] ) . get_expiration ( ) : <EOL> raise InsufficientRights ( '<STR_LIT>' ) <EOL> if requested_time > datetime . datetime . utcnow ( ) + datetime . timedelta ( days = max_renew_days ) : <EOL> raise Exception ( '<STR_LIT>' % max_renew_days ) <EOL> return self . api . manager . RenewSliver ( self . api , slice_xrn , valid_creds , expiration_time , options ) </s>
