Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support ec2 profile #162

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions beeswithmachineguns/bees.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 5 additions & 2 deletions beeswithmachineguns/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down