Skip to content
This repository was archived by the owner on Feb 3, 2021. It is now read-only.

Commit a0bc2f0

Browse files
emlynjafreck
authored andcommitted
Feature: Include cluster creation time in cluster list and cluster get output (#678)
* Include cluster creation time in cluster list and info * Make helper function for formatting * Make yapf happy
1 parent 385040d commit a0bc2f0

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

aztk_cli/utils.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ def get_ssh_key_or_prompt(ssh_key, username, password, secrets_configuration):
4242
return ssh_key, password
4343

4444

45+
def format_datetime(datetime, include_seconds=True):
46+
format = '%Y-%m-%d %H:%M' + (':%S' if include_seconds else '')
47+
return datetime.strftime(format)
48+
49+
4550
def print_cluster(client, cluster: models.Cluster, internal: bool = False):
4651
node_count = __pretty_node_count(cluster)
4752

@@ -50,6 +55,7 @@ def print_cluster(client, cluster: models.Cluster, internal: bool = False):
5055
log.info("------------------------------------------")
5156
log.info("State: %s", cluster.state.value)
5257
log.info("Node Size: %s", cluster.vm_size)
58+
log.info("Created: %s", format_datetime(cluster.pool.creation_time))
5359
log.info("Nodes: %s", node_count)
5460
log.info("| Dedicated: %s", __pretty_dedicated_node_count(cluster))
5561
log.info("| Low priority: %s", __pretty_low_pri_node_count(cluster))
@@ -106,15 +112,17 @@ def __pretty_low_pri_node_count(cluster: models.Cluster) -> str:
106112

107113

108114
def print_clusters(clusters: List[models.Cluster]):
109-
print_format = "{:<34}| {:<10}| {:<20}| {:<7}"
110-
print_format_underline = "{:-<34}|{:-<11}|{:-<21}|{:-<7}"
115+
print_format = "{:<34}| {:<10}| {:<20}| {:<7}| {:<16}"
116+
print_format_underline = "{:-<34}|{:-<11}|{:-<21}|{:-<8}|{:-<17}"
111117

112-
log.info(print_format.format("Cluster", "State", "VM Size", "Nodes"))
113-
log.info(print_format_underline.format("", "", "", ""))
118+
log.info(print_format.format("Cluster", "State", "VM Size", "Nodes", "Created"))
119+
log.info(print_format_underline.format("", "", "", "", ""))
114120
for cluster in clusters:
115121
node_count = __pretty_node_count(cluster)
116122

117-
log.info(print_format.format(cluster.id, cluster.state.value, cluster.vm_size, node_count))
123+
log.info(
124+
print_format.format(cluster.id, cluster.state.value, cluster.vm_size, node_count,
125+
format_datetime(cluster.pool.creation_time, False)))
118126

119127

120128
def print_clusters_quiet(clusters: List[models.Cluster]):

0 commit comments

Comments
 (0)