Commit d6449711 by Michael DeHaan

Revert "Added an elb_region parameter for interacting with the ec2 elastic load…

Revert "Added an elb_region parameter for interacting with the ec2 elastic load balancer to work with regions other than us-east-1"

This reverts commit 1264a5b4.
parent 7d2585ca
...@@ -53,11 +53,6 @@ options: ...@@ -53,11 +53,6 @@ options:
- AWS Access API key - AWS Access API key
required: false required: false
default: None default: None
elb_region:
description:
- AWS Region the load balancer is in
required: false
default: None
""" """
...@@ -88,7 +83,6 @@ import os ...@@ -88,7 +83,6 @@ import os
try: try:
import boto import boto
from boto.ec2.elb import regions as elb_regions
except ImportError: except ImportError:
print "failed=True msg='boto required for this module'" print "failed=True msg='boto required for this module'"
sys.exit(1) sys.exit(1)
...@@ -98,23 +92,12 @@ class ElbManager: ...@@ -98,23 +92,12 @@ class ElbManager:
"""Handles EC2 instance ELB registration and de-registration""" """Handles EC2 instance ELB registration and de-registration"""
def __init__(self, module, instance_id=None, ec2_elbs=None, def __init__(self, module, instance_id=None, ec2_elbs=None,
ec2_access_key=None, ec2_secret_key=None, elb_region_name=None): ec2_access_key=None, ec2_secret_key=None):
self.ec2_access_key = ec2_access_key self.ec2_access_key = ec2_access_key
self.ec2_secret_key = ec2_secret_key self.ec2_secret_key = ec2_secret_key
self.module = module self.module = module
self.instance_id = instance_id self.instance_id = instance_id
self.elb_region = None
if elb_region_name is not None:
for region in elb_regions():
if region.name == elb_region_name:
self.elb_region = region
if self.elb_region is None:
self.module.fail_json(msg=str("Invalid region"))
self.lbs = self._get_instance_lbs(ec2_elbs) self.lbs = self._get_instance_lbs(ec2_elbs)
# if there are no ELBs to operate on # if there are no ELBs to operate on
# there will be no changes made # there will be no changes made
if len(self.lbs) > 0: if len(self.lbs) > 0:
...@@ -157,7 +140,7 @@ class ElbManager: ...@@ -157,7 +140,7 @@ class ElbManager:
are attached to self.instance_id""" are attached to self.instance_id"""
try: try:
elb = boto.connect_elb(self.ec2_access_key, self.ec2_secret_key, region=self.elb_region) elb = boto.connect_elb(self.ec2_access_key, self.ec2_secret_key)
except boto.exception.NoAuthHandlerFound, e: except boto.exception.NoAuthHandlerFound, e:
self.module.fail_json(msg=str(e)) self.module.fail_json(msg=str(e))
elbs = elb.get_all_load_balancers() elbs = elb.get_all_load_balancers()
...@@ -182,15 +165,13 @@ def main(): ...@@ -182,15 +165,13 @@ def main():
instance_id={'required': True}, instance_id={'required': True},
ec2_elbs={'default': None, 'required': False}, ec2_elbs={'default': None, 'required': False},
ec2_secret_key={'default': None, 'aliases': ['EC2_SECRET_KEY']}, ec2_secret_key={'default': None, 'aliases': ['EC2_SECRET_KEY']},
ec2_access_key={'default': None, 'aliases': ['EC2_ACCESS_KEY']}, ec2_access_key={'default': None, 'aliases': ['EC2_ACCESS_KEY']}
elb_region={'required': False, 'default': None}
) )
) )
ec2_secret_key = module.params['ec2_secret_key'] ec2_secret_key = module.params['ec2_secret_key']
ec2_access_key = module.params['ec2_access_key'] ec2_access_key = module.params['ec2_access_key']
ec2_elbs = module.params['ec2_elbs'] ec2_elbs = module.params['ec2_elbs']
elb_region = module.params['elb_region']
if module.params['state'] == 'present' and 'ec2_elbs' not in module.params: if module.params['state'] == 'present' and 'ec2_elbs' not in module.params:
module.fail_json(msg="ELBs are required for registration") module.fail_json(msg="ELBs are required for registration")
...@@ -202,7 +183,7 @@ def main(): ...@@ -202,7 +183,7 @@ def main():
instance_id = module.params['instance_id'] instance_id = module.params['instance_id']
elb_man = ElbManager(module, instance_id, ec2_elbs, ec2_access_key, elb_man = ElbManager(module, instance_id, ec2_elbs, ec2_access_key,
ec2_secret_key, elb_region) ec2_secret_key)
if module.params['state'] == 'present': if module.params['state'] == 'present':
elb_man.register() elb_man.register()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment