mirror of
https://github.com/ansible/awx.git
synced 2026-05-10 10:57:35 -02:30
Merge pull request #6382 from chrismeyersfsu/fix-4514
support vmware via source_vars
This commit is contained in:
@@ -1094,8 +1094,7 @@ class InventorySourceOptions(BaseModel):
|
|||||||
|
|
||||||
def clean_instance_filters(self):
|
def clean_instance_filters(self):
|
||||||
instance_filters = unicode(self.instance_filters or '')
|
instance_filters = unicode(self.instance_filters or '')
|
||||||
if self.source != 'ec2':
|
if self.source == 'ec2':
|
||||||
return ''
|
|
||||||
invalid_filters = []
|
invalid_filters = []
|
||||||
instance_filter_re = re.compile(r'^((tag:.+)|([a-z][a-z\.-]*[a-z]))=.*$')
|
instance_filter_re = re.compile(r'^((tag:.+)|([a-z][a-z\.-]*[a-z]))=.*$')
|
||||||
for instance_filter in instance_filters.split(','):
|
for instance_filter in instance_filters.split(','):
|
||||||
@@ -1114,11 +1113,14 @@ class InventorySourceOptions(BaseModel):
|
|||||||
raise ValidationError(_('Invalid filter expression: %(filter)s') %
|
raise ValidationError(_('Invalid filter expression: %(filter)s') %
|
||||||
{'filter': ', '.join(invalid_filters)})
|
{'filter': ', '.join(invalid_filters)})
|
||||||
return instance_filters
|
return instance_filters
|
||||||
|
elif self.source == 'vmware':
|
||||||
|
return instance_filters
|
||||||
|
else:
|
||||||
|
return ''
|
||||||
|
|
||||||
def clean_group_by(self):
|
def clean_group_by(self):
|
||||||
group_by = unicode(self.group_by or '')
|
group_by = unicode(self.group_by or '')
|
||||||
if self.source != 'ec2':
|
if self.source == 'ec2':
|
||||||
return ''
|
|
||||||
get_choices = getattr(self, 'get_%s_group_by_choices' % self.source)
|
get_choices = getattr(self, 'get_%s_group_by_choices' % self.source)
|
||||||
valid_choices = [x[0] for x in get_choices()]
|
valid_choices = [x[0] for x in get_choices()]
|
||||||
choice_transform = lambda x: x.strip().lower()
|
choice_transform = lambda x: x.strip().lower()
|
||||||
@@ -1132,6 +1134,10 @@ class InventorySourceOptions(BaseModel):
|
|||||||
raise ValidationError(_('Invalid group by choice: %(choice)s') %
|
raise ValidationError(_('Invalid group by choice: %(choice)s') %
|
||||||
{'choice': ', '.join(invalid_choices)})
|
{'choice': ', '.join(invalid_choices)})
|
||||||
return ','.join(choices)
|
return ','.join(choices)
|
||||||
|
elif self.source == 'vmware':
|
||||||
|
return group_by
|
||||||
|
else:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
class InventorySource(UnifiedJobTemplate, InventorySourceOptions):
|
class InventorySource(UnifiedJobTemplate, InventorySourceOptions):
|
||||||
|
|||||||
@@ -1598,7 +1598,7 @@ class RunInventoryUpdate(BaseTask):
|
|||||||
if inventory_update.instance_filters:
|
if inventory_update.instance_filters:
|
||||||
vmware_opts.setdefault('host_filters', inventory_update.instance_filters)
|
vmware_opts.setdefault('host_filters', inventory_update.instance_filters)
|
||||||
if inventory_update.group_by:
|
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():
|
for k,v in vmware_opts.items():
|
||||||
cp.set(section, k, unicode(v))
|
cp.set(section, k, unicode(v))
|
||||||
|
|||||||
Reference in New Issue
Block a user