def get(self, request, format=None): """Return some basic information about this instance Everything returned here should be considered public / insecure, as this requires no auth and is intended for use by the installer process. """ response = { 'ha': is_ha_environment(), 'version': get_awx_version(), 'active_node': settings.CLUSTER_HOST_ID, 'install_uuid': settings.INSTALL_UUID, } response['instances'] = [] for instance in Instance.objects.all(): response['instances'].append( dict(node=instance.hostname, uuid=instance.uuid, heartbeat=instance.modified, capacity=instance.capacity, version=instance.version)) sorted(response['instances'], key=operator.itemgetter('node')) response['instance_groups'] = [] for instance_group in InstanceGroup.objects.prefetch_related( 'instances'): response['instance_groups'].append( dict(name=instance_group.name, capacity=instance_group.capacity, instances=[ x.hostname for x in instance_group.instances.all() ])) return Response(response)
def test_db_localhost(): assert is_ha_environment() is False
def test_multiple_instances(): for i in range(2): Instance.objects.create(hostname=f'foo{i}', node_type='hybrid') assert is_ha_environment()
def test_multiple_instances(): assert is_ha_environment()
def test_db_localhost(): Instance.objects.create(hostname='foo', node_type='hybrid') Instance.objects.create(hostname='bar', node_type='execution') assert is_ha_environment() is False