ci: add flake8
This commit is contained in:
parent
014596d271
commit
dd501a6e4e
32 changed files with 170 additions and 171 deletions
|
@ -23,12 +23,12 @@ class BridgeAutomation(TerraformAutomation):
|
|||
def create_missing(self) -> None:
|
||||
bridgeconfs: Iterable[BridgeConf] = BridgeConf.query.filter(
|
||||
BridgeConf.provider == self.provider,
|
||||
BridgeConf.destroyed == None
|
||||
BridgeConf.destroyed.is_(None)
|
||||
).all()
|
||||
for bridgeconf in bridgeconfs:
|
||||
active_bridges = Bridge.query.filter(
|
||||
Bridge.conf_id == bridgeconf.id,
|
||||
Bridge.deprecated == None
|
||||
Bridge.deprecated.is_(None)
|
||||
).all()
|
||||
if len(active_bridges) < bridgeconf.number:
|
||||
for i in range(bridgeconf.number - len(active_bridges)):
|
||||
|
@ -49,7 +49,7 @@ class BridgeAutomation(TerraformAutomation):
|
|||
def destroy_expired(self) -> None:
|
||||
cutoff = datetime.datetime.utcnow() - datetime.timedelta(days=0)
|
||||
bridges = [b for b in Bridge.query.filter(
|
||||
Bridge.destroyed == None,
|
||||
Bridge.destroyed.is_(None),
|
||||
Bridge.deprecated < cutoff
|
||||
).all() if b.conf.provider == self.provider]
|
||||
for bridge in bridges:
|
||||
|
@ -66,7 +66,7 @@ class BridgeAutomation(TerraformAutomation):
|
|||
self.template,
|
||||
groups=Group.query.all(),
|
||||
bridgeconfs=BridgeConf.query.filter(
|
||||
BridgeConf.destroyed == None,
|
||||
BridgeConf.destroyed.is_(None),
|
||||
BridgeConf.provider == self.provider
|
||||
).all(),
|
||||
global_namespace=app.config['GLOBAL_NAMESPACE'],
|
||||
|
|
|
@ -20,17 +20,17 @@ class BridgeAWSAutomation(BridgeAutomation):
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
provider "aws" {
|
||||
access_key = "{{ aws_access_key }}"
|
||||
secret_key = "{{ aws_secret_key }}"
|
||||
region = "us-east-1"
|
||||
}
|
||||
|
||||
|
||||
locals {
|
||||
ssh_key = file("{{ ssh_public_key_path }}")
|
||||
}
|
||||
|
||||
|
||||
{% for group in groups %}
|
||||
module "label_{{ group.id }}" {
|
||||
source = "cloudposse/label/null"
|
||||
|
@ -40,7 +40,7 @@ class BridgeAWSAutomation(BridgeAutomation):
|
|||
label_order = ["namespace", "tenant", "name", "attributes"]
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
{% for bridgeconf in bridgeconfs %}
|
||||
{% for bridge in bridgeconf.bridges %}
|
||||
{% if not bridge.destroyed %}
|
||||
|
@ -54,11 +54,11 @@ class BridgeAWSAutomation(BridgeAutomation):
|
|||
attributes = ["{{ bridge.id }}"]
|
||||
distribution_method = "{{ bridge.conf.method }}"
|
||||
}
|
||||
|
||||
|
||||
output "bridge_hashed_fingerprint_{{ bridge.id }}" {
|
||||
value = module.bridge_{{ bridge.id }}.hashed_fingerprint
|
||||
}
|
||||
|
||||
|
||||
output "bridge_bridgeline_{{ bridge.id }}" {
|
||||
value = module.bridge_{{ bridge.id }}.bridgeline
|
||||
sensitive = true
|
||||
|
|
|
@ -34,7 +34,7 @@ class BridgeOvhAutomation(BridgeAutomation):
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
provider "openstack" {
|
||||
auth_url = "https://auth.cloud.ovh.net/v3/"
|
||||
domain_name = "Default" # Domain name - Always at 'default' for OVHcloud
|
||||
|
@ -42,24 +42,24 @@ class BridgeOvhAutomation(BridgeAutomation):
|
|||
password = "{{ ovh_openstack_password }}"
|
||||
tenant_id = "{{ ovh_openstack_tenant_id }}"
|
||||
}
|
||||
|
||||
|
||||
provider "ovh" {
|
||||
endpoint = "ovh-eu"
|
||||
application_key = "{{ ovh_cloud_application_key }}"
|
||||
application_secret = "{{ ovh_cloud_application_secret }}"
|
||||
consumer_key = "{{ ovh_cloud_consumer_key }}"
|
||||
}
|
||||
|
||||
|
||||
locals {
|
||||
public_ssh_key = file("{{ ssh_public_key_path }}")
|
||||
private_ssh_key = file("{{ ssh_private_key_path }}")
|
||||
}
|
||||
|
||||
|
||||
data "ovh_cloud_project_regions" "regions" {
|
||||
service_name = "{{ ovh_openstack_tenant_id }}"
|
||||
has_services_up = ["instance"]
|
||||
}
|
||||
|
||||
|
||||
{% for group in groups %}
|
||||
module "label_{{ group.id }}" {
|
||||
source = "cloudposse/label/null"
|
||||
|
@ -69,19 +69,19 @@ class BridgeOvhAutomation(BridgeAutomation):
|
|||
label_order = ["namespace", "tenant", "name", "attributes"]
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
{% for bridgeconf in bridgeconfs %}
|
||||
{% for bridge in bridgeconf.bridges %}
|
||||
{% if not bridge.destroyed %}
|
||||
resource "random_shuffle" "region_{{ bridge.id }}" {
|
||||
input = data.ovh_cloud_project_regions.regions.names
|
||||
result_count = 1
|
||||
|
||||
|
||||
lifecycle {
|
||||
ignore_changes = [input] # don't replace all the bridges if a new region appears
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module "bridge_{{ bridge.id }}" {
|
||||
source = "sr2c/tor-bridge/openstack"
|
||||
version = "0.0.7"
|
||||
|
@ -94,11 +94,11 @@ class BridgeOvhAutomation(BridgeAutomation):
|
|||
contact_info = "hi"
|
||||
distribution_method = "{{ bridge.conf.method }}"
|
||||
}
|
||||
|
||||
|
||||
output "bridge_hashed_fingerprint_{{ bridge.id }}" {
|
||||
value = module.bridge_{{ bridge.id }}.hashed_fingerprint
|
||||
}
|
||||
|
||||
|
||||
output "bridge_bridgeline_{{ bridge.id }}" {
|
||||
value = module.bridge_{{ bridge.id }}.bridgeline
|
||||
sensitive = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue