• Uncategorized

About python : Extract-data-from-terminal-command-duplicate

Question Detail

I am doing a query:

az aks nodepool show \                                                                  ⎈ 
                --resource-group $RESOURCE_GROUP_NAME \
                --cluster-name $CLUSTER_NAME \
                --name $NODE_POOL_NAME -o table

I get output with a table name ProvisiongState. I need some help to gather that result from that query into a variable, so that I can run checks on it until it turns from UpgradingNodeImageVersion to Succeeded. I was thinking of doing this as a shell script or maybe Python program.

Table I need to get info from:

Thank you!

EDIT: I used this command to get what I needed. Thank you all for the help!

az aks nodepool show --resource-group $RESOURCE_GROUP_NAME --cluster-name $CLUSTER_NAME --name $NODE_POOL_NAME | grep "\"provisioningState\": \"Succeeded\""

Question Answer

az aks nodepool show \                                                                  
                --resource-group $RESOURCE_GROUP_NAME \
                --cluster-name $CLUSTER_NAME \
                --name $NODE_POOL_NAME -o table |
    grep -q UpgradingNodeImageVersion && echo Not done || echo Done

Or

az aks nodepool show \                                                                  
                --resource-group $RESOURCE_GROUP_NAME \
                --cluster-name $CLUSTER_NAME \
                --name $NODE_POOL_NAME -o table |
    grep -q Succeeded && echo Done || echo Not done

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.