1
0
Files
hetzner-automation/list.py
Philipp Klüter 2b4c99d1fc Minor fixes
2020-05-22 17:04:37 +02:00

21 lines
448 B
Python
Executable File

#!/usr/bin/env python3
from hcloud import Client, APIException
import argparse
# Get Servername
parser = argparse.ArgumentParser()
parser.add_argument("apiKey")
args = parser.parse_args()
apiKey = args.apiKey
try:
client = Client(token=apiKey)
servers = client.servers.get_all()
for server in servers:
print("Servername: %s\t\tStatus: %s" %(server.name ,server.status))
except APIException as e:
print("API Error ", e)