Config Edit changes #8 (#11)

* Issues #8 Config Edit changes

* Patch #8
This commit is contained in:
Seting-dev
2025-05-26 10:28:01 +03:00
committed by GitHub
parent 7e986834f6
commit 96c6e29c00
4 changed files with 39 additions and 6 deletions

View File

@@ -1,5 +1,8 @@
import os
import subprocess
from cluster_api import *
from data_pools_api import *
from rich import print
from rich.panel import Panel
from rich.console import Console , Align
@@ -55,7 +58,12 @@ def config_edit(config_relative_path):
menu_choice=str(read_input)
if menu_choice == "Y" or menu_choice == "y":
base_url = input("Type SpaceVM Controller IP: ")
while ping(base_url) != True:
base_url = console.input("[bold red]No response.\nCheck and type SpaceVM Controller IP again: [/]")
api_key = input("Type your API Key: ")
while check_api_key(base_url, "jwt " + api_key) != 200:
api_key = console.input("[bold red]Check and type SpaceVM Controller API Key again: [/]")
data_pools(base_url,"jwt " + api_key)
data_pool_uuid = input("Type Data Pool UUID you wish to use: ")
lines = [base_url, api_key, data_pool_uuid]
with open(config_relative_path, "w+") as file:
@@ -74,4 +82,16 @@ def config_edit(config_relative_path):
cls()
def cls():
os.system('cls' if os.name=='nt' else 'clear')
os.system('cls' if os.name=='nt' else 'clear')
def ping(base_url):
DNULL = open(os.devnull, 'w')
if os.name == 'nt':
status = subprocess.call(["ping","-n","1",base_url],stdout = DNULL)
else:
status = subprocess.call(["ping","-c","1",base_url],stdout = DNULL)
if status == 0:
return True
else:
return False