Skip to content
Merged
31 changes: 26 additions & 5 deletions src/azure-cli/azure/cli/command_modules/acs/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,36 @@ def aks_machine_list_table_format(results):
return [aks_machine_show_table_format(r) for r in results]


def aks_machine_show_table_format(result):
def parser(entry):
def aks_machine_show_table_format(result: dict):
def parser(entry: dict):
ip_addresses = ""
for k in entry["properties"]["network"]["ipAddresses"]:
ip_addresses += "ip:" + k["ip"] + "," + "family:" + k["family"] + ";"
zones = ""
if "zones" in entry and entry["zones"]:
zones_data = entry["zones"]
if isinstance(zones_data, list):
zones = ', '.join(part.strip() for part in zones_data if part and part.strip())
elif isinstance(zones_data, str):
zones = zones_data.strip()
# If no zones at top-level, check in properties
elif "properties" in entry and "zones" in entry["properties"] and entry["properties"]["zones"]:
zones_data = entry["properties"]["zones"]
if isinstance(zones_data, list):
zones = ', '.join(part.strip() for part in zones_data if part and part.strip())
elif isinstance(zones_data, str):
zones = zones_data.strip()
if "properties" in entry and isinstance(entry["properties"], dict):
if "network" in entry["properties"] and isinstance(entry["properties"]["network"], dict):
if ("ipAddresses" in entry["properties"]["network"] and
isinstance(entry["properties"]["network"]["ipAddresses"], list)):
for k in entry["properties"]["network"]["ipAddresses"]:
if isinstance(k, dict) and "ip" in k and "family" in k:
ip_addresses += f"ip:{k['ip']},family:{k['family']};"
entry["ip"] = ip_addresses
entry["zones"] = zones
parsed = compile_jmes("""{
name: name,
ip: ip
ip: ip,
zones: zones
}""")
return parsed.search(entry, Options(dict_cls=OrderedDict))
return parser(result)
Expand Down
10 changes: 5 additions & 5 deletions src/azure-cli/azure/cli/command_modules/acs/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2583,9 +2583,9 @@
- name: --nodepool-name
type: string
short-summary: Name of the agentpool of a managed cluster
exmaples:
- name: Get information about IP Addresses, Hostname for all machines in an agentpool
text: az aks machine list --cluster-name <clusterName> --nodepool-name <apName>
examples:
- name: Get information about IP Addresses, Hostname, Availability Zones for all machines in an agentpool
text: az aks machine list --resource-group <rg> --cluster-name <clusterName> --nodepool-name <apName>
"""
helps['aks machine show'] = """
type: command
Expand All @@ -2601,6 +2601,6 @@
type: string
short-summary: Name of the machine in the agentpool of a managed cluster
exmaples:
Comment thread
skuchipudi295 marked this conversation as resolved.
- name: Get IP Addresses, Hostname for a specific machine in an agentpool
text: az aks machine show --cluster-name <clusterName> --nodepool-name <apName> --machine-name <machineName>
- name: Get IP Addresses, Hostname, Availability Zones for a specific machine in an agentpool
text: az aks machine show --resource-group <rg> --cluster-name <clusterName> --nodepool-name <apName> --machine-name <machineName>
"""
Loading
Loading