diff --git a/README.md b/README.md index 2aee0ea..29439fc 100644 --- a/README.md +++ b/README.md @@ -7,18 +7,31 @@ _For now, this utility is focused on managing virtual disks_ _Works with SpaceVM 6.5.5+_ -# Config File +# Utility usage +Clone repository or use compiled .exe + +Config file is essential for the utility. + +## Config File Config file contains all necessary data for utility and has to be placed in the same directory as Utility itself. +The following parameters are required: +``` +1. Controller IP Address (Master) +2. API Integration Key +3. Data Pool UUID (which will be used for operations) +4. Virtual Machine UUID (List of selected VMs for operations) +5. Virtual Machine UUID +6. ... +``` + You can populate config within Utility Main Menu. For manual input see format below: ``` -Controller IP Address -API Integration Key -Data Pool UUID -VM UUID #1 -VM UUID #2 -VM UUID #3 -... +1.2.3.4 +eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ1... +67497424-e54b-46f1-b023-4d6d65eac104 +304fd7be-06a6-4f4e-9bb9-41bf532ec4fb +f840320f-cecc-4a31-a799-fd84e7baf089 ``` diff --git a/main.py b/main.py index ce06db7..06f6fe6 100644 --- a/main.py +++ b/main.py @@ -31,18 +31,21 @@ def config_edit(): while (vm_input != ""): vm_input = input(">> ") file.write(vm_input + '\n') - + print("UUIDs has been written in config") + print("\nConfiguration completed!") if os.path.exists(config_relative_path) and os.path.getsize(config_relative_path) > 0: #check if file exists and not empty -#importing API-KEY / IP / DATA POOL UUID from config - with open(config_relative_path, "r") as f: # using '\' (instead of '\\') throws syntax warning - all_lines = f.readlines() - base_url = all_lines[0].strip('\n') - api_key = "jwt " + all_lines[1].strip('\n') #actual format for api_key. That was realy obvious DACOM >:C - data_pool_uuid = all_lines[2].strip('\n') + pass #do nothing else: print("Config file was not found or empty.. ") config_edit() - + +#importing API-KEY / IP / DATA POOL UUID from config +with open(config_relative_path, "r") as f: + all_lines = f.readlines() + base_url = all_lines[0].strip('\n') + api_key = "jwt " + all_lines[1].strip('\n') #actual format for api_key. That was realy obvious DACOM >:C + data_pool_uuid = all_lines[2].strip('\n') + #importing VM-UUIDs vm_uuids = [] with open(config_relative_path, "r") as f: @@ -57,13 +60,22 @@ with open(config_relative_path, "r") as f: #so-called INT MAIN menu_choice=0 while(menu_choice != ""): #main menu loop - read_input=input("\nUitility Main Menu: \n1) Edit config \n2) Enter disk edit mode \n3) Show breif cluster overview \n4) Show VM info \n>>> ") + read_input=input("\nUitility Main Menu: \n1) Manage utility config \n2) Enter disk edit mode \n3) Show breif cluster overview \n4) Show VM info \n>>> ") menu_choice=str(read_input) if menu_choice == "1": - config_edit() - if menu_choice == "2": print("\033[H\033[2J", end="") # clears cmd screen, but saves scrollback buffer + print("1) Show current configuration \n2) Change configuraion") + read_input=input(">> ") + menu_choice=int(read_input) + if menu_choice == 1: + print("Current configuration:\n") + with open(config_relative_path, "r") as f: + print(f.read()) + if menu_choice == 2: + config_edit() + if menu_choice == "2": + print("\033[H\033[2J", end="") print("Select option: \n 1) Delete vDisk by UUID \n 2) Delete ALL vDisks on selected Virtual Machine \n 3) Create Disk \n 4) Prepare VMs for Courses™") read_input=input(">> ") menu_choice=int(read_input)