platypush/platypush/entities/cloud.py
Fabio Manganiello d872835093
New API to check if a table class exists before defining it.
- Check if it's part of the metadata through a function call rather than
  checking `Base.metadata` in every single module.

- Make it possible to override them (mostly for doc generation logic
  that needs to be able to import those classes).

- Make it possible to extend them.
2023-10-09 01:33:44 +02:00

44 lines
1 KiB
Python

from sqlalchemy import (
Column,
ForeignKey,
Integer,
JSON,
String,
)
from platypush.common.db import is_defined
from .devices import Device
if not is_defined('cloud_instance'):
class CloudInstance(Device):
"""
Entity that maps a cloud node - like a Linode or AWS instance.
"""
__tablename__ = 'cloud_instance'
id = Column(
Integer, ForeignKey(Device.id, ondelete='CASCADE'), primary_key=True
)
status = Column(String)
instance_type = Column(String)
ipv4_addresses = Column(JSON)
ipv6_address = Column(String)
group = Column(String)
tags = Column(JSON)
image = Column(String)
region = Column(String)
hypervisor = Column(String)
uuid = Column(String)
specs = Column(JSON)
alerts = Column(JSON)
backups = Column(JSON)
__table_args__ = {'extend_existing': True}
__mapper_args__ = {
'polymorphic_identity': __tablename__,
}