mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 23:51:09 +03:00
moved filterint out policy instance values in the api browser input box into the instanceGroupDetail class where I overrode the update_raw_data function to parse out the unneeded data. Additionally added the fix for checking the value in the serializer.
This commit is contained in:
parent
ef7b3fec94
commit
4c199b0ab2
@ -46,7 +46,7 @@ from awx.main.utils import (
|
||||
decrypt_field
|
||||
)
|
||||
from awx.main.utils.db import get_all_field_names
|
||||
from awx.api.serializers import ResourceAccessListElementSerializer, CopySerializer, UserSerializer, InstanceGroupSerializer
|
||||
from awx.api.serializers import ResourceAccessListElementSerializer, CopySerializer, UserSerializer
|
||||
from awx.api.versioning import URLPathVersioning
|
||||
from awx.api.metadata import SublistAttachDetatchMetadata, Metadata
|
||||
|
||||
@ -317,12 +317,6 @@ class GenericAPIView(generics.GenericAPIView, APIView):
|
||||
for name, field in list(serializer.fields.items()):
|
||||
if getattr(field, 'read_only', None):
|
||||
del serializer.fields[name]
|
||||
# Additionally, remove the following fields if an instance group is containerized.
|
||||
if name == 'is_containerized' and type(serializer) == InstanceGroupSerializer:
|
||||
if serializer.instance is not None and serializer.instance.is_containerized:
|
||||
del serializer.fields['policy_instance_percentage']
|
||||
del serializer.fields['policy_instance_minimum']
|
||||
del serializer.fields['policy_instance_list']
|
||||
serializer._data = self.update_raw_data(serializer.data)
|
||||
return serializer
|
||||
|
||||
|
@ -4801,7 +4801,7 @@ class InstanceGroupSerializer(BaseSerializer):
|
||||
raise serializers.ValidationError(_('Isolated instances may not be added or removed from instances groups via the API.'))
|
||||
if self.instance and self.instance.controller_id is not None:
|
||||
raise serializers.ValidationError(_('Isolated instance group membership may not be managed via the API.'))
|
||||
if self.instance.is_containerized:
|
||||
if value and self.instance.is_containerized:
|
||||
raise serializers.ValidationError(_('Containerized instances may not be managed via the API'))
|
||||
return value
|
||||
|
||||
|
@ -383,6 +383,13 @@ class InstanceGroupDetail(RelatedJobsPreventDeleteMixin, RetrieveUpdateDestroyAP
|
||||
serializer_class = serializers.InstanceGroupSerializer
|
||||
permission_classes = (InstanceGroupTowerPermission,)
|
||||
|
||||
def update_raw_data(self, data):
|
||||
if self.get_object().is_containerized:
|
||||
data.pop('policy_instance_percentage', None)
|
||||
data.pop('policy_instance_minimum', None)
|
||||
data.pop('policy_instance_list', None)
|
||||
return super(InstanceGroupDetail, self).update_raw_data(data)
|
||||
|
||||
def destroy(self, request, *args, **kwargs):
|
||||
instance = self.get_object()
|
||||
if instance.controller is not None:
|
||||
|
Loading…
Reference in New Issue
Block a user