Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding support for using vpc subnets.

This change introduces parameter dependencies when using a vpc subnet in
that security group identifiers must be passed as ID's instead of names,
and at least one security group is required in order to create an
instance in a vpc subnet.
  • Loading branch information...
commit 58b3c422af31b22a741b45fdf3ea05ed9b77d0b9 1 parent 1c93f61
Caleb Fornari calebfornari authored
Showing with 26 additions and 12 deletions.
  1. +20 −9 beeswithmachineguns/bees.py
  2. +6 −3 beeswithmachineguns/main.py
29 beeswithmachineguns/bees.py
View
@@ -74,7 +74,7 @@ def _get_region(zone):
# Methods
-def up(count, group, zone, image_id, instance_type, username, key_name):
+def up(count, group, zone, image_id, instance_type, username, key_name, subnet):
"""
Startup the load testing server.
"""
@@ -98,14 +98,25 @@ def up(count, group, zone, image_id, instance_type, username, key_name):
print 'Attempting to call up %i bees.' % count
- reservation = ec2_connection.run_instances(
- image_id=image_id,
- min_count=count,
- max_count=count,
- key_name=key_name,
- security_groups=[group],
- instance_type=instance_type,
- placement=zone)
+ if not subnet:
+ reservation = ec2_connection.run_instances(
+ image_id=image_id,
+ min_count=count,
+ max_count=count,
+ key_name=key_name,
+ security_groups=[group],
+ instance_type=instance_type,
+ placement=zone)
+ else:
+ reservation = ec2_connection.run_instances(
+ image_id=image_id,
+ min_count=count,
+ max_count=count,
+ key_name=key_name,
+ security_group_ids=[group],
+ instance_type=instance_type,
+ placement=zone,
+ subnet_id=subnet)
print 'Waiting for bees to load their machine guns...'
9 beeswithmachineguns/main.py
View
@@ -61,7 +61,7 @@ def parse_options():
help="The number of servers to start (default: 5).")
up_group.add_option('-g', '--group', metavar="GROUP", nargs=1,
action='store', dest='group', type='string', default='default',
- help="The security group to run the instances under (default: default).")
+ help="The security group to run the instances under. If a vpc subnet is specified using the -v parameter, you must specify security group id's instead of names (default: default).")
up_group.add_option('-z', '--zone', metavar="ZONE", nargs=1,
action='store', dest='zone', type='string', default='us-east-1d',
help="The availability zone to start the instances in (default: us-east-1d).")
@@ -74,6 +74,9 @@ def parse_options():
up_group.add_option('-l', '--login', metavar="LOGIN", nargs=1,
action='store', dest='login', type='string', default='newsapps',
help="The ssh username name to use to connect to the new servers (default: newsapps).")
+ up_group.add_option('-v', '--subnet', metavar="SUBNET", nargs=1,
+ action='store', dest='subnet', type='string', default=None,
+ help="The vpc subnet id in which the instances should be launched. When using this option, you must specify at least one security group id using the -g parameter (default: None).")
parser.add_option_group(up_group)
@@ -110,8 +113,8 @@ def parse_options():
if options.group == 'default':
print 'New bees will use the "default" EC2 security group. Please note that port 22 (SSH) is not normally open on this group. You will need to use to the EC2 tools to open it before you will be able to attack.'
-
- bees.up(options.servers, options.group, options.zone, options.instance, options.type, options.login, options.key)
+
+ bees.up(options.servers, options.group, options.zone, options.instance, options.type, options.login, options.key, options.subnet)
elif command == 'attack':
if not options.url:
parser.error('To run an attack you need to specify a url with -u')
Please sign in to comment.
Something went wrong with that request. Please try again.