Various followup fixes for boto modules

This commit is contained in:
Ryan Lane 2015-10-09 14:25:00 -07:00
parent c45f989699
commit 81028e86ad
4 changed files with 71 additions and 60 deletions

View File

@ -77,7 +77,6 @@ except ImportError:
# Import Salt libs
from salt.ext.six import string_types
from salt.utils.boto_elb_tag import TagDescriptions as TagDescriptions
import salt.utils.odict as odict
@ -165,7 +164,7 @@ def get_elb_config(name, region=None, key=None, keyid=None, profile=None):
return []
def _listener_dict_to_tuple(listener):
def listener_dict_to_tuple(listener):
'''
Convert an ELB listener dict into a listener tuple used by certain parts of
the AWS ELB API.
@ -206,7 +205,7 @@ def create(name, availability_zones, listeners, subnets=None,
_complex_listeners = []
for listener in listeners:
_complex_listeners.append(_listener_dict_to_tuple(listener))
_complex_listeners.append(listener_dict_to_tuple(listener))
try:
lb = conn.create_load_balancer(name, availability_zones, [],
subnets, security_groups, scheme,
@ -269,7 +268,7 @@ def create_listeners(name, listeners, region=None, key=None, keyid=None,
_complex_listeners = []
for listener in listeners:
_complex_listeners.append(_listener_dict_to_tuple(listener))
_complex_listeners.append(listener_dict_to_tuple(listener))
try:
conn.create_load_balancer_listeners(name, [], _complex_listeners)
msg = 'Created ELB listeners on {0}'.format(name)
@ -903,8 +902,12 @@ def _get_all_tags(conn, load_balancer_names=None):
conn.build_list_params(params, load_balancer_names,
'LoadBalancerNames.member.%d')
tags = conn.get_object('DescribeTags', params, TagDescriptions,
verb='POST')
tags = conn.get_object(
'DescribeTags',
params,
__utils__['boto_elb_tag.get_tag_descriptions'](),
verb='POST'
)
if tags[load_balancer_names]:
return tags[load_balancer_names]
else:

View File

@ -434,8 +434,8 @@ def present(
if sg_index:
log.debug('security group associations found in launch config')
_group_ids = __salt__['boto_secgroup.convert_to_group_ids'](
launch_config[sg_index]['security_groups'], vpc_id, region,
key, keyid, profile
launch_config[sg_index]['security_groups'], vpc_id=vpc_id,
region=region, key=key, keyid=keyid, profile=profile
)
launch_config[sg_index]['security_groups'] = _group_ids

View File

@ -548,7 +548,8 @@ def _elb_present(
msg = 'Subnets {0} do not map to a valid vpc id.'.format(subnets)
raise SaltInvocationError(msg)
security_groups = __salt__['boto_secgroup.convert_to_group_ids'](
security_groups, vpc_id, region, key, keyid, profile
security_groups, vpc_id=vpc_id, region=region, key=key,
keyid=keyid, profile=profile
)
if not security_groups:
msg = 'Security groups {0} do not map to valid security group ids.'
@ -628,11 +629,11 @@ def _listeners_present(
expected_listeners_by_tuple = {}
for l in listeners:
key = __salt__['boto_elb._listener_dict_to_tuple'](l)
key = __salt__['boto_elb.listener_dict_to_tuple'](l)
expected_listeners_by_tuple[key] = l
actual_listeners_by_tuple = {}
for l in lb['listeners']:
key = __salt__['boto_elb._listener_dict_to_tuple'](l)
key = __salt__['boto_elb.listener_dict_to_tuple'](l)
actual_listeners_by_tuple[key] = l
to_delete = []
@ -651,10 +652,10 @@ def _listeners_present(
msg.append('ELB {0} set to have listeners modified:'.format(name))
for listener in to_create:
msg.append('Listener {0} added.'.format(
__salt__['boto_elb._listener_dict_to_tuple'](listener)))
__salt__['boto_elb.listener_dict_to_tuple'](listener)))
for listener in to_delete:
msg.append('Listener {0} deleted.'.format(
__salt__['boto_elb._listener_dict_to_tuple'](listener)))
__salt__['boto_elb.listener_dict_to_tuple'](listener)))
else:
msg.append('Listeners already set on ELB {0}.'.format(name))
ret['comment'] = ' '.join(msg)

View File

@ -22,9 +22,15 @@
# IN THE SOFTWARE.
def __virtual__():
return True
def get_tag_descriptions():
class TagDescriptions(dict):
'''
A TagDescriptions is used to collect the tags associated with ELB resources.
A TagDescriptions is used to collect the tags associated with ELB
resources.
See :class:`boto.ec2.elb.LoadBalancer` for more details.
'''
@ -49,7 +55,6 @@ class TagDescriptions(dict):
elif name == 'member':
self[self._load_balancer_name] = self._tags
class TagSet(dict):
'''
A TagSet is used to collect the tags associated with a particular
@ -76,3 +81,5 @@ class TagSet(dict):
self._current_value = value
elif name == 'member':
self[self._current_key] = self._current_value
return TagDescriptions