diff --git a/README.textile b/README.textile index 57ae2a4..8aae06b 100644 --- a/README.textile +++ b/README.textile @@ -217,6 +217,8 @@ Options: launched. (default: None). -b BID, --bid=BID The maximum bid price per spot instance (default: None). + -q PROFILE, --profile=PROFILE + The iam instance profile. (default: None). attack: Beginning an attack requires only that you specify the -u option with diff --git a/beeswithmachineguns/bees.py b/beeswithmachineguns/bees.py index ddba869..81466f6 100644 --- a/beeswithmachineguns/bees.py +++ b/beeswithmachineguns/bees.py @@ -53,7 +53,7 @@ from sets import Set STATE_FILENAME = os.path.expanduser('~/.bees') - +HEADER = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11'} # Utilities @contextmanager @@ -117,7 +117,7 @@ def _get_security_group_id(connection, security_group_name, subnet): # Methods -def up(count, group, zone, image_id, instance_type, username, key_name, subnet, bid = None): +def up(count, group, zone, image_id, instance_type, username, key_name, subnet, bid = None, profile = None): """ Startup the load testing server. """ @@ -185,7 +185,8 @@ def up(count, group, zone, image_id, instance_type, username, key_name, subnet, security_group_ids=[groupId], instance_type=instance_type, placement=placement, - subnet_id=subnet) + subnet_id=subnet, + instance_profile_arn=profile) # it can take a few seconds before the spot requests are fully processed time.sleep(5) @@ -203,7 +204,8 @@ def up(count, group, zone, image_id, instance_type, username, key_name, subnet, security_group_ids=[groupId], instance_type=instance_type, placement=placement, - subnet_id=subnet) + subnet_id=subnet, + instance_profile_arn=profile) except boto.exception.EC2ResponseError as e: print("Unable to call bees:", e.message) @@ -333,7 +335,7 @@ def _sting(params): basic_auth = params['basic_auth'] # Create request - request = Request(url) + request = Request(url, headers=HEADER) # Need to revisit to support all http verbs. if post_file: @@ -873,7 +875,7 @@ def hurl_attack(url, n, c, **options): print('Stinging URL so it will be cached for the attack.') - request = Request(url) + request = Request(url, headers=HEADER) # Need to revisit to support all http verbs. if post_file: try: diff --git a/beeswithmachineguns/main.py b/beeswithmachineguns/main.py index 329ba4c..5691805 100644 --- a/beeswithmachineguns/main.py +++ b/beeswithmachineguns/main.py @@ -85,6 +85,9 @@ def parse_options(): up_group.add_option('-b', '--bid', metavar="BID", nargs=1, action='store', dest='bid', type='float', default=None, help="The maximum bid price per spot instance (default: None).") + up_group.add_option('-q', '--profile', metavar="PROFILE", nargs=1, + action='store', dest='profile', type='string', default=None, + help="The iam instance profile. (default: None).") parser.add_option_group(up_group) @@ -199,11 +202,11 @@ def parse_options(): options.zone, options.instance, options.type,options.login, options.key, options.subnet, - options.bid)).start() + options.bid,options.profile)).start() #time allowed between threads time.sleep(delay) else: - bees.up(options.servers, options.group, options.zone, options.instance, options.type, options.login, options.key, options.subnet, options.bid) + bees.up(options.servers, options.group, options.zone, options.instance, options.type, options.login, options.key, options.subnet, options.bid, options.profile) elif command == 'attack': if not options.url: