in application-load-balancer-copy-utility/copy_classic_load_balancer.py [0:0]
def get_elb_data(elb_name, region, profile):
if debug:
print("Getting existing Classic ELB data")
session = boto3.Session(profile_name=profile)
elbc = session.client('elb', region_name=region)
# Describes the specified the load balancer.
try:
describe_load_balancers = elbc.describe_load_balancers(
LoadBalancerNames=[elb_name])
except botocore.exceptions.ClientError as e:
if 'LoadBalancerNotFound' in e.response['Error']['Code']:
print('Cannot find a Classic load balancer in region {} named {}'.format(
region, elb_name))
if alb_exist(elb_name, region):
print('Your load balancer {} is already an Application Load Balancer in {}'.format(
elb_name, region))
sys.exit(1)
else:
sys.exit(1)
else:
print(e)
# Describes the attributes for the specified load balancer.
describe_load_balancer_attributes = elbc.describe_load_balancer_attributes(
LoadBalancerName=elb_name)
# Describes the specified policies.
describe_load_balancer_policies = elbc.describe_load_balancer_policies(
LoadBalancerName=elb_name)
# Describes the tags associated with the specified load balancers.
describe_tags = elbc.describe_tags(
LoadBalancerNames=[elb_name])
# Render a dictionary that contains load balancer attributes
elb_data = {}
elb_data.update(describe_load_balancers)
elb_data.update(describe_load_balancer_attributes)
elb_data.update(describe_load_balancer_policies)
elb_data.update(describe_tags)
if debug:
print("elb data:")
pprint(elb_data)
return elb_data