Commit a9e6d103 by John Jarvis

PEP8 cleanup

parent ae37b137
...@@ -129,11 +129,11 @@ def parse_args(): ...@@ -129,11 +129,11 @@ def parse_args():
group = parser.add_mutually_exclusive_group() group = parser.add_mutually_exclusive_group()
group.add_argument('-b', '--base-ami', required=False, group.add_argument('-b', '--base-ami', required=False,
help="ami to use as a base ami", help="ami to use as a base ami",
default="ami-0568456c") default="ami-0568456c")
group.add_argument('--blessed', action='store_true', group.add_argument('--blessed', action='store_true',
help="Look up blessed ami for env-dep-play.", help="Look up blessed ami for env-dep-play.",
default=False) default=False)
return parser.parse_args() return parser.parse_args()
...@@ -153,6 +153,7 @@ def get_instance_sec_group(vpc_id): ...@@ -153,6 +153,7 @@ def get_instance_sec_group(vpc_id):
return grp_details[0].id return grp_details[0].id
def get_blessed_ami(): def get_blessed_ami():
images = ec2.get_all_images( images = ec2.get_all_images(
filters={ filters={
...@@ -169,6 +170,7 @@ def get_blessed_ami(): ...@@ -169,6 +170,7 @@ def get_blessed_ami():
return images[0].id return images[0].id
def create_instance_args(): def create_instance_args():
""" """
Looks up security group, subnet Looks up security group, subnet
...@@ -542,6 +544,7 @@ def create_ami(instance_id, name, description): ...@@ -542,6 +544,7 @@ def create_ami(instance_id, name, description):
return image_id return image_id
def launch_and_configure(ec2_args): def launch_and_configure(ec2_args):
""" """
Creates an sqs queue, launches an ec2 instance, Creates an sqs queue, launches an ec2 instance,
...@@ -631,14 +634,15 @@ def launch_and_configure(ec2_args): ...@@ -631,14 +634,15 @@ def launch_and_configure(ec2_args):
return run_summary, ami return run_summary, ami
def send_hipchat_message(message): def send_hipchat_message(message):
#If hipchat is configured send the details to the specified room #If hipchat is configured send the details to the specified room
if args.hipchat_api_token and args.hipchat_room_id: if args.hipchat_api_token and args.hipchat_room_id:
import hipchat import hipchat
try: try:
hipchat = hipchat.HipChat(token=args.hipchat_api_token) hipchat = hipchat.HipChat(token=args.hipchat_api_token)
hipchat.message_room(args.hipchat_room_id,'AbbeyNormal', hipchat.message_room(args.hipchat_room_id, 'AbbeyNormal',
message) message)
except Exception as e: except Exception as e:
print("Hipchat messaging resulted in an error: %s." % e) print("Hipchat messaging resulted in an error: %s." % e)
...@@ -714,12 +718,11 @@ if __name__ == '__main__': ...@@ -714,12 +718,11 @@ if __name__ == '__main__':
run[0], run[1] / 60, run[1] % 60) run[0], run[1] / 60, run[1] % 60)
print "AMI: {}".format(ami) print "AMI: {}".format(ami)
message = 'Finished baking AMI {image_id} for {environment} ' \ message = 'Finished baking AMI {image_id} for {environment} {deployment} {play}.'.format(
'{deployment} {play}.'.format( image_id=ami,
image_id=ami, environment=args.environment,
environment=args.environment, deployment=args.deployment,
deployment=args.deployment, play=args.play)
play=args.play)
send_hipchat_message(message) send_hipchat_message(message)
except Exception as e: except Exception as e:
......
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