这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Mar 4, 2021. It is now read-only.
Merged
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
9 changes: 9 additions & 0 deletions src/main/java/com/netflix/simianarmy/aws/AWSClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.LinkedList;

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
import com.netflix.simianarmy.CloudClient;

import com.amazonaws.services.ec2.AmazonEC2;
Expand Down Expand Up @@ -49,6 +50,14 @@ public AWSClient(AWSCredentials cred, String region) {
this.region = region;
}

/**
* This constructor will use the {@link DefaultAWSCredentialsProviderChain} to obtain credentials.
* @param region
*/
public AWSClient(String region){
this(new DefaultAWSCredentialsProviderChain().getCredentials(), region);
}

protected AmazonEC2 ec2Client() {
AmazonEC2 client = new AmazonEC2Client(cred);
client.setEndpoint("ec2." + region + ".amazonaws.com");
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/netflix/simianarmy/aws/SimpleDBRecorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.auth.AWSCredentials;

import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
import com.amazonaws.services.simpledb.AmazonSimpleDB;
import com.amazonaws.services.simpledb.AmazonSimpleDBClient;
import com.amazonaws.services.simpledb.model.PutAttributesRequest;
Expand Down Expand Up @@ -73,8 +74,18 @@ public SimpleDBRecorder(AWSCredentials cred, String region, String domain) {
this.domain = domain;
}

/**
* Use {@link DefaultAWSCredentialsProviderChain} to provide credentials.
* @param region
* @param domain
*/
public SimpleDBRecorder(String region, String domain) {
this(new DefaultAWSCredentialsProviderChain().getCredentials(), region, domain);
}

protected AmazonSimpleDB sdbClient() {
AmazonSimpleDB client = new AmazonSimpleDBClient(cred);
client.setEndpoint("sdb." + region + ".amazonaws.com");
return client;
}

Expand Down Expand Up @@ -111,6 +122,8 @@ public void recordEvent(Event evt) {
List<ReplaceableAttribute> attrs = new LinkedList<ReplaceableAttribute>();
attrs.add(new ReplaceableAttribute(Keys.id.name(), evt.id(), true));
attrs.add(new ReplaceableAttribute(Keys.eventTime.name(), String.valueOf(evt.eventTime().getTime()), true));
//TODO I think region is overloaded here, probably need to distinguish between the region being changed
//and where the data is being stored.
attrs.add(new ReplaceableAttribute(Keys.region.name(), region, true));
attrs.add(new ReplaceableAttribute(Keys.recordType.name(), "MonkeyEvent", true));
attrs.add(new ReplaceableAttribute(Keys.monkeyType.name(), enumToValue(evt.monkeyType()), true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void init() {
}

@Test
public void testServlet() {
public void testResource() {
MonkeyRunner.getInstance().replaceMonkey(BasicChaosMonkey.class, MockTestChaosMonkeyContext.class);

ChaosMonkeyResource resource = new ChaosMonkeyResource();
Expand Down