def get_vm_state(uid, context):
    """
    See nova/compute/vm_states.py nova/compute/task_states.py

    Mapping assumptions:
    - active == VM can service requests from network. These requests
            can be from users or VMs
    - inactive == the oppose! :-)
    - suspended == machine in a frozen state e.g. via suspend or pause

    uid -- Id of the VM.
    context -- the os context.
    """
    instance = get_vm(uid, context)
    state = 'inactive'
    actions = []

    if instance['vm_state'] in [vm_states.ACTIVE]:
        state = 'active'
        actions.append(infrastructure.STOP)
        actions.append(infrastructure.SUSPEND)
        actions.append(infrastructure.RESTART)
    elif instance['vm_state'] in [vm_states.BUILDING]:
        state = 'inactive'
    elif instance['vm_state'] in [vm_states.PAUSED, vm_states.SUSPENDED,
                                  vm_states.STOPPED]:
        state = 'inactive'
        actions.append(infrastructure.START)
    elif instance['vm_state'] in [vm_states.RESCUED,
                                  vm_states.ERROR,
                                  vm_states.DELETED]:
        state = 'inactive'

    # Some task states require a state
    if instance['vm_state'] in [task_states.IMAGE_SNAPSHOT]:
        state = 'inactive'
        actions = []

    return state, actions

# Image management
dataset/ETHPy150Open tmetsch/occi-os/occi_os_api/nova_glue/vm.py/get_vm_state/original