30 lines
1.3 KiB
Python
30 lines
1.3 KiB
Python
from hcloud import Client
|
|
|
|
client = Client(
|
|
token="V5gkzZ13coCVPKWkQbmbyGPyxDdsTjiubwVtx35jH7mix8A32JqM5CWJtqoLjtFK"
|
|
)
|
|
PREFIX = "PD"
|
|
|
|
YOUR_LOCAL_SSH_PUBKEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzIOEX3AABgr3ZKLFcvZYkKr10JJjD0+AXlXoJ5CfpNw56SVj17Gh/Qbag4QeB8eJYaJxHV+TPhIOtHNxDJFlcVXUKPCBDErlIFYIJ8t0uhqvssd9r6XCZxvDjTC20FNayG+Zr1adB3BYe501I3JB9KiGZxg9juh/lY/1jZyqjjPzt8vLE1M2j6C7rbLAlIOub37B8OC7SGsy/nz4Ub5kS3Jxh9Trmr6vtuXa5WnASIaqX+3jl9hBhsg55j5WKUrGM1BOEKmwYxFJEH7bY0NjmcNAeaw1mm5bxERSW6EFXX3hEk+kx5zuFbO1LXDBh3HP5FyjwOXDKY70aLfVVpdGj"
|
|
|
|
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}: {action.data_model.status}")
|
|
|
|
ssh_keys = client.ssh_keys.get_all()
|
|
print(f"Usuwanie {len(ssh_keys)} kluczy SSH")
|
|
for s in ssh_keys:
|
|
if s.data_model.name.startswith(PREFIX):
|
|
action = client.ssh_keys.delete(s)
|
|
print(f"\tUsuwanie klucza {s.name}: {action}")
|
|
|
|
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}")
|