Commit 41f3921d authored by Alejandro Alvarez Ayllon's avatar Alejandro Alvarez Ayllon
Browse files

FTS-822: Use enum for the states

parent ff1d62a7
......@@ -16,15 +16,16 @@
# limitations under the License.
from sqlalchemy import BigInteger
from sqlalchemy import Boolean, Column, DateTime, Float
from sqlalchemy import ForeignKey, Integer, String
from sqlalchemy import ForeignKey, Integer, String, Enum
from sqlalchemy.dialects import sqlite
from sqlalchemy.orm import relation, backref
from base import Base, Json
FileActiveStates = ['SUBMITTED', 'READY', 'STARTED', 'ACTIVE', 'STAGING']
FileActiveStates = ['STAGING', 'STARTED', 'SUBMITTED', 'READY', 'ACTIVE']
FileTerminalStates = ['FINISHED', 'FAILED', 'CANCELED']
# NOT_USED is not terminal, nor not-terminal
FileOnHoldStates = ['NOT_USED']
# sqlite doesn't like auto increment with BIGINT, so we need to use a variant
# on that case
......@@ -41,7 +42,7 @@ class File(Base):
vo_name = Column(String(50))
source_se = Column(String(255))
dest_se = Column(String(255))
file_state = Column(String(32))
file_state = Column(Enum(*(FileActiveStates + FileTerminalStates + FileOnHoldStates)))
transfer_host = Column(String(255))
source_surl = Column(String(1100))
dest_surl = Column(String(1100))
......
......@@ -16,14 +16,14 @@
# limitations under the License.
from file import ArchivedFile
from sqlalchemy import Column, DateTime, Integer, String, Text
from sqlalchemy import Column, DateTime, Integer, String, Enum
from sqlalchemy.orm import relation, backref
from base import Base, Flag, TernaryFlag, Json
JobActiveStates = ['SUBMITTED', 'READY', 'ACTIVE', 'STAGING', 'DELETE']
JobTerminalStates = ['FINISHED', 'CANCELED', 'FAILED', 'FINISHEDDIRTY']
JobActiveStates = ['STAGING', 'SUBMITTED', 'READY', 'ACTIVE', 'DELETE']
JobTerminalStates = ['FINISHED', 'FAILED', 'FINISHEDDIRTY', 'CANCELED']
class Job(Base):
......@@ -32,7 +32,7 @@ class Job(Base):
job_id = Column(String(36), primary_key=True)
source_se = Column(String(255))
dest_se = Column(String(255))
job_state = Column(String(32))
job_state = Column(Enum(*(JobActiveStates + JobTerminalStates)))
job_type = Column(String(1), default='N')
cancel_job = Column(Flag(negative=None))
submit_host = Column(String(255))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment