From 27ad680f4d19e2a1ef50c28b037a0a0c27976856 Mon Sep 17 00:00:00 2001 From: Chris Church Date: Wed, 23 Oct 2013 22:46:04 -0400 Subject: [PATCH] AC-567 Remove source_tags from API/UI. Modify EC2 inventory to not return instance ID groups. --- awx/main/models/__init__.py | 1 + awx/main/serializers.py | 10 +++------- awx/main/tests/inventory.py | 4 ++++ awx/plugins/inventory/ec2.py | 3 ++- awx/ui/static/js/forms/Groups.js | 13 ------------- awx/ui/static/js/helpers/Groups.js | 1 - 6 files changed, 10 insertions(+), 22 deletions(-) diff --git a/awx/main/models/__init__.py b/awx/main/models/__init__.py index 04c9c022de..e39f7b667a 100644 --- a/awx/main/models/__init__.py +++ b/awx/main/models/__init__.py @@ -686,6 +686,7 @@ class InventorySource(PrimordialModel): blank=True, default='', ) + # FIXME: Remove tags field when making other migrations for credential changes! source_tags = models.CharField( max_length=1024, blank=True, diff --git a/awx/main/serializers.py b/awx/main/serializers.py index d2bd05dea7..6cc7f8fb7f 100644 --- a/awx/main/serializers.py +++ b/awx/main/serializers.py @@ -672,9 +672,9 @@ class InventorySourceSerializer(BaseSerializer): fields = ('id', 'url', 'related', 'summary_fields', 'created', 'modified', 'inventory', 'group', 'source', 'source_path', 'source_vars', 'source_username', 'source_password', - 'source_regions', 'source_tags', 'overwrite', - 'overwrite_vars', 'update_on_launch', 'update_interval', - 'last_update_failed', 'status', 'last_updated') + 'source_regions', 'overwrite', 'overwrite_vars', + 'update_on_launch', 'update_interval', 'last_update_failed', + 'status', 'last_updated') read_only_fields = ('inventory', 'group') def to_native(self, obj): @@ -764,10 +764,6 @@ class InventorySourceSerializer(BaseSerializer): # FIXME return attrs - def validate_source_tags(self, attrs, source): - # FIXME - return attrs - class InventoryUpdateSerializer(BaseSerializer): class Meta: diff --git a/awx/main/tests/inventory.py b/awx/main/tests/inventory.py index 7386053956..ca29a11d88 100644 --- a/awx/main/tests/inventory.py +++ b/awx/main/tests/inventory.py @@ -5,6 +5,7 @@ import datetime import json import os +import re # Django from django.conf import settings @@ -1021,6 +1022,9 @@ class InventoryUpdatesTest(BaseTransactionTest): source_pks = group.inventory_sources.values_list('pk', flat=True) self.assertTrue(inventory_source.pk in source_pks) self.assertTrue(group.has_inventory_sources) + # Make sure EC2 instance ID groups are excluded. + self.assertFalse(re.match(r'^i-[0-9a-f]{8}$', group.name, re.I), + group.name) def test_update_from_ec2(self): source_username = getattr(settings, 'TEST_AWS_ACCESS_KEY_ID', '') diff --git a/awx/plugins/inventory/ec2.py b/awx/plugins/inventory/ec2.py index 27d724ea53..ae8e4a1050 100755 --- a/awx/plugins/inventory/ec2.py +++ b/awx/plugins/inventory/ec2.py @@ -336,8 +336,9 @@ class Ec2Inventory(object): # Add to index self.index[dest] = [region, instance.id] + # For AWX: do not output group based on instance ID!!! # Inventory: Group by instance ID (always a group of 1) - self.inventory[instance.id] = [dest] + # self.inventory[instance.id] = [dest] # Inventory: Group by region self.push(self.inventory, region, dest) diff --git a/awx/ui/static/js/forms/Groups.js b/awx/ui/static/js/forms/Groups.js index 74ff58b0e1..ebf7ee1148 100644 --- a/awx/ui/static/js/forms/Groups.js +++ b/awx/ui/static/js/forms/Groups.js @@ -155,19 +155,6 @@ angular.module('GroupFormDefinition', []) "Only hosts associated with the list of regions will be included in the update process.

", dataContainer: 'body' }, - source_tags: { - label: 'Tags', - excludeModal: true, - type: 'text', - ngShow: "source.value == 'ec2'", - addRequired: false, - editRequired: false, - dataTitle: 'Source Regions', - dataPlacement: 'left', - awPopOver: "

Comma separated list of tags. Tag names must match those defined at the inventory source." + - " Only hosts associated with the list of tags will be included in the update process.

", - dataContainer: 'body' - }, source_vars: { label: 'Source Variables', ngShow: "source.value == 'file' || source.value == 'ec2'", diff --git a/awx/ui/static/js/helpers/Groups.js b/awx/ui/static/js/helpers/Groups.js index 1215707640..3da93077f4 100644 --- a/awx/ui/static/js/helpers/Groups.js +++ b/awx/ui/static/js/helpers/Groups.js @@ -810,7 +810,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' source_username: scope['source_username'], source_password: scope['source_password'], source_regions: scope['source_regions'], - source_tags: scope['source_tags'], overwrite: scope['overwrite'], overwrite_vars: scope['overwrite_vars'], update_on_launch: scope['update_on_launch'],