Fix the way self.properties is checked for a value.

The following only checks if the key is in the properties, and
all schema keys are, so it is not the way to check if a value
has been set.

if 'DesiredCapacity' in self.properties:
change to:
if self.properties:

Fixes: #199

Change-Id: I6bcb3e74420031532dc249aafe85d5a428d0a80e
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
Angus Salkeld 2012-08-27 14:02:26 +10:00
parent 5e41a1ee73
commit 20345dc8c6
4 changed files with 6 additions and 10 deletions

View File

@ -59,7 +59,7 @@ class AutoScalingGroup(Resource):
def handle_create(self): def handle_create(self):
if 'DesiredCapacity' in self.properties: if self.properties['DesiredCapacity']:
num_to_create = int(self.properties['DesiredCapacity']) num_to_create = int(self.properties['DesiredCapacity'])
else: else:
num_to_create = int(self.properties['MinSize']) num_to_create = int(self.properties['MinSize'])

View File

@ -85,10 +85,7 @@ class ElasticIpAssociation(Resource):
super(ElasticIpAssociation, self).__init__(name, json_snippet, stack) super(ElasticIpAssociation, self).__init__(name, json_snippet, stack)
def FnGetRefId(self): def FnGetRefId(self):
if not 'EIP' in self.properties: return unicode(self.properties.get('EIP', '0.0.0.0'))
return unicode('0.0.0.0')
else:
return unicode(self.properties['EIP'])
def validate(self): def validate(self):
''' '''

View File

@ -49,7 +49,7 @@ class SecurityGroup(Resource):
self.properties['GroupDescription']) self.properties['GroupDescription'])
self.instance_id_set(sec.id) self.instance_id_set(sec.id)
if 'SecurityGroupIngress' in self.properties: if self.properties['SecurityGroupIngress']:
rules_client = self.nova().security_group_rules rules_client = self.nova().security_group_rules
for i in self.properties['SecurityGroupIngress']: for i in self.properties['SecurityGroupIngress']:
try: try:

View File

@ -44,7 +44,6 @@ class User(Resource):
def handle_create(self): def handle_create(self):
passwd = '' passwd = ''
if 'LoginProfile' in self.properties:
if self.properties['LoginProfile'] and \ if self.properties['LoginProfile'] and \
'Password' in self.properties['LoginProfile']: 'Password' in self.properties['LoginProfile']:
passwd = self.properties['LoginProfile']['Password'] passwd = self.properties['LoginProfile']['Password']