def update_resources(module, p):
    params = p.copy()
    identity_map = {'project': 'name', 'inventory': 'name', 'credential': 'name', 'vault_credential': 'name'}
    for (k, v) in identity_map.items():
        try:
            if params[k]:
                key = ('credential' if ('_credential' in k) else k)
                result = tower_cli.get_resource(key).get(**{v: params[k]})
                params[k] = result['id']
            elif (k in params):
                del params[k]
        except exc.NotFound as excinfo:
            module.fail_json(msg='Failed to update job template: {0}'.format(excinfo), changed=False)
    return params
def update_resources(module, p):
    params = p.copy()
    identity_map = {'project': 'name', 'inventory': 'name', 'credential': 'name', 'vault_credential': 'name'}
    for (k, v) in identity_map.items():
        try:
            if params[k]:
                key = ('credential' if ('_credential' in k) else k)
                result = tower_cli.get_resource(key).get(**{v: params[k]})
                params[k] = result['id']
            elif (k in params):
                del params[k]
        except exc.NotFound as excinfo:
            module.fail_json(msg='Failed to update job template: {0}'.format(excinfo), changed=False)
    return params