38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
from pillar_tool.db.base_model import Base
|
|
|
|
from sqlalchemy import Column, UUID, String, ForeignKey, UniqueConstraint, Boolean
|
|
|
|
|
|
class Pillar(Base):
|
|
"""
|
|
A value for a given pillar on a given host.
|
|
"""
|
|
__tablename__ = 'pillar_tool_pillar'
|
|
id = Column(UUID, primary_key=True)
|
|
pillar_name = Column(String, nullable=False)
|
|
host_id = Column(UUID, ForeignKey('pillar_tool_host.id'), nullable=True)
|
|
parameter_type = Column(String, nullable=False)
|
|
value = Column(String, nullable=False)
|
|
|
|
__table_args__ = (
|
|
UniqueConstraint('pillar_name', 'host_id', name='pillar_unique_pillar_name'),
|
|
)
|
|
|
|
|
|
class Host(Base):
|
|
"""
|
|
Describes a host or a hostgroup by its name and parent. A parent equal to NULL mains that the host is a top level
|
|
host or hostgroup.
|
|
"""
|
|
__tablename__ = 'pillar_tool_host'
|
|
id = Column(UUID, primary_key=True)
|
|
name = Column(String, nullable=False)
|
|
parent_id = Column(UUID, ForeignKey('pillar_tool_host.id'), nullable=True)
|
|
is_hostgroup = Column(Boolean, nullable=False, server_default="FALSE")
|
|
|
|
__table_args__ = (
|
|
UniqueConstraint('name', 'parent_id', name='pillar_tool_host_unique_name'),
|
|
)
|
|
|
|
|