if trying to create a vOLT with the same (ss_id, vlan_id) as an existing vOLT Tenant, then return the original
diff --git a/xos/core/xoslib/methods/volttenant.py b/xos/core/xoslib/methods/volttenant.py
index a1ae656..ba0e909 100644
--- a/xos/core/xoslib/methods/volttenant.py
+++ b/xos/core/xoslib/methods/volttenant.py
@@ -3,6 +3,7 @@
from rest_framework.reverse import reverse
from rest_framework import serializers
from rest_framework import generics
+from rest_framework import status
from core.models import *
from django.forms import widgets
from cord.models import VOLTTenant, VOLTService
@@ -68,6 +69,21 @@
return queryset
+ def post(self, request, format=None):
+ data = request.DATA
+
+ existing_obj = None
+ for obj in VOLTTenant.get_tenant_objects().all():
+ if (obj.vlan_id == data.get("vlan_id", None)) and (obj.service_specific_id == data.get("service_specific_id",None)):
+ existing_obj = obj
+
+ if existing_obj:
+ serializer = VOLTTenantIdSerializer(existing_obj)
+ headers = self.get_success_headers(serializer.data)
+ return Response( serializer.data, status=status.HTTP_200_OK )
+
+ return super(VOLTTenantList, self).post(request, format)
+
class VOLTTenantDetail(XOSRetrieveUpdateDestroyAPIView):
serializer_class = VOLTTenantIdSerializer
queryset = VOLTTenant.get_tenant_objects().select_related().all()