parent
bd73255824
commit
9b8ac493b1
3 changed files with 18 additions and 4 deletions
|
@ -41,6 +41,17 @@ class ProxyAutomation(BaseAutomation):
|
||||||
db.session.add(proxy)
|
db.session.add(proxy)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
def deprecate_orphaned_proxies(self):
|
||||||
|
proxies = Proxy.query.filter(
|
||||||
|
Proxy.destroyed == None,
|
||||||
|
Proxy.provider == self.provider,
|
||||||
|
Proxy.deprecated == None
|
||||||
|
).all()
|
||||||
|
for proxy in proxies:
|
||||||
|
if proxy.origin.destroyed is not None:
|
||||||
|
proxy.deprecate(reason="origin_destroyed")
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
def destroy_expired_proxies(self):
|
def destroy_expired_proxies(self):
|
||||||
cutoff = datetime.datetime.utcnow() - datetime.timedelta(days=3)
|
cutoff = datetime.datetime.utcnow() - datetime.timedelta(days=3)
|
||||||
proxies = Proxy.query.filter(
|
proxies = Proxy.query.filter(
|
||||||
|
@ -53,6 +64,11 @@ class ProxyAutomation(BaseAutomation):
|
||||||
proxy.updated = datetime.datetime.utcnow()
|
proxy.updated = datetime.datetime.utcnow()
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
def pre_housekeeping(self):
|
||||||
|
self.create_missing_proxies()
|
||||||
|
self.deprecate_orphaned_proxies()
|
||||||
|
self.destroy_expired_proxies()
|
||||||
|
|
||||||
def generate_terraform(self):
|
def generate_terraform(self):
|
||||||
self.write_terraform_config(
|
self.write_terraform_config(
|
||||||
self.template,
|
self.template,
|
||||||
|
|
|
@ -232,8 +232,7 @@ def import_monitor_alerts():
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
auto = ProxyAzureCdnAutomation()
|
auto = ProxyAzureCdnAutomation()
|
||||||
auto.create_missing_proxies()
|
auto.pre_housekeeping()
|
||||||
auto.destroy_expired_proxies()
|
|
||||||
auto.generate_terraform()
|
auto.generate_terraform()
|
||||||
auto.terraform_init()
|
auto.terraform_init()
|
||||||
auto.terraform_apply(refresh=False, parallelism=1) # Rate limits are problem
|
auto.terraform_apply(refresh=False, parallelism=1) # Rate limits are problem
|
||||||
|
|
|
@ -149,8 +149,7 @@ def import_cloudwatch_alarms():
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
auto = ProxyCloudfrontAutomation()
|
auto = ProxyCloudfrontAutomation()
|
||||||
auto.destroy_expired_proxies()
|
auto.pre_housekeeping()
|
||||||
auto.create_missing_proxies()
|
|
||||||
auto.generate_terraform()
|
auto.generate_terraform()
|
||||||
auto.terraform_init()
|
auto.terraform_init()
|
||||||
auto.terraform_apply(refresh=False)
|
auto.terraform_apply(refresh=False)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue