feat: abstracting cloud providers
This commit is contained in:
parent
af36a545a1
commit
0a72aeed96
18 changed files with 629 additions and 181 deletions
|
@ -50,7 +50,7 @@ class BridgeConf(AbstractConfiguration):
|
|||
|
||||
class Bridge(AbstractResource):
|
||||
conf_id = db.Column(db.Integer, db.ForeignKey("bridge_conf.id"), nullable=False)
|
||||
provider = db.Column(db.String(), nullable=False)
|
||||
cloud_account_id = db.Column(db.Integer, db.ForeignKey("cloud_account.id"))
|
||||
terraform_updated = db.Column(db.DateTime(), nullable=True)
|
||||
nickname = db.Column(db.String(255), nullable=True)
|
||||
fingerprint = db.Column(db.String(255), nullable=True)
|
||||
|
@ -58,13 +58,14 @@ class Bridge(AbstractResource):
|
|||
bridgeline = db.Column(db.String(255), nullable=True)
|
||||
|
||||
conf = db.relationship("BridgeConf", back_populates="bridges")
|
||||
cloud_account = db.relationship("CloudAccount", back_populates="bridges")
|
||||
|
||||
@property
|
||||
def brn(self) -> BRN:
|
||||
return BRN(
|
||||
group_id=0,
|
||||
product="bridge",
|
||||
provider=self.provider,
|
||||
provider=self.cloud_account.provider.key,
|
||||
resource_type="bridge",
|
||||
resource_id=str(self.id)
|
||||
)
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
import enum
|
||||
|
||||
from app.brm.brn import BRN
|
||||
from app.extensions import db
|
||||
from app.models import AbstractConfiguration
|
||||
|
||||
|
||||
class CloudProvider(enum.Enum):
|
||||
AWS = ("aws", "Amazon Web Services")
|
||||
AZURE = ("azure", "Microsoft Azure")
|
||||
BUNNY = ("bunny", "bunny.net")
|
||||
CLOUDFLARE = ("cloudflare", "Cloudflare")
|
||||
FASTLY = ("fastly", "Fastly")
|
||||
HTTP = ("http", "HTTP")
|
||||
GANDI = ("gandi", "Gandi")
|
||||
GITHUB = ("github", "GitHub")
|
||||
GITLAB = ("gitlab", "GitLab")
|
||||
HCLOUD = ("hcloud", "Hetzner Cloud")
|
||||
MAXMIND = ("maxmind", "MaxMind")
|
||||
OVH = ("ovh", "OVH")
|
||||
RFC2136 = ("rfc2136", "RFC2136 DNS Server")
|
||||
|
||||
def __init__(self, key: str, description: str):
|
||||
self.key = key
|
||||
self.description = description
|
||||
|
||||
|
||||
class CloudAccount(AbstractConfiguration):
|
||||
provider = db.Column(db.Enum(CloudProvider))
|
||||
credentials = db.Column(db.JSON())
|
||||
enabled = db.Column(db.Boolean())
|
||||
# CDN Quotas
|
||||
max_distributions = db.Column(db.Integer())
|
||||
max_sub_distributions = db.Column(db.Integer())
|
||||
# Compute Quotas
|
||||
max_instances = db.Column(db.Integer())
|
||||
|
||||
bridges = db.relationship("Bridge", back_populates="cloud_account")
|
||||
|
||||
@property
|
||||
def brn(self) -> BRN:
|
||||
raise NotImplementedError("No BRN for cloud accounts")
|
Loading…
Add table
Add a link
Reference in a new issue