Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # We use tags to identify hosts - tag is Name: host_short_name.
- # Tags are also used for other aws objects - Load balancers, snapshots etc..
- tagger = ec2conn.get_all_tags()
- for i in tagger:
- # Iterate through all tags and pull out the one that matches a hostname
- # We're interested in res_id (instance id) and value (tag value)
- # We are only interested in instances
- if i.res_type == 'instance':
- # We only want the tags that contain the hostname
- if i.name == 'Name':
- # This dict statement prints the full attributes of each tag/instance combo - for debugging
- #pprint.pprint(i.__dict__)
- # We want to make sure that the value pulled matches the hostname of the host we're running this on
- if i.value == small_host:
- print "Hostname of the node we're running this on is:"
- print small_host
- lbees = awslbconn.get_all_load_balancers()
- print "This is our load balancer:"
- print lbees
- # Only do load balancing actions on an app Server node
- if small_host.startswith ( 'n6a1' ) == True:
- print "This is the node name:"
- print i.value
- print "This is the instance id:"
- print i.res_id
- # Put LB stuff here
- print "Trying to install into the load balancer:"
- varvar = i.res_id
- print varvar
- lbtoggle = awslbconn.register_instances('server-lb', 'i-ef154389')
- print "The result is:"
- print lbtoggle
Add Comment
Please, Sign In to add comment