def describe_item_request()

in ec2stack/providers/cloudstack/__init__.py [0:0]


def describe_item_request(args, keyname, not_found):
    """
    Executes the request and searches the Cloudstack response for the item.

    @param args: Arguments involved in the request.
    @param keyname: Keyname of the Cloudstack response.
    @param not_found: Function to call if the item is not found.
    @return: Response.
    """
    request = describe_items_request(args, not_found)
    request = request[keyname]

    for item in request:
        if 'id' in args and args['id'].lower() == item['id'].lower():
            return item
        elif 'name' in args and args['name'].lower() == item['name'].lower():
            return item

    return not_found()