|
13 | 13 | import jmespath
|
14 | 14 | import yaml
|
15 | 15 |
|
| 16 | +from hpecp.logger import Logger |
| 17 | + |
| 18 | +from hpecp.gateway import ( |
| 19 | + Gateway, |
| 20 | + GatewayStatus, |
| 21 | +) |
| 22 | +from hpecp.k8s_cluster import ( |
| 23 | + K8sClusterHostConfig, |
| 24 | + K8sClusterStatus, |
| 25 | +) |
| 26 | +from hpecp.user import User |
| 27 | + |
16 | 28 | from hpecp import (
|
17 | 29 | APIException,
|
18 | 30 | APIItemConflictException,
|
19 | 31 | ContainerPlatformClient,
|
20 | 32 | ContainerPlatformClientException,
|
21 | 33 | )
|
22 |
| -from hpecp.gateway import Gateway, GatewayStatus |
23 |
| -from hpecp.k8s_cluster import K8sClusterHostConfig, K8sClusterStatus |
24 | 34 | from hpecp.k8s_worker import WorkerK8sStatus
|
25 | 35 |
|
26 | 36 | if sys.version_info[0] >= 3:
|
27 | 37 | unicode = str
|
28 | 38 |
|
| 39 | +_log = Logger().get_logger(__file__) |
| 40 | + |
29 | 41 | PROFILE = os.getenv("PROFILE", "default",)
|
30 |
| -HPECP_CONFIG_FILE = os.getenv("HPECP_CONFIG_FILE", "~/.hpecp.conf",) |
| 42 | + |
| 43 | +_log.debug( |
| 44 | + "PROFILE envirionment variable exists with value '{}'".format(PROFILE) |
| 45 | +) |
| 46 | + |
| 47 | +if "HPECP_CONFIG_FILE" in os.environ: |
| 48 | + HPECP_CONFIG_FILE = os.getenv("HPECP_CONFIG_FILE") |
| 49 | + _log.debug( |
| 50 | + "HPECP_CONFIG_FILE envirionment variable exists with value '{}'".format( |
| 51 | + HPECP_CONFIG_FILE |
| 52 | + ) |
| 53 | + ) |
| 54 | +else: |
| 55 | + HPECP_CONFIG_FILE = "~/.hpecp.conf" |
| 56 | + _log.debug( |
| 57 | + "HPECP_CONFIG_FILE envirionment variable not found, setting to '{}'".format( |
| 58 | + HPECP_CONFIG_FILE |
| 59 | + ) |
| 60 | + ) |
31 | 61 |
|
32 | 62 |
|
33 | 63 | def get_client():
|
@@ -797,7 +827,24 @@ def create(
|
797 | 827 | print("User already exists.")
|
798 | 828 | sys.exit(1)
|
799 | 829 |
|
800 |
| - # raise NotImplementedError |
| 830 | + def list( |
| 831 | + self, output="table", columns=User.default_display_fields, |
| 832 | + ): |
| 833 | + """Retrieve the list of Users |
| 834 | + :param output: how to display the output [text|table|json] |
| 835 | + """ |
| 836 | + if output == "table": |
| 837 | + print(get_client().user.list().tabulate(columns=columns)) |
| 838 | + elif output == "text": |
| 839 | + print( |
| 840 | + get_client() |
| 841 | + .user.list() |
| 842 | + .tabulate( |
| 843 | + columns=columns, style="plain", display_headers=False, |
| 844 | + ) |
| 845 | + ) |
| 846 | + else: |
| 847 | + print(get_client().user.list().json) |
801 | 848 |
|
802 | 849 |
|
803 | 850 | class AutoComplete:
|
@@ -975,6 +1022,7 @@ def __init__(self,):
|
975 | 1022 | self.lock = LockProxy()
|
976 | 1023 | self.license = LicenseProxy()
|
977 | 1024 | self.httpclient = HttpClientProxy()
|
| 1025 | + self.user = UserProxy() |
978 | 1026 | self.autocomplete = AutoComplete()
|
979 | 1027 | self.configure_cli = configure_cli
|
980 | 1028 |
|
|
0 commit comments