Integrations/AzureCompute_v2/AzureCompute_v2.py
def validate_provisioning_state(args):
    """
    Ensure that the provisioning state of a VM is 'Succeeded'

    For all provisioning states other than 'Succeeded', this method will raise an
    exception with an informative error message.

    parameter: (dict) args
        The command arguments passed to either the `azure-vm-start-instance` or
        `azure-vm-poweroff-instance` commands

    returns:
        None
    """
    response = get_vm(args)
    # Retrieve relevant properties for checking provisioning state and returning
    # informative error messages if necessary
    vm_name = response.get('name')
    properties = response.get('properties')
    provisioning_state = properties.get('provisioningState')
    statuses = properties.get('instanceView', {}).get('statuses')

    # Check if the current ProvisioningState of the VM allows for executing this command
    if provisioning_state.lower() == 'failed':
        for status in statuses:
            status_code = status.get('code')
            if 'provisioningstate/failed' in status_code.lower():
                message = status.get('message')
                err_msg = PROVISIONING_STATE_TO_ERRORS.get('failed')
                raise Exception(err_msg.format(vm_name, status_code, message))  # type: ignore
        # In the case that the microsoft API changes and the status code is no longer
        # relevant, preventing the above exception with its detailed error message from
        # being raised, then raise the below exception with a more general error message
        err_msg = 'Cannot execute this command because the ProvisioningState of the VM is \'Failed\'.'
        raise Exception(err_msg)
    elif provisioning_state.lower() in PROVISIONING_STATE_TO_ERRORS.keys():
        err_msg = PROVISIONING_STATE_TO_ERRORS.get(provisioning_state.lower())
        raise Exception(err_msg)

    Ensure that the provisioning state of a VM is 'Succeeded'

    For all provisioning states other than 'Succeeded', this method will raise an
    exception with an informative error message.

    parameter: (dict) args
        The command arguments passed to either the `azure-vm-start-instance` or
        `azure-vm-poweroff-instance` commands

    returns:
        None
    
Ensure that the provisioning state of a VM is 'Succeeded'
For all provisioning states other than 'Succeeded', this method will raise an
exception with an informative error message.



None
Ensure that the provisioning state of a VM is ' Succeeded ' For all provisioning states other than ' Succeeded ' this method will raise an exception with an informative error message . None
def validate_provisioning_state(args):
    response = get_vm(args)
    vm_name = response.get('name')
    properties = response.get('properties')
    provisioning_state = properties.get('provisioningState')
    statuses = properties.get('instanceView', {}).get('statuses')
    if provisioning_state.lower() == 'failed':
        for status in statuses:
            status_code = status.get('code')
            if 'provisioningstate/failed' in status_code.lower():
                message = status.get('message')
                err_msg = PROVISIONING_STATE_TO_ERRORS.get('failed')
                raise Exception(err_msg.format(vm_name, status_code, message))  
        err_msg = 'Cannot execute this command because the ProvisioningState of the VM is \'Failed\'.'
        raise Exception(err_msg)
    elif provisioning_state.lower() in PROVISIONING_STATE_TO_ERRORS.keys():
        err_msg = PROVISIONING_STATE_TO_ERRORS.get(provisioning_state.lower())
        raise Exception(err_msg)
def validate_provisioning_state ( args ) : response = get_vm ( args ) vm_name = response . get ( 'name' ) properties = response . get ( 'properties' ) provisioning_state = properties . get ( 'provisioningState' ) statuses = properties . get ( 'instanceView' , { } ) . get ( 'statuses' ) if provisioning_state . lower ( ) == 'failed' : for status in statuses : status_code = status . get ( 'code' ) if 'provisioningstate/failed' in status_code . lower ( ) : message = status . get ( 'message' ) err_msg = PROVISIONING_STATE_TO_ERRORS . get ( 'failed' ) raise Exception ( err_msg . format ( vm_name , status_code , message ) ) err_msg = 'Cannot execute this command because the ProvisioningState of the VM is \'Failed\'.' raise Exception ( err_msg ) elif provisioning_state . lower ( ) in PROVISIONING_STATE_TO_ERRORS . keys ( ) : err_msg = PROVISIONING_STATE_TO_ERRORS . get ( provisioning_state . lower ( ) ) raise Exception ( err_msg )
Ensure that the provisioning state of a VM is 'Succeeded'
For all provisioning states other than 'Succeeded', this method will raise an
exception with an informative error message.
Ensure that the provisioning state of a VM is ' Succeeded ' For all provisioning states other than ' Succeeded ' this method will raise an exception with an informative error message .
"""
    Ensure that the provisioning state of a VM is 'Succeeded'

    For all provisioning states other than 'Succeeded', this method will raise an
    exception with an informative error message.

    parameter: (dict) args
        The command arguments passed to either the `azure-vm-start-instance` or
        `azure-vm-poweroff-instance` commands

    returns:
        None
    """ # Retrieve relevant properties for checking provisioning state and returning # informative error messages if necessary # Check if the current ProvisioningState of the VM allows for executing this command # type: ignore # In the case that the microsoft API changes and the status code is no longer # relevant, preventing the above exception with its detailed error message from # being raised, then raise the below exception with a more general error message
args