mirror of
https://github.com/ansible/awx.git
synced 2026-04-05 01:59:25 -02:30
Attempt to deal with foreign keys that get mislabeled as type integer
such as through the use of DeprecatedCredentialField.
This commit is contained in:
@@ -266,13 +266,14 @@ class ApiV2(base.Base):
|
|||||||
for field, value in asset.items():
|
for field, value in asset.items():
|
||||||
if field not in options:
|
if field not in options:
|
||||||
continue
|
continue
|
||||||
if options[field]['type'] == 'id':
|
if options[field]['type'] in ('id', 'integer') and isinstance(value, dict):
|
||||||
page = self._get_by_natural_key(value)
|
page = self._get_by_natural_key(value)
|
||||||
post_data[field] = page['id'] if page is not None else None
|
post_data[field] = page['id'] if page is not None else None
|
||||||
else:
|
else:
|
||||||
post_data[field] = value
|
post_data[field] = value
|
||||||
|
|
||||||
page = self._get_by_natural_key(asset['natural_key'], fetch=False)
|
page = self._get_by_natural_key(asset['natural_key'], fetch=False)
|
||||||
|
try:
|
||||||
if page is None:
|
if page is None:
|
||||||
if resource == 'users':
|
if resource == 'users':
|
||||||
# We should only impose a default password if the resource doesn't exist.
|
# We should only impose a default password if the resource doesn't exist.
|
||||||
@@ -280,6 +281,9 @@ class ApiV2(base.Base):
|
|||||||
page = endpoint.post(post_data)
|
page = endpoint.post(post_data)
|
||||||
else:
|
else:
|
||||||
page = page.put(post_data)
|
page = page.put(post_data)
|
||||||
|
except exc.Common:
|
||||||
|
log.exception("post_data: %r", post_data)
|
||||||
|
raise
|
||||||
|
|
||||||
self._register_page(page)
|
self._register_page(page)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user