summaryrefslogtreecommitdiff
path: root/src/automationstatus/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/automationstatus/views.py')
-rw-r--r--src/automationstatus/views.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/automationstatus/views.py b/src/automationstatus/views.py
new file mode 100644
index 0000000..df75868
--- /dev/null
+++ b/src/automationstatus/views.py
@@ -0,0 +1,19 @@
+from rest_framework import viewsets
+from caas.models import Cluster, Location, Server
+from .models import AutomationStatus
+from .serializers import AutomationStatusSerializer
+
+class AutomationStatusViewSet(viewsets.ModelViewSet):
+ queryset = AutomationStatus.objects.all().order_by('created_at')
+ serializer_class = AutomationStatusSerializer
+
+ def perform_create(self, serializer):
+ # Lookup cluster name based on the ilo_host_address
+ server = Server.objects.get(ilo_host_address=self.request.data['ilo_host_address'])
+ cluster = Cluster.objects.get(id=server.cluster_id)
+ fuze_id = cluster.location_id
+ location = Location.objects.get(id=fuze_id)
+ serializer.save(
+ cluster_name=cluster.cluster_name,
+ fuze_spm_site_name=location.fuze_spm_site_name,
+ fuze_spm_site_id=location.fuze_spm_site_id)