1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00

removed policy_instance variables from container groups default values in the API put/patch view

This commit is contained in:
Rebeccah 2019-10-22 15:57:06 -04:00
parent 93bd1e6705
commit ef7b3fec94
3 changed files with 6 additions and 11 deletions

View File

@ -318,12 +318,11 @@ class GenericAPIView(generics.GenericAPIView, APIView):
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':
import sdb
sdb.set_trace()
del serializer.fields['policy_instance_percentage']
del serializer.fields['policy_instance_minimum']
del serializer.fields['policy_instance_list']
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

View File

@ -4802,7 +4802,7 @@ class InstanceGroupSerializer(BaseSerializer):
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:
raise serializers.ValidationError(_('Containerized instances may not be managed via the API'))
raise serializers.ValidationError(_('Containerized instances may not be managed via the API'))
return value
def validate_policy_instance_percentage(self, value):

View File

@ -366,10 +366,6 @@ def get_allowed_fields(obj, serializer_mapping):
field_blacklist = ACTIVITY_STREAM_FIELD_EXCLUSIONS.get(obj._meta.model_name, [])
if field_blacklist:
allowed_fields = [f for f in allowed_fields if f not in field_blacklist]
# raise Exception(_("please render this"))
# if obj.__class__.__name__ == 'InstanceGroup' and obj.is_containerized:
# container_group_blacklist = ["policy_instance_percentage", "policy_instance_minimum", "policy_instance_list"]
# allowed_fields = [f for f in allowed_fields if f not in container_group_blacklist]
return allowed_fields