Browse files

Merge pull request #49 from calebfornari/master

Add VPC support
  • Loading branch information...
cosmin committed Apr 17, 2013
2 parents 877458d + 42683a4 commit 95398abb3ed351fe38302ce6f90a8c812d28be8a
Showing with 23 additions and 6 deletions.
  1. +17 −3 beeswithmachineguns/
  2. +6 −3 beeswithmachineguns/
@@ -71,10 +71,23 @@ def _get_pem_path(key):
def _get_region(zone):
return zone[:-1] # chop off the "d" in the "us-east-1d" to get the "Region"
+def _get_security_group_ids(connection, security_group_names):
+ ids = []
+ # Since we cannot get security groups in a vpc by name, we get all security groups and parse them by name later
+ security_groups = connection.get_all_security_groups()
+ # Parse the name of each security group and add the id of any match to the group list
+ for group in security_groups:
+ for name in security_group_names:
+ if == name:
+ ids.append(
+ return ids
# 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.
@@ -103,9 +116,10 @@ def up(count, group, zone, image_id, instance_type, username, key_name):
- security_groups=[group],
+ security_group_ids=_get_security_group_ids(ec2_connection, [group]),
- placement=zone)
+ placement=zone,
+ subnet_id=subnet)
print 'Waiting for bees to load their machine guns...'
@@ -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(s) to run the instances under (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. (default: None).")
@@ -115,8 +118,8 @@ def parse_options():
if == '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.instance, options.type, options.login, options.key)
+ bees.up(options.servers,,, 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')

0 comments on commit 95398ab

Please sign in to comment.