first commit
This commit is contained in:
76
01_create_backend_service_link11.py
Executable file
76
01_create_backend_service_link11.py
Executable file
@@ -0,0 +1,76 @@
|
||||
#!/bin/python
|
||||
from env import *
|
||||
import requests
|
||||
import json
|
||||
|
||||
# === Konfiguration ===
|
||||
CONFIG_ID = "prod"
|
||||
|
||||
# Proxy Templates – nur einen aktiv lassen
|
||||
PROXY_TEMPLATE = "f4bf25a205a5"
|
||||
# PROXY_TEMPLATE = "andere_template_id"
|
||||
|
||||
# === Header für alle Requests ===
|
||||
HEADERS = {
|
||||
"Authorization": f"Bearer {API_TOKEN}",
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
|
||||
def domain_to_id(domain):
|
||||
return domain.replace(".", "-")
|
||||
|
||||
def domain_to_backend_id(domain):
|
||||
return f"backend-{domain_to_id(domain)}"
|
||||
|
||||
|
||||
def create_backend_service(name, ip):
|
||||
entry_id = domain_to_backend_id(name)
|
||||
url = f"https://jtlwaap.app.reblaze.io/api/v4.3/conf/{CONFIG_ID}/backend-services/{entry_id}"
|
||||
|
||||
print(f"\n📦 creating Backend Service for {name} → IP: {ip}")
|
||||
|
||||
payload = {
|
||||
"back_hosts": [
|
||||
{
|
||||
"backup": False,
|
||||
"down": False,
|
||||
"fail_timeout": 10,
|
||||
"host": ip,
|
||||
"http_ports": [80],
|
||||
"https_ports": [443],
|
||||
"max_fails": 0,
|
||||
"monitor_state": "",
|
||||
"weight": 1
|
||||
}
|
||||
],
|
||||
"description": f"JTL Shopserver {name}",
|
||||
"http11": True,
|
||||
"id": entry_id,
|
||||
"least_conn": True,
|
||||
"name": name,
|
||||
"sticky": "none",
|
||||
"sticky_cookie_name": "",
|
||||
"transport_mode": "default"
|
||||
}
|
||||
|
||||
print(payload)
|
||||
response = requests.post(url, headers=HEADERS, data=json.dumps(payload)
|
||||
|
||||
)
|
||||
|
||||
if response.status_code == 201:
|
||||
print(f"[✓] Backend Service '{name}' erfolgreich erstellt.")
|
||||
else:
|
||||
print(f"[✗] Fehler bei {name} ({ip}): {response.status_code} → {response.text} {response.json()}")
|
||||
|
||||
|
||||
def main():
|
||||
#create_backend_service("shop022.jtl-hosting.de", "31.172.84.222")
|
||||
#create_backend_service("shop056.jtl-hosting.de", "31.172.91.121")
|
||||
#create_backend_service("shop000.jtl-hosting.de", "31.172.91.145")
|
||||
#create_backend_service("shop051.jtl-hosting.de", "31.172.91.88")
|
||||
create_backend_service("shop009.jtl-hosting.de", "31.172.84.33")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user