44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
from pillar_tool.db.base_model import Base
|
|
|
|
from sqlalchemy import Column, UUID, String, ForeignKey, UniqueConstraint
|
|
|
|
|
|
class Pillar(Base):
|
|
__tablename__ = 'pillar_tool_pillar'
|
|
id = Column(UUID, primary_key=True)
|
|
name = Column(String, nullable=False)
|
|
parent_id = Column(UUID, ForeignKey('pillar_tool_pillar.id'), nullable=True)
|
|
|
|
|
|
class PillarValue(Base):
|
|
__tablename__ = 'pillar_tool_pillar_value'
|
|
pillar_id = Column(UUID, ForeignKey('pillar_tool_pillar.id'), primary_key=True)
|
|
host_id = Column(UUID, ForeignKey('pillar_tool_host.id'), primary_key=True)
|
|
host_group_id = Column(UUID, ForeignKey('pillar_tool_host_group.id'), primary_key=True)
|
|
type = Column(String, nullable=False)
|
|
value = Column(String, nullable=False)
|
|
|
|
|
|
class Host(Base):
|
|
__tablename__ = 'pillar_tool_host'
|
|
id = Column(UUID, primary_key=True)
|
|
name = Column(String, nullable=False)
|
|
host_group_id = Column(UUID, ForeignKey('pillar_tool_host_group.id'), nullable=True)
|
|
|
|
__table_args__ = (
|
|
UniqueConstraint('name', name='pillar_tool_host_unique_name'),
|
|
|
|
)
|
|
|
|
|
|
class HostGroup(Base):
|
|
__tablename__ = 'pillar_tool_host_group'
|
|
id = Column(UUID, primary_key=True)
|
|
name = Column(String, nullable=False)
|
|
parent_id = Column(UUID, ForeignKey('pillar_tool_host_group.id'), nullable=True)
|
|
|
|
__table_args__ = (
|
|
UniqueConstraint('name', name='pillar_tool_host_group_unique_name'),
|
|
)
|
|
|