def _create_server_ec2(connection,<EOL>region,<EOL>disk_name,<EOL>disk_size,<EOL>ami,<EOL>key_pair,<EOL>instance_type,<EOL>tags={},<EOL>security_groups=None,<EOL>delete_on_termination=True,<EOL>log=False,<EOL>wait_for_ssh_available=True):
if log:<EOL><INDENT>log_green("<STR_LIT>")<EOL>log_yellow("<STR_LIT>")<EOL><DEDENT>ebs_volume = EBSBlockDeviceType()<EOL>ebs_volume.size = disk_size<EOL>bdm = BlockDeviceMapping()<EOL>bdm[disk_name] = ebs_volume<EOL>image = connection.get_all_images(ami)[<NUM_LIT:0>]<EOL>reservation = image.run(<NUM_LIT:1>, <NUM_LIT:1>,<EOL>key_name=key_pair,<EOL>security_groups=security_groups,<EOL>block_device_map=bdm,<EOL>instance_type=instance_type)<EOL>instance = reservation.instances[<NUM_LIT:0>]<EOL>while instance.state == u'<STR_LIT>':<EOL><INDENT>if log:<EOL><INDENT>log_yellow("<STR_LIT>" % instance.state)<EOL><DEDENT>sleep(<NUM_LIT:10>)<EOL>instance.update()<EOL><DEDENT>if log:<EOL><INDENT>log_green("<STR_LIT>" % instance.state)<EOL><DEDENT>if wait_for_ssh_available:<EOL><INDENT>wait_for_ssh(instance.public_dns_name)<EOL><DEDENT>if delete_on_termination:<EOL><INDENT>for dev, bd in instance.block_device_mapping.items():<EOL><INDENT>instance.modify_attribute('<STR_LIT>',<EOL>["<STR_LIT>" % (dev, <NUM_LIT:1>)])<EOL><DEDENT><DEDENT>if tags:<EOL><INDENT>connection.create_tags([instance.id], tags)<EOL><DEDENT>if log:<EOL><INDENT>log_green("<STR_LIT>" % instance.public_dns_name)<EOL><DEDENT>return instance<EOL>
Creates EC2 Instance