class User(db.Model): __tablename__ = 'User' id = db.Column(db.Integer, primary_key=True, autoincrement=True) username = db.Column(db.String(100), unique=True, nullable=False) token = db.Column(db.String(1000)) email = db.Column(db.String(100), unique=True) name = db.Column(db.String(100)) vm = db.relationship('Vm', backref='user', lazy='dynamic') def __repr__(self): return '<user {}>'.format(self.username)
class Node_request(db.Model): __tablename__ = 'Node_request' id = db.Column(db.Integer, primary_key=True, autoincrement=True) node_name = db.Column(db.String(100), unique=True, nullable=False) node_counts = db.Column(db.Integer, nullable=False) hours = db.Column(db.Integer, nullable=False) pubkey = db.Column(db.VARCHAR(1024), nullable=False) vms = db.relationship('Vm', backref='details', lazy='dynamic') def as_dict(self): return{ "node_name" : self.node_name, "node_counts" : self.nodes, "hours" : self.hours }
class User(db.Model): ''' User model ''' __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True, autoincrement=True) username = db.Column(db.String(100), unique=True, nullable=False) token = db.Column(db.String(1000)) email = db.Column(db.String(100), unique=True) name = db.Column(db.String(100)) pubkey = db.Column(db.String(4096), nullable=True) admin = db.Column(db.Boolean, default=False, nullable=False) node_request = db.relationship('NodeRequest', backref='user', lazy='dynamic') def __repr__(self): return '<user {}>'.format(self.username)
class NodeRequest(db.Model): ''' Requesting node model ''' __tablename__ = 'node_request' id = db.Column(db.Integer, primary_key=True, autoincrement=True) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) node_name = db.Column(db.String(100), nullable=False) node_counts = db.Column(db.Integer, nullable=False) hours = db.Column(db.Integer, nullable=False) vms = db.relationship('Vm', backref='details', lazy='dynamic') def as_dict(self): return { "node_name": self.node_name, "node_counts": self.node_counts, "hours": self.hours }