diff --git a/aztk_cli/utils.py b/aztk_cli/utils.py index 55a6d949..e3d6521b 100644 --- a/aztk_cli/utils.py +++ b/aztk_cli/utils.py @@ -42,6 +42,11 @@ def get_ssh_key_or_prompt(ssh_key, username, password, secrets_configuration): return ssh_key, password +def format_datetime(datetime, include_seconds=True): + format = '%Y-%m-%d %H:%M' + (':%S' if include_seconds else '') + return datetime.strftime(format) + + def print_cluster(client, cluster: models.Cluster, internal: bool = False): node_count = __pretty_node_count(cluster) @@ -50,6 +55,7 @@ def print_cluster(client, cluster: models.Cluster, internal: bool = False): log.info("------------------------------------------") log.info("State: %s", cluster.state.value) log.info("Node Size: %s", cluster.vm_size) + log.info("Created: %s", format_datetime(cluster.pool.creation_time)) log.info("Nodes: %s", node_count) log.info("| Dedicated: %s", __pretty_dedicated_node_count(cluster)) 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: def print_clusters(clusters: List[models.Cluster]): - print_format = "{:<34}| {:<10}| {:<20}| {:<7}" - print_format_underline = "{:-<34}|{:-<11}|{:-<21}|{:-<7}" + print_format = "{:<34}| {:<10}| {:<20}| {:<7}| {:<16}" + print_format_underline = "{:-<34}|{:-<11}|{:-<21}|{:-<8}|{:-<17}" - log.info(print_format.format("Cluster", "State", "VM Size", "Nodes")) - log.info(print_format_underline.format("", "", "", "")) + log.info(print_format.format("Cluster", "State", "VM Size", "Nodes", "Created")) + log.info(print_format_underline.format("", "", "", "", "")) for cluster in clusters: node_count = __pretty_node_count(cluster) - log.info(print_format.format(cluster.id, cluster.state.value, cluster.vm_size, node_count)) + log.info( + print_format.format(cluster.id, cluster.state.value, cluster.vm_size, node_count, + format_datetime(cluster.pool.creation_time, False))) def print_clusters_quiet(clusters: List[models.Cluster]):