mirror of
https://github.com/ansible/awx.git
synced 2026-04-14 06:29:25 -02:30
prevent constructed inventory host,group,inventory_source creation
This commit is contained in:
@@ -1941,8 +1941,8 @@ class HostSerializer(BaseSerializerWithVariables):
|
|||||||
return value
|
return value
|
||||||
|
|
||||||
def validate_inventory(self, value):
|
def validate_inventory(self, value):
|
||||||
if value.kind == 'smart':
|
if value.kind in ('constructed', 'smart'):
|
||||||
raise serializers.ValidationError({"detail": _("Cannot create Host for Smart Inventory")})
|
raise serializers.ValidationError({"detail": _("Cannot create Host for Smart or Constructed Inventories")})
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def validate_variables(self, value):
|
def validate_variables(self, value):
|
||||||
@@ -2040,8 +2040,8 @@ class GroupSerializer(BaseSerializerWithVariables):
|
|||||||
return value
|
return value
|
||||||
|
|
||||||
def validate_inventory(self, value):
|
def validate_inventory(self, value):
|
||||||
if value.kind == 'smart':
|
if value.kind in ('constructed', 'smart'):
|
||||||
raise serializers.ValidationError({"detail": _("Cannot create Group for Smart Inventory")})
|
raise serializers.ValidationError({"detail": _("Cannot create Group for Smart or Constructed Inventories")})
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def to_representation(self, obj):
|
def to_representation(self, obj):
|
||||||
@@ -2222,8 +2222,8 @@ class InventorySourceSerializer(UnifiedJobTemplateSerializer, InventorySourceOpt
|
|||||||
return value
|
return value
|
||||||
|
|
||||||
def validate_inventory(self, value):
|
def validate_inventory(self, value):
|
||||||
if value and value.kind == 'smart':
|
if value and value.kind in ('constructed', 'smart'):
|
||||||
raise serializers.ValidationError({"detail": _("Cannot create Inventory Source for Smart Inventory")})
|
raise serializers.ValidationError({"detail": _("Cannot create Inventory Source for Smart or Constructed Inventories")})
|
||||||
return value
|
return value
|
||||||
|
|
||||||
# TODO: remove when old 'credential' fields are removed
|
# TODO: remove when old 'credential' fields are removed
|
||||||
|
|||||||
Reference in New Issue
Block a user