mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 07:26:03 -03:30
Merge pull request #11454 from AlexSCorey/ReceptorEndPoints
Creates end point and beginning of serializer for receptor mesh
This commit is contained in:
@@ -57,6 +57,7 @@ from awx.main.models import (
|
|||||||
Host,
|
Host,
|
||||||
Instance,
|
Instance,
|
||||||
InstanceGroup,
|
InstanceGroup,
|
||||||
|
InstanceLink,
|
||||||
Inventory,
|
Inventory,
|
||||||
InventorySource,
|
InventorySource,
|
||||||
InventoryUpdate,
|
InventoryUpdate,
|
||||||
@@ -4767,6 +4768,28 @@ class ScheduleSerializer(LaunchConfigurationBaseSerializer, SchedulePreviewSeria
|
|||||||
return super(ScheduleSerializer, self).validate(attrs)
|
return super(ScheduleSerializer, self).validate(attrs)
|
||||||
|
|
||||||
|
|
||||||
|
class InstanceLinkSerializer(BaseSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = InstanceLink
|
||||||
|
fields = ('source', 'target')
|
||||||
|
|
||||||
|
source = serializers.SlugRelatedField(slug_field="hostname", read_only=True)
|
||||||
|
target = serializers.SlugRelatedField(slug_field="hostname", read_only=True)
|
||||||
|
|
||||||
|
|
||||||
|
class InstanceNodeSerializer(BaseSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Instance
|
||||||
|
fields = ('id', 'hostname', 'node_type', 'node_state')
|
||||||
|
|
||||||
|
node_state = serializers.SerializerMethodField()
|
||||||
|
|
||||||
|
def get_node_state(self, obj):
|
||||||
|
if not obj.enabled:
|
||||||
|
return "disabled"
|
||||||
|
return "unhealthy" if obj.errors else "healthy"
|
||||||
|
|
||||||
|
|
||||||
class InstanceSerializer(BaseSerializer):
|
class InstanceSerializer(BaseSerializer):
|
||||||
|
|
||||||
consumed_capacity = serializers.SerializerMethodField()
|
consumed_capacity = serializers.SerializerMethodField()
|
||||||
|
|||||||
1
awx/api/templates/api/mesh_visualizer.md
Normal file
1
awx/api/templates/api/mesh_visualizer.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Make a GET request to this resource to obtain a list all Receptor Nodes and their links.
|
||||||
@@ -28,6 +28,7 @@ from awx.api.views import (
|
|||||||
OAuth2TokenList,
|
OAuth2TokenList,
|
||||||
ApplicationOAuth2TokenList,
|
ApplicationOAuth2TokenList,
|
||||||
OAuth2ApplicationDetail,
|
OAuth2ApplicationDetail,
|
||||||
|
MeshVisualizer,
|
||||||
)
|
)
|
||||||
|
|
||||||
from awx.api.views.metrics import MetricsView
|
from awx.api.views.metrics import MetricsView
|
||||||
@@ -95,6 +96,7 @@ v2_urls = [
|
|||||||
url(r'^me/$', UserMeList.as_view(), name='user_me_list'),
|
url(r'^me/$', UserMeList.as_view(), name='user_me_list'),
|
||||||
url(r'^dashboard/$', DashboardView.as_view(), name='dashboard_view'),
|
url(r'^dashboard/$', DashboardView.as_view(), name='dashboard_view'),
|
||||||
url(r'^dashboard/graphs/jobs/$', DashboardJobsGraphView.as_view(), name='dashboard_jobs_graph_view'),
|
url(r'^dashboard/graphs/jobs/$', DashboardJobsGraphView.as_view(), name='dashboard_jobs_graph_view'),
|
||||||
|
url(r'^mesh_visualizer/', MeshVisualizer.as_view(), name='mesh_visualizer_view'),
|
||||||
url(r'^settings/', include('awx.conf.urls')),
|
url(r'^settings/', include('awx.conf.urls')),
|
||||||
url(r'^instances/', include(instance_urls)),
|
url(r'^instances/', include(instance_urls)),
|
||||||
url(r'^instance_groups/', include(instance_group_urls)),
|
url(r'^instance_groups/', include(instance_group_urls)),
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ from awx.api.views.inventory import ( # noqa
|
|||||||
InventoryJobTemplateList,
|
InventoryJobTemplateList,
|
||||||
InventoryCopy,
|
InventoryCopy,
|
||||||
)
|
)
|
||||||
|
from awx.api.views.mesh_visualizer import MeshVisualizer # noqa
|
||||||
from awx.api.views.root import ( # noqa
|
from awx.api.views.root import ( # noqa
|
||||||
ApiRootView,
|
ApiRootView,
|
||||||
ApiOAuthAuthorizationRootView,
|
ApiOAuthAuthorizationRootView,
|
||||||
|
|||||||
23
awx/api/views/mesh_visualizer.py
Normal file
23
awx/api/views/mesh_visualizer.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Copyright (c) 2018 Red Hat, Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
|
||||||
|
from awx.main.models import InstanceLink, Instance
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from awx.api.generics import APIView, Response
|
||||||
|
|
||||||
|
from awx.api.serializers import InstanceLinkSerializer, InstanceNodeSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class MeshVisualizer(APIView):
|
||||||
|
|
||||||
|
name = _("Mesh Visualizer")
|
||||||
|
|
||||||
|
def get(self, request, format=None):
|
||||||
|
|
||||||
|
data = {
|
||||||
|
'nodes': InstanceNodeSerializer(Instance.objects.all(), many=True).data,
|
||||||
|
'links': InstanceLinkSerializer(InstanceLink.objects.all(), many=True).data,
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response(data)
|
||||||
@@ -123,6 +123,7 @@ class ApiVersionRootView(APIView):
|
|||||||
data['workflow_approvals'] = reverse('api:workflow_approval_list', request=request)
|
data['workflow_approvals'] = reverse('api:workflow_approval_list', request=request)
|
||||||
data['workflow_job_template_nodes'] = reverse('api:workflow_job_template_node_list', request=request)
|
data['workflow_job_template_nodes'] = reverse('api:workflow_job_template_node_list', request=request)
|
||||||
data['workflow_job_nodes'] = reverse('api:workflow_job_node_list', request=request)
|
data['workflow_job_nodes'] = reverse('api:workflow_job_node_list', request=request)
|
||||||
|
data['mesh_visualizer_view'] = reverse('api:mesh_visualizer_view', request=request)
|
||||||
return Response(data)
|
return Response(data)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user