mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Code cleanup and fixes for boto modules
This commit is contained in:
parent
a74828f437
commit
0d17e70e90
@ -505,7 +505,7 @@ def _get_conn(region, key, keyid, profile):
|
||||
_profile = profile
|
||||
key = _profile.get('key', None)
|
||||
keyid = _profile.get('keyid', None)
|
||||
region = _profile.get('keyid', None)
|
||||
region = _profile.get('region', None)
|
||||
|
||||
if not region and __salt__['config.option']('elb.region'):
|
||||
region = __salt__['config.option']('elb.region')
|
||||
|
@ -36,6 +36,7 @@ Connection module for Amazon SQS
|
||||
|
||||
# Import Python libs
|
||||
import logging
|
||||
import json
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -155,6 +156,8 @@ def set_attributes(name, attributes, region=None, key=None, keyid=None,
|
||||
if not queue_obj:
|
||||
log.error('Queue {0} does not exist.'.format(name))
|
||||
ret = False
|
||||
if isinstance(attributes, string_types):
|
||||
attributes = json.loads(attributes)
|
||||
for attr, val in attributes.iteritems():
|
||||
attr_set = queue_obj.set_attribute(attr, val)
|
||||
if not attr_set:
|
||||
|
@ -36,8 +36,8 @@ as a passed in dict, or as a string to pull from pillars or minion config:
|
||||
myqueue:
|
||||
boto_sqs.present:
|
||||
- region: us-east-1
|
||||
- key: GKTADJGHEIQSXMKKRBJ08H
|
||||
- keyid: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
|
||||
- keyid: GKTADJGHEIQSXMKKRBJ08H
|
||||
- key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
|
||||
- attributes:
|
||||
ReceiveMessageWaitTimeSeconds: 20
|
||||
|
||||
@ -52,8 +52,8 @@ as a passed in dict, or as a string to pull from pillars or minion config:
|
||||
boto_sqs.present:
|
||||
- region: us-east-1
|
||||
- profile:
|
||||
key: GKTADJGHEIQSXMKKRBJ08H
|
||||
keyid: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
|
||||
keyid: GKTADJGHEIQSXMKKRBJ08H
|
||||
key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
|
||||
'''
|
||||
|
||||
|
||||
@ -77,8 +77,11 @@ def present(
|
||||
name
|
||||
Name of the SQS queue.
|
||||
|
||||
attributes
|
||||
A dict of key/value SQS attributes.
|
||||
|
||||
region
|
||||
Region to create the queue
|
||||
Region to connect to.
|
||||
|
||||
key
|
||||
Secret key to be used.
|
||||
@ -90,18 +93,19 @@ def present(
|
||||
A dict with region, key and keyid, or a pillar key (string)
|
||||
that contains a dict with region, key and keyid.
|
||||
'''
|
||||
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
|
||||
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
|
||||
|
||||
is_present = __salt__['boto_sqs.exists'](name, region, key, keyid, profile)
|
||||
|
||||
if not is_present:
|
||||
ret['comment'] = 'AWS SQS queue {0} is set to be created.'.format(name)
|
||||
if __opts__['test']:
|
||||
ret['result'] = None
|
||||
msg = 'AWS SQS queue {0} is set to be created.'.format(name)
|
||||
ret['comment'] = msg
|
||||
return ret
|
||||
created = __salt__['boto_sqs.create'](name, region, key, keyid,
|
||||
profile)
|
||||
if created:
|
||||
ret['result'] = True
|
||||
ret['changes']['old'] = None
|
||||
ret['changes']['new'] = {'queue': name}
|
||||
else:
|
||||
@ -158,7 +162,7 @@ def absent(
|
||||
Name of the SQS queue.
|
||||
|
||||
region
|
||||
Region to remove the queue from
|
||||
Region to connect to.
|
||||
|
||||
key
|
||||
Secret key to be used.
|
||||
@ -176,7 +180,6 @@ def absent(
|
||||
|
||||
if is_present:
|
||||
if __opts__['test']:
|
||||
ret['result'] = None
|
||||
ret['comment'] = 'AWS SQS queue {0} is set to be removed.'.format(
|
||||
name)
|
||||
return ret
|
||||
|
Loading…
Reference in New Issue
Block a user