def validate_datetime (self, key, incoming):
if isinstance (incoming, datetime): return incoming
elif isinstance (incoming, (int,float)):return datetime.fromtimestamp (incoming)
+ else: logger.info("Cannot validate datetime for key %s with input %s"%\
+ (key,incoming))
@validates ('date_created')
def validate_date_created (self, key, incoming): return self.validate_datetime (key, incoming)
auth_record = dbsession.query(RegAuthority).filter_by(hrn=authority_hrn).first()
return auth_record.reg_pis
+ @validates ('expires')
+ def validate_expires (self, key, incoming): return self.validate_datetime (key, incoming)
####################
class RegNode (RegRecord):
result += ">"
return result
+class SliverAllocation(Base,AlchemyObj):
+ __tablename__ = 'sliver_allocation'
+ sliver_id = Column(String, primary_key=True)
+ allocation_state = Column(String)
+
+ def __init__(self, sliver_id, allocation_state):
+ self.sliver_id = sliver_id
+ self.allocation_state = allocation_state
+
+ def __repr__(self):
+ result = "<sliver_allocation sliver_id=%s allocation_state=%s" % \
+ (self.sliver_id, self.allocation_state)
+ return result
+
+ @validates('allocation_state')
+ def validate_allocation_state(self, key, state):
+ allocation_states = ['geni_unallocated', 'geni_allocated', 'geni_provisioned']
+ assert state in allocation_states
+ return state
+
##############################
# although the db needs of course to be reachable for the following functions
# the schema management functions are here and not in alchemy