mirror of
https://github.com/ansible/awx.git
synced 2026-05-22 16:27:42 -02:30
abuse group_by and instance_filters
This commit is contained in:
@@ -1093,8 +1093,7 @@ class InventorySourceOptions(BaseModel):
|
||||
|
||||
def clean_instance_filters(self):
|
||||
instance_filters = unicode(self.instance_filters or '')
|
||||
if self.source != 'ec2':
|
||||
return ''
|
||||
if self.source == 'ec2':
|
||||
invalid_filters = []
|
||||
instance_filter_re = re.compile(r'^((tag:.+)|([a-z][a-z\.-]*[a-z]))=.*$')
|
||||
for instance_filter in instance_filters.split(','):
|
||||
@@ -1113,11 +1112,14 @@ class InventorySourceOptions(BaseModel):
|
||||
raise ValidationError(_('Invalid filter expression: %(filter)s') %
|
||||
{'filter': ', '.join(invalid_filters)})
|
||||
return instance_filters
|
||||
elif self.source == 'vmware':
|
||||
return instance_filters
|
||||
else:
|
||||
return ''
|
||||
|
||||
def clean_group_by(self):
|
||||
group_by = unicode(self.group_by or '')
|
||||
if self.source != 'ec2':
|
||||
return ''
|
||||
if self.source == 'ec2':
|
||||
get_choices = getattr(self, 'get_%s_group_by_choices' % self.source)
|
||||
valid_choices = [x[0] for x in get_choices()]
|
||||
choice_transform = lambda x: x.strip().lower()
|
||||
@@ -1131,6 +1133,10 @@ class InventorySourceOptions(BaseModel):
|
||||
raise ValidationError(_('Invalid group by choice: %(choice)s') %
|
||||
{'choice': ', '.join(invalid_choices)})
|
||||
return ','.join(choices)
|
||||
elif self.source == 'vmware':
|
||||
return group_by
|
||||
else:
|
||||
return ''
|
||||
|
||||
|
||||
class InventorySource(UnifiedJobTemplate, InventorySourceOptions):
|
||||
|
||||
@@ -1597,7 +1597,7 @@ class RunInventoryUpdate(BaseTask):
|
||||
if inventory_update.instance_filters:
|
||||
vmware_opts.setdefault('host_filters', inventory_update.instance_filters)
|
||||
if inventory_update.group_by:
|
||||
vmware_opts.setdefault('groupby_patterns', inventory_update.groupby_patterns)
|
||||
vmware_opts.setdefault('groupby_patterns', inventory_update.group_by)
|
||||
|
||||
for k,v in vmware_opts.items():
|
||||
cp.set(section, k, unicode(v))
|
||||
|
||||
Reference in New Issue
Block a user