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.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):
|
||||
cutoff = datetime.datetime.utcnow() - datetime.timedelta(days=3)
|
||||
proxies = Proxy.query.filter(
|
||||
|
@ -53,6 +64,11 @@ class ProxyAutomation(BaseAutomation):
|
|||
proxy.updated = datetime.datetime.utcnow()
|
||||
db.session.commit()
|
||||
|
||||
def pre_housekeeping(self):
|
||||
self.create_missing_proxies()
|
||||
self.deprecate_orphaned_proxies()
|
||||
self.destroy_expired_proxies()
|
||||
|
||||
def generate_terraform(self):
|
||||
self.write_terraform_config(
|
||||
self.template,
|
||||
|
|
|
@ -232,8 +232,7 @@ def import_monitor_alerts():
|
|||
if __name__ == "__main__":
|
||||
with app.app_context():
|
||||
auto = ProxyAzureCdnAutomation()
|
||||
auto.create_missing_proxies()
|
||||
auto.destroy_expired_proxies()
|
||||
auto.pre_housekeeping()
|
||||
auto.generate_terraform()
|
||||
auto.terraform_init()
|
||||
auto.terraform_apply(refresh=False, parallelism=1) # Rate limits are problem
|
||||
|
|
|
@ -149,8 +149,7 @@ def import_cloudwatch_alarms():
|
|||
if __name__ == "__main__":
|
||||
with app.app_context():
|
||||
auto = ProxyCloudfrontAutomation()
|
||||
auto.destroy_expired_proxies()
|
||||
auto.create_missing_proxies()
|
||||
auto.pre_housekeeping()
|
||||
auto.generate_terraform()
|
||||
auto.terraform_init()
|
||||
auto.terraform_apply(refresh=False)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue