Skip to content

Commit 1bc9b4e

Browse files
committed
merged
2 parents e588721 + 951198a commit 1bc9b4e

File tree

1 file changed

+52
-4
lines changed

1 file changed

+52
-4
lines changed

bin/cli.py

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,51 @@
1313
import jmespath
1414
import yaml
1515

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+
1628
from hpecp import (
1729
APIException,
1830
APIItemConflictException,
1931
ContainerPlatformClient,
2032
ContainerPlatformClientException,
2133
)
22-
from hpecp.gateway import Gateway, GatewayStatus
23-
from hpecp.k8s_cluster import K8sClusterHostConfig, K8sClusterStatus
2434
from hpecp.k8s_worker import WorkerK8sStatus
2535

2636
if sys.version_info[0] >= 3:
2737
unicode = str
2838

39+
_log = Logger().get_logger(__file__)
40+
2941
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+
)
3161

3262

3363
def get_client():
@@ -797,7 +827,24 @@ def create(
797827
print("User already exists.")
798828
sys.exit(1)
799829

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)
801848

802849

803850
class AutoComplete:
@@ -975,6 +1022,7 @@ def __init__(self,):
9751022
self.lock = LockProxy()
9761023
self.license = LicenseProxy()
9771024
self.httpclient = HttpClientProxy()
1025+
self.user = UserProxy()
9781026
self.autocomplete = AutoComplete()
9791027
self.configure_cli = configure_cli
9801028

0 commit comments

Comments
 (0)