Ejemplo n.º 1
0
class PipelineType(PipelineTypeJsonSerializer, db.Model):
    __tablename__ = 'pipeline_types'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(256))
    pipelines = db.relationship("Pipeline", back_populates="pipeline_type")
    tasks = db.relationship("PipelineCatalog", back_populates="pipeline_type")

    def __repr__(self):
        return '<PipelineType id=%s>' % self.id
Ejemplo n.º 2
0
class PipelineCatalog(db.Model):
    __tablename__ = 'pipeline_catalog2'
    pipeline_type_id = db.Column(db.Integer, db.ForeignKey('pipeline_types.id'), primary_key=True)
    current_task_type_id = db.Column(db.Integer, db.ForeignKey('task_types.id'), primary_key=True)
    next_task_type_id = db.Column(db.Integer, db.ForeignKey('task_types.id'), primary_key=True)

    pipeline_type = db.relationship("PipelineType", back_populates="tasks")
    current_task_type = db.relationship("TaskType", foreign_keys=[current_task_type_id])
    next_task_type = db.relationship("TaskType", foreign_keys=[next_task_type_id])
Ejemplo n.º 3
0
class Catalog(db.Model):
    __tablename__ = 'catalog2'
    container_id = db.Column(db.Integer,
                             db.ForeignKey('containers.id'),
                             primary_key=True)
    file_id = db.Column(db.Integer,
                        db.ForeignKey('files.id'),
                        primary_key=True)
    type = db.Column(db.String(50))
    file = db.relationship("File", back_populates="containers")
    cont = db.relationship("Container", back_populates="files")
Ejemplo n.º 4
0
class TaskType(TaskTypeJsonSerializer, db.Model):
    __tablename__ = 'task_types'
    id = db.Column(db.Integer, primary_key=True)
    method = db.Column(db.String(256))
    trf_template = db.Column(db.String(1024))
    ifiles_template = db.Column(db.String(1024))
    ofiles_template = db.Column(db.String(1024))
    tasks = db.relationship("Task", back_populates="task_type")
    distr_id = db.Column(db.Integer, db.ForeignKey('distr.id'))
    distr = db.relationship("Distributive")

    def __repr__(self):
        return '<TaskType id=%s>' % self.id
Ejemplo n.º 5
0
class Client(db.Model):
    __tablename__ = 'clients'
    # human readable name, not required
    name = db.Column(db.String(40))

    # human readable description, not required
    description = db.Column(db.String(400))

    # creator of the client, not required
    user_id = db.Column(db.ForeignKey('users.id'))

    client_id = db.Column(db.String(40), primary_key=True)
    client_secret = db.Column(db.String(55),
                              unique=True,
                              index=True,
                              nullable=False)

    # public or confidential
    is_confidential = db.Column(db.Boolean)

    tokens = db.relationship('Token',
                             backref=db.backref('client', lazy='joined'),
                             lazy='dynamic')
    grants = db.relationship('Grant',
                             backref=db.backref('client', lazy='joined'),
                             lazy='dynamic')

    _redirect_uris = db.Column(db.Text)
    _default_scopes = db.Column(db.Text)

    @property
    def client_type(self):
        if self.is_confidential:
            return 'confidential'
        return 'public'

    @property
    def redirect_uris(self):
        if self._redirect_uris:
            return self._redirect_uris.split()
        return []

    @property
    def default_redirect_uri(self):
        return self.redirect_uris[0]

    @property
    def default_scopes(self):
        if self._default_scopes:
            return self._default_scopes.split()
        return []
Ejemplo n.º 6
0
class Container(db.Model):
    __tablename__ = 'containers'
    id = db.Column(db.Integer, primary_key=True)
    guid = db.Column(db.String(100))
    status = db.Column(db.String(20))
    jobs = db.relationship('Job',
                           backref=db.backref('container', lazy='joined'),
                           lazy='dynamic')
    #files = db.relationship('File', secondary=catalog2,
    #    backref=db.backref('containers', lazy='joined'), lazy='dynamic')
    files = db.relationship("Catalog", back_populates="cont")

    def __repr__(self):
        return '<Container id=%s>' % self.id
Ejemplo n.º 7
0
class Task(TaskJsonSerializer, db.Model):
    __tablename__ = 'tasks'
    id = db.Column(db.Integer, primary_key=True)
    owner_id = db.Column(db.Integer, db.ForeignKey('users.id'))
    task_type_id = db.Column(db.Integer, db.ForeignKey('task_types.id'))
    task_type = db.relationship("TaskType", back_populates="tasks")
    tag = db.Column(db.String(256))
    creation_time = db.Column(db.DateTime)
    modification_time = db.Column(db.DateTime)
    status = db.Column(db.String(64), default='defined')
    #TODO place comment - task_status= ?(defined, starting, sent,running finished, cancelled, failed). Also for pipelines -?
    jobs = db.relationship('Job', secondary=tasks_jobs)
    trf = db.Column(db.String(1024))
    input = db.Column(db.Integer, db.ForeignKey('containers.id'), default=None)
    output = db.Column(db.Integer, db.ForeignKey('containers.id'), default=None)
    comment = db.Column(db.String(1024))
    params = db.Column(db.Text)

    def __repr__(self):
        return '<Task id=%s tag=%s>' % (self.id, self.tag)
Ejemplo n.º 8
0
class File(db.Model):
    __tablename__ = 'files'
    id = db.Column(db.Integer, primary_key=True)
    scope = db.Column(db.String(64))
    attemptn = db.Column(db.Integer, default=0)
    guid = db.Column(db.String(100))
    type = db.Column(db.String(20))  #input/output
    lfn = db.Column(db.String(200))  #local file name
    status = db.Column(db.String(20))  #ready/transfer
    transfertask = db.Column(db.String(40))  #ui transfer task id
    fsize = db.Column(db.BigInteger)
    md5sum = db.Column(db.String(36))
    checksum = db.Column(db.String(36))
    modification_time = db.Column(db.DateTime)
    downloaded = db.Column(db.Integer, default=0)
    replicas = db.relationship('Replica',
                               backref=db.backref('original', lazy='joined'),
                               lazy='dynamic')
    containers = db.relationship("Catalog", back_populates="file")

    def __repr__(self):
        return '<File id=%s>' % self.id
Ejemplo n.º 9
0
class Pipeline(PipelineJsonSerializer, db.Model):
    __tablename__ = 'pipelines'
    id = db.Column(db.Integer, primary_key=True)
    owner_id = db.Column(db.Integer, db.ForeignKey('users.id'))
    type_id = db.Column(db.Integer, db.ForeignKey('pipeline_types.id'))
    pipeline_type = db.relationship("PipelineType", back_populates="pipelines")
    tag = db.Column(db.String(256))
    current_task_id = db.Column(db.Integer, db.ForeignKey('tasks.id'), default=None)
    status = db.Column(db.String(256))
    creation_time = db.Column(db.DateTime)
    modification_time = db.Column(db.DateTime)

    def __repr__(self):
        return '<Pipeline id=%s name=%s>' % (self.id, self.name)
Ejemplo n.º 10
0
class Distributive(db.Model):
    __tablename__ = 'distr'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64))
    command = db.Column(db.String(1024))
    version = db.Column(db.String(64))
    release = db.Column(db.Integer)
    jobs = db.relationship('Job',
                           backref=db.backref('distr', lazy='joined'),
                           lazy='dynamic')

    def __repr__(self):
        return '<Distributive id=%s>' % self.id

    def __str__(self):
        return '%s [%s]' % (self.name, self.version)
Ejemplo n.º 11
0
class User(UserMixin, db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(64), index=True)
    working_group = db.Column(db.String(32))
    password_hash = db.Column(db.String(128))
    active = db.Column(db.Integer, default=1)
    last_seen = db.Column(db.DateTime)
    role = db.Column(db.Integer, default=ROLE_USER)
    jobs = db.relationship('Job',
                           backref=db.backref('owner', lazy='joined'),
                           lazy='dynamic')
    clients = db.relationship('Client',
                              backref=db.backref('user', lazy='joined'),
                              lazy='dynamic')
    tokens = db.relationship('Token',
                             backref=db.backref('user', lazy='joined'),
                             lazy='dynamic')
    grants = db.relationship('Grant',
                             backref=db.backref('user', lazy='joined'),
                             lazy='dynamic')

    @property
    def is_authenticated(self):
        return True

    @property
    def is_active(self):
        return self.active == 1

    @property
    def is_anonymous(self):
        return False

    def get_id(self):
        return unicode(self.id)

    @property
    def password(self):
        raise AttributeError('password is not a readable attribute')

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

    def verify_password(self, password):
        return check_password_hash(self.password_hash, password)

    @staticmethod
    def verify_ldap(username, password):
        conn = get_ldap_connection()

        ldap_result_id = conn.search(current_app.config['LDAP_BASE_DN'],
                                     ldap.SCOPE_SUBTREE,
                                     "uid= {user}".format(user=username), None)

        result_type, result_data = conn.result(ldap_result_id, 0)

        if type(result_data
                ) == list and result_data != [] and len(result_data) != 0:
            if result_type == ldap.RES_SEARCH_ENTRY:
                dn = result_data[0][0]
            else:
                print "bad result type"
                raise ldap.INVALID_CREDENTIALS
        else:
            print "bad return list"
            raise ldap.INVALID_CREDENTIALS

        conn.simple_bind_s(dn, password)

    def save(self):
        db.session.add(self)
        db.session.commit()

    def __repr__(self):
        return '<User name=%s>' % self.username