Loading client/Dockerfile +1 −1 Original line number Diff line number Diff line Loading @@ -21,4 +21,4 @@ USER client WORKDIR /home/client/ # Install python dependencies RUN pip3.9 install --no-cache-dir pika RUN pip3.9 install --no-cache-dir pika tabulate client/vos_data +12 −5 Original line number Diff line number Diff line Loading @@ -5,6 +5,8 @@ import uuid import json import sys from tabulate import tabulate class AMQPClient(object): Loading Loading @@ -71,14 +73,19 @@ DESCRIPTION sys.exit("FATAL: Malformed response, storage acknowledge expected.\n") elif storeResponse["responseType"] == "STORE_ACK": storageList = storeResponse["storageList"] print("Choose one of the following storage locations:\n") print("----------------------------------------------------------------------") if not storageList: sys.exit("No storage point found. Please add a storage point using the 'vos_storage' command.") print("Choose one of the following storage locations:") print() print(tabulate(storageList, headers = "keys", tablefmt = "pretty")) print() #print("----------------------------------------------------------------------") storageIdList = [] for st in storageList: storageIdList.append(st["storage_id"]) print("[*] storage_id: {:<2d} => hostname: {}".format(st['storage_id'], st['hostname'])) #print("[*] storage_id: {:<2d} => hostname: {}".format(st['storage_id'], st['hostname'])) storageId = None print("----------------------------------------------------------------------\n") #print("----------------------------------------------------------------------\n") while not storageId in storageIdList: try: storageId = input("Please, insert a storage id: ") Loading Loading @@ -122,7 +129,7 @@ DESCRIPTION elif storeResponse["responseType"] == "ERROR": errorCode = storeResponse["errorCode"] errorMsg = storeResponse["errorMsg"] sys.exit(f"Error code: {errorCode}, Error message: {errorMsg}\n") sys.exit(f"Error code: {errorCode}\nError message: {errorMsg}\n") else: sys.exit("\nFATAL: Unknown response type.\n") Loading client/vos_storage +24 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,8 @@ import json import os import sys from tabulate import tabulate class AMQPClient(object): Loading Loading @@ -81,6 +83,23 @@ class AMQPClient(object): else: sys.exit("\nFATAL: Unknown response type.\n") def list(self): storageRequest = { "requestType": "STORAGE_LST" } storageResponse = self.call(storageRequest) if "responseType" not in storageResponse: sys.exit("FATAL: Malformed response, storage acknowledge expected.\n") elif storageResponse["responseType"] == "STORAGE_LST_DONE": print() print(tabulate(storageResponse["storageList"], headers = "keys", tablefmt = "pretty")) print() elif storageResponse["responseType"] == "ERROR": errorCode = storageResponse["errorCode"] errorMsg = storageResponse["errorMsg"] sys.exit(f"\nError code: {errorCode}\nError message: {errorMsg}\n") else: sys.exit("\nFATAL: Unknown response type.\n") def help(self): sys.exit(""" NAME Loading @@ -97,6 +116,9 @@ DESCRIPTION add adds a storage point to the database. list prints the storage points list. """) # Create new AMQPClient object Loading @@ -110,5 +132,7 @@ else: if cmd == "add": vosStorageCli.add() elif cmd == "list": vosStorageCli.list() else: vosStorageCli.help() Loading
client/Dockerfile +1 −1 Original line number Diff line number Diff line Loading @@ -21,4 +21,4 @@ USER client WORKDIR /home/client/ # Install python dependencies RUN pip3.9 install --no-cache-dir pika RUN pip3.9 install --no-cache-dir pika tabulate
client/vos_data +12 −5 Original line number Diff line number Diff line Loading @@ -5,6 +5,8 @@ import uuid import json import sys from tabulate import tabulate class AMQPClient(object): Loading Loading @@ -71,14 +73,19 @@ DESCRIPTION sys.exit("FATAL: Malformed response, storage acknowledge expected.\n") elif storeResponse["responseType"] == "STORE_ACK": storageList = storeResponse["storageList"] print("Choose one of the following storage locations:\n") print("----------------------------------------------------------------------") if not storageList: sys.exit("No storage point found. Please add a storage point using the 'vos_storage' command.") print("Choose one of the following storage locations:") print() print(tabulate(storageList, headers = "keys", tablefmt = "pretty")) print() #print("----------------------------------------------------------------------") storageIdList = [] for st in storageList: storageIdList.append(st["storage_id"]) print("[*] storage_id: {:<2d} => hostname: {}".format(st['storage_id'], st['hostname'])) #print("[*] storage_id: {:<2d} => hostname: {}".format(st['storage_id'], st['hostname'])) storageId = None print("----------------------------------------------------------------------\n") #print("----------------------------------------------------------------------\n") while not storageId in storageIdList: try: storageId = input("Please, insert a storage id: ") Loading Loading @@ -122,7 +129,7 @@ DESCRIPTION elif storeResponse["responseType"] == "ERROR": errorCode = storeResponse["errorCode"] errorMsg = storeResponse["errorMsg"] sys.exit(f"Error code: {errorCode}, Error message: {errorMsg}\n") sys.exit(f"Error code: {errorCode}\nError message: {errorMsg}\n") else: sys.exit("\nFATAL: Unknown response type.\n") Loading
client/vos_storage +24 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,8 @@ import json import os import sys from tabulate import tabulate class AMQPClient(object): Loading Loading @@ -81,6 +83,23 @@ class AMQPClient(object): else: sys.exit("\nFATAL: Unknown response type.\n") def list(self): storageRequest = { "requestType": "STORAGE_LST" } storageResponse = self.call(storageRequest) if "responseType" not in storageResponse: sys.exit("FATAL: Malformed response, storage acknowledge expected.\n") elif storageResponse["responseType"] == "STORAGE_LST_DONE": print() print(tabulate(storageResponse["storageList"], headers = "keys", tablefmt = "pretty")) print() elif storageResponse["responseType"] == "ERROR": errorCode = storageResponse["errorCode"] errorMsg = storageResponse["errorMsg"] sys.exit(f"\nError code: {errorCode}\nError message: {errorMsg}\n") else: sys.exit("\nFATAL: Unknown response type.\n") def help(self): sys.exit(""" NAME Loading @@ -97,6 +116,9 @@ DESCRIPTION add adds a storage point to the database. list prints the storage points list. """) # Create new AMQPClient object Loading @@ -110,5 +132,7 @@ else: if cmd == "add": vosStorageCli.add() elif cmd == "list": vosStorageCli.list() else: vosStorageCli.help()