mirror of
https://github.com/ansible/awx.git
synced 2026-03-20 10:27:34 -02:30
remove group_by from inventory source
* Does not remove group_by testing
This commit is contained in:
committed by
Ryan Petrello
parent
e11040f421
commit
7278e7c025
@@ -122,12 +122,6 @@ class Metadata(metadata.SimpleMetadata):
|
|||||||
get_regions = getattr(InventorySource, 'get_%s_region_choices' % cp)
|
get_regions = getattr(InventorySource, 'get_%s_region_choices' % cp)
|
||||||
field_info['%s_region_choices' % cp] = get_regions()
|
field_info['%s_region_choices' % cp] = get_regions()
|
||||||
|
|
||||||
# Special handling of group_by choices for EC2.
|
|
||||||
if field.field_name == 'group_by':
|
|
||||||
for cp in ('ec2',):
|
|
||||||
get_group_by_choices = getattr(InventorySource, 'get_%s_group_by_choices' % cp)
|
|
||||||
field_info['%s_group_by_choices' % cp] = get_group_by_choices()
|
|
||||||
|
|
||||||
# Special handling of notification configuration where the required properties
|
# Special handling of notification configuration where the required properties
|
||||||
# are conditional on the type selected.
|
# are conditional on the type selected.
|
||||||
if field.field_name == 'notification_configuration':
|
if field.field_name == 'notification_configuration':
|
||||||
|
|||||||
@@ -1937,7 +1937,7 @@ class InventorySourceOptionsSerializer(BaseSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
fields = ('*', 'source', 'source_path', 'source_script', 'source_vars', 'credential',
|
fields = ('*', 'source', 'source_path', 'source_script', 'source_vars', 'credential',
|
||||||
'source_regions', 'instance_filters', 'group_by', 'overwrite', 'overwrite_vars',
|
'source_regions', 'instance_filters', 'overwrite', 'overwrite_vars',
|
||||||
'custom_virtualenv', 'timeout', 'verbosity')
|
'custom_virtualenv', 'timeout', 'verbosity')
|
||||||
|
|
||||||
def get_related(self, obj):
|
def get_related(self, obj):
|
||||||
|
|||||||
@@ -56,4 +56,12 @@ class Migration(migrations.Migration):
|
|||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.RunPython(inventory_source_vars_forward, inventory_source_vars_backward,),
|
migrations.RunPython(inventory_source_vars_forward, inventory_source_vars_backward,),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='inventorysource',
|
||||||
|
name='group_by',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='inventoryupdate',
|
||||||
|
name='group_by',
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -958,12 +958,6 @@ class InventorySourceOptions(BaseModel):
|
|||||||
default='',
|
default='',
|
||||||
help_text=_('Comma-separated list of filter expressions (EC2 only). Hosts are imported when ANY of the filters match.'),
|
help_text=_('Comma-separated list of filter expressions (EC2 only). Hosts are imported when ANY of the filters match.'),
|
||||||
)
|
)
|
||||||
group_by = models.CharField(
|
|
||||||
max_length=1024,
|
|
||||||
blank=True,
|
|
||||||
default='',
|
|
||||||
help_text=_('Limit groups automatically created from inventory source (EC2 only).'),
|
|
||||||
)
|
|
||||||
overwrite = models.BooleanField(
|
overwrite = models.BooleanField(
|
||||||
default=False,
|
default=False,
|
||||||
help_text=_('Overwrite local groups and hosts from remote inventory source.'),
|
help_text=_('Overwrite local groups and hosts from remote inventory source.'),
|
||||||
@@ -983,24 +977,6 @@ class InventorySourceOptions(BaseModel):
|
|||||||
default=1,
|
default=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def get_ec2_group_by_choices(cls):
|
|
||||||
return [
|
|
||||||
('ami_id', _('Image ID')),
|
|
||||||
('availability_zone', _('Availability Zone')),
|
|
||||||
('aws_account', _('Account')),
|
|
||||||
('instance_id', _('Instance ID')),
|
|
||||||
('instance_state', _('Instance State')),
|
|
||||||
('platform', _('Platform')),
|
|
||||||
('instance_type', _('Instance Type')),
|
|
||||||
('key_pair', _('Key Name')),
|
|
||||||
('region', _('Region')),
|
|
||||||
('security_group', _('Security Group')),
|
|
||||||
('tag_keys', _('Tags')),
|
|
||||||
('tag_none', _('Tag None')),
|
|
||||||
('vpc_id', _('VPC ID')),
|
|
||||||
]
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_ec2_region_choices(cls):
|
def get_ec2_region_choices(cls):
|
||||||
ec2_region_names = getattr(settings, 'EC2_REGION_NAMES', {})
|
ec2_region_names = getattr(settings, 'EC2_REGION_NAMES', {})
|
||||||
@@ -1189,27 +1165,6 @@ class InventorySourceOptions(BaseModel):
|
|||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def clean_group_by(self):
|
|
||||||
group_by = str(self.group_by or '')
|
|
||||||
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()
|
|
||||||
valid_choices = [choice_transform(x) for x in valid_choices]
|
|
||||||
choices = [choice_transform(x) for x in group_by.split(',') if x.strip()]
|
|
||||||
invalid_choices = []
|
|
||||||
for c in choices:
|
|
||||||
if c not in valid_choices and c not in invalid_choices:
|
|
||||||
invalid_choices.append(c)
|
|
||||||
if invalid_choices:
|
|
||||||
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, CustomVirtualEnvMixin, RelatedJobsMixin):
|
class InventorySource(UnifiedJobTemplate, InventorySourceOptions, CustomVirtualEnvMixin, RelatedJobsMixin):
|
||||||
|
|
||||||
|
|||||||
@@ -69,10 +69,6 @@ options:
|
|||||||
description:
|
description:
|
||||||
- Comma-separated list of filter expressions for matching hosts.
|
- Comma-separated list of filter expressions for matching hosts.
|
||||||
type: str
|
type: str
|
||||||
group_by:
|
|
||||||
description:
|
|
||||||
- Limit groups automatically created from inventory source.
|
|
||||||
type: str
|
|
||||||
overwrite:
|
overwrite:
|
||||||
description:
|
description:
|
||||||
- Delete child groups and hosts not found in source.
|
- Delete child groups and hosts not found in source.
|
||||||
@@ -167,7 +163,6 @@ def main():
|
|||||||
credential=dict(),
|
credential=dict(),
|
||||||
source_regions=dict(),
|
source_regions=dict(),
|
||||||
instance_filters=dict(),
|
instance_filters=dict(),
|
||||||
group_by=dict(),
|
|
||||||
overwrite=dict(type='bool'),
|
overwrite=dict(type='bool'),
|
||||||
overwrite_vars=dict(type='bool'),
|
overwrite_vars=dict(type='bool'),
|
||||||
custom_virtualenv=dict(),
|
custom_virtualenv=dict(),
|
||||||
@@ -245,7 +240,7 @@ def main():
|
|||||||
|
|
||||||
OPTIONAL_VARS = (
|
OPTIONAL_VARS = (
|
||||||
'description', 'source', 'source_path', 'source_vars',
|
'description', 'source', 'source_path', 'source_vars',
|
||||||
'source_regions', 'instance_filters', 'group_by',
|
'source_regions', 'instance_filters',
|
||||||
'overwrite', 'overwrite_vars', 'custom_virtualenv',
|
'overwrite', 'overwrite_vars', 'custom_virtualenv',
|
||||||
'timeout', 'verbosity', 'update_on_launch', 'update_cache_timeout',
|
'timeout', 'verbosity', 'update_on_launch', 'update_cache_timeout',
|
||||||
'update_on_project_update'
|
'update_on_project_update'
|
||||||
|
|||||||
@@ -192,7 +192,6 @@ def test_falsy_value(run_module, admin_user, base_inventory):
|
|||||||
# UoPL ? ? o - - - - - - - - - -
|
# UoPL ? ? o - - - - - - - - - -
|
||||||
# source_regions ? ? - o o o - - - - - - -
|
# source_regions ? ? - o o o - - - - - - -
|
||||||
# instance_filters ? ? - o - - o - - - - o -
|
# instance_filters ? ? - o - - o - - - - o -
|
||||||
# group_by ? ? - o - - o - - - - - -
|
|
||||||
# source_vars* ? ? - o - o o o o o - - -
|
# source_vars* ? ? - o - o o o o o - - -
|
||||||
# environmet vars* ? ? o - - - - - - - - - o
|
# environmet vars* ? ? o - - - - - - - - - o
|
||||||
# source_script ? ? - - - - - - - - - - r
|
# source_script ? ? - - - - - - - - - - r
|
||||||
|
|||||||
@@ -499,7 +499,6 @@ class InventorySource(HasCreate, HasNotifications, UnifiedJobTemplate):
|
|||||||
payload.source_project = project.id
|
payload.source_project = project.id
|
||||||
|
|
||||||
optional_fields = (
|
optional_fields = (
|
||||||
'group_by',
|
|
||||||
'instance_filters',
|
'instance_filters',
|
||||||
'source_path',
|
'source_path',
|
||||||
'source_regions',
|
'source_regions',
|
||||||
|
|||||||
Reference in New Issue
Block a user