|
|
|
@ -10,7 +10,6 @@ def assert_availibilty(target_host: str, wake_if_offline: bool = False):
|
|
|
|
|
ips = get_target_ips()
|
|
|
|
|
ip_target = ips[target_host]
|
|
|
|
|
target_node_route = f'http://{ip_target}:9713/status'
|
|
|
|
|
available = False
|
|
|
|
|
try:
|
|
|
|
|
response = requests.get(target_node_route, timeout=30)
|
|
|
|
|
#print(f"{response =}")
|
|
|
|
@ -18,7 +17,7 @@ def assert_availibilty(target_host: str, wake_if_offline: bool = False):
|
|
|
|
|
print(f"{target_host} is online and ready.")
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
print(f"{target_host} is offline.")
|
|
|
|
|
print(f"{target_host} is not responding correctly {response.status_code}.")
|
|
|
|
|
return False
|
|
|
|
|
except requests.exceptions.RequestException as re:
|
|
|
|
|
#print(f"Error: {str(re)}")
|
|
|
|
@ -29,7 +28,6 @@ def assert_availibilty(target_host: str, wake_if_offline: bool = False):
|
|
|
|
|
time.sleep(60)
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
print(f"{target_host} is offline.")
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -85,15 +83,17 @@ def process_arguments():
|
|
|
|
|
parser = argparse.ArgumentParser(description="Osiris Node Skript kommuniziert mit Osiris Listener bei Target Host.")
|
|
|
|
|
parser.add_argument('target_host', type=str, choices=["nuc_morroc"], help='Profil des Ziel-Hostes')
|
|
|
|
|
parser.add_argument('command', type=str, choices=['testcommand', 'shutdown', 'status'], help='Command to send to the target host')
|
|
|
|
|
parser.add_argument('-w', '--wake', action='store_true', help='Weckt Ziel-Host auf wenn offline')
|
|
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
target_host = args.target_host
|
|
|
|
|
#target_host = 'nuc_morroc'
|
|
|
|
|
wake = args.wake
|
|
|
|
|
|
|
|
|
|
match args.command:
|
|
|
|
|
case "status":
|
|
|
|
|
assert_availibilty(target_host)
|
|
|
|
|
assert_availibilty(target_host,wake)
|
|
|
|
|
case "shutdown":
|
|
|
|
|
assert_availibilty(target_host, wake_if_offline=True)
|
|
|
|
|
send_shutdown_command(target_host)
|
|
|
|
|