mirror of
https://github.com/ansible/awx.git
synced 2026-03-07 19:51:08 -03:30
Add primary and secondary IP output to ping view.
This commit is contained in:
@@ -130,11 +130,32 @@ class ApiV1PingView(APIView):
|
|||||||
Everything returned here should be considered public / insecure, as
|
Everything returned here should be considered public / insecure, as
|
||||||
this requires no auth and is intended for use by the installer process.
|
this requires no auth and is intended for use by the installer process.
|
||||||
"""
|
"""
|
||||||
return Response({
|
# Most of this response is canned; just build the dictionary.
|
||||||
|
response = {
|
||||||
'ha': is_ha_environment(),
|
'ha': is_ha_environment(),
|
||||||
'role': Instance.objects.my_role(),
|
'role': Instance.objects.my_role(),
|
||||||
'version': get_awx_version(),
|
'version': get_awx_version(),
|
||||||
})
|
}
|
||||||
|
|
||||||
|
# If this is an HA environment, we also include the IP address of
|
||||||
|
# all of the instances.
|
||||||
|
#
|
||||||
|
# Set up a default structure.
|
||||||
|
response['instances'] = {
|
||||||
|
'primary': None,
|
||||||
|
'secondaries': [],
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add all of the instances into the structure.
|
||||||
|
for instance in Instance.objects.all():
|
||||||
|
if instance.primary:
|
||||||
|
response['instances']['primary'] = instance.ip_address
|
||||||
|
else:
|
||||||
|
response['instances']['secondaries'].append(instance.ip_address)
|
||||||
|
response['instances']['secondaries'].sort()
|
||||||
|
|
||||||
|
# Done; return the response.
|
||||||
|
return Response(response)
|
||||||
|
|
||||||
|
|
||||||
class ApiV1ConfigView(APIView):
|
class ApiV1ConfigView(APIView):
|
||||||
|
|||||||
Reference in New Issue
Block a user