23 lines
661 B
Python
23 lines
661 B
Python
|
import os
|
||
|
|
||
|
from hcloud import Client
|
||
|
|
||
|
client = Client(
|
||
|
token="qOpoQdAg5VxZVpNONWbLbJO3xgGqSvkjm4kQV9H1RlnDhL2rI2P8CbII3hl2nyYb"
|
||
|
)
|
||
|
|
||
|
PREFIX = "s452662"
|
||
|
|
||
|
servers = client.servers.get_all()
|
||
|
print(f"Usuwanie {len(servers)} serwerów")
|
||
|
for s in servers:
|
||
|
if s.data_model.name.startswith(PREFIX):
|
||
|
action = client.servers.delete(s)
|
||
|
print(f"Usuwanie serwera {s.data_model.name} ({s.data_model.public_net.ipv4.ip}): {action.data_model.status}")
|
||
|
|
||
|
servers = client.load_balancers.get_all()
|
||
|
print(f"Usuwanie {len(servers)} load balancer")
|
||
|
for s in servers:
|
||
|
if s.data_model.name.startswith(PREFIX):
|
||
|
action = client.load_balancers.delete(s)
|