From 7194fe1064fcee99a863f0b47b1dac129683f883 Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Tue, 12 Aug 2014 15:40:15 -0400 Subject: [PATCH 1/2] need to handle the case where include_pattern and exclude_pattern exist in the config file but contain empty strings --- plugins/inventory/ec2.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/inventory/ec2.py b/plugins/inventory/ec2.py index c8e6d6e7f3..a1dec1c37b 100755 --- a/plugins/inventory/ec2.py +++ b/plugins/inventory/ec2.py @@ -257,6 +257,8 @@ class Ec2Inventory(object): pattern_include = config.get('ec2', 'pattern_include') if pattern_include and len(pattern_include) > 0: self.pattern_include = re.compile(pattern_include) + else + self.pattern_include = None except ConfigParser.NoOptionError, e: self.pattern_include = None @@ -265,8 +267,10 @@ class Ec2Inventory(object): pattern_exclude = config.get('ec2', 'pattern_exclude'); if pattern_exclude and len(pattern_exclude) > 0: self.pattern_exclude = re.compile(pattern_exclude) + else + self.pattern_exclude = None except ConfigParser.NoOptionError, e: - self.pattern_exclude = '' + self.pattern_exclude = None def parse_cli_args(self): ''' Command line argument processing ''' From 8b1d6f5e75529f41bfee973b7ed5e20e3d64f03a Mon Sep 17 00:00:00 2001 From: Michael Peters Date: Tue, 12 Aug 2014 15:48:14 -0400 Subject: [PATCH 2/2] fixing "else" typo --- plugins/inventory/ec2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/inventory/ec2.py b/plugins/inventory/ec2.py index a1dec1c37b..f4e98f6dd7 100755 --- a/plugins/inventory/ec2.py +++ b/plugins/inventory/ec2.py @@ -257,7 +257,7 @@ class Ec2Inventory(object): pattern_include = config.get('ec2', 'pattern_include') if pattern_include and len(pattern_include) > 0: self.pattern_include = re.compile(pattern_include) - else + else: self.pattern_include = None except ConfigParser.NoOptionError, e: self.pattern_include = None @@ -267,7 +267,7 @@ class Ec2Inventory(object): pattern_exclude = config.get('ec2', 'pattern_exclude'); if pattern_exclude and len(pattern_exclude) > 0: self.pattern_exclude = re.compile(pattern_exclude) - else + else: self.pattern_exclude = None except ConfigParser.NoOptionError, e: self.pattern_exclude = None