From 640ff61422bc0ee3966941b93d9889ddbbd38d77 Mon Sep 17 00:00:00 2001 From: ckonstanski Date: Thu, 30 Jul 2026 18:17:14 -0600 Subject: more files --- src/automationstatus/views.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/automationstatus/views.py (limited to 'src/automationstatus/views.py') 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) -- cgit v1.3