You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by di...@apache.org on 2022/12/21 07:47:48 UTC

[airavata-mft] branch master updated: Listing storages through python CLI

This is an automated email from the ASF dual-hosted git repository.

dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-mft.git


The following commit(s) were added to refs/heads/master by this push:
     new 27b9d68  Listing storages through python CLI
27b9d68 is described below

commit 27b9d6871758428fe634a95e712a94ba1aefacb0
Author: Dimuthu Wannipurage <di...@gmail.com>
AuthorDate: Wed Dec 21 02:47:39 2022 -0500

    Listing storages through python CLI
---
 python-cli/mft_cli/mft_cli/storage/__init__.py | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/python-cli/mft_cli/mft_cli/storage/__init__.py b/python-cli/mft_cli/mft_cli/storage/__init__.py
index 70067e3..51fbdac 100644
--- a/python-cli/mft_cli/mft_cli/storage/__init__.py
+++ b/python-cli/mft_cli/mft_cli/storage/__init__.py
@@ -1,6 +1,10 @@
 import typer
 from pick import pick
 import mft_cli.storage.s3 as s3
+from airavata_mft_sdk import mft_client
+from airavata_mft_sdk.common import StorageCommon_pb2
+from rich.console import Console
+from rich.table import Table
 
 app = typer.Typer()
 
@@ -15,4 +19,21 @@ def add_storage():
 
 @app.command("list")
 def list_storage():
-    print("Listing storages")
+    client = mft_client.MFTClient()
+    list_req = StorageCommon_pb2.StorageListRequest()
+    list_response = client.common_api.listStorages(list_req)
+
+    console = Console()
+    table = Table(show_header=True, header_style='bold #2070b2')
+
+    table.add_column('Storage Name', justify='left')
+    table.add_column('Type', justify='center')
+    table.add_column('Storage ID', justify='center')
+
+    for storage in list_response.storageList:
+
+        table.add_row('[bold]' + storage.storageName + '[/bold]',
+                      StorageCommon_pb2.StorageType.Name(storage.storageType),
+                      storage.storageId)
+
+    console.print(table)
\ No newline at end of file