a little nicer wrt pep8
[sfa.git] / sfa / iotlab / iotlablease.py
1 # -*- coding:utf-8 -*-
2 """  PostGreSQL table management """
3
4 from sfa.storage.model import Base
5 from sqlalchemy import Column, Integer, String
6
7
8 class LeaseTable(Base):
9     """ SQL alchemy class to manipulate the rows of the lease_table table in the
10     SFA database. Table creation is made by the importer (iotlabimporter.py)
11     if it is not in the database yet.
12
13     As we don't have a link between a lease (OAR job submission) and a slice we
14     store this information in database. We matched OAR job id and slice hrn.
15     """
16     # pylint:disable=R0903
17     __tablename__ = 'lease_table'
18
19     job_id = Column(Integer, primary_key=True)
20     slice_hrn = Column(String)
21
22     def __init__(self, job_id, slice_hrn):
23         """
24         Defines a row of the lease_table table
25         """
26         self.job_id = job_id
27         self.slice_hrn = slice_hrn
28
29     def __repr__(self):
30         """Prints the SQLAlchemy record to the format defined
31         by the function.
32         """
33         result = "job_id %s, slice_hrn = %s" % (self.job_id,
34                                                 self.slice_hrn)
35         return result