<s> from datetime import datetime <EOL> from openflow . optin_manager . sfa . util . sfatime import utcparse , datetime_to_epoch <EOL> from openflow . optin_manager . sfa . models import ExpiringComponents <EOL> class ExpirationManager : <EOL> @ staticmethod <EOL> def extend_expiration ( slice_name , authority , time_extension ) : <EOL> time_extended = time_extension <EOL> try : <EOL> exp_sl = ExpiringComponents . objects . get ( slice = slice , authority = authority ) <EOL> except : <EOL> raise Exception ( "<STR_LIT>" % slice_name ) <EOL> exp_sl . extend_expiration ( time_extension ) <EOL> @ staticmethod <EOL> def find_expired_slices ( ) : <EOL> try : <EOL> from openflow . optin_manager . sfa . drivers . OFSfaDriver import OFSfaDriver <EOL> except : <EOL> pass <EOL> slices = ExpiringComponets . objects . all ( ) <EOL> expired_components = list ( ) <EOL> for slice in slices : <EOL> expiration_date = int ( datetime_to_epoch ( utcparse ( slice . expires ) ) ) <EOL> if expiration_date <= int ( datetime_to_epoch ( utcparse ( datetime . utcnow ( ) ) ) ) : <EOL> try : <EOL> OFSfaDriver ( ) . crud_slice ( slice . slice , slice . authority , '<STR_LIT>' ) <EOL> except : <EOL> pass </s>
