36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
from hcloud import Client
|
|
client = Client(
|
|
token="V5gkzZ13coCVPKWkQbmbyGPyxDdsTjiubwVtx35jH7mix8A32JqM5CWJtqoLjtFK"
|
|
)
|
|
PREFIX = "464962"
|
|
|
|
lbs = client.load_balancers.get_all()
|
|
print(f"Usuwanie {len(lbs)} mechanizmów LB")
|
|
for s in lbs:
|
|
if s.data_model.name.startswith(PREFIX):
|
|
action = client.load_balancers.delete(s)
|
|
print(f"\tUsuwanie LB {s.data_model.name}: {action}")
|
|
|
|
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"\tUsuwanie serwera {s.data_model.name} ({s.data_model.public_net.ipv4.ip}): {action.data_model.status}")
|
|
|
|
|
|
vnets = client.networks.get_all()
|
|
print(f"Usuwanie {len(vnets)} sieci wirtualnych")
|
|
for s in vnets:
|
|
if s.data_model.name.startswith(PREFIX):
|
|
action = client.networks.delete(s)
|
|
print(f"\tUsuwanie sieci wirtualnej {s.name}: {action}")
|
|
|
|
volumes = client.volumes.get_all()
|
|
print(f"Usuwanie {len(volumes)} wolumenów")
|
|
for v in volumes:
|
|
if s.data_model.name.startswith(PREFIX):
|
|
action = client.volumes.delete(v)
|
|
print(f"\tUsuwanie wolumenu {v.name}: {action}")
|
|
|