mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Various followup fixes for boto modules
This commit is contained in:
parent
c45f989699
commit
81028e86ad
@ -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:
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -22,57 +22,64 @@
|
||||
# IN THE SOFTWARE.
|
||||
|
||||
|
||||
class TagDescriptions(dict):
|
||||
'''
|
||||
A TagDescriptions is used to collect the tags associated with ELB resources.
|
||||
See :class:`boto.ec2.elb.LoadBalancer` for more details.
|
||||
'''
|
||||
|
||||
def __init__(self, connection=None):
|
||||
dict.__init__(self)
|
||||
self.connection = connection
|
||||
self._load_balancer_name = None
|
||||
self._tags = None
|
||||
|
||||
def startElement(self, name, attrs, connection):
|
||||
if name == 'member':
|
||||
self.load_balancer_name = None
|
||||
self.tags = None
|
||||
if name == 'Tags':
|
||||
self._tags = TagSet()
|
||||
return self._tags
|
||||
return None
|
||||
|
||||
def endElement(self, name, value, connection):
|
||||
if name == 'LoadBalancerName':
|
||||
self._load_balancer_name = value
|
||||
elif name == 'member':
|
||||
self[self._load_balancer_name] = self._tags
|
||||
def __virtual__():
|
||||
return True
|
||||
|
||||
|
||||
class TagSet(dict):
|
||||
'''
|
||||
A TagSet is used to collect the tags associated with a particular
|
||||
ELB resource. See :class:`boto.ec2.elb.LoadBalancer` for more
|
||||
details.
|
||||
'''
|
||||
def get_tag_descriptions():
|
||||
class TagDescriptions(dict):
|
||||
'''
|
||||
A TagDescriptions is used to collect the tags associated with ELB
|
||||
resources.
|
||||
See :class:`boto.ec2.elb.LoadBalancer` for more details.
|
||||
'''
|
||||
|
||||
def __init__(self, connection=None):
|
||||
dict.__init__(self)
|
||||
self.connection = connection
|
||||
self._current_key = None
|
||||
self._current_value = None
|
||||
def __init__(self, connection=None):
|
||||
dict.__init__(self)
|
||||
self.connection = connection
|
||||
self._load_balancer_name = None
|
||||
self._tags = None
|
||||
|
||||
def startElement(self, name, attrs, connection):
|
||||
if name == 'member':
|
||||
def startElement(self, name, attrs, connection):
|
||||
if name == 'member':
|
||||
self.load_balancer_name = None
|
||||
self.tags = None
|
||||
if name == 'Tags':
|
||||
self._tags = TagSet()
|
||||
return self._tags
|
||||
return None
|
||||
|
||||
def endElement(self, name, value, connection):
|
||||
if name == 'LoadBalancerName':
|
||||
self._load_balancer_name = value
|
||||
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
|
||||
ELB resource. See :class:`boto.ec2.elb.LoadBalancer` for more
|
||||
details.
|
||||
'''
|
||||
|
||||
def __init__(self, connection=None):
|
||||
dict.__init__(self)
|
||||
self.connection = connection
|
||||
self._current_key = None
|
||||
self._current_value = None
|
||||
return None
|
||||
|
||||
def endElement(self, name, value, connection):
|
||||
if name == 'Key':
|
||||
self._current_key = value
|
||||
elif name == 'Value':
|
||||
self._current_value = value
|
||||
elif name == 'member':
|
||||
self[self._current_key] = self._current_value
|
||||
def startElement(self, name, attrs, connection):
|
||||
if name == 'member':
|
||||
self._current_key = None
|
||||
self._current_value = None
|
||||
return None
|
||||
|
||||
def endElement(self, name, value, connection):
|
||||
if name == 'Key':
|
||||
self._current_key = value
|
||||
elif name == 'Value':
|
||||
self._current_value = value
|
||||
elif name == 'member':
|
||||
self[self._current_key] = self._current_value
|
||||
|
||||
return TagDescriptions
|
||||
|
Loading…
Reference in New Issue
Block a user