Update EC2 inventory import to use any variables defined in source_vars. Fix AC-565 by setting default regions_exclude to us-gov-west1 (same as default ec2.ini). Fix AC-566 by stripping extra whitespace from comma-separated region names.

This commit is contained in:
Chris Church
2013-10-16 23:05:51 -04:00
parent a11f25a68d
commit 432ed60a1f
3 changed files with 25 additions and 14 deletions

View File

@@ -649,6 +649,7 @@ class InventorySource(PrimordialModel):
source_vars = models.TextField(
blank=True,
default='',
help_text=_('Inventory source variables in YAML or JSON format.'),
)
source_username = models.CharField(
max_length=1024,
@@ -760,6 +761,13 @@ class InventorySource(PrimordialModel):
if update_fields:
self.save(update_fields=update_fields)
@property
def source_vars_dict(self):
try:
return json.loads(self.source_vars.strip() or '{}')
except ValueError:
return yaml.safe_load(self.source_vars)
@property
def needs_source_password(self):
return self.source and self.source_password == 'ASK'