Merge pull request #37882 from attiasr/fix_missing_tags

multiple issues in boto_rds state and module
This commit is contained in:
Mike Place 2016-11-28 14:09:11 -07:00 committed by GitHub
commit eb3d81a1de
2 changed files with 30 additions and 27 deletions

View file

@ -256,7 +256,7 @@ def create(name, allocated_storage, db_instance_class, engine,
raise SaltInvocationError('master_username is required')
if not master_user_password:
raise SaltInvocationError('master_user_password is required')
if availability_zone and MultiAZ:
if availability_zone and multi_az:
raise SaltInvocationError('availability_zone and multi_az are mutually'
' exclusive arguments.')
if wait_status:
@ -529,6 +529,10 @@ def describe(name, tags=None, region=None, key=None, keyid=None,
return {'results': bool(conn)}
rds = conn.describe_db_instances(DBInstanceIdentifier=name)
rds = [
i for i in rds.get('DBInstances', [])
if i.get('DBInstanceIdentifier') == name
].pop(0)
if rds:
keys = ('DBInstanceIdentifier', 'DBInstanceClass', 'Engine',
@ -549,6 +553,8 @@ def describe(name, tags=None, region=None, key=None, keyid=None,
return {'rds': None}
except ClientError as e:
return {'error': salt.utils.boto3.get_error(e)}
except IndexError:
return {'rds': None}
def get_endpoint(name, tags=None, region=None, key=None, keyid=None,

View file

@ -309,7 +309,7 @@ def present(name,
'changes': {}
}
r = __salt__['boto_rds.exists'](name, region, key, keyid, profile)
r = __salt__['boto_rds.exists'](name, tags, region, key, keyid, profile)
if not r.get('exists'):
if __opts__['test']:
@ -350,7 +350,7 @@ def present(name,
ret['comment'] = 'Failed to create RDS instance {0}.'.format(r['error']['message'])
return ret
_describe = __salt__['boto_rds.describe'](name, region, key, keyid, profile)
_describe = __salt__['boto_rds.describe'](name, tags, region, key, keyid, profile)
ret['changes']['old'] = {'instance': None}
ret['changes']['new'] = _describe
ret['comment'] = 'RDS instance {0} created.'.format(name)
@ -488,36 +488,33 @@ def subnet_group_present(name, description, subnet_ids=None, subnet_names=None,
return ret
subnet_ids.append(r['id'])
for i in subnet_ids:
r = __salt__['boto_rds.create_subnet_group'](name=name,
exists = __salt__['boto_rds.subnet_group_exists'](name=name, tags=tags, region=region, key=key,
keyid=keyid, profile=profile)
if not exists:
if __opts__['test']:
ret['comment'] = 'Subnet group {0} is set to be created.'.format(name)
ret['result'] = None
return ret
if not r.get('created'):
ret['result'] = False
ret['comment'] = 'Failed to create {0} subnet group.'.format(r['error']['message'])
return ret
created = __salt__['boto_rds.create_subnet_group'](name=name,
description=description,
subnet_ids=subnet_ids,
tags=tags, region=region,
key=key, keyid=keyid,
profile=profile)
if not r.get('exists'):
if __opts__['test']:
ret['comment'] = 'Subnet group {0} is set to be created.'.format(name)
ret['result'] = None
return ret
if not r.get('created'):
ret['result'] = False
ret['comment'] = 'Failed to create {0} subnet group.'.format(r['error']['message'])
return ret
_describe = __salt__['boto_rds.describe']('subnet',
name=i,
region=region,
key=key,
keyid=keyid,
profile=profile)
ret['changes']['old'] = None
ret['changes']['new'] = _describe
ret['comment'] = 'Subnet {0} created.'.format(name)
else:
ret['comment'] = 'Subnet {0} present.'.format(name)
if not created:
ret['result'] = False
ret['comment'] = 'Failed to create {0} subnet group.'.format(name)
return ret
ret['changes']['old'] = None
ret['changes']['new'] = name
ret['comment'] = 'Subnet {0} created.'.format(name)
else:
ret['comment'] = 'Subnet {0} present.'.format(name)
return ret