mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
Merge pull request #6992 from AlanCoding/inv_src_name
Make inventory source naming consistent with v1
This commit is contained in:
commit
28b311fdb5
@ -1390,7 +1390,9 @@ class GroupSerializer(BaseSerializerWithVariables):
|
||||
def create(self, validated_data): # TODO: remove in 3.3
|
||||
instance = super(GroupSerializer, self).create(validated_data)
|
||||
if self.version == 1: # TODO: remove in 3.3
|
||||
InventorySource.objects.create(deprecated_group=instance, inventory=instance.inventory)
|
||||
manual_src = InventorySource(deprecated_group=instance, inventory=instance.inventory)
|
||||
manual_src.v1_group_name = instance.name
|
||||
manual_src.save()
|
||||
return instance
|
||||
|
||||
def validate_name(self, value):
|
||||
|
@ -1249,10 +1249,11 @@ class InventorySource(UnifiedJobTemplate, InventorySourceOptions):
|
||||
replace_text = '__replace_%s__' % now()
|
||||
old_name_re = re.compile(r'^inventory_source \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*?$')
|
||||
if not self.name or old_name_re.match(self.name) or '__replace_' in self.name:
|
||||
group_name = getattr(self, 'v1_group_name', '')
|
||||
if self.inventory and self.pk:
|
||||
self.name = '%s (%s)' % (self.inventory.name, self.pk)
|
||||
self.name = '%s (%s - %s)' % (group_name, self.inventory.name, self.pk)
|
||||
elif self.inventory:
|
||||
self.name = '%s (%s)' % (self.inventory.name, replace_text)
|
||||
self.name = '%s (%s - %s)' % (group_name, self.inventory.name, replace_text)
|
||||
elif not is_new_instance:
|
||||
self.name = 'inventory source (%s)' % self.pk
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user