Create an image from a terminated host (with auto_delete_boot_disk=False)

    Args:
        name: The name of the image

def terminate_and_create_image(name):
    '''
    Create an image from a terminated host (with auto_delete_boot_disk=False)

    Args:
        name: The name of the image
    '''
    node = _host_node()
    operation = _gcp().instances().delete(project=DEFAULT_PROJECT, zone=DEFAULT_ZONE,
                                          instance=node['real_name']).execute()
    while True:
        status = get_zone_operation_status(operation=operation)
        if status == 'DONE':
            break

        print 'Terminating instance [OPERATION %s]' % status
        time.sleep(5)

    body = {
        'name': name,
        'sourceDisk': node['source_disk'],
    }

    operation = _gcp().images().insert(project=DEFAULT_PROJECT, body=body).execute()
    while True:
        status = get_global_operation_status(operation=operation)
        if status == 'DONE':
            break

        print 'Creating image [OPERATION %s]' % status
        time.sleep(5)

    print 'Created image: %s' % operation['targetLink']