Add action table for bp add-mysql-support-for-freezer
Add table action and ActionReport in v2. The other tables,api and test will be added in following patch. ref: https://storyboard.openstack.org/#!/story/2004132 Story: #2004132 Task: #27578 Change-Id: Idafc9d9c26540735fe8a4ddb24af1f09964d3846 Implements: bp add-mysql-support-for-freezer
This commit is contained in:
parent
9db61ba0ba
commit
8c63de54e9
|
@ -11,7 +11,8 @@
|
|||
# under the License.
|
||||
|
||||
from sqlalchemy import Boolean, Column, DateTime
|
||||
from sqlalchemy import MetaData, String, Table
|
||||
from sqlalchemy import Integer, MetaData, String, Table, Text
|
||||
from sqlalchemy import BLOB, TIMESTAMP
|
||||
|
||||
CLASS_NAME = 'default'
|
||||
|
||||
|
@ -34,7 +35,52 @@ def define_tables(meta):
|
|||
mysql_charset='utf8'
|
||||
)
|
||||
|
||||
return [clients]
|
||||
# The field metadata is json, including :
|
||||
# nova_inst_id, engine_name, storage, remove_older_than, restore_from_date,
|
||||
# command, incremental, restore_abs_path, etc
|
||||
actions = Table(
|
||||
'actions', meta,
|
||||
Column('created_at', DateTime(timezone=False)),
|
||||
Column('updated_at', DateTime(timezone=False)),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', String(36), primary_key=True, nullable=False),
|
||||
Column('action', String(255), nullable=False),
|
||||
Column('project_id', String(36), nullable=False),
|
||||
Column('user_id', String(36), nullable=False),
|
||||
Column('mode', String(255)),
|
||||
Column('src_file', String(255)),
|
||||
Column('backup_name', String(255)),
|
||||
Column('container', String(255)),
|
||||
Column('timeout', Integer),
|
||||
Column('priority', Integer),
|
||||
Column('max_retries_interval', Integer, default=6),
|
||||
Column('max_retries', Integer, default=5),
|
||||
Column('mandatory', Boolean, default=False),
|
||||
Column('log_file', String(255)),
|
||||
Column('backup_metadata', Text),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
||||
|
||||
action_reports = Table(
|
||||
'action_reports', meta,
|
||||
Column('created_at', DateTime(timezone=False)),
|
||||
Column('updated_at', DateTime(timezone=False)),
|
||||
Column('deleted_at', DateTime),
|
||||
Column('deleted', Boolean),
|
||||
Column('id', String(36), primary_key=True, nullable=False),
|
||||
Column('project_id', String(36), nullable=False),
|
||||
Column('user_id', String(36), nullable=False),
|
||||
Column('result', String(255)),
|
||||
Column('time_elapsed', String(255)),
|
||||
Column('report_date', TIMESTAMP),
|
||||
Column('log', BLOB),
|
||||
mysql_engine='InnoDB',
|
||||
mysql_charset='utf8'
|
||||
)
|
||||
|
||||
return [clients, actions, action_reports]
|
||||
|
||||
|
||||
def upgrade(migrate_engine):
|
||||
|
|
|
@ -66,16 +66,30 @@ class Client(BASE, FreezerBase):
|
|||
|
||||
class Action(BASE, FreezerBase):
|
||||
"""Represents freezer action."""
|
||||
# The field backup_metadata is json, including :
|
||||
# hostname ,snapshot ,storage ,dry_run , lvm_auto_snap, lvm_dirmount,
|
||||
# lvm_snapname max_level , max_priority, max_segment_size , mode,
|
||||
# mysql_conf, path_to_backup, remove_older_than restore_abs_path
|
||||
# restore_from_host, ssh_host , ssh_key , ssh_username, ssh_port , proxy
|
||||
# no_incremental, overwrite , nova_inst_id , engine_name
|
||||
# restore_from_date , command , incremental
|
||||
|
||||
__tablename__ = 'actions'
|
||||
id = Column(String(36), primary_key=True)
|
||||
action = Column(String(255), nullable=False)
|
||||
project_id = Column(String(36), nullable=False)
|
||||
user_id = Column(String(64), nullable=False)
|
||||
mode = Column(String(255))
|
||||
src_file = Column(String(255))
|
||||
backup_name = Column(String(255))
|
||||
container = Column(String(255))
|
||||
restore_abs_path = Column(String(255))
|
||||
timeout = Column(Integer)
|
||||
priority = Column(Integer)
|
||||
max_retries_interval = Column(Integer, default=6)
|
||||
max_retries = Column(Integer, default=5)
|
||||
mandatory = Column(Boolean, default=False)
|
||||
log_file = Column(String(255))
|
||||
backup_metadata = Column(Text)
|
||||
|
||||
|
||||
class Job(BASE, FreezerBase):
|
||||
|
@ -98,53 +112,15 @@ class Session(BASE, FreezerBase):
|
|||
policy = Column(String(255))
|
||||
|
||||
|
||||
class ActionAttachment(BASE, FreezerBase):
|
||||
__tablename__ = 'action_attachments'
|
||||
id = Column(String(36), primary_key=True)
|
||||
action_id = Column(String(36), ForeignKey('actions.id'), nullable=False)
|
||||
job_id = Column(String(36), ForeignKey('jobs.id'), nullable=False)
|
||||
project_id = Column(String(36), nullable=False)
|
||||
priority = Column(Integer)
|
||||
retries = Column(Integer)
|
||||
retry_interval = Column(Integer)
|
||||
mandatory = Column(Boolean, default=False)
|
||||
action = relationship(Action, backref='action_attachments',
|
||||
foreign_keys=action_id,
|
||||
primaryjoin='and_('
|
||||
'ActionAttachment.action_id == Action.id,'
|
||||
'ActionAttachment.deleted == False)')
|
||||
job = relationship(Job, backref='action_attachments',
|
||||
foreign_keys=job_id,
|
||||
primaryjoin='and_('
|
||||
'ActionAttachment.job_id == Job.id,'
|
||||
'ActionAttachment.deleted == False)')
|
||||
|
||||
|
||||
class ActionReport(BASE, FreezerBase):
|
||||
__tablename__ = 'action_reports'
|
||||
id = Column(String(36), primary_key=True)
|
||||
action_id = Column(String(36), ForeignKey('actions.id'), nullable=False)
|
||||
action_attachment_id = Column(
|
||||
String(36), ForeignKey('actions.id'), nullable=False
|
||||
)
|
||||
project_id = Column(String(36), nullable=False)
|
||||
user_id = Column(String(64), nullable=False)
|
||||
result = Column(String(255))
|
||||
time_elapsed = Column(String(255))
|
||||
backup_metadata = Column(Text)
|
||||
report_date = Column(TIMESTAMP)
|
||||
log = Column(BLOB)
|
||||
action = relationship(Action, backref='action_reports',
|
||||
foreign_keys=action_id,
|
||||
primaryjoin='and_('
|
||||
'ActionReport.action_id == Action.id,'
|
||||
'ActionReport.deleted == False)')
|
||||
action_attachment = relationship(
|
||||
ActionAttachment,
|
||||
backref='action_reports',
|
||||
foreign_keys=action_attachment_id,
|
||||
primaryjoin='and_('
|
||||
'ActionReport.action_attachment_id == ActionAttachment.id,'
|
||||
'ActionReport.deleted == False)')
|
||||
|
||||
|
||||
class JobAttachment(BASE, FreezerBase):
|
||||
|
|
Loading…
Reference in New Issue