Esempio n. 1
0
class Server(db.Model):
    __tablename__ = 'dns_servers'
    id = db.Column(db.Integer, primary_key=True)
    host = db.Column(db.String(64), index=True)
    ip = db.Column(db.String(64))
    env = db.Column(db.String(64))
    dns_type = db.Column(db.String(64))
    status = db.Column(db.String(64), default='初始化中')
    logs = db.Column(db.Text())
Esempio n. 2
0
class Zone(db.Model):
    __tablename__ = 'dns_zones'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), index=True)
    is_inner = db.Column(db.Integer)
    z_type = db.Column(db.String(64))
    views = db.Column(db.String(64))
    forwarders = db.Column(db.String(64))
    records = db.relationship('Record', backref='zone', lazy='dynamic')
    view_id = db.Column(db.Integer, db.ForeignKey('dns_views.id'))
Esempio n. 3
0
class Logs(db.Model):
    __tablename__ = 'logs'
    id = db.Column(db.Integer, primary_key=True)
    operation_time = db.Column(db.DateTime(), default=datetime.now)
    operation_type = db.Column(db.String(64))
    operator = db.Column(db.String(64))
    target_type = db.Column(db.String(64))
    target_name = db.Column(db.String(64))
    target_id = db.Column(db.String(64))
    target_detail = db.Column(db.Text())
Esempio n. 4
0
class User(UserMixin, db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(64), unique=True, index=True)
    username = db.Column(db.String(64), unique=True, index=True)
    password_hash = db.Column(db.String(128))
    chinese_name = db.Column(db.String(64))
    cellphone = db.Column(db.String(64))
    actived = db.Column(db.Boolean, default=False)
    position = db.Column(db.String(64))
    location = db.Column(db.String(64))
    acitve = db.Column(db.Integer)
    admin = db.Column(db.Integer, index=True, default=0)
    member_since = db.Column(db.DateTime(), default=datetime.now)
    last_seen = db.Column(db.DateTime(), default=datetime.now)

    @property
    def password(self):
        raise AttributeError('密码禁止读取!')

    @password.setter
    def password(self, password):
        self.password_hash = generate_password_hash(password)

    def verify_password(self, password):
        if self.password_hash is None:
            return False
        return check_password_hash(self.password_hash, password)
Esempio n. 5
0
class User(UserMixin, db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(64), unique=True, index=True)
    username = db.Column(db.String(64), unique=True, index=True)
    chinese_name = db.Column(db.String(64))
    cellphone = db.Column(db.String(64))
    actived = db.Column(db.Boolean, default=False)
    position = db.Column(db.String(64))
    location = db.Column(db.String(64))
    acitve = db.Column(db.Integer)
    admin = db.Column(db.Integer, index=True, default=0)
    member_since = db.Column(db.DateTime(), default=datetime.now)
    last_seen = db.Column(db.DateTime(), default=datetime.now)
Esempio n. 6
0
class Server(db.Model):
    __tablename__ = 'dns_servers'
    id = db.Column(db.Integer, primary_key=True)
    host = db.Column(db.String(64), index=True)
    ip = db.Column(db.String(64))
    env = db.Column(db.String(64))
    dns_type = db.Column(db.String(64))
    zabbix_itemid = db.Column(db.String(64))
    status = db.Column(db.String(64), default='初始化中')
    zb_status_itemid = db.Column(db.String(64))
    zb_dns_parsing_itemid = db.Column(db.String(64))
    logs = db.Column(db.Text())

    def to_json(self):
        json_server = {
            'id': self.id,
            'host': self.host,
            'ip': self.ip,
            'env': self.env,
            'dns_type': self.dns_type,
            'status': self.status,
            'logs': self.logs
        }
        return json_server
Esempio n. 7
0
class Record(db.Model):
    __tablename__ = 'dns_records'
    id = db.Column(db.Integer, primary_key=True)
    record_id = db.Column(db.String(64), index=True)
    host = db.Column(db.String(64))
    record_type = db.Column(db.String(64))
    TTL = db.Column(db.String(64))
    value = db.Column(db.String(64))
    line_type = db.Column(db.String(64), default='')
    comment = db.Column(db.String(64))
    creator = db.Column(db.String(64))
    updator = db.Column(db.String(64))
    status = db.Column(db.String(64), default='enabled')
    enabled = db.Column(db.String(64), default='1')
    alive = db.Column(db.String(64), default='ON')
    create_time = db.Column(db.DateTime(), default=datetime.now)
    update_time = db.Column(db.DateTime(), default=datetime.now)
    zone_id = db.Column(db.Integer, db.ForeignKey('dns_zones.id'))
Esempio n. 8
0
class View(db.Model):
    __tablename__ = 'dns_views'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), index=True)
    data = db.Column(db.Text())
    zones = db.relationship('Zone', backref='view', lazy='dynamic')