first commit
This commit is contained in:
54
certtest.py
Executable file
54
certtest.py
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/bin/python
|
||||
from env import *
|
||||
import requests
|
||||
import csv
|
||||
import json
|
||||
import time
|
||||
|
||||
# === KONFIGURATION ===
|
||||
CONFIG_ID = "prod"
|
||||
|
||||
# Load Balancer Settings (eintragen oder automatisch abrufen)
|
||||
PROVIDER = "link11"
|
||||
REGION = "global"
|
||||
LISTENER = "jtlwaap-lb-prod-443"
|
||||
LISTENER_PORT = 443
|
||||
|
||||
HEADERS_JSON = {
|
||||
"Authorization": f"Bearer {API_TOKEN}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
HEADERS_GET = {
|
||||
"Authorization": f"Bearer {API_TOKEN}",
|
||||
"Accept": "*/*"
|
||||
}
|
||||
|
||||
def sanitize_entry_id(domain):
|
||||
"""Erstellt eine gültige entry_id ohne Punkte, wie von der API gefordert."""
|
||||
return domain.replace(".", "-")
|
||||
|
||||
def domain_to_cert_id(domain):
|
||||
return f"jtlwaap-{sanitize_entry_id(domain)}"
|
||||
|
||||
def assign_to_load_balancer(cert_id):
|
||||
url = f"https://jtlwaap.app.reblaze.io/api/v4.3/conf/{CONFIG_ID}/load-balancers/{LISTENER}/certificates/{cert_id}"
|
||||
params = {
|
||||
"provider": PROVIDER,
|
||||
"region": REGION,
|
||||
"listener": LISTENER,
|
||||
"listener-port": LISTENER_PORT
|
||||
}
|
||||
|
||||
response = requests.put(url, headers=HEADERS_JSON, params=params)
|
||||
|
||||
if response.status_code == 200:
|
||||
print(f"[✓] Zertifikat dem Load Balancer zugewiesen: {cert_id}")
|
||||
else:
|
||||
print(f"[✗] Fehler beim Load Balancer für {cert_id}: {response.status_code} → {response.text}")
|
||||
|
||||
|
||||
def main():
|
||||
assign_to_load_balancer('jtlwaap-eb-autotest2-shop000-jtl-hosting-de')
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user