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 internal/ext ip addresses if you don't have dns forwarding setup #201

Open
wants to merge 1 commit 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
16 changes: 13 additions & 3 deletions beeswithmachineguns/bees.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,18 +398,27 @@ def _attack(params):
print('Bee %i is joining the swarm.' % params['i'])

try:
# Support using local ssh config
config = paramiko.SSHConfig()
home = os.path.expanduser("~")
config.parse(open(home + '/.ssh/config'))

target = config.lookup(params['instance_name'])

client = paramiko.SSHClient()
# Load host keys
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

pem_path = params.get('key_name') and _get_pem_path(params['key_name']) or None
if not os.path.isfile(pem_path):
client.load_system_host_keys()
client.connect(params['instance_name'], username=params['username'])
client.connect(params['instance_ip'], username=params['username'])
else:
client.connect(
params['instance_name'],
params['instance_ip'],
username=params['username'],
key_filename=pem_path)
key_filename=target['identityfile'])

print('Bee %i is firing her machine gun. Bang bang!' % params['i'])

Expand Down Expand Up @@ -754,6 +763,7 @@ def attack(url, n, c, **options):
params.append({
'i': i,
'instance_id': instance.id,
'instance_ip': instance.private_ip_address if len(instance.ip_address) == 0 else instance.ip_address,
'instance_name': instance.private_dns_name if instance.public_dns_name == "" else instance.public_dns_name,
'url': urls[i % url_count],
'concurrent_requests': connections_per_instance,
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
boto==2.38.0
boto==2.48.0
paramiko==1.15.2
future

Expand Down