Exemplo n.º 1
0
class TransferTask(db.Model):
    __tablename__ = 'transfertasks'
    id = db.Column(db.Integer, primary_key=True)
    replica_id = db.Column(db.Integer, db.ForeignKey('replicas.id'))
    se = db.Column(db.String(40))
    task_id = db.Column(db.String(40))
    task_status = db.Column(db.String(20))
Exemplo n.º 2
0
class Token(db.Model):
    __tablename__ = 'tokens'
    id = db.Column(db.Integer, primary_key=True)
    client_id = db.Column(
        db.String(40),
        db.ForeignKey('clients.client_id'),
        nullable=False,
    )
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'))

    # currently only bearer is supported
    token_type = db.Column(db.String(40))

    access_token = db.Column(db.String(255), unique=True)
    refresh_token = db.Column(db.String(255), unique=True)
    expires = db.Column(db.DateTime)
    _scopes = db.Column(db.Text)

    def delete(self):
        db.session.delete(self)
        db.session.commit()
        return self

    @property
    def scopes(self):
        if self._scopes:
            return self._scopes.split()
        return []
Exemplo n.º 3
0
class Grant(db.Model):
    __tablename__ = 'grants'
    id = db.Column(db.Integer, primary_key=True)

    user_id = db.Column(db.Integer,
                        db.ForeignKey('users.id', ondelete='CASCADE'))
    client_id = db.Column(
        db.String(40),
        db.ForeignKey('clients.client_id'),
        nullable=False,
    )

    code = db.Column(db.String(255), index=True, nullable=False)

    redirect_uri = db.Column(db.String(255))
    expires = db.Column(db.DateTime)

    _scopes = db.Column(db.Text)

    def delete(self):
        db.session.delete(self)
        db.session.commit()
        return self

    @property
    def scopes(self):
        if self._scopes:
            return self._scopes.split()
        return []
Exemplo n.º 4
0
class TaskMeta(db.Model):
    __tablename__ = 'celery_taskmeta'
    id = db.Column(db.Integer, primary_key=True)
    task_id = db.Column(db.String(255))
    status = db.Column(db.String(50))
    result = db.Column(db.BLOB)
    date_done = db.Column(db.DateTime)
    traceback = db.Column(db.Text)
Exemplo n.º 5
0
class Replica(db.Model):
    __tablename__ = 'replicas'
    id = db.Column(db.Integer, primary_key=True)
    original_id = db.Column(db.Integer, db.ForeignKey('files.id'))
    se = db.Column(db.String(20))
    status = db.Column(db.String(20))  #ready/transfer
    lfn = db.Column(db.String(200))  #local file name
    token = db.Column(db.String(200))  #string of params to get file

    def __repr__(self):
        return '<Replica id=%s>' % self.id
Exemplo n.º 6
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
Exemplo n.º 7
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 []
Exemplo n.º 8
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
Exemplo 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)
Exemplo n.º 10
0
class Site(db.Model):
    __tablename__ = 'sites'
    id = db.Column(db.Integer, primary_key=True)
    se = db.Column(db.String(64))
    ce = db.Column(db.String(64))
    plugin = db.Column(db.String(20))
    active = db.Column(db.Integer, default=1)
    datadir = db.Column(db.String(200))
    encode_commands = db.Column(db.Boolean, default=True)

    def __repr__(self):
        return '<SE=%s CE=%s>' % (self.se, self.ce)

    def __str__(self):
        return self.__repr__()
Exemplo n.º 11
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)
Exemplo n.º 12
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
Exemplo n.º 13
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)
Exemplo n.º 14
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")
Exemplo n.º 15
0
class Job(JobJsonSerializer, db.Model):
    __tablename__ = 'jobs'
    id = db.Column(db.Integer, primary_key=True)
    pandaid = db.Column(db.Integer)
    status = db.Column(db.String(20))
    owner_id = db.Column(db.Integer, db.ForeignKey('users.id'))
    distr_id = db.Column(db.Integer, db.ForeignKey('distr.id'))
    params = db.Column(db.String(1000))
    container_id = db.Column(db.Integer, db.ForeignKey('containers.id'))
    creation_time = db.Column(db.DateTime)
    modification_time = db.Column(db.DateTime)
    ninputfiles = db.Column(db.Integer)
    noutputfiles = db.Column(db.Integer)
    registered = db.Column(db.Integer, default=0)
    registation_time = db.Column(db.DateTime)
    ce = db.Column(db.String(40))
    corecount = db.Column(db.Integer, default=0)
    tags = db.Column(db.String(256), default='')
    attemptnr = db.Column(db.Integer, default=0)

    def __repr__(self):
        return '<Job id=%s>' % self.id
Exemplo n.º 16
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
Exemplo n.º 17
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
Exemplo n.º 18
0
class TaskSetMeta(db.Model):
    __tablename__ = 'celery_tasksetmeta'
    id = db.Column(db.Integer, primary_key=True)
    taskset_id = db.Column(db.String(255))
    result = db.Column(db.BLOB)
    date_done = db.Column(db.DateTime)