refactored token and ssh key loading
This commit is contained in:
parent
de1891f9b1
commit
db9277f366
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.credentials/
|
21
main.py
21
main.py
@ -3,10 +3,15 @@ from hcloud.images.domain import Image
|
||||
from hcloud.networks.domain import NetworkSubnet
|
||||
from hcloud.locations.domain import Location
|
||||
from hcloud.server_types.domain import ServerType
|
||||
from pathlib import Path
|
||||
|
||||
client = Client(token="")
|
||||
ssh_raw = ""
|
||||
ssh_name = ssh_raw.split()[2]
|
||||
with open('.credentials/token', 'r') as file:
|
||||
client = Client(token=str(file.readline()).strip())
|
||||
|
||||
with open(f'{str(Path.home())}/.ssh/id_ed25519.pub', 'r') as file:
|
||||
ssh_raw = file.readline()
|
||||
|
||||
ssh_name = "ssh-s444501"
|
||||
network_name = "s444501-gitea"
|
||||
|
||||
|
||||
@ -155,8 +160,8 @@ print(f"Tworzenie serwera gitea: {gitea_server.action.complete}")
|
||||
|
||||
|
||||
|
||||
# servers = client.servers.get_all()
|
||||
# print(f"Usuwanie {len(servers)} serwerów")
|
||||
# for s in servers:
|
||||
# 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.servers.get_all()
|
||||
print(f"Usuwanie {len(servers)} serwerów")
|
||||
for s in servers:
|
||||
action = client.servers.delete(s)
|
||||
print(f"Usuwanie serwera {s.data_model.name} ({s.data_model.public_net.ipv4.ip}): {action.data_model.status}")
|
||||
|
Loading…
Reference in New Issue
Block a user