mirror of https://github.com/apache/jclouds.git
Issue 606:add ability to authorize ec2 ingress rules by source group constrained by port range
This commit is contained in:
parent
fc0277523f
commit
a26c568d7b
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.ec2.binders;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.aws.util.AWSUtils;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rest.Binder;
|
||||
|
||||
/**
|
||||
* Binds the String [] to query parameters named with GroupId.index
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class BindGroupIdsToIndexedFormParams implements Binder {
|
||||
@Override
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||
return AWSUtils.indexStringArrayToFormValuesWithPrefix(request, "GroupId", input);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.ec2.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.ec2.domain.IpPermission;
|
||||
import org.jclouds.ec2.util.IpPermissions;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.utils.ModifyRequest;
|
||||
import org.jclouds.rest.Binder;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class BindIpPermissionToIndexedFormParams implements Binder {
|
||||
|
||||
@Override
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||
checkArgument(checkNotNull(input, "input") instanceof IpPermission, "this binder is only valid for IpPermission");
|
||||
IpPermission perm = (IpPermission) input;
|
||||
return ModifyRequest.putFormParams(request, IpPermissions.buildFormParametersForIndex(0, perm));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.ec2.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.ec2.domain.IpPermission;
|
||||
import org.jclouds.ec2.util.IpPermissions;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.utils.ModifyRequest;
|
||||
import org.jclouds.rest.Binder;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableMultimap.Builder;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class BindIpPermissionsToIndexedFormParams implements Binder {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
|
||||
checkArgument(checkNotNull(input, "input") instanceof Iterable,
|
||||
"this binder is only valid for Iterable<IpPermission>");
|
||||
Builder<String, String> headers = ImmutableMultimap.<String, String> builder();
|
||||
int index = 0;
|
||||
for (IpPermission perm : (Iterable<IpPermission>) input)
|
||||
headers.putAll(IpPermissions.buildFormParametersForIndex(index++, perm));
|
||||
return ModifyRequest.putFormParams(request, headers.build());
|
||||
}
|
||||
|
||||
}
|
|
@ -71,8 +71,8 @@ public class EC2TemplateOptions extends TemplateOptions implements Cloneable {
|
|||
super.copyTo(to);
|
||||
if (to instanceof EC2TemplateOptions) {
|
||||
EC2TemplateOptions eTo = EC2TemplateOptions.class.cast(to);
|
||||
if (getGroupIds().size() > 0)
|
||||
eTo.securityGroups(getGroupIds());
|
||||
if (getGroups().size() > 0)
|
||||
eTo.securityGroups(getGroups());
|
||||
if (getKeyPair() != null)
|
||||
eTo.keyPair(getKeyPair());
|
||||
if (getBlockDeviceMappings().size() > 0)
|
||||
|
@ -84,7 +84,7 @@ public class EC2TemplateOptions extends TemplateOptions implements Cloneable {
|
|||
}
|
||||
}
|
||||
|
||||
private Set<String> groupIds = ImmutableSet.of();
|
||||
private Set<String> groupNames = ImmutableSet.of();
|
||||
private String keyPair = null;
|
||||
private boolean noKeyPair;
|
||||
private byte[] userData;
|
||||
|
@ -96,18 +96,18 @@ public class EC2TemplateOptions extends TemplateOptions implements Cloneable {
|
|||
*
|
||||
* @see EC2TemplateOptions#securityGroups(Iterable<String>)
|
||||
*/
|
||||
public EC2TemplateOptions securityGroups(String... groupIds) {
|
||||
return securityGroups(ImmutableSet.copyOf(groupIds));
|
||||
public EC2TemplateOptions securityGroups(String... groupNames) {
|
||||
return securityGroups(ImmutableSet.copyOf(groupNames));
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the security groups to be used for nodes with this template
|
||||
*/
|
||||
public EC2TemplateOptions securityGroups(Iterable<String> groupIds) {
|
||||
checkArgument(Iterables.size(groupIds) > 0, "you must specify at least one security group");
|
||||
for (String groupId : groupIds)
|
||||
public EC2TemplateOptions securityGroups(Iterable<String> groupNames) {
|
||||
checkArgument(Iterables.size(groupNames) > 0, "you must specify at least one security group");
|
||||
for (String groupId : groupNames)
|
||||
Preconditions2.checkNotEmpty(groupId, "all security groups must be non-empty");
|
||||
this.groupIds = ImmutableSet.copyOf(groupIds);
|
||||
this.groupNames = ImmutableSet.copyOf(groupNames);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -213,17 +213,17 @@ public class EC2TemplateOptions extends TemplateOptions implements Cloneable {
|
|||
/**
|
||||
* @see EC2TemplateOptions#securityGroups(Iterable<String>)
|
||||
*/
|
||||
public static EC2TemplateOptions securityGroups(String... groupIds) {
|
||||
public static EC2TemplateOptions securityGroups(String... groupNames) {
|
||||
EC2TemplateOptions options = new EC2TemplateOptions();
|
||||
return EC2TemplateOptions.class.cast(options.securityGroups(groupIds));
|
||||
return EC2TemplateOptions.class.cast(options.securityGroups(groupNames));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EC2TemplateOptions#securityGroups(Iterable<String>)
|
||||
*/
|
||||
public static EC2TemplateOptions securityGroups(Iterable<String> groupIds) {
|
||||
public static EC2TemplateOptions securityGroups(Iterable<String> groupNames) {
|
||||
EC2TemplateOptions options = new EC2TemplateOptions();
|
||||
return EC2TemplateOptions.class.cast(options.securityGroups(groupIds));
|
||||
return EC2TemplateOptions.class.cast(options.securityGroups(groupNames));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -427,11 +427,11 @@ public class EC2TemplateOptions extends TemplateOptions implements Cloneable {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return groupIds the user specified to run instances with, or zero length set to create an
|
||||
* @return groupNames the user specified to run instances with, or zero length set to create an
|
||||
* implicit group
|
||||
*/
|
||||
public Set<String> getGroupIds() {
|
||||
return groupIds;
|
||||
public Set<String> getGroups() {
|
||||
return groupNames;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -468,7 +468,7 @@ public class EC2TemplateOptions extends TemplateOptions implements Cloneable {
|
|||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((blockDeviceMappings == null) ? 0 : blockDeviceMappings.hashCode());
|
||||
result = prime * result + ((groupIds == null) ? 0 : groupIds.hashCode());
|
||||
result = prime * result + ((groupNames == null) ? 0 : groupNames.hashCode());
|
||||
result = prime * result + ((keyPair == null) ? 0 : keyPair.hashCode());
|
||||
result = prime * result + (noKeyPair ? 1231 : 1237);
|
||||
result = prime * result + Arrays.hashCode(userData);
|
||||
|
@ -489,10 +489,10 @@ public class EC2TemplateOptions extends TemplateOptions implements Cloneable {
|
|||
return false;
|
||||
} else if (!blockDeviceMappings.equals(other.blockDeviceMappings))
|
||||
return false;
|
||||
if (groupIds == null) {
|
||||
if (other.groupIds != null)
|
||||
if (groupNames == null) {
|
||||
if (other.groupNames != null)
|
||||
return false;
|
||||
} else if (!groupIds.equals(other.groupIds))
|
||||
} else if (!groupNames.equals(other.groupNames))
|
||||
return false;
|
||||
if (keyPair == null) {
|
||||
if (other.keyPair != null)
|
||||
|
@ -508,7 +508,7 @@ public class EC2TemplateOptions extends TemplateOptions implements Cloneable {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[groupIds=" + groupIds + ", keyPair=" + keyPair + ", noKeyPair=" + noKeyPair + ", userData="
|
||||
return "[groupNames=" + groupNames + ", keyPair=" + keyPair + ", noKeyPair=" + noKeyPair + ", userData="
|
||||
+ Arrays.toString(userData) + ", blockDeviceMappings=" + blockDeviceMappings.build() + "]";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,12 +150,11 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions {
|
|||
groups.add(markerGroup);
|
||||
|
||||
RegionNameAndIngressRules regionNameAndIngessRulesForMarkerGroup;
|
||||
|
||||
if (options instanceof EC2TemplateOptions && EC2TemplateOptions.class.cast(options).getGroupIds().size() > 0) {
|
||||
|
||||
if (userSpecifiedTheirOwnGroups(options)) {
|
||||
regionNameAndIngessRulesForMarkerGroup = new RegionNameAndIngressRules(region, markerGroup, new int[] {},
|
||||
false);
|
||||
groups.addAll(EC2TemplateOptions.class.cast(options).getGroupIds());
|
||||
|
||||
groups.addAll(EC2TemplateOptions.class.cast(options).getGroups());
|
||||
} else {
|
||||
regionNameAndIngessRulesForMarkerGroup = new RegionNameAndIngressRules(region, markerGroup,
|
||||
options.getInboundPorts(), true);
|
||||
|
@ -169,6 +168,10 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions {
|
|||
return groups.build();
|
||||
}
|
||||
|
||||
protected boolean userSpecifiedTheirOwnGroups(TemplateOptions options) {
|
||||
return options instanceof EC2TemplateOptions && EC2TemplateOptions.class.cast(options).getGroups().size() > 0;
|
||||
}
|
||||
|
||||
// allows us to mock this method
|
||||
@VisibleForTesting
|
||||
public javax.inject.Provider<RunInstancesOptions> getOptionsProvider() {
|
||||
|
|
|
@ -102,4 +102,10 @@ public class BlockDevice {
|
|||
return deleteOnTermination;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[volumeId=" + volumeId + ", attachmentStatus=" + attachmentStatus + ", attachTime="
|
||||
+ attachTime + ", deleteOnTermination=" + deleteOnTermination + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -20,119 +20,55 @@ package org.jclouds.ec2.domain;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-IpPermissionType.html"
|
||||
* @see <a href=
|
||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-IpPermissionType.html"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class IpPermission implements Comparable<IpPermission> {
|
||||
private final int fromPort;
|
||||
private final int toPort;
|
||||
private final Set<UserIdGroupPair> groups;
|
||||
private final IpProtocol ipProtocol;
|
||||
private final Set<String> ipRanges;
|
||||
|
||||
public IpPermission(int fromPort, int toPort, Set<UserIdGroupPair> groups,
|
||||
IpProtocol ipProtocol, Set<String> ipRanges) {
|
||||
this.fromPort = fromPort;
|
||||
this.toPort = toPort;
|
||||
this.groups = groups;
|
||||
this.ipProtocol = ipProtocol;
|
||||
this.ipRanges = ipRanges;
|
||||
}
|
||||
public interface IpPermission extends Comparable<IpPermission> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Start of port range for the TCP and UDP protocols, or an ICMP type number.
|
||||
* An ICMP type number of -1 indicates a wildcard (i.e., any ICMP type
|
||||
* number).
|
||||
*/
|
||||
public int compareTo(IpPermission o) {
|
||||
return (this == o) ? 0 : getIpProtocol().compareTo(o.getIpProtocol());
|
||||
}
|
||||
int getFromPort();
|
||||
|
||||
/**
|
||||
* Start of port range for the TCP and UDP protocols, or an ICMP type number. An ICMP type number
|
||||
* of -1 indicates a wildcard (i.e., any ICMP type number).
|
||||
* End of port range for the TCP and UDP protocols, or an ICMP code. An ICMP
|
||||
* code of -1 indicates a wildcard (i.e., any ICMP code).
|
||||
*/
|
||||
public int getFromPort() {
|
||||
return fromPort;
|
||||
}
|
||||
int getToPort();
|
||||
|
||||
/**
|
||||
* End of port range for the TCP and UDP protocols, or an ICMP code. An ICMP code of -1 indicates
|
||||
* a wildcard (i.e., any ICMP code).
|
||||
* List of security group and user ID pairs.
|
||||
*
|
||||
* @see #getUserIdGroupPairs
|
||||
*/
|
||||
public int getToPort() {
|
||||
return toPort;
|
||||
}
|
||||
@Deprecated
|
||||
Set<UserIdGroupPair> getGroups();
|
||||
|
||||
/**
|
||||
* List of security group and user ID pairs.
|
||||
*/
|
||||
public Set<UserIdGroupPair> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
Multimap<String, String> getUserIdGroupPairs();
|
||||
|
||||
/**
|
||||
* List of security group Ids
|
||||
*/
|
||||
Set<String> getGroupIds();
|
||||
|
||||
/**
|
||||
* IP protocol
|
||||
*/
|
||||
public IpProtocol getIpProtocol() {
|
||||
return ipProtocol;
|
||||
}
|
||||
IpProtocol getIpProtocol();
|
||||
|
||||
/**
|
||||
* IP ranges.
|
||||
*/
|
||||
public Set<String> getIpRanges() {
|
||||
return ipRanges;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + fromPort;
|
||||
result = prime * result + ((groups == null) ? 0 : groups.hashCode());
|
||||
result = prime * result + ((ipProtocol == null) ? 0 : ipProtocol.hashCode());
|
||||
result = prime * result + ((ipRanges == null) ? 0 : ipRanges.hashCode());
|
||||
result = prime * result + toPort;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
IpPermission other = (IpPermission) obj;
|
||||
if (fromPort != other.fromPort)
|
||||
return false;
|
||||
if (groups == null) {
|
||||
if (other.groups != null)
|
||||
return false;
|
||||
} else if (!groups.equals(other.groups))
|
||||
return false;
|
||||
if (ipProtocol == null) {
|
||||
if (other.ipProtocol != null)
|
||||
return false;
|
||||
} else if (!ipProtocol.equals(other.ipProtocol))
|
||||
return false;
|
||||
if (ipRanges == null) {
|
||||
if (other.ipRanges != null)
|
||||
return false;
|
||||
} else if (!ipRanges.equals(other.ipRanges))
|
||||
return false;
|
||||
if (toPort != other.toPort)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "IpPermission [fromPort=" + fromPort + ", groups=" + groups + ", ipProtocol="
|
||||
+ ipProtocol + ", ipRanges=" + ipRanges + ", toPort=" + toPort + "]";
|
||||
}
|
||||
|
||||
}
|
||||
Set<String> getIpRanges();
|
||||
}
|
|
@ -0,0 +1,239 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.ec2.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.LinkedHashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
*
|
||||
* @see <a href=
|
||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-IpPermissionType.html"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class IpPermissionImpl implements IpPermission {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private int fromPort;
|
||||
private int toPort;
|
||||
private IpProtocol ipProtocol;
|
||||
private Multimap<String, String> userIdGroupPairs = LinkedHashMultimap.create();
|
||||
private Set<String> groupIds = Sets.newLinkedHashSet();
|
||||
private Set<String> ipRanges = Sets.newLinkedHashSet();
|
||||
|
||||
public Builder fromPort(int fromPort) {
|
||||
this.fromPort = fromPort;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder toPort(int toPort) {
|
||||
this.fromPort = toPort;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder ipProtocol(IpProtocol ipProtocol) {
|
||||
this.ipProtocol = ipProtocol;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder userIdGroupPair(String userId, String groupNameOrId) {
|
||||
this.userIdGroupPairs.put(userId, groupNameOrId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder userIdGroupPairs(Multimap<String, String> userIdGroupPairs) {
|
||||
this.userIdGroupPairs.putAll(userIdGroupPairs);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder ipRange(String ipRange) {
|
||||
this.ipRanges.add(ipRange);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder ipRanges(Iterable<String> ipRanges) {
|
||||
Iterables.addAll(this.ipRanges, ipRanges);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder groupId(String groupId) {
|
||||
this.groupIds.add(groupId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder groupIds(Iterable<String> groupIds) {
|
||||
Iterables.addAll(this.groupIds, groupIds);
|
||||
return this;
|
||||
}
|
||||
|
||||
public IpPermission build() {
|
||||
return new IpPermissionImpl(ipProtocol, fromPort, toPort, userIdGroupPairs, groupIds, ipRanges);
|
||||
}
|
||||
}
|
||||
|
||||
private final int fromPort;
|
||||
private final int toPort;
|
||||
private final Multimap<String, String> userIdGroupPairs;
|
||||
private final Set<String> groupIds;
|
||||
private final IpProtocol ipProtocol;
|
||||
private final Set<String> ipRanges;
|
||||
|
||||
public IpPermissionImpl(IpProtocol ipProtocol, int fromPort, int toPort,
|
||||
Multimap<String, String> userIdGroupPairs, Iterable<String> groupIds, Iterable<String> ipRanges) {
|
||||
this.fromPort = fromPort;
|
||||
this.toPort = toPort;
|
||||
this.userIdGroupPairs = ImmutableMultimap.copyOf(checkNotNull(userIdGroupPairs, "userIdGroupPairs"));
|
||||
this.ipProtocol = checkNotNull(ipProtocol, "ipProtocol");
|
||||
this.groupIds = ImmutableSet.copyOf(checkNotNull(groupIds, "groupIds"));
|
||||
this.ipRanges = ImmutableSet.copyOf(checkNotNull(ipRanges, "ipRanges"));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public int compareTo(IpPermission o) {
|
||||
return (this == o) ? 0 : getIpProtocol().compareTo(o.getIpProtocol());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int getFromPort() {
|
||||
return fromPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int getToPort() {
|
||||
return toPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Set<UserIdGroupPair> getGroups() {
|
||||
ImmutableSet.Builder<UserIdGroupPair> groups = ImmutableSet.<UserIdGroupPair> builder();
|
||||
for (Entry<String, String> pair : userIdGroupPairs.entries())
|
||||
groups.add(new UserIdGroupPair(pair.getKey(), pair.getValue()));
|
||||
return groups.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Multimap<String, String> getUserIdGroupPairs() {
|
||||
return userIdGroupPairs;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getGroupIds() {
|
||||
return groupIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public IpProtocol getIpProtocol() {
|
||||
return ipProtocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getIpRanges() {
|
||||
return ipRanges;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + fromPort;
|
||||
result = prime * result + ((groupIds == null) ? 0 : groupIds.hashCode());
|
||||
result = prime * result + ((ipProtocol == null) ? 0 : ipProtocol.hashCode());
|
||||
result = prime * result + ((ipRanges == null) ? 0 : ipRanges.hashCode());
|
||||
result = prime * result + toPort;
|
||||
result = prime * result + ((userIdGroupPairs == null) ? 0 : userIdGroupPairs.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
IpPermissionImpl other = (IpPermissionImpl) obj;
|
||||
if (fromPort != other.fromPort)
|
||||
return false;
|
||||
if (groupIds == null) {
|
||||
if (other.groupIds != null)
|
||||
return false;
|
||||
} else if (!groupIds.equals(other.groupIds))
|
||||
return false;
|
||||
if (ipProtocol != other.ipProtocol)
|
||||
return false;
|
||||
if (ipRanges == null) {
|
||||
if (other.ipRanges != null)
|
||||
return false;
|
||||
} else if (!ipRanges.equals(other.ipRanges))
|
||||
return false;
|
||||
if (toPort != other.toPort)
|
||||
return false;
|
||||
if (userIdGroupPairs == null) {
|
||||
if (other.userIdGroupPairs != null)
|
||||
return false;
|
||||
} else if (!userIdGroupPairs.equals(other.userIdGroupPairs))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[fromPort=" + fromPort + ", toPort=" + toPort + ", userIdGroupPairs=" + userIdGroupPairs + ", groupIds="
|
||||
+ groupIds + ", ipProtocol=" + ipProtocol + ", ipRanges=" + ipRanges + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -26,10 +26,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
*/
|
||||
public enum IpProtocol {
|
||||
|
||||
TCP, UDP, ICMP, UNRECOGNIZED;
|
||||
TCP, UDP, ICMP, ALL, UNRECOGNIZED;
|
||||
|
||||
public String value() {
|
||||
return name().toLowerCase();
|
||||
return this == ALL ? "-1" : name().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,6 +39,8 @@ public enum IpProtocol {
|
|||
|
||||
public static IpProtocol fromValue(String protocol) {
|
||||
try {
|
||||
if (protocol.equalsIgnoreCase("-1"))
|
||||
return ALL;
|
||||
return valueOf(checkNotNull(protocol, "protocol").toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
|
|
|
@ -580,7 +580,7 @@ public class RunningInstance implements Comparable<RunningInstance> {
|
|||
+ ", instanceState=" + instanceState + ", instanceType=" + instanceType + ", virtualizationType="
|
||||
+ virtualizationType + ", imageId=" + imageId + ", ipAddress=" + ipAddress + ", dnsName=" + dnsName
|
||||
+ ", privateIpAddress=" + privateIpAddress + ", privateDnsName=" + privateDnsName + ", keyName="
|
||||
+ keyName + ", platform=" + platform + ", launchTime=" + launchTime + ", rootDeviceName="
|
||||
+ keyName + ", groupIds=" + groupIds + ", platform=" + platform + ", launchTime=" + launchTime + ", rootDeviceName="
|
||||
+ rootDeviceName + ", rootDeviceType=" + rootDeviceType + ", ebsBlockDevices=" + ebsBlockDevices + "]";
|
||||
}
|
||||
|
||||
|
|
|
@ -22,23 +22,28 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-SecurityGroupItemType.html"
|
||||
* @see <a href=
|
||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-SecurityGroupItemType.html"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class SecurityGroup implements Comparable<SecurityGroup> {
|
||||
|
||||
private final String region;
|
||||
private final String id;
|
||||
private final String name;
|
||||
private final String ownerId;
|
||||
private final String description;
|
||||
private final Set<IpPermission> ipPermissions;
|
||||
private final Set<IpPermissionImpl> ipPermissions;
|
||||
|
||||
public SecurityGroup(String region, String name, String ownerId, String description,
|
||||
Set<IpPermission> ipPermissions) {
|
||||
public SecurityGroup(String region, String id, String name, String ownerId, String description,
|
||||
Set<IpPermissionImpl> ipPermissions) {
|
||||
this.region = checkNotNull(region, "region");
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.ownerId = ownerId;
|
||||
this.description = description;
|
||||
|
@ -46,9 +51,10 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Security groups are not copied across Regions. Instances within the Region cannot communicate
|
||||
* with instances outside the Region using group-based firewall rules. Traffic from instances in
|
||||
* another Region is seen as WAN bandwidth.
|
||||
* Security groups are not copied across Regions. Instances within the Region
|
||||
* cannot communicate with instances outside the Region using group-based
|
||||
* firewall rules. Traffic from instances in another Region is seen as WAN
|
||||
* bandwidth.
|
||||
*/
|
||||
public String getRegion() {
|
||||
return region;
|
||||
|
@ -61,6 +67,14 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
|
|||
return (this == o) ? 0 : getName().compareTo(o.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* id of the security group. Not in all EC2 impls
|
||||
*/
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Name of the security group.
|
||||
*/
|
||||
|
@ -85,7 +99,7 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
|
|||
/**
|
||||
* Set of IP permissions associated with the security group.
|
||||
*/
|
||||
public Set<IpPermission> getIpPermissions() {
|
||||
public Set<IpPermissionImpl> getIpPermissions() {
|
||||
return ipPermissions;
|
||||
}
|
||||
|
||||
|
@ -94,6 +108,7 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
|
|||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
result = prime * result + ((ipPermissions == null) ? 0 : ipPermissions.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((ownerId == null) ? 0 : ownerId.hashCode());
|
||||
|
@ -115,6 +130,11 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
|
|||
return false;
|
||||
} else if (!description.equals(other.description))
|
||||
return false;
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
if (ipPermissions == null) {
|
||||
if (other.ipPermissions != null)
|
||||
return false;
|
||||
|
@ -140,7 +160,7 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SecurityGroup [description=" + description + ", ipPermissions=" + ipPermissions
|
||||
+ ", name=" + name + ", ownerId=" + ownerId + ", region=" + region + "]";
|
||||
return "[region=" + region + ", id=" + id + ", name=" + name + ", ownerId=" + ownerId + ", description="
|
||||
+ description + ", ipPermissions=" + ipPermissions + "]";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,9 +79,9 @@ public class CreateImageOptions extends BaseEC2RequestOptions {
|
|||
/**
|
||||
* @see CreateImageOptions#withDescription(String )
|
||||
*/
|
||||
public static CreateImageOptions withDescription(String identityId) {
|
||||
public static CreateImageOptions withDescription(String description) {
|
||||
CreateImageOptions options = new CreateImageOptions();
|
||||
return options.withDescription(identityId);
|
||||
return options.withDescription(description);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,199 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.ec2.util;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.jclouds.ec2.domain.IpPermission;
|
||||
import org.jclouds.ec2.domain.IpPermissionImpl;
|
||||
import org.jclouds.ec2.domain.IpProtocol;
|
||||
import org.jclouds.util.Maps2;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Multimaps;
|
||||
|
||||
/**
|
||||
*
|
||||
* Shortcut to create ingress rules
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class IpPermissions extends IpPermissionImpl {
|
||||
|
||||
protected IpPermissions(IpProtocol ipProtocol, int fromPort, int toPort,
|
||||
Multimap<String, String> userIdGroupPairs, Iterable<String> groupIds, Iterable<String> ipRanges) {
|
||||
super(ipProtocol, fromPort, toPort, userIdGroupPairs, groupIds, userIdGroupPairs.size() == 0 ? ipRanges
|
||||
: ImmutableSet.<String> of());
|
||||
}
|
||||
|
||||
/**
|
||||
* don't rely on this being here.. it will move
|
||||
*/
|
||||
@Beta
|
||||
public static Multimap<String, String> buildFormParametersForIndex(final int index, IpPermission permission) {
|
||||
Map<String, String> headers = Maps.newLinkedHashMap();
|
||||
headers.put("IpPermissions.%d.IpProtocol", permission.getIpProtocol().toString());
|
||||
headers.put("IpPermissions.%d.FromPort", permission.getFromPort() + "");
|
||||
headers.put("IpPermissions.%d.ToPort", permission.getToPort() + "");
|
||||
String prefix = "IpPermissions.%d.IpRanges.";
|
||||
int i = 0;
|
||||
for (String cidrIp : checkNotNull(permission.getIpRanges(), "cidrIps")) {
|
||||
headers.put(prefix + i++ + ".CidrIp", cidrIp);
|
||||
}
|
||||
prefix = "IpPermissions.%d.Groups.";
|
||||
i = 0;
|
||||
for (String groupId : checkNotNull(permission.getGroupIds(), "groupIds")) {
|
||||
headers.put(prefix + i++ + ".GroupId", groupId);
|
||||
}
|
||||
prefix = "IpPermissions.%d.Groups.";
|
||||
i = 0;
|
||||
for (Entry<String, String> userIdGroupNamePair : checkNotNull(permission.getUserIdGroupPairs(),
|
||||
"userIdGroupNamePairs").entries()) {
|
||||
headers.put(prefix + i++ + ".UserId", userIdGroupNamePair.getKey());
|
||||
headers.put(prefix + i + ".GroupName", userIdGroupNamePair.getValue());
|
||||
}
|
||||
prefix = "IpPermissions.%d.IpRanges.";
|
||||
i = 0;
|
||||
for (String cidrIp : checkNotNull(permission.getIpRanges(), "cidrIps")) {
|
||||
headers.put(prefix + i++ + ".CidrIp", cidrIp);
|
||||
}
|
||||
return Multimaps.forMap(Maps2.transformKeys(headers, new Function<String, String>() {
|
||||
|
||||
@Override
|
||||
public String apply(String arg0) {
|
||||
return String.format(arg0, index);
|
||||
}
|
||||
|
||||
}));
|
||||
}
|
||||
|
||||
public static ICMPTypeSelection permitICMP() {
|
||||
return new ICMPTypeSelection();
|
||||
}
|
||||
|
||||
public static ToSourceSelection permitAnyProtocol() {
|
||||
return new ToSourceSelection(IpProtocol.ALL, 1, 65535);
|
||||
}
|
||||
|
||||
public static PortSelection permit(IpProtocol protocol) {
|
||||
return new PortSelection(checkNotNull(protocol, "protocol"));
|
||||
}
|
||||
|
||||
public static class ICMPTypeSelection extends ToSourceSelection {
|
||||
|
||||
ICMPTypeSelection() {
|
||||
super(IpProtocol.ICMP, -1, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type ex. 8 for ECHO (i.e. Ping)
|
||||
* @see <a href="http://www.iana.org/assignments/icmp-parameters/icmp-parameters.xml"> ICMP Types</a>
|
||||
*/
|
||||
public AndCodeSelection type(int type) {
|
||||
return new AndCodeSelection(type);
|
||||
}
|
||||
}
|
||||
|
||||
public static class AndCodeSelection extends ToSourceSelection {
|
||||
AndCodeSelection(int type) {
|
||||
super(IpProtocol.ICMP, type, -1);
|
||||
}
|
||||
|
||||
public ToSourceSelection andCode(int code) {
|
||||
return new ToSourceSelection(getIpProtocol(), getFromPort(), code);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class PortSelection extends ToSourceSelection {
|
||||
|
||||
PortSelection(IpProtocol ipProtocol) {
|
||||
super(ipProtocol, ipProtocol == IpProtocol.ICMP ? -1 : 1, ipProtocol == IpProtocol.ICMP ? -1 : 65535);
|
||||
}
|
||||
|
||||
public ToPortSelection fromPort(int port) {
|
||||
return new ToPortSelection(getIpProtocol(), port);
|
||||
}
|
||||
|
||||
public ToSourceSelection port(int port) {
|
||||
return new ToSourceSelection(getIpProtocol(), port, port);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ToPortSelection extends ToSourceSelection {
|
||||
|
||||
ToPortSelection(IpProtocol ipProtocol, int fromPort) {
|
||||
super(ipProtocol, fromPort, ipProtocol == IpProtocol.ICMP ? -1 : 65535);
|
||||
}
|
||||
|
||||
public ToSourceSelection to(int port) {
|
||||
return new ToSourceSelection(getIpProtocol(), getFromPort(), port);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ToVPCSourceSelection extends IpPermissions {
|
||||
|
||||
protected ToVPCSourceSelection(IpProtocol ipProtocol, int fromPort, int toPort) {
|
||||
super(ipProtocol, fromPort, toPort, ImmutableMultimap.<String, String> of(), ImmutableSet.<String> of(),
|
||||
ImmutableSet.of("0.0.0.0/0"));
|
||||
}
|
||||
|
||||
public IpPermissions originatingFromSecurityGroupId(String groupId) {
|
||||
return toVPCSecurityGroups(ImmutableSet.of(checkNotNull(groupId, "groupId")));
|
||||
}
|
||||
|
||||
public IpPermissions toVPCSecurityGroups(Iterable<String> groupIds) {
|
||||
return new IpPermissions(getIpProtocol(), getFromPort(), getToPort(), getUserIdGroupPairs(), groupIds,
|
||||
ImmutableSet.<String> of());
|
||||
}
|
||||
}
|
||||
|
||||
public static class ToSourceSelection extends ToVPCSourceSelection {
|
||||
ToSourceSelection(IpProtocol ipProtocol, int fromPort, int toPort) {
|
||||
super(ipProtocol, fromPort, toPort);
|
||||
}
|
||||
|
||||
public IpPermissions originatingFromCidrBlock(String cidrIp) {
|
||||
return originatingFromCidrBlocks(ImmutableSet.of(checkNotNull(cidrIp, "cidrIp")));
|
||||
}
|
||||
|
||||
public IpPermissions originatingFromCidrBlocks(Iterable<String> cidrIps) {
|
||||
return new IpPermissions(getIpProtocol(), getFromPort(), getToPort(),
|
||||
ImmutableMultimap.<String, String> of(), ImmutableSet.<String> of(), cidrIps);
|
||||
}
|
||||
|
||||
public IpPermissions originatingFromUserAndSecurityGroup(String userId, String groupName) {
|
||||
return toEC2SecurityGroups(ImmutableMultimap.of(checkNotNull(userId, "userId"),
|
||||
checkNotNull(groupName, "groupName")));
|
||||
}
|
||||
|
||||
public IpPermissions toEC2SecurityGroups(Multimap<String, String> userIdGroupNamePairs) {
|
||||
return new IpPermissions(getIpProtocol(), getFromPort(), getToPort(), userIdGroupNamePairs, getGroupIds(),
|
||||
ImmutableSet.<String> of());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,6 +18,9 @@
|
|||
*/
|
||||
package org.jclouds.ec2.xml;
|
||||
|
||||
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -56,7 +59,7 @@ public abstract class BaseReservationHandler<T> extends HandlerForGeneratedReque
|
|||
|
||||
@Inject
|
||||
public BaseReservationHandler(DateService dateService, @Region String defaultRegion,
|
||||
Provider<RunningInstance.Builder> builderProvider) {
|
||||
Provider<RunningInstance.Builder> builderProvider) {
|
||||
this.dateService = dateService;
|
||||
this.defaultRegion = defaultRegion;
|
||||
this.builderProvider = builderProvider;
|
||||
|
@ -85,103 +88,98 @@ public abstract class BaseReservationHandler<T> extends HandlerForGeneratedReque
|
|||
private Set<RunningInstance> instances = Sets.newLinkedHashSet();
|
||||
|
||||
public void startElement(String uri, String name, String qName, Attributes attrs) {
|
||||
if (qName.equals("item")) {
|
||||
if (equalsOrSuffix(qName, "item")) {
|
||||
itemDepth++;
|
||||
} else if (qName.equals("instancesSet")) {
|
||||
} else if (equalsOrSuffix(qName, "instancesSet")) {
|
||||
inInstancesSet = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected String currentOrNull() {
|
||||
String returnVal = currentText.toString().trim();
|
||||
return returnVal.equals("") ? null : returnVal;
|
||||
}
|
||||
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
if (qName.equals("item")) {
|
||||
if (equalsOrSuffix(qName, "item")) {
|
||||
inItem();
|
||||
itemDepth--;
|
||||
} else if (qName.equals("instancesSet")) {
|
||||
} else if (equalsOrSuffix(qName, "instancesSet")) {
|
||||
inInstancesSet = false;
|
||||
} else if (qName.equals("groupId")) {
|
||||
groupIds.add(currentOrNull());
|
||||
} else if (qName.equals("ownerId")) {
|
||||
ownerId = currentOrNull();
|
||||
} else if (qName.equals("requesterId")) {
|
||||
requesterId = currentOrNull();
|
||||
} else if (qName.equals("reservationId")) {
|
||||
reservationId = currentOrNull();
|
||||
} else if (qName.equals("amiLaunchIndex")) {
|
||||
builder.amiLaunchIndex(currentOrNull());
|
||||
} else if (qName.equals("dnsName")) {
|
||||
String dnsName = currentOrNull();
|
||||
} else if (equalsOrSuffix(qName, "groupId")) {
|
||||
groupIds.add(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "ownerId")) {
|
||||
ownerId = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "requesterId")) {
|
||||
requesterId = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "reservationId")) {
|
||||
reservationId = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "amiLaunchIndex")) {
|
||||
builder.amiLaunchIndex(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "dnsName")) {
|
||||
String dnsName = currentOrNull(currentText);
|
||||
// Eucalyptus
|
||||
if (!"0.0.0.0".equals(dnsName))
|
||||
builder.dnsName(dnsName);
|
||||
} else if (qName.equals("imageId")) {
|
||||
builder.imageId(currentOrNull());
|
||||
} else if (qName.equals("instanceId")) {
|
||||
builder.instanceId(currentOrNull());
|
||||
} else if (qName.equals("name")) {
|
||||
builder.instanceState(InstanceState.fromValue(currentOrNull()));
|
||||
} else if (qName.equals("instanceType")) {
|
||||
builder.instanceType(currentOrNull());
|
||||
} else if (qName.equals("ipAddress")) {
|
||||
builder.ipAddress(currentOrNull());
|
||||
} else if (qName.equals("kernelId")) {
|
||||
builder.kernelId(currentOrNull());
|
||||
} else if (qName.equals("keyName")) {
|
||||
builder.keyName(currentOrNull());
|
||||
} else if (qName.equals("launchTime")) {
|
||||
} else if (equalsOrSuffix(qName, "imageId")) {
|
||||
builder.imageId(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "instanceId")) {
|
||||
builder.instanceId(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "name")) {
|
||||
builder.instanceState(InstanceState.fromValue(currentOrNull(currentText)));
|
||||
} else if (equalsOrSuffix(qName, "instanceType")) {
|
||||
builder.instanceType(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "ipAddress")) {
|
||||
builder.ipAddress(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "kernelId")) {
|
||||
builder.kernelId(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "keyName")) {
|
||||
builder.keyName(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "launchTime")) {
|
||||
builder.launchTime(parseDate());
|
||||
} else if (qName.equals("availabilityZone")) {
|
||||
builder.availabilityZone(currentOrNull());
|
||||
} else if (qName.equals("virtualizationType")) {
|
||||
builder.virtualizationType(currentOrNull());
|
||||
} else if (qName.equals("platform")) {
|
||||
builder.platform(currentOrNull());
|
||||
} else if (qName.equals("privateDnsName")) {
|
||||
String privateDnsName = currentOrNull();
|
||||
} else if (equalsOrSuffix(qName, "availabilityZone")) {
|
||||
builder.availabilityZone(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "virtualizationType")) {
|
||||
builder.virtualizationType(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "platform")) {
|
||||
builder.platform(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "privateDnsName")) {
|
||||
String privateDnsName = currentOrNull(currentText);
|
||||
// Eucalyptus
|
||||
if (!"0.0.0.0".equals(privateDnsName))
|
||||
builder.privateDnsName(privateDnsName);
|
||||
} else if (qName.equals("privateIpAddress")) {
|
||||
builder.privateIpAddress(currentOrNull());
|
||||
} else if (qName.equals("ramdiskId")) {
|
||||
builder.ramdiskId(currentOrNull());
|
||||
} else if (qName.equals("reason")) {
|
||||
builder.reason(currentOrNull());
|
||||
} else if (qName.equals("rootDeviceType")) {
|
||||
builder.rootDeviceType(RootDeviceType.fromValue(currentOrNull()));
|
||||
} else if (qName.equals("rootDeviceName")) {
|
||||
builder.rootDeviceName(currentOrNull());
|
||||
} else if (qName.equals("deviceName")) {
|
||||
deviceName = currentOrNull();
|
||||
} else if (qName.equals("volumeId")) {
|
||||
volumeId = currentOrNull();
|
||||
} else if (qName.equals("status")) {
|
||||
} else if (equalsOrSuffix(qName, "privateIpAddress")) {
|
||||
builder.privateIpAddress(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "ramdiskId")) {
|
||||
builder.ramdiskId(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "reason")) {
|
||||
builder.reason(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "rootDeviceType")) {
|
||||
builder.rootDeviceType(RootDeviceType.fromValue(currentOrNull(currentText)));
|
||||
} else if (equalsOrSuffix(qName, "rootDeviceName")) {
|
||||
builder.rootDeviceName(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "deviceName")) {
|
||||
deviceName = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "volumeId")) {
|
||||
volumeId = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "status")) {
|
||||
attachmentStatus = Attachment.Status.fromValue(currentText.toString().trim());
|
||||
} else if (qName.equals("attachTime")) {
|
||||
} else if (equalsOrSuffix(qName, "attachTime")) {
|
||||
attachTime = dateService.iso8601DateParse(currentText.toString().trim());
|
||||
} else if (qName.equals("deleteOnTermination")) {
|
||||
} else if (equalsOrSuffix(qName, "deleteOnTermination")) {
|
||||
deleteOnTermination = Boolean.parseBoolean(currentText.toString().trim());
|
||||
} else if (qName.equals("ebs")) {
|
||||
} else if (equalsOrSuffix(qName, "ebs")) {
|
||||
builder.device(deviceName, new BlockDevice(volumeId, attachmentStatus, attachTime, deleteOnTermination));
|
||||
this.deviceName = null;
|
||||
this.volumeId = null;
|
||||
this.attachmentStatus = null;
|
||||
this.attachTime = null;
|
||||
this.deleteOnTermination = true;
|
||||
}
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
protected Date parseDate() {
|
||||
try {
|
||||
return dateService.iso8601DateParse(currentOrNull());
|
||||
return dateService.iso8601DateParse(currentOrNull(currentText));
|
||||
} catch (RuntimeException e) {
|
||||
// Eucalyptus
|
||||
return dateService.iso8601SecondsDateParse(currentOrNull());
|
||||
return dateService.iso8601SecondsDateParse(currentOrNull(currentText));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,7 +200,7 @@ public abstract class BaseReservationHandler<T> extends HandlerForGeneratedReque
|
|||
builder.dnsName(null);
|
||||
}
|
||||
if (builder.getPrivateIpAddress() == null && builder.getPrivateDnsName() != null
|
||||
&& builder.getPrivateDnsName().matches(".*[0-9]$")) {
|
||||
&& builder.getPrivateDnsName().matches(".*[0-9]$")) {
|
||||
builder.privateIpAddress(builder.getPrivateDnsName());
|
||||
builder.privateDnsName(null);
|
||||
}
|
||||
|
@ -228,7 +226,7 @@ public abstract class BaseReservationHandler<T> extends HandlerForGeneratedReque
|
|||
if (region == null)
|
||||
region = defaultRegion;
|
||||
Reservation<? extends RunningInstance> info = new Reservation<RunningInstance>(region, groupIds, instances,
|
||||
ownerId, requesterId, reservationId);
|
||||
ownerId, requesterId, reservationId);
|
||||
this.groupIds = Sets.newLinkedHashSet();
|
||||
this.instances = Sets.newLinkedHashSet();
|
||||
this.ownerId = null;
|
||||
|
|
|
@ -18,43 +18,51 @@
|
|||
*/
|
||||
package org.jclouds.ec2.xml;
|
||||
|
||||
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.util.AWSUtils;
|
||||
import org.jclouds.ec2.domain.IpPermission;
|
||||
import org.jclouds.ec2.domain.IpPermissionImpl;
|
||||
import org.jclouds.ec2.domain.IpProtocol;
|
||||
import org.jclouds.ec2.domain.SecurityGroup;
|
||||
import org.jclouds.ec2.domain.UserIdGroupPair;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.location.Region;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.LinkedHashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Parses: DescribeSecurityGroupsResponse xmlns="http://ec2.amazonaws.com/doc/2010-06-15/"
|
||||
* Parses: DescribeSecurityGroupsResponse
|
||||
* xmlns="http://ec2.amazonaws.com/doc/2010-06-15/"
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeSecurityGroups.html"
|
||||
* @see <a href=
|
||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeSecurityGroups.html"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class DescribeSecurityGroupsResponseHandler extends
|
||||
ParseSax.HandlerForGeneratedRequestWithResult<Set<SecurityGroup>> {
|
||||
ParseSax.HandlerForGeneratedRequestWithResult<Set<SecurityGroup>> {
|
||||
@Inject
|
||||
@Region
|
||||
String defaultRegion;
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private Set<SecurityGroup> securtyGroups = Sets.newLinkedHashSet();
|
||||
private String groupId;
|
||||
private String groupName;
|
||||
private String ownerId;
|
||||
private String groupDescription;
|
||||
private Set<IpPermission> ipPermissions = Sets.newLinkedHashSet();
|
||||
private Set<IpPermissionImpl> ipPermissions = Sets.newLinkedHashSet();
|
||||
private int fromPort;
|
||||
private int toPort;
|
||||
private Set<UserIdGroupPair> groups = Sets.newLinkedHashSet();
|
||||
private Multimap<String, String> groups = LinkedHashMultimap.create();
|
||||
private String userId;
|
||||
private String userIdGroupName;
|
||||
private IpProtocol ipProtocol;
|
||||
|
@ -69,60 +77,64 @@ public class DescribeSecurityGroupsResponseHandler extends
|
|||
}
|
||||
|
||||
public void startElement(String uri, String name, String qName, Attributes attrs) {
|
||||
if (qName.equals("ipPermissions")) {
|
||||
if (equalsOrSuffix(qName, "ipPermissions")) {
|
||||
inIpPermissions = true;
|
||||
} else if (qName.equals("ipRanges")) {
|
||||
} else if (equalsOrSuffix(qName, "ipRanges")) {
|
||||
inIpRanges = true;
|
||||
} else if (qName.equals("groups")) {
|
||||
} else if (equalsOrSuffix(qName, "groups")) {
|
||||
inGroups = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
if (qName.equals("groupName")) {
|
||||
if (equalsOrSuffix(qName, "groupName")) {
|
||||
if (!inGroups)
|
||||
this.groupName = currentText.toString().trim();
|
||||
this.groupName = currentOrNull(currentText);
|
||||
else
|
||||
this.userIdGroupName = currentText.toString().trim();
|
||||
} else if (qName.equals("ownerId")) {
|
||||
this.ownerId = currentText.toString().trim();
|
||||
} else if (qName.equals("userId")) {
|
||||
this.userId = currentText.toString().trim();
|
||||
} else if (qName.equals("groupDescription")) {
|
||||
this.groupDescription = currentText.toString().trim();
|
||||
} else if (qName.equals("ipProtocol")) {
|
||||
this.ipProtocol = IpProtocol.fromValue(currentText.toString().trim());
|
||||
} else if (qName.equals("fromPort")) {
|
||||
this.fromPort = Integer.parseInt(currentText.toString().trim());
|
||||
} else if (qName.equals("toPort")) {
|
||||
this.toPort = Integer.parseInt(currentText.toString().trim());
|
||||
} else if (qName.equals("cidrIp")) {
|
||||
this.ipRanges.add(currentText.toString().trim());
|
||||
} else if (qName.equals("ipPermissions")) {
|
||||
this.userIdGroupName = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "groupId")) {
|
||||
this.groupId = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "ownerId")) {
|
||||
this.ownerId = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "userId")) {
|
||||
this.userId = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "groupDescription")) {
|
||||
this.groupDescription = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "ipProtocol")) {
|
||||
this.ipProtocol = IpProtocol.fromValue(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "fromPort")) {
|
||||
this.fromPort = Integer.parseInt(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "toPort")) {
|
||||
this.toPort = Integer.parseInt(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "cidrIp")) {
|
||||
this.ipRanges.add(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "ipPermissions")) {
|
||||
inIpPermissions = false;
|
||||
} else if (qName.equals("ipRanges")) {
|
||||
} else if (equalsOrSuffix(qName, "ipRanges")) {
|
||||
inIpRanges = false;
|
||||
} else if (qName.equals("groups")) {
|
||||
} else if (equalsOrSuffix(qName, "groups")) {
|
||||
inGroups = false;
|
||||
} else if (qName.equals("item")) {
|
||||
} else if (equalsOrSuffix(qName, "item")) {
|
||||
if (inIpPermissions && !inIpRanges && !inGroups) {
|
||||
ipPermissions.add(new IpPermission(fromPort, toPort, groups, ipProtocol, ipRanges));
|
||||
// TODO groups? we need an example of VPC stuff
|
||||
ipPermissions.add(new IpPermissionImpl(ipProtocol, fromPort, toPort, groups, ImmutableSet.<String> of(),
|
||||
ipRanges));
|
||||
this.fromPort = -1;
|
||||
this.toPort = -1;
|
||||
this.groups = Sets.newLinkedHashSet();
|
||||
this.groups = LinkedHashMultimap.create();
|
||||
this.ipProtocol = null;
|
||||
this.ipRanges = Sets.newLinkedHashSet();
|
||||
} else if (inIpPermissions && !inIpRanges && inGroups) {
|
||||
this.groups.add(new UserIdGroupPair(userId, userIdGroupName));
|
||||
this.groups.put(userId, userIdGroupName);
|
||||
this.userId = null;
|
||||
this.userIdGroupName = null;
|
||||
} else if (!inIpPermissions && !inIpRanges && !inGroups) {
|
||||
String region = AWSUtils.findRegionInArgsOrNull(getRequest());
|
||||
if (region == null)
|
||||
region = defaultRegion;
|
||||
securtyGroups.add(new SecurityGroup(region, groupName, ownerId, groupDescription,
|
||||
ipPermissions));
|
||||
securtyGroups.add(new SecurityGroup(region, groupId, groupName, ownerId, groupDescription, ipPermissions));
|
||||
this.groupName = null;
|
||||
this.groupId = null;
|
||||
this.ownerId = null;
|
||||
this.groupDescription = null;
|
||||
this.ipPermissions = Sets.newLinkedHashSet();
|
||||
|
|
|
@ -62,14 +62,14 @@ public class EC2TemplateOptionsTest {
|
|||
public void testsecurityGroupsIterable() {
|
||||
EC2TemplateOptions options = new EC2TemplateOptions();
|
||||
options.securityGroups(ImmutableSet.of("group1", "group2"));
|
||||
assertEquals(options.getGroupIds(), ImmutableSet.of("group1", "group2"));
|
||||
assertEquals(options.getGroups(), ImmutableSet.of("group1", "group2"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testsecurityGroupsIterableStatic() {
|
||||
EC2TemplateOptions options = securityGroups(ImmutableSet.of("group1", "group2"));
|
||||
assertEquals(options.getGroupIds(), ImmutableSet.of("group1", "group2"));
|
||||
assertEquals(options.getGroups(), ImmutableSet.of("group1", "group2"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
|
@ -82,7 +82,7 @@ public class EC2TemplateOptionsTest {
|
|||
public void testsecurityGroupsVarArgs() {
|
||||
EC2TemplateOptions options = new EC2TemplateOptions();
|
||||
options.securityGroups("group1", "group2");
|
||||
assertEquals(options.getGroupIds(), ImmutableSet.of("group1", "group2"));
|
||||
assertEquals(options.getGroups(), ImmutableSet.of("group1", "group2"));
|
||||
|
||||
}
|
||||
|
||||
|
@ -95,13 +95,13 @@ public class EC2TemplateOptionsTest {
|
|||
@Test
|
||||
public void testDefaultGroupsVarArgsEmpty() {
|
||||
EC2TemplateOptions options = new EC2TemplateOptions();
|
||||
assertEquals(options.getGroupIds(), ImmutableSet.of());
|
||||
assertEquals(options.getGroups(), ImmutableSet.of());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testsecurityGroupsVarArgsStatic() {
|
||||
EC2TemplateOptions options = securityGroups("group1", "group2");
|
||||
assertEquals(options.getGroupIds(), ImmutableSet.of("group1", "group2"));
|
||||
assertEquals(options.getGroups(), ImmutableSet.of("group1", "group2"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
|
|
|
@ -286,7 +286,7 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest {
|
|||
EC2TemplateOptions options = createMock(EC2TemplateOptions.class);
|
||||
|
||||
// setup expectations
|
||||
expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce();
|
||||
expect(options.getGroups()).andReturn(groupIds).atLeastOnce();
|
||||
expect(options.getInboundPorts()).andReturn(ports).atLeastOnce();
|
||||
RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
|
||||
ports, shouldAuthorizeSelf);
|
||||
|
@ -322,7 +322,7 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest {
|
|||
EC2TemplateOptions options = createMock(EC2TemplateOptions.class);
|
||||
|
||||
// setup expectations
|
||||
expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce();
|
||||
expect(options.getGroups()).andReturn(groupIds).atLeastOnce();
|
||||
expect(options.getInboundPorts()).andReturn(ports).atLeastOnce();
|
||||
RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
|
||||
ports, shouldAuthorizeSelf);
|
||||
|
@ -358,7 +358,7 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest {
|
|||
EC2TemplateOptions options = createMock(EC2TemplateOptions.class);
|
||||
|
||||
// setup expectations
|
||||
expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce();
|
||||
expect(options.getGroups()).andReturn(groupIds).atLeastOnce();
|
||||
expect(options.getInboundPorts()).andReturn(ports).atLeastOnce();
|
||||
RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
|
||||
ports, shouldAuthorizeSelf);
|
||||
|
@ -392,7 +392,7 @@ public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest {
|
|||
EC2TemplateOptions options = createMock(EC2TemplateOptions.class);
|
||||
|
||||
// setup expectations
|
||||
expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce();
|
||||
expect(options.getGroups()).andReturn(groupIds).atLeastOnce();
|
||||
RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
|
||||
ports, shouldAuthorizeSelf); // note
|
||||
// this
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.testng.annotations.BeforeGroups;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
@ -57,7 +58,7 @@ import com.google.inject.Module;
|
|||
@Test(groups = "live", singleThreaded = true)
|
||||
public class SecurityGroupClientLiveTest {
|
||||
|
||||
private SecurityGroupClient client;
|
||||
protected SecurityGroupClient client;
|
||||
private RestContext<EC2Client, EC2AsyncClient> context;
|
||||
|
||||
protected String provider = "ec2";
|
||||
|
@ -69,10 +70,9 @@ public class SecurityGroupClientLiveTest {
|
|||
protected void setupCredentials() {
|
||||
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
||||
credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
|
||||
+ ".credential");
|
||||
endpoint = checkNotNull(System.getProperty("test." + provider + ".endpoint"), "test." + provider + ".endpoint");
|
||||
apiversion = checkNotNull(System.getProperty("test." + provider + ".apiversion"), "test." + provider
|
||||
+ ".apiversion");
|
||||
+ ".credential");
|
||||
endpoint = System.getProperty("test." + provider + ".endpoint");
|
||||
apiversion = System.getProperty("test." + provider + ".apiversion");
|
||||
}
|
||||
|
||||
protected Properties setupProperties() {
|
||||
|
@ -81,8 +81,10 @@ public class SecurityGroupClientLiveTest {
|
|||
overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
|
||||
overrides.setProperty(provider + ".identity", identity);
|
||||
overrides.setProperty(provider + ".credential", credential);
|
||||
overrides.setProperty(provider + ".endpoint", endpoint);
|
||||
overrides.setProperty(provider + ".apiversion", apiversion);
|
||||
if (endpoint != null)
|
||||
overrides.setProperty(provider + ".endpoint", endpoint);
|
||||
if (apiversion != null)
|
||||
overrides.setProperty(provider + ".apiversion", apiversion);
|
||||
return overrides;
|
||||
}
|
||||
|
||||
|
@ -91,21 +93,21 @@ public class SecurityGroupClientLiveTest {
|
|||
setupCredentials();
|
||||
Properties overrides = setupProperties();
|
||||
context = new ComputeServiceContextFactory().createContext(provider,
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext();
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext();
|
||||
client = context.getApi().getSecurityGroupServices();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDescribe() {
|
||||
for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1,
|
||||
Region.AP_SOUTHEAST_1, Region.AP_NORTHEAST_1)) {
|
||||
Region.AP_SOUTHEAST_1, Region.AP_NORTHEAST_1)) {
|
||||
SortedSet<SecurityGroup> allResults = ImmutableSortedSet.<SecurityGroup> copyOf(client
|
||||
.describeSecurityGroupsInRegion(region));
|
||||
.describeSecurityGroupsInRegion(region));
|
||||
assertNotNull(allResults);
|
||||
if (allResults.size() >= 1) {
|
||||
SecurityGroup group = allResults.last();
|
||||
SortedSet<SecurityGroup> result = ImmutableSortedSet.<SecurityGroup> copyOf(client
|
||||
.describeSecurityGroupsInRegion(region, group.getName()));
|
||||
.describeSecurityGroupsInRegion(region, group.getName()));
|
||||
assertNotNull(result);
|
||||
SecurityGroup compare = result.last();
|
||||
assertEquals(compare, group);
|
||||
|
@ -127,7 +129,7 @@ public class SecurityGroupClientLiveTest {
|
|||
}
|
||||
}
|
||||
|
||||
private void cleanupAndSleep(String groupName) {
|
||||
protected void cleanupAndSleep(String groupName) {
|
||||
try {
|
||||
client.deleteSecurityGroupInRegion(null, groupName);
|
||||
Thread.sleep(2000);
|
||||
|
@ -179,7 +181,7 @@ public class SecurityGroupClientLiveTest {
|
|||
|
||||
@Test
|
||||
void testAuthorizeSecurityGroupIngressSourceGroup() {
|
||||
String group1Name = PREFIX + "ingress1";
|
||||
final String group1Name = PREFIX + "ingress1";
|
||||
String group2Name = PREFIX + "ingress2";
|
||||
cleanupAndSleep(group2Name);
|
||||
cleanupAndSleep(group1Name);
|
||||
|
@ -192,19 +194,19 @@ public class SecurityGroupClientLiveTest {
|
|||
Set<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(null, group1Name);
|
||||
assertNotNull(oneResult);
|
||||
assertEquals(oneResult.size(), 1);
|
||||
SecurityGroup group = oneResult.iterator().next();
|
||||
final SecurityGroup group = oneResult.iterator().next();
|
||||
assertEquals(group.getName(), group1Name);
|
||||
final UserIdGroupPair to = new UserIdGroupPair(group.getOwnerId(), group1Name);
|
||||
client.authorizeSecurityGroupIngressInRegion(null, group2Name, to);
|
||||
assertEventually(new GroupHasPermission(client, group2Name, new Predicate<IpPermission>() {
|
||||
@Override
|
||||
public boolean apply(IpPermission arg0) {
|
||||
return arg0.getGroups().equals(ImmutableSet.of(to));
|
||||
return arg0.getUserIdGroupPairs().equals(ImmutableMultimap.of(group.getOwnerId(), group1Name));
|
||||
}
|
||||
}));
|
||||
|
||||
client.revokeSecurityGroupIngressInRegion(null, group2Name,
|
||||
new UserIdGroupPair(group.getOwnerId(), group1Name));
|
||||
new UserIdGroupPair(group.getOwnerId(), group1Name));
|
||||
assertEventually(new GroupHasNoPermissions(client, group2Name));
|
||||
} finally {
|
||||
client.deleteSecurityGroupInRegion(null, group2Name);
|
||||
|
@ -212,20 +214,20 @@ public class SecurityGroupClientLiveTest {
|
|||
}
|
||||
}
|
||||
|
||||
private final class TCPPort80AllIPs implements Predicate<IpPermission> {
|
||||
public final class TCPPort80AllIPs implements Predicate<IpPermission> {
|
||||
@Override
|
||||
public boolean apply(IpPermission arg0) {
|
||||
return arg0.getIpProtocol() == IpProtocol.TCP && arg0.getFromPort() == 80 && arg0.getToPort() == 80
|
||||
&& arg0.getIpRanges().equals(ImmutableSet.of("0.0.0.0/0"));
|
||||
&& arg0.getIpRanges().equals(ImmutableSet.of("0.0.0.0/0"));
|
||||
}
|
||||
}
|
||||
|
||||
private static final class GroupHasPermission implements Runnable {
|
||||
public static final class GroupHasPermission implements Runnable {
|
||||
private final SecurityGroupClient client;
|
||||
private final String group;
|
||||
private final Predicate<IpPermission> permission;
|
||||
|
||||
private GroupHasPermission(SecurityGroupClient client, String group, Predicate<IpPermission> permission) {
|
||||
public GroupHasPermission(SecurityGroupClient client, String group, Predicate<IpPermission> permission) {
|
||||
this.client = client;
|
||||
this.group = group;
|
||||
this.permission = permission;
|
||||
|
@ -235,18 +237,18 @@ public class SecurityGroupClientLiveTest {
|
|||
try {
|
||||
Set<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(null, group);
|
||||
assert Iterables.all(Iterables.getOnlyElement(oneResult).getIpPermissions(), permission) : permission
|
||||
+ ": " + oneResult;
|
||||
+ ": " + oneResult;
|
||||
} catch (Exception e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final class GroupHasNoPermissions implements Runnable {
|
||||
public static final class GroupHasNoPermissions implements Runnable {
|
||||
private final SecurityGroupClient client;
|
||||
private final String group;
|
||||
|
||||
private GroupHasNoPermissions(SecurityGroupClient client, String group) {
|
||||
public GroupHasNoPermissions(SecurityGroupClient client, String group) {
|
||||
this.client = client;
|
||||
this.group = group;
|
||||
}
|
||||
|
@ -264,9 +266,9 @@ public class SecurityGroupClientLiveTest {
|
|||
}
|
||||
}
|
||||
|
||||
private void ensureGroupsExist(String group1Name, String group2Name) {
|
||||
protected void ensureGroupsExist(String group1Name, String group2Name) {
|
||||
SortedSet<SecurityGroup> twoResults = ImmutableSortedSet.copyOf(client.describeSecurityGroupsInRegion(null,
|
||||
group1Name, group2Name));
|
||||
group1Name, group2Name));
|
||||
assertNotNull(twoResults);
|
||||
assertEquals(twoResults.size(), 2);
|
||||
Iterator<SecurityGroup> iterator = twoResults.iterator();
|
||||
|
@ -282,8 +284,9 @@ public class SecurityGroupClientLiveTest {
|
|||
private static final int INCONSISTENCY_WINDOW = 5000;
|
||||
|
||||
/**
|
||||
* Due to eventual consistency, container commands may not return correctly immediately. Hence,
|
||||
* we will try up to the inconsistency window to see if the assertion completes.
|
||||
* Due to eventual consistency, container commands may not return correctly
|
||||
* immediately. Hence, we will try up to the inconsistency window to see if
|
||||
* the assertion completes.
|
||||
*/
|
||||
protected static void assertEventually(Runnable assertion) {
|
||||
long start = System.currentTimeMillis();
|
||||
|
@ -293,7 +296,7 @@ public class SecurityGroupClientLiveTest {
|
|||
assertion.run();
|
||||
if (i > 0)
|
||||
System.err.printf("%d attempts and %dms asserting %s%n", i + 1, System.currentTimeMillis() - start,
|
||||
assertion.getClass().getSimpleName());
|
||||
assertion.getClass().getSimpleName());
|
||||
return;
|
||||
} catch (AssertionError e) {
|
||||
error = e;
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.ec2.util;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.ec2.domain.IpProtocol;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Tests possible uses of IpPermissions
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(testName = "IpPermissionsTest")
|
||||
public class IpPermissionsTest {
|
||||
public void testAllProtocol() {
|
||||
IpPermissions authorization = IpPermissions.permitAnyProtocol();
|
||||
assertEquals(
|
||||
IpPermissions.buildFormParametersForIndex(0, authorization).toString(),
|
||||
"{IpPermissions.0.IpProtocol=[-1], IpPermissions.0.FromPort=[1], IpPermissions.0.ToPort=[65535], IpPermissions.0.IpRanges.0.CidrIp=[0.0.0.0/0]}");
|
||||
}
|
||||
|
||||
public void testAllProtocolCidrBound() {
|
||||
IpPermissions authorization = IpPermissions.permit(IpProtocol.ALL).originatingFromCidrBlock("1.1.1.1/32");
|
||||
assertEquals(
|
||||
IpPermissions.buildFormParametersForIndex(0, authorization).toString(),
|
||||
"{IpPermissions.0.IpProtocol=[-1], IpPermissions.0.FromPort=[1], IpPermissions.0.ToPort=[65535], IpPermissions.0.IpRanges.0.CidrIp=[1.1.1.1/32]}");
|
||||
}
|
||||
|
||||
public void testJustProtocolAndCidr() {
|
||||
IpPermissions authorization = IpPermissions.permit(IpProtocol.TCP).originatingFromCidrBlock("1.1.1.1/32");
|
||||
assertEquals(
|
||||
IpPermissions.buildFormParametersForIndex(0, authorization).toString(),
|
||||
"{IpPermissions.0.IpProtocol=[tcp], IpPermissions.0.FromPort=[1], IpPermissions.0.ToPort=[65535], IpPermissions.0.IpRanges.0.CidrIp=[1.1.1.1/32]}");
|
||||
}
|
||||
|
||||
public void testAnyProtocol() {
|
||||
IpPermissions authorization = IpPermissions.permitAnyProtocol().originatingFromCidrBlock("1.1.1.1/32");
|
||||
assertEquals(
|
||||
IpPermissions.buildFormParametersForIndex(0, authorization).toString(),
|
||||
"{IpPermissions.0.IpProtocol=[-1], IpPermissions.0.FromPort=[1], IpPermissions.0.ToPort=[65535], IpPermissions.0.IpRanges.0.CidrIp=[1.1.1.1/32]}");
|
||||
}
|
||||
|
||||
public void testMultipleCidrs() {
|
||||
IpPermissions authorization = IpPermissions.permit(IpProtocol.TCP).originatingFromCidrBlocks(
|
||||
ImmutableSet.of("1.1.1.1/32", "1.1.1.2/32"));
|
||||
assertEquals(
|
||||
IpPermissions.buildFormParametersForIndex(0, authorization).toString(),
|
||||
"{IpPermissions.0.IpProtocol=[tcp], IpPermissions.0.FromPort=[1], IpPermissions.0.ToPort=[65535], IpPermissions.0.IpRanges.0.CidrIp=[1.1.1.1/32], IpPermissions.0.IpRanges.1.CidrIp=[1.1.1.2/32]}");
|
||||
}
|
||||
|
||||
public void testProtocolFromAndToPortAndGroupIds() {
|
||||
IpPermissions authorization = IpPermissions.permit(IpProtocol.UDP).fromPort(11).to(53)
|
||||
.originatingFromSecurityGroupId("groupId");
|
||||
assertEquals(
|
||||
IpPermissions.buildFormParametersForIndex(0, authorization).toString(),
|
||||
"{IpPermissions.0.IpProtocol=[udp], IpPermissions.0.FromPort=[11], IpPermissions.0.ToPort=[53], IpPermissions.0.Groups.0.GroupId=[groupId]}");
|
||||
}
|
||||
|
||||
public void testProtocolICMPAny() {
|
||||
IpPermissions authorization = IpPermissions.permitICMP().originatingFromSecurityGroupId("groupId");
|
||||
assertEquals(
|
||||
IpPermissions.buildFormParametersForIndex(0, authorization).toString(),
|
||||
"{IpPermissions.0.IpProtocol=[icmp], IpPermissions.0.FromPort=[-1], IpPermissions.0.ToPort=[-1], IpPermissions.0.Groups.0.GroupId=[groupId]}");
|
||||
}
|
||||
|
||||
public void testProtocolICMPTypeAnyCode() {
|
||||
IpPermissions authorization = IpPermissions.permitICMP().type(8).originatingFromSecurityGroupId("groupId");
|
||||
assertEquals(
|
||||
IpPermissions.buildFormParametersForIndex(0, authorization).toString(),
|
||||
"{IpPermissions.0.IpProtocol=[icmp], IpPermissions.0.FromPort=[8], IpPermissions.0.ToPort=[-1], IpPermissions.0.Groups.0.GroupId=[groupId]}");
|
||||
}
|
||||
|
||||
public void testProtocolICMPTypeCode() {
|
||||
IpPermissions authorization = IpPermissions.permitICMP().type(8).andCode(0)
|
||||
.originatingFromSecurityGroupId("groupId");
|
||||
assertEquals(
|
||||
IpPermissions.buildFormParametersForIndex(0, authorization).toString(),
|
||||
"{IpPermissions.0.IpProtocol=[icmp], IpPermissions.0.FromPort=[8], IpPermissions.0.ToPort=[0], IpPermissions.0.Groups.0.GroupId=[groupId]}");
|
||||
}
|
||||
|
||||
public void testProtocolFromAndToPortAndUserGroups() {
|
||||
IpPermissions authorization = IpPermissions.permit(IpProtocol.ICMP).originatingFromUserAndSecurityGroup("userId",
|
||||
"groupId");
|
||||
assertEquals(
|
||||
IpPermissions.buildFormParametersForIndex(0, authorization).toString(),
|
||||
"{IpPermissions.0.IpProtocol=[icmp], IpPermissions.0.FromPort=[-1], IpPermissions.0.ToPort=[-1], IpPermissions.0.Groups.0.UserId=[userId], IpPermissions.0.Groups.1.GroupName=[groupId]}");
|
||||
}
|
||||
}
|
|
@ -26,15 +26,15 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.io.InputStream;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.ec2.domain.IpPermission;
|
||||
import org.jclouds.ec2.domain.IpPermissionImpl;
|
||||
import org.jclouds.ec2.domain.IpProtocol;
|
||||
import org.jclouds.ec2.domain.SecurityGroup;
|
||||
import org.jclouds.ec2.domain.UserIdGroupPair;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
|
@ -42,24 +42,23 @@ import com.google.common.collect.ImmutableSet;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during
|
||||
// surefire
|
||||
@Test(groups = "unit", testName = "DescribeSecurityGroupsResponseHandlerTest")
|
||||
public class DescribeSecurityGroupsResponseHandlerTest extends BaseEC2HandlerTest {
|
||||
public void testApplyInputStream() {
|
||||
|
||||
InputStream is = getClass().getResourceAsStream("/describe_securitygroups.xml");
|
||||
|
||||
Set<SecurityGroup> expected = ImmutableSet.of(new SecurityGroup(defaultRegion,
|
||||
"WebServers", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Web Servers", ImmutableSet
|
||||
.of(new IpPermission(80, 80, ImmutableSet.<UserIdGroupPair> of(),
|
||||
IpProtocol.TCP, ImmutableSet.of("0.0.0.0/0")))),
|
||||
new SecurityGroup(defaultRegion, "RangedPortsBySource", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM",
|
||||
"Group A", ImmutableSet.of(new IpPermission(6000, 7000,
|
||||
ImmutableSet.<UserIdGroupPair> of(), IpProtocol.TCP,
|
||||
ImmutableSet.<String> of()))));
|
||||
Set<SecurityGroup> expected = ImmutableSet.of(
|
||||
new SecurityGroup(defaultRegion, null, "WebServers", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Web Servers",
|
||||
ImmutableSet.of(new IpPermissionImpl(IpProtocol.TCP, 80, 80, ImmutableMultimap.<String, String> of(),
|
||||
ImmutableSet.<String> of(), ImmutableSet.of("0.0.0.0/0")))),
|
||||
new SecurityGroup(defaultRegion, null, "RangedPortsBySource", "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", "Group A",
|
||||
ImmutableSet.of(new IpPermissionImpl(IpProtocol.TCP, 6000, 7000, ImmutableMultimap
|
||||
.<String, String> of(), ImmutableSet.<String> of(), ImmutableSet.<String> of()))));
|
||||
|
||||
DescribeSecurityGroupsResponseHandler handler = injector
|
||||
.getInstance(DescribeSecurityGroupsResponseHandler.class);
|
||||
DescribeSecurityGroupsResponseHandler handler = injector.getInstance(DescribeSecurityGroupsResponseHandler.class);
|
||||
addDefaultRegionToHandler(handler);
|
||||
Set<SecurityGroup> result = factory.create(handler).parse(is);
|
||||
|
||||
|
@ -68,7 +67,7 @@ public class DescribeSecurityGroupsResponseHandlerTest extends BaseEC2HandlerTes
|
|||
|
||||
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||
expect(request.getArgs()).andReturn(ImmutableList.<Object>of()).atLeastOnce();
|
||||
expect(request.getArgs()).andReturn(ImmutableList.<Object> of()).atLeastOnce();
|
||||
replay(request);
|
||||
handler.setContext(request);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
<properties>
|
||||
<test.aws-ec2.endpoint>https://ec2.us-east-1.amazonaws.com</test.aws-ec2.endpoint>
|
||||
<test.aws-ec2.apiversion>2010-11-15</test.aws-ec2.apiversion>
|
||||
<test.aws-ec2.apiversion>2011-05-15</test.aws-ec2.apiversion>
|
||||
<test.aws-ec2.identity>${test.aws.identity}</test.aws-ec2.identity>
|
||||
<test.aws-ec2.credential>${test.aws.credential}</test.aws-ec2.credential>
|
||||
</properties>
|
||||
|
|
|
@ -40,6 +40,7 @@ package org.jclouds.aws.ec2;
|
|||
import org.jclouds.aws.ec2.services.AWSAMIAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.AWSInstanceAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.AWSKeyPairAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.AWSSecurityGroupAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.MonitoringAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.PlacementGroupAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.SpotInstanceAsyncClient;
|
||||
|
@ -52,7 +53,7 @@ import org.jclouds.rest.annotations.Delegate;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
public interface AWSEC2AsyncClient extends EC2AsyncClient {
|
||||
public final static String VERSION = "2010-11-15";
|
||||
public final static String VERSION = "2011-05-15";
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
@ -68,6 +69,13 @@ public interface AWSEC2AsyncClient extends EC2AsyncClient {
|
|||
@Override
|
||||
AWSAMIAsyncClient getAMIServices();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Delegate
|
||||
@Override
|
||||
AWSSecurityGroupAsyncClient getSecurityGroupServices();
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to PlacementGroup services.
|
||||
*/
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.jclouds.aws.ec2.services.AWSAMIClient;
|
||||
import org.jclouds.aws.ec2.services.AWSInstanceClient;
|
||||
import org.jclouds.aws.ec2.services.AWSKeyPairClient;
|
||||
import org.jclouds.aws.ec2.services.AWSSecurityGroupClient;
|
||||
import org.jclouds.aws.ec2.services.MonitoringClient;
|
||||
import org.jclouds.aws.ec2.services.PlacementGroupClient;
|
||||
import org.jclouds.aws.ec2.services.SpotInstanceClient;
|
||||
|
@ -45,6 +46,13 @@ public interface AWSEC2Client extends EC2Client {
|
|||
@Override
|
||||
AWSInstanceClient getInstanceServices();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Delegate
|
||||
@Override
|
||||
AWSSecurityGroupClient getSecurityGroupServices();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -61,8 +61,10 @@ public class BindLaunchSpecificationToFormParams implements Binder, Function<Lau
|
|||
AWSRunInstancesOptions options = new AWSRunInstancesOptions();
|
||||
if (launchSpec.getBlockDeviceMappings().size() > 0)
|
||||
options.withBlockDeviceMappings(launchSpec.getBlockDeviceMappings());
|
||||
if (launchSpec.getGroupIds().size() > 0)
|
||||
options.withSecurityGroups(launchSpec.getGroupIds());
|
||||
if (launchSpec.getSecurityGroupNames().size() > 0)
|
||||
options.withSecurityGroups(launchSpec.getSecurityGroupNames());
|
||||
if (launchSpec.getSecurityGroupIds().size() > 0)
|
||||
options.withSecurityGroupIds(launchSpec.getSecurityGroupIds());
|
||||
options.asType(checkNotNull(launchSpec.getInstanceType(), "instanceType"));
|
||||
if (launchSpec.getKernelId() != null)
|
||||
options.withKernelId(launchSpec.getKernelId());
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.aws.ec2.compute;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
|
@ -35,6 +36,9 @@ import org.jclouds.io.Payload;
|
|||
import org.jclouds.scriptbuilder.domain.Statement;
|
||||
import org.jclouds.util.Preconditions2;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* Contains options supported in the {@code ComputeService#runNode} operation on the "ec2" provider.
|
||||
* <h2>
|
||||
|
@ -73,6 +77,8 @@ public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneab
|
|||
eTo.noPlacementGroup();
|
||||
if (getPlacementGroup() != null)
|
||||
eTo.placementGroup(getPlacementGroup());
|
||||
if (getGroupIds().size() > 0)
|
||||
eTo.securityGroupIds(getGroupIds());
|
||||
if (getSpotPrice() != null)
|
||||
eTo.spotPrice(getSpotPrice());
|
||||
if (getSpotOptions() != null)
|
||||
|
@ -86,6 +92,7 @@ public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneab
|
|||
private String subnetId;
|
||||
private Float spotPrice;
|
||||
private RequestSpotInstancesOptions spotOptions = RequestSpotInstancesOptions.NONE;
|
||||
private Set<String> groupIds = ImmutableSet.of();
|
||||
|
||||
public static final AWSEC2TemplateOptions NONE = new AWSEC2TemplateOptions();
|
||||
|
||||
|
@ -145,7 +152,51 @@ public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneab
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see AWSEC2TemplateOptions#securityGroupIds(Iterable<String>)
|
||||
*/
|
||||
public AWSEC2TemplateOptions securityGroupIds(String... groupIds) {
|
||||
return securityGroupIds(ImmutableSet.copyOf(groupIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the security group ids to be used for nodes with this template
|
||||
*/
|
||||
public AWSEC2TemplateOptions securityGroupIds(Iterable<String> groupIds) {
|
||||
checkArgument(Iterables.size(groupIds) > 0, "you must specify at least one security group");
|
||||
for (String groupId : groupIds)
|
||||
Preconditions2.checkNotEmpty(groupId, "all security groups must be non-empty");
|
||||
this.groupIds = ImmutableSet.copyOf(groupIds);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Set<String> getGroupIds() {
|
||||
return groupIds;
|
||||
}
|
||||
|
||||
public void setGroupIds(Set<String> groupIds) {
|
||||
this.groupIds = groupIds;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
/**
|
||||
* @see AWSEC2TemplateOptions#securityGroupIds(Iterable<String>)
|
||||
*/
|
||||
public static AWSEC2TemplateOptions securityGroupIds(String... groupNames) {
|
||||
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
|
||||
return AWSEC2TemplateOptions.class.cast(options.securityGroupIds(groupNames));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AWSEC2TemplateOptions#securityGroupIds(Iterable<String>)
|
||||
*/
|
||||
public static AWSEC2TemplateOptions securityGroupIds(Iterable<String> groupNames) {
|
||||
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
|
||||
return AWSEC2TemplateOptions.class.cast(options.securityGroupIds(groupNames));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EC2TemplateOptions#blockDeviceMappings
|
||||
*/
|
||||
|
@ -629,7 +680,7 @@ public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneab
|
|||
@Override
|
||||
public String toString() {
|
||||
|
||||
return "[groupIds=" + getGroupIds() + ", keyPair=" + getKeyPair() + ", noKeyPair="
|
||||
return "[groupIds=" + getGroups() + ", keyPair=" + getKeyPair() + ", noKeyPair="
|
||||
+ !shouldAutomaticallyCreateKeyPair() + ", monitoringEnabled=" + monitoringEnabled + ", placementGroup="
|
||||
+ placementGroup + ", noPlacementGroup=" + noPlacementGroup + ", subnetId=" + subnetId + ", userData="
|
||||
+ Arrays.toString(getUserData()) + ", blockDeviceMappings=" + getBlockDeviceMappings() + ", spotPrice="
|
||||
|
|
|
@ -75,7 +75,6 @@ public class AWSEC2CreateNodesInGroupThenAddToSet extends EC2CreateNodesInGroupT
|
|||
Function<RunningInstance, NodeMetadata> runningInstanceToNodeMetadata,
|
||||
Function<RunningInstance, Credentials> instanceToCredentials, Map<String, Credentials> credentialStore,
|
||||
ComputeUtils utils, SpotInstanceRequestToAWSRunningInstance spotConverter) {
|
||||
|
||||
super(client, templateBuilderProvider, createKeyPairAndSecurityGroupsAsNeededAndReturncustomize, instancePresent,
|
||||
runningInstanceToNodeMetadata, instanceToCredentials, credentialStore, utils);
|
||||
this.client = checkNotNull(client, "client");
|
||||
|
|
|
@ -164,10 +164,21 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions
|
|||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean userSpecifiedTheirOwnGroups(TemplateOptions options) {
|
||||
return options instanceof AWSEC2TemplateOptions
|
||||
&& AWSEC2TemplateOptions.class.cast(options).getGroupIds().size() > 0
|
||||
|| super.userSpecifiedTheirOwnGroups(options);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addSecurityGroups(String region, String group, Template template, RunInstancesOptions instanceOptions) {
|
||||
String subnetId = AWSEC2TemplateOptions.class.cast(template.getOptions()).getSubnetId();
|
||||
AWSEC2TemplateOptions awsTemplateOptions = AWSEC2TemplateOptions.class.cast(template.getOptions());
|
||||
AWSRunInstancesOptions awsInstanceOptions = AWSRunInstancesOptions.class.cast(instanceOptions);
|
||||
if (awsTemplateOptions.getGroupIds().size() > 0)
|
||||
awsInstanceOptions.withSecurityGroupIds(awsTemplateOptions.getGroupIds());
|
||||
String subnetId = awsTemplateOptions.getSubnetId();
|
||||
if (subnetId != null) {
|
||||
AWSRunInstancesOptions.class.cast(instanceOptions).withSubnetId(subnetId);
|
||||
} else {
|
||||
|
|
|
@ -32,6 +32,8 @@ import org.jclouds.aws.ec2.services.AWSInstanceAsyncClient;
|
|||
import org.jclouds.aws.ec2.services.AWSInstanceClient;
|
||||
import org.jclouds.aws.ec2.services.AWSKeyPairAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.AWSKeyPairClient;
|
||||
import org.jclouds.aws.ec2.services.AWSSecurityGroupAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.AWSSecurityGroupClient;
|
||||
import org.jclouds.aws.ec2.services.MonitoringAsyncClient;
|
||||
import org.jclouds.aws.ec2.services.MonitoringClient;
|
||||
import org.jclouds.aws.ec2.services.PlacementGroupAsyncClient;
|
||||
|
@ -73,18 +75,18 @@ import com.google.inject.Provides;
|
|||
public class AWSEC2RestClientModule extends EC2RestClientModule<AWSEC2Client, AWSEC2AsyncClient> {
|
||||
|
||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
|
||||
.put(AWSAMIClient.class, AWSAMIAsyncClient.class)//
|
||||
.put(ElasticIPAddressClient.class, ElasticIPAddressAsyncClient.class)//
|
||||
.put(AWSInstanceClient.class, AWSInstanceAsyncClient.class)//
|
||||
.put(AWSKeyPairClient.class, AWSKeyPairAsyncClient.class)//
|
||||
.put(SecurityGroupClient.class, SecurityGroupAsyncClient.class)//
|
||||
.put(PlacementGroupClient.class, PlacementGroupAsyncClient.class)//
|
||||
.put(MonitoringClient.class, MonitoringAsyncClient.class)//
|
||||
.put(WindowsClient.class, WindowsAsyncClient.class)//
|
||||
.put(AvailabilityZoneAndRegionClient.class, AvailabilityZoneAndRegionAsyncClient.class)//
|
||||
.put(ElasticBlockStoreClient.class, ElasticBlockStoreAsyncClient.class)//
|
||||
.put(SpotInstanceClient.class, SpotInstanceAsyncClient.class)//
|
||||
.build();
|
||||
.put(AWSAMIClient.class, AWSAMIAsyncClient.class)//
|
||||
.put(ElasticIPAddressClient.class, ElasticIPAddressAsyncClient.class)//
|
||||
.put(AWSInstanceClient.class, AWSInstanceAsyncClient.class)//
|
||||
.put(AWSKeyPairClient.class, AWSKeyPairAsyncClient.class)//
|
||||
.put(AWSSecurityGroupClient.class, AWSSecurityGroupAsyncClient.class)//
|
||||
.put(PlacementGroupClient.class, PlacementGroupAsyncClient.class)//
|
||||
.put(MonitoringClient.class, MonitoringAsyncClient.class)//
|
||||
.put(WindowsClient.class, WindowsAsyncClient.class)//
|
||||
.put(AvailabilityZoneAndRegionClient.class, AvailabilityZoneAndRegionAsyncClient.class)//
|
||||
.put(ElasticBlockStoreClient.class, ElasticBlockStoreAsyncClient.class)//
|
||||
.put(SpotInstanceClient.class, SpotInstanceAsyncClient.class)//
|
||||
.build();
|
||||
|
||||
public AWSEC2RestClientModule() {
|
||||
super(AWSEC2Client.class, AWSEC2AsyncClient.class, DELEGATE_MAP);
|
||||
|
@ -114,6 +116,18 @@ public class AWSEC2RestClientModule extends EC2RestClientModule<AWSEC2Client, AW
|
|||
return in.getInstanceServices();
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
SecurityGroupClient getSecurityGroupServices(AWSEC2Client in) {
|
||||
return in.getSecurityGroupServices();
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
SecurityGroupAsyncClient getSecurityGroupServices(AWSEC2AsyncClient in) {
|
||||
return in.getSecurityGroupServices();
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
AMIClient getAMIServices(AWSEC2Client in) {
|
||||
|
|
|
@ -31,12 +31,15 @@ import org.jclouds.ec2.domain.InstanceState;
|
|||
import org.jclouds.ec2.domain.RootDeviceType;
|
||||
import org.jclouds.ec2.domain.RunningInstance;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-RunningInstancesItemType.html"
|
||||
* @see <a href=
|
||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-RunningInstancesItemType.html"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -52,6 +55,19 @@ public class AWSRunningInstance extends RunningInstance {
|
|||
private String subnetId;
|
||||
private String spotInstanceRequestId;
|
||||
private String vpcId;
|
||||
private Map<String, String> securityGroupIdToNames = Maps.newLinkedHashMap();
|
||||
|
||||
public Builder securityGroupIdToNames(Map<String, String> securityGroupIdToNames) {
|
||||
this.securityGroupIdToNames = ImmutableMap.copyOf(checkNotNull(securityGroupIdToNames,
|
||||
"securityGroupIdToNames"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder securityGroupIdToName(String key, String value) {
|
||||
if (key != null && value != null)
|
||||
this.securityGroupIdToNames.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder monitoringState(MonitoringState monitoringState) {
|
||||
this.monitoringState = monitoringState;
|
||||
|
@ -211,11 +227,11 @@ public class AWSRunningInstance extends RunningInstance {
|
|||
|
||||
@Override
|
||||
public AWSRunningInstance build() {
|
||||
return new AWSRunningInstance(region, groupIds, amiLaunchIndex, dnsName, imageId, instanceId, instanceState,
|
||||
instanceType, ipAddress, kernelId, keyName, launchTime, availabilityZone, virtualizationType,
|
||||
platform, privateDnsName, privateIpAddress, ramdiskId, reason, rootDeviceType, rootDeviceName,
|
||||
ebsBlockDevices, monitoringState, placementGroup, productCodes, subnetId, spotInstanceRequestId,
|
||||
vpcId);
|
||||
return new AWSRunningInstance(region, securityGroupIdToNames, amiLaunchIndex, dnsName, imageId, instanceId,
|
||||
instanceState, instanceType, ipAddress, kernelId, keyName, launchTime, availabilityZone,
|
||||
virtualizationType, platform, privateDnsName, privateIpAddress, ramdiskId, reason, rootDeviceType,
|
||||
rootDeviceName, ebsBlockDevices, monitoringState, placementGroup, productCodes, subnetId,
|
||||
spotInstanceRequestId, vpcId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -230,23 +246,30 @@ public class AWSRunningInstance extends RunningInstance {
|
|||
private final String spotInstanceRequestId;
|
||||
@Nullable
|
||||
private final String vpcId;
|
||||
private final Map<String, String> securityGroupIdToNames;
|
||||
|
||||
protected AWSRunningInstance(String region, Iterable<String> groupIds, String amiLaunchIndex, String dnsName,
|
||||
String imageId, String instanceId, InstanceState instanceState, String instanceType, String ipAddress,
|
||||
String kernelId, String keyName, Date launchTime, String availabilityZone, String virtualizationType,
|
||||
String platform, String privateDnsName, String privateIpAddress, String ramdiskId, String reason,
|
||||
RootDeviceType rootDeviceType, String rootDeviceName, Map<String, BlockDevice> ebsBlockDevices,
|
||||
MonitoringState monitoringState, String placementGroup, Iterable<String> productCodes, String subnetId,
|
||||
String spotInstanceRequestId, String vpcId) {
|
||||
super(region, groupIds, amiLaunchIndex, dnsName, imageId, instanceId, instanceState, instanceType, ipAddress,
|
||||
kernelId, keyName, launchTime, availabilityZone, virtualizationType, platform, privateDnsName,
|
||||
privateIpAddress, ramdiskId, reason, rootDeviceType, rootDeviceName, ebsBlockDevices);
|
||||
protected AWSRunningInstance(String region, Map<String, String> securityGroupIdToNames, String amiLaunchIndex,
|
||||
String dnsName, String imageId, String instanceId, InstanceState instanceState, String instanceType,
|
||||
String ipAddress, String kernelId, String keyName, Date launchTime, String availabilityZone,
|
||||
String virtualizationType, String platform, String privateDnsName, String privateIpAddress, String ramdiskId,
|
||||
String reason, RootDeviceType rootDeviceType, String rootDeviceName, Map<String, BlockDevice> ebsBlockDevices,
|
||||
MonitoringState monitoringState, String placementGroup, Iterable<String> productCodes, String subnetId,
|
||||
String spotInstanceRequestId, String vpcId) {
|
||||
super(region, securityGroupIdToNames.values(), amiLaunchIndex, dnsName, imageId, instanceId, instanceState,
|
||||
instanceType, ipAddress, kernelId, keyName, launchTime, availabilityZone, virtualizationType, platform,
|
||||
privateDnsName, privateIpAddress, ramdiskId, reason, rootDeviceType, rootDeviceName, ebsBlockDevices);
|
||||
this.monitoringState = checkNotNull(monitoringState, "monitoringState");
|
||||
this.placementGroup = placementGroup;
|
||||
this.productCodes = ImmutableSet.copyOf(checkNotNull(groupIds, "groupIds"));
|
||||
this.productCodes = ImmutableSet.copyOf(checkNotNull(productCodes, "productCodes"));
|
||||
this.subnetId = subnetId;
|
||||
this.spotInstanceRequestId = spotInstanceRequestId;
|
||||
this.vpcId = vpcId;
|
||||
this.securityGroupIdToNames = ImmutableMap.<String, String> copyOf(checkNotNull(securityGroupIdToNames,
|
||||
"securityGroupIdToNames"));
|
||||
}
|
||||
|
||||
public Map<String, String> getSecurityGroupIdToNames() {
|
||||
return securityGroupIdToNames;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -257,7 +280,8 @@ public class AWSRunningInstance extends RunningInstance {
|
|||
}
|
||||
|
||||
/**
|
||||
* The name of the placement group the instance is in (for cluster compute instances).
|
||||
* The name of the placement group the instance is in (for cluster compute
|
||||
* instances).
|
||||
*/
|
||||
public String getPlacementGroup() {
|
||||
return placementGroup;
|
||||
|
@ -278,14 +302,16 @@ public class AWSRunningInstance extends RunningInstance {
|
|||
}
|
||||
|
||||
/**
|
||||
* Specifies the VPC in which the instance is running (Amazon Virtual Private Cloud).
|
||||
* Specifies the VPC in which the instance is running (Amazon Virtual Private
|
||||
* Cloud).
|
||||
*/
|
||||
public String getVpcId() {
|
||||
return vpcId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the subnet ID in which the instance is running (Amazon Virtual Private Cloud).
|
||||
* Specifies the subnet ID in which the instance is running (Amazon Virtual
|
||||
* Private Cloud).
|
||||
*/
|
||||
public String getSubnetId() {
|
||||
return subnetId;
|
||||
|
@ -343,14 +369,13 @@ public class AWSRunningInstance extends RunningInstance {
|
|||
@Override
|
||||
public String toString() {
|
||||
return "[region=" + region + ", availabilityZone=" + availabilityZone + ", instanceId=" + instanceId
|
||||
+ ", instanceState=" + instanceState + ", instanceType=" + instanceType + ", virtualizationType="
|
||||
+ virtualizationType + ", imageId=" + imageId + ", ipAddress=" + ipAddress + ", dnsName=" + dnsName
|
||||
+ ", privateIpAddress=" + privateIpAddress + ", privateDnsName=" + privateDnsName + ", keyName="
|
||||
+ keyName + ", platform=" + platform + ", launchTime=" + launchTime + ", rootDeviceName="
|
||||
+ rootDeviceName + ", rootDeviceType=" + rootDeviceType + ", ebsBlockDevices=" + ebsBlockDevices
|
||||
+ ", monitoringState=" + monitoringState + ", placementGroup=" + placementGroup + ", productCodes="
|
||||
+ productCodes + ", spotInstanceRequestId=" + spotInstanceRequestId + ", subnetId=" + subnetId
|
||||
+ ", vpcId=" + vpcId + "]";
|
||||
+ ", instanceState=" + instanceState + ", instanceType=" + instanceType + ", virtualizationType="
|
||||
+ virtualizationType + ", imageId=" + imageId + ", ipAddress=" + ipAddress + ", dnsName=" + dnsName
|
||||
+ ", privateIpAddress=" + privateIpAddress + ", privateDnsName=" + privateDnsName + ", keyName=" + keyName
|
||||
+ ", platform=" + platform + ", launchTime=" + launchTime + ", rootDeviceName=" + rootDeviceName
|
||||
+ ", rootDeviceType=" + rootDeviceType + ", ebsBlockDevices=" + ebsBlockDevices + ", monitoringState="
|
||||
+ monitoringState + ", placementGroup=" + placementGroup + ", productCodes=" + productCodes
|
||||
+ ", spotInstanceRequestId=" + spotInstanceRequestId + ", subnetId=" + subnetId + ", vpcId=" + vpcId + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.aws.ec2.domain;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -30,6 +31,7 @@ import org.jclouds.ec2.domain.BlockDeviceMapping.MapEBSSnapshotToDevice;
|
|||
import org.jclouds.ec2.domain.BlockDeviceMapping.MapEphemeralDeviceToDevice;
|
||||
import org.jclouds.ec2.domain.BlockDeviceMapping.MapNewVolumeToDevice;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
|
||||
|
@ -47,7 +49,7 @@ public class LaunchSpecification {
|
|||
}
|
||||
|
||||
public static class Builder {
|
||||
protected ImmutableSet.Builder<String> groupIds = ImmutableSet.<String> builder();
|
||||
protected ImmutableMap.Builder<String, String> securityGroupIdToNames = ImmutableMap.<String, String> builder();
|
||||
protected String imageId;
|
||||
protected String instanceType;
|
||||
protected String kernelId;
|
||||
|
@ -57,10 +59,12 @@ public class LaunchSpecification {
|
|||
protected Boolean monitoringEnabled;
|
||||
protected ImmutableSet.Builder<BlockDeviceMapping> blockDeviceMappings = ImmutableSet
|
||||
.<BlockDeviceMapping> builder();
|
||||
protected ImmutableSet.Builder<String> securityGroupIds = ImmutableSet.<String> builder();
|
||||
protected ImmutableSet.Builder<String> securityGroupNames = ImmutableSet.<String> builder();
|
||||
protected byte[] userData;
|
||||
|
||||
public void clear() {
|
||||
groupIds = ImmutableSet.<String> builder();
|
||||
securityGroupIdToNames = ImmutableMap.<String, String> builder();
|
||||
imageId = null;
|
||||
instanceType = null;
|
||||
kernelId = null;
|
||||
|
@ -69,17 +73,19 @@ public class LaunchSpecification {
|
|||
ramdiskId = null;
|
||||
monitoringEnabled = false;
|
||||
blockDeviceMappings = ImmutableSet.<BlockDeviceMapping> builder();
|
||||
securityGroupIds = ImmutableSet.<String> builder();
|
||||
securityGroupNames = ImmutableSet.<String> builder();
|
||||
userData = null;
|
||||
}
|
||||
|
||||
public Builder groupIds(Iterable<String> groupIds) {
|
||||
this.groupIds.addAll(checkNotNull(groupIds, "groupIds"));
|
||||
public Builder securityGroupIdToNames(Map<String, String> securityGroupIdToNames) {
|
||||
this.securityGroupIdToNames.putAll(checkNotNull(securityGroupIdToNames, "securityGroupIdToNames"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder groupId(String groupId) {
|
||||
if (groupId != null)
|
||||
this.groupIds.add(groupId);
|
||||
public Builder securityGroupIdToName(String groupId, String groupName) {
|
||||
if (groupId != null && groupName != null)
|
||||
this.securityGroupIdToNames.put(checkNotNull(groupId, "groupId"), checkNotNull(groupName, "groupName"));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -144,6 +150,28 @@ public class LaunchSpecification {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder securityGroupIds(Iterable<String> securityGroupIds) {
|
||||
this.securityGroupIds.addAll(checkNotNull(securityGroupIds, "securityGroupIds"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder securityGroupId(String securityGroupId) {
|
||||
if (securityGroupId != null)
|
||||
this.securityGroupIds.add(securityGroupId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder securityGroupNames(Iterable<String> securityGroupNames) {
|
||||
this.securityGroupNames.addAll(checkNotNull(securityGroupNames, "securityGroupNames"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder securityGroupName(String securityGroupName) {
|
||||
if (securityGroupName != null)
|
||||
this.securityGroupNames.add(securityGroupName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder userData(byte[] userData) {
|
||||
this.userData = userData;
|
||||
return this;
|
||||
|
@ -151,13 +179,15 @@ public class LaunchSpecification {
|
|||
|
||||
public LaunchSpecification build() {
|
||||
return new LaunchSpecification(instanceType, imageId, kernelId, ramdiskId, availabilityZone, keyName,
|
||||
groupIds.build(), blockDeviceMappings.build(), monitoringEnabled, userData);
|
||||
securityGroupIdToNames.build(), blockDeviceMappings.build(), monitoringEnabled,
|
||||
securityGroupIds.build(), securityGroupNames.build(), userData);
|
||||
}
|
||||
|
||||
public static Builder fromLaunchSpecification(LaunchSpecification in) {
|
||||
return new Builder().instanceType(in.getInstanceType()).imageId(in.getImageId()).kernelId(in.getKernelId())
|
||||
.ramdiskId(in.getRamdiskId()).availabilityZone(in.getAvailabilityZone()).keyName(in.getKeyName())
|
||||
.groupIds(in.getGroupIds()).blockDeviceMappings(in.getBlockDeviceMappings())
|
||||
.securityGroupIdToNames(in.getSecurityGroupIdToNames()).securityGroupIds(in.getSecurityGroupIds())
|
||||
.securityGroupNames(in.getSecurityGroupNames()).blockDeviceMappings(in.getBlockDeviceMappings())
|
||||
.monitoringEnabled(in.isMonitoringEnabled()).userData(in.getUserData());
|
||||
}
|
||||
}
|
||||
|
@ -168,26 +198,35 @@ public class LaunchSpecification {
|
|||
protected final String ramdiskId;
|
||||
protected final String availabilityZone;
|
||||
protected final String keyName;
|
||||
protected final Set<String> groupIds;
|
||||
protected final Map<String, String> securityGroupIdToNames;
|
||||
protected final Set<? extends BlockDeviceMapping> blockDeviceMappings;
|
||||
protected final Set<String> securityGroupIds;
|
||||
protected final Set<String> securityGroupNames;
|
||||
protected final Boolean monitoringEnabled;
|
||||
protected final byte[] userData;
|
||||
|
||||
public LaunchSpecification(String instanceType, String imageId, String kernelId, String ramdiskId,
|
||||
String availabilityZone, String keyName, Iterable<String> groupIds,
|
||||
Iterable<? extends BlockDeviceMapping> blockDeviceMappings, Boolean monitoringEnabled, byte[] userData) {
|
||||
String availabilityZone, String keyName, Map<String, String> securityGroupIdToNames,
|
||||
Iterable<? extends BlockDeviceMapping> blockDeviceMappings, Boolean monitoringEnabled,
|
||||
Set<String> securityGroupIds, Set<String> securityGroupNames, byte[] userData) {
|
||||
this.instanceType = checkNotNull(instanceType, "instanceType");
|
||||
this.imageId = checkNotNull(imageId, "imageId");
|
||||
this.kernelId = kernelId;
|
||||
this.ramdiskId = ramdiskId;
|
||||
this.availabilityZone = availabilityZone;
|
||||
this.keyName = keyName;
|
||||
this.groupIds = ImmutableSortedSet.copyOf(checkNotNull(groupIds, "groupIds"));
|
||||
this.securityGroupIdToNames = ImmutableMap.copyOf(checkNotNull(securityGroupIdToNames, "securityGroupIdToNames"));
|
||||
this.blockDeviceMappings = ImmutableSortedSet.copyOf(checkNotNull(blockDeviceMappings, "blockDeviceMappings"));
|
||||
this.securityGroupIds = ImmutableSortedSet.copyOf(checkNotNull(securityGroupIds, "securityGroupIds"));
|
||||
this.securityGroupNames = ImmutableSortedSet.copyOf(checkNotNull(securityGroupNames, "securityGroupNames"));
|
||||
this.monitoringEnabled = monitoringEnabled;
|
||||
this.userData = userData;
|
||||
}
|
||||
|
||||
public Map<String, String> getSecurityGroupIdToNames() {
|
||||
return securityGroupIdToNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Image ID of the AMI used to launch the instance.
|
||||
*/
|
||||
|
@ -217,7 +256,8 @@ public class LaunchSpecification {
|
|||
}
|
||||
|
||||
/**
|
||||
* If this instance was launched with an associated key pair, this displays the key pair name.
|
||||
* If this instance was launched with an associated key pair, this displays
|
||||
* the key pair name.
|
||||
*/
|
||||
public String getKeyName() {
|
||||
return keyName;
|
||||
|
@ -247,8 +287,15 @@ public class LaunchSpecification {
|
|||
/**
|
||||
* Names of the security groups.
|
||||
*/
|
||||
public Set<String> getGroupIds() {
|
||||
return groupIds;
|
||||
public Set<String> getSecurityGroupNames() {
|
||||
return securityGroupNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ids of the security groups.
|
||||
*/
|
||||
public Set<String> getSecurityGroupIds() {
|
||||
return securityGroupIds;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -264,13 +311,15 @@ public class LaunchSpecification {
|
|||
int result = 1;
|
||||
result = prime * result + ((availabilityZone == null) ? 0 : availabilityZone.hashCode());
|
||||
result = prime * result + ((blockDeviceMappings == null) ? 0 : blockDeviceMappings.hashCode());
|
||||
result = prime * result + ((groupIds == null) ? 0 : groupIds.hashCode());
|
||||
result = prime * result + ((imageId == null) ? 0 : imageId.hashCode());
|
||||
result = prime * result + ((instanceType == null) ? 0 : instanceType.hashCode());
|
||||
result = prime * result + ((kernelId == null) ? 0 : kernelId.hashCode());
|
||||
result = prime * result + ((keyName == null) ? 0 : keyName.hashCode());
|
||||
result = prime * result + ((monitoringEnabled == null) ? 0 : monitoringEnabled.hashCode());
|
||||
result = prime * result + ((ramdiskId == null) ? 0 : ramdiskId.hashCode());
|
||||
result = prime * result + ((securityGroupIdToNames == null) ? 0 : securityGroupIdToNames.hashCode());
|
||||
result = prime * result + ((securityGroupIds == null) ? 0 : securityGroupIds.hashCode());
|
||||
result = prime * result + ((securityGroupNames == null) ? 0 : securityGroupNames.hashCode());
|
||||
result = prime * result + Arrays.hashCode(userData);
|
||||
return result;
|
||||
}
|
||||
|
@ -294,11 +343,6 @@ public class LaunchSpecification {
|
|||
return false;
|
||||
} else if (!blockDeviceMappings.equals(other.blockDeviceMappings))
|
||||
return false;
|
||||
if (groupIds == null) {
|
||||
if (other.groupIds != null)
|
||||
return false;
|
||||
} else if (!groupIds.equals(other.groupIds))
|
||||
return false;
|
||||
if (imageId == null) {
|
||||
if (other.imageId != null)
|
||||
return false;
|
||||
|
@ -329,6 +373,21 @@ public class LaunchSpecification {
|
|||
return false;
|
||||
} else if (!ramdiskId.equals(other.ramdiskId))
|
||||
return false;
|
||||
if (securityGroupIdToNames == null) {
|
||||
if (other.securityGroupIdToNames != null)
|
||||
return false;
|
||||
} else if (!securityGroupIdToNames.equals(other.securityGroupIdToNames))
|
||||
return false;
|
||||
if (securityGroupIds == null) {
|
||||
if (other.securityGroupIds != null)
|
||||
return false;
|
||||
} else if (!securityGroupIds.equals(other.securityGroupIds))
|
||||
return false;
|
||||
if (securityGroupNames == null) {
|
||||
if (other.securityGroupNames != null)
|
||||
return false;
|
||||
} else if (!securityGroupNames.equals(other.securityGroupNames))
|
||||
return false;
|
||||
if (!Arrays.equals(userData, other.userData))
|
||||
return false;
|
||||
return true;
|
||||
|
@ -341,9 +400,10 @@ public class LaunchSpecification {
|
|||
@Override
|
||||
public String toString() {
|
||||
return "[instanceType=" + instanceType + ", imageId=" + imageId + ", kernelId=" + kernelId + ", ramdiskId="
|
||||
+ ramdiskId + ", availabilityZone=" + availabilityZone + ", keyName=" + keyName + ", groupIds=" + groupIds
|
||||
+ ", blockDeviceMappings=" + blockDeviceMappings + ", monitoringEnabled=" + monitoringEnabled
|
||||
+ ", userData=" + (userData != null) + "]";
|
||||
+ ramdiskId + ", availabilityZone=" + availabilityZone + ", keyName=" + keyName
|
||||
+ ", securityGroupIdToNames=" + securityGroupIdToNames + ", blockDeviceMappings=" + blockDeviceMappings
|
||||
+ ", securityGroupIds=" + securityGroupIds + ", securityGroupNames=" + securityGroupNames
|
||||
+ ", monitoringEnabled=" + monitoringEnabled + ", userData=" + Arrays.toString(userData) + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
|
||||
/**
|
||||
|
@ -36,6 +38,7 @@ public class SpotInstanceRequest implements Comparable<SpotInstanceRequest> {
|
|||
public static class Builder {
|
||||
private String region;
|
||||
private String availabilityZoneGroup;
|
||||
private String launchedAvailabilityZone;
|
||||
private Date createTime;
|
||||
private String faultCode;
|
||||
private String faultMessage;
|
||||
|
@ -53,6 +56,7 @@ public class SpotInstanceRequest implements Comparable<SpotInstanceRequest> {
|
|||
public Builder clear() {
|
||||
this.region = null;
|
||||
this.availabilityZoneGroup = null;
|
||||
this.launchedAvailabilityZone = null;
|
||||
this.createTime = null;
|
||||
this.faultCode = null;
|
||||
this.faultMessage = null;
|
||||
|
@ -79,6 +83,11 @@ public class SpotInstanceRequest implements Comparable<SpotInstanceRequest> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder launchedAvailabilityZone(String launchedAvailabilityZone) {
|
||||
this.launchedAvailabilityZone = launchedAvailabilityZone;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder createTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
return this;
|
||||
|
@ -145,8 +154,9 @@ public class SpotInstanceRequest implements Comparable<SpotInstanceRequest> {
|
|||
}
|
||||
|
||||
public SpotInstanceRequest build() {
|
||||
return new SpotInstanceRequest(region, availabilityZoneGroup, createTime, faultCode, faultMessage, instanceId,
|
||||
launchGroup, launchSpecification, productDescription, id, spotPrice, state, type, validFrom, validUntil);
|
||||
return new SpotInstanceRequest(region, availabilityZoneGroup, launchedAvailabilityZone, createTime, faultCode,
|
||||
faultMessage, instanceId, launchGroup, launchSpecification, productDescription, id, spotPrice, state,
|
||||
type, validFrom, validUntil);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,6 +204,7 @@ public class SpotInstanceRequest implements Comparable<SpotInstanceRequest> {
|
|||
|
||||
private final String region;
|
||||
private final String availabilityZoneGroup;
|
||||
private final String launchedAvailabilityZone;
|
||||
private final Date createTime;
|
||||
private final String faultCode;
|
||||
private final String faultMessage;
|
||||
|
@ -208,11 +219,13 @@ public class SpotInstanceRequest implements Comparable<SpotInstanceRequest> {
|
|||
private final Date validFrom;
|
||||
private final Date validUntil;
|
||||
|
||||
public SpotInstanceRequest(String region, String availabilityZoneGroup, Date createTime, String faultCode,
|
||||
String faultMessage, String instanceId, String launchGroup, LaunchSpecification launchSpecification,
|
||||
String productDescription, String id, float spotPrice, State state, Type type, Date validFrom, Date validUntil) {
|
||||
public SpotInstanceRequest(String region, String availabilityZoneGroup, @Nullable String launchedAvailabilityZone,
|
||||
Date createTime, String faultCode, String faultMessage, String instanceId, String launchGroup,
|
||||
LaunchSpecification launchSpecification, String productDescription, String id, float spotPrice, State state,
|
||||
Type type, Date validFrom, Date validUntil) {
|
||||
this.region = checkNotNull(region, "region");
|
||||
this.availabilityZoneGroup = availabilityZoneGroup;
|
||||
this.launchedAvailabilityZone = launchedAvailabilityZone;
|
||||
this.createTime = createTime;
|
||||
this.faultCode = faultCode;
|
||||
this.faultMessage = faultMessage;
|
||||
|
@ -239,6 +252,10 @@ public class SpotInstanceRequest implements Comparable<SpotInstanceRequest> {
|
|||
return availabilityZoneGroup;
|
||||
}
|
||||
|
||||
public String getLaunchedAvailabilityZone() {
|
||||
return launchedAvailabilityZone;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
@ -303,9 +320,11 @@ public class SpotInstanceRequest implements Comparable<SpotInstanceRequest> {
|
|||
result = prime * result + ((instanceId == null) ? 0 : instanceId.hashCode());
|
||||
result = prime * result + ((launchGroup == null) ? 0 : launchGroup.hashCode());
|
||||
result = prime * result + ((launchSpecification == null) ? 0 : launchSpecification.hashCode());
|
||||
result = prime * result + ((launchedAvailabilityZone == null) ? 0 : launchedAvailabilityZone.hashCode());
|
||||
result = prime * result + ((productDescription == null) ? 0 : productDescription.hashCode());
|
||||
result = prime * result + ((region == null) ? 0 : region.hashCode());
|
||||
result = prime * result + Float.floatToIntBits(spotPrice);
|
||||
result = prime * result + ((state == null) ? 0 : state.hashCode());
|
||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||
result = prime * result + ((validFrom == null) ? 0 : validFrom.hashCode());
|
||||
result = prime * result + ((validUntil == null) ? 0 : validUntil.hashCode());
|
||||
|
@ -361,6 +380,11 @@ public class SpotInstanceRequest implements Comparable<SpotInstanceRequest> {
|
|||
return false;
|
||||
} else if (!launchSpecification.equals(other.launchSpecification))
|
||||
return false;
|
||||
if (launchedAvailabilityZone == null) {
|
||||
if (other.launchedAvailabilityZone != null)
|
||||
return false;
|
||||
} else if (!launchedAvailabilityZone.equals(other.launchedAvailabilityZone))
|
||||
return false;
|
||||
if (productDescription == null) {
|
||||
if (other.productDescription != null)
|
||||
return false;
|
||||
|
@ -373,6 +397,8 @@ public class SpotInstanceRequest implements Comparable<SpotInstanceRequest> {
|
|||
return false;
|
||||
if (Float.floatToIntBits(spotPrice) != Float.floatToIntBits(other.spotPrice))
|
||||
return false;
|
||||
if (state != other.state)
|
||||
return false;
|
||||
if (type != other.type)
|
||||
return false;
|
||||
if (validFrom == null) {
|
||||
|
@ -390,11 +416,12 @@ public class SpotInstanceRequest implements Comparable<SpotInstanceRequest> {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[region=" + region + ", id=" + id + ", spotPrice=" + spotPrice + ", state=" + state
|
||||
+ ", availabilityZoneGroup=" + availabilityZoneGroup + ", createTime=" + createTime + ", faultCode="
|
||||
+ faultCode + ", type=" + type + ", instanceId=" + instanceId + ", launchGroup=" + launchGroup
|
||||
+ ", launchSpecification=" + launchSpecification + ", productDescription=" + productDescription
|
||||
+ ", validFrom=" + validFrom + ", validUntil=" + validUntil + "]";
|
||||
return "[region=" + region + ", availabilityZoneGroup=" + availabilityZoneGroup + ", launchedAvailabilityZone="
|
||||
+ launchedAvailabilityZone + ", createTime=" + createTime + ", faultCode=" + faultCode + ", faultMessage="
|
||||
+ faultMessage + ", instanceId=" + instanceId + ", launchGroup=" + launchGroup + ", launchSpecification="
|
||||
+ launchSpecification + ", productDescription=" + productDescription + ", id=" + id + ", spotPrice="
|
||||
+ spotPrice + ", state=" + state + ", type=" + type + ", validFrom=" + validFrom + ", validUntil="
|
||||
+ validUntil + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -49,7 +49,7 @@ public class SpotInstanceRequestToAWSRunningInstance implements Function<SpotIns
|
|||
builder.availabilityZone(spec.getAvailabilityZone());
|
||||
// TODO convert
|
||||
// builder.devices(spec.getBlockDeviceMappings());
|
||||
builder.groupIds(spec.getGroupIds());
|
||||
builder.groupIds(spec.getSecurityGroupNames());
|
||||
builder.imageId(spec.getImageId());
|
||||
builder.instanceType(spec.getInstanceType());
|
||||
builder.kernelId(spec.getKernelId());
|
||||
|
|
|
@ -81,8 +81,30 @@ public class AWSRunInstancesOptions extends RunInstancesOptions {
|
|||
return this;
|
||||
}
|
||||
|
||||
public AWSRunInstancesOptions withSecurityGroupId(String securityGroup) {
|
||||
return withSecurityGroupIds(securityGroup);
|
||||
}
|
||||
|
||||
public AWSRunInstancesOptions withSecurityGroupIds(Iterable<String> securityGroupIds) {
|
||||
launchSpecificationBuilder.securityGroupIds(securityGroupIds);
|
||||
indexFormValuesWithPrefix("SecurityGroupId", securityGroupIds);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AWSRunInstancesOptions withSecurityGroupIds(String... securityGroupIds) {
|
||||
return withSecurityGroupIds(ImmutableSet.copyOf(securityGroupIds));
|
||||
}
|
||||
|
||||
public static class Builder extends RunInstancesOptions.Builder {
|
||||
|
||||
/**
|
||||
* @see AWSRunInstancesOptions#withSecurityGroupId(String)
|
||||
*/
|
||||
public static AWSRunInstancesOptions withSecurityGroupId(String securityGroup) {
|
||||
AWSRunInstancesOptions options = new AWSRunInstancesOptions();
|
||||
return options.withSecurityGroupId(securityGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AWSRunInstancesOptions#inPlacementGroup(String)
|
||||
*/
|
||||
|
@ -191,19 +213,19 @@ public class AWSRunInstancesOptions extends RunInstancesOptions {
|
|||
|
||||
@Override
|
||||
public AWSRunInstancesOptions withSecurityGroup(String securityGroup) {
|
||||
launchSpecificationBuilder.groupId(securityGroup);
|
||||
launchSpecificationBuilder.securityGroupName(securityGroup);
|
||||
return AWSRunInstancesOptions.class.cast(super.withSecurityGroup(securityGroup));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AWSRunInstancesOptions withSecurityGroups(Iterable<String> securityGroups) {
|
||||
launchSpecificationBuilder.groupIds(securityGroups);
|
||||
launchSpecificationBuilder.securityGroupNames(securityGroups);
|
||||
return AWSRunInstancesOptions.class.cast(super.withSecurityGroups(securityGroups));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AWSRunInstancesOptions withSecurityGroups(String... securityGroups) {
|
||||
launchSpecificationBuilder.groupIds(ImmutableSet.copyOf(securityGroups));
|
||||
launchSpecificationBuilder.securityGroupNames(ImmutableSet.copyOf(securityGroups));
|
||||
return AWSRunInstancesOptions.class.cast(super.withSecurityGroups(securityGroups));
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.aws.ec2.options;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.ec2.options.internal.BaseEC2RequestOptions;
|
||||
|
||||
/**
|
||||
* Contains options supported in the Form API for the CreateSecurityGroup
|
||||
* operation. <h2>
|
||||
* Usage</h2> The recommended way to instantiate a CreateSecurityGroupOptions
|
||||
* object is to statically import CreateSecurityGroupOptions.Builder.* and
|
||||
* invoke a static creation method followed by an instance mutator (if needed):
|
||||
* <p/>
|
||||
* <code>
|
||||
* import static org.jclouds.aws.ec2.options.CreateSecurityGroupOptions.Builder.*
|
||||
* <p/>
|
||||
* AWSEC2Client connection = // get connection
|
||||
* group = connection.getAMIServices().createSecurityGroup(vpcId("123125").noReboot());
|
||||
* <code>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see <a href=
|
||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-CreateSecurityGroup.html"
|
||||
* />
|
||||
*/
|
||||
public class CreateSecurityGroupOptions extends BaseEC2RequestOptions {
|
||||
|
||||
/**
|
||||
* ID of the VPC.
|
||||
*/
|
||||
public CreateSecurityGroupOptions vpcId(String vpcId) {
|
||||
formParameters.put("VpcId", checkNotNull(vpcId, "vpcId"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
/**
|
||||
* @see CreateSecurityGroupOptions#vpcId(String )
|
||||
*/
|
||||
public static CreateSecurityGroupOptions vpcId(String vpcId) {
|
||||
CreateSecurityGroupOptions options = new CreateSecurityGroupOptions();
|
||||
return options.vpcId(vpcId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.aws.ec2.services;
|
||||
|
||||
import static org.jclouds.aws.reference.FormParameters.ACTION;
|
||||
import static org.jclouds.aws.reference.FormParameters.VERSION;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.ws.rs.FormParam;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
import org.jclouds.aws.ec2.AWSEC2AsyncClient;
|
||||
import org.jclouds.aws.ec2.options.CreateSecurityGroupOptions;
|
||||
import org.jclouds.aws.ec2.xml.CreateSecurityGroupResponseHandler;
|
||||
import org.jclouds.aws.filters.FormSigner;
|
||||
import org.jclouds.ec2.binders.BindGroupIdsToIndexedFormParams;
|
||||
import org.jclouds.ec2.binders.BindIpPermissionToIndexedFormParams;
|
||||
import org.jclouds.ec2.binders.BindIpPermissionsToIndexedFormParams;
|
||||
import org.jclouds.ec2.domain.IpPermission;
|
||||
import org.jclouds.ec2.domain.SecurityGroup;
|
||||
import org.jclouds.ec2.services.SecurityGroupAsyncClient;
|
||||
import org.jclouds.ec2.xml.DescribeSecurityGroupsResponseHandler;
|
||||
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.FormParams;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.VirtualHost;
|
||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* Provides access to EC2 SecurityGroup Services via their REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@RequestFilters(FormSigner.class)
|
||||
@FormParams(keys = VERSION, values = AWSEC2AsyncClient.VERSION)
|
||||
@VirtualHost
|
||||
@Beta
|
||||
public interface AWSSecurityGroupAsyncClient extends SecurityGroupAsyncClient {
|
||||
/**
|
||||
* @see AWSSecurityGroupClient#createSecurityGroupInRegion
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@XMLResponseParser(CreateSecurityGroupResponseHandler.class)
|
||||
@FormParams(keys = ACTION, values = "CreateSecurityGroup")
|
||||
ListenableFuture<String> createSecurityGroupInRegionAndReturnId(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||
@FormParam("GroupName") String name, @FormParam("GroupDescription") String description,
|
||||
CreateSecurityGroupOptions... options);
|
||||
|
||||
/**
|
||||
* @see AWSSecurityGroupClient#authorizeSecurityGroupIngressInRegion(String,
|
||||
* String,IpPermission)
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = ACTION, values = "AuthorizeSecurityGroupIngress")
|
||||
ListenableFuture<Void> authorizeSecurityGroupIngressInRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||
@FormParam("GroupId") String groupId, @BinderParam(BindIpPermissionToIndexedFormParams.class) IpPermission perm);
|
||||
|
||||
/**
|
||||
* @see AWSSecurityGroupClient#authorizeSecurityGroupIngressInRegion(String,
|
||||
* String,Iterable)
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = ACTION, values = "AuthorizeSecurityGroupIngress")
|
||||
ListenableFuture<Void> authorizeSecurityGroupIngressInRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||
@FormParam("GroupId") String groupId,
|
||||
@BinderParam(BindIpPermissionsToIndexedFormParams.class) Iterable<IpPermission> perms);
|
||||
|
||||
/**
|
||||
* @see AWSSecurityGroupClient#revokeSecurityGroupIngressInRegion(@Nullable
|
||||
* Region, String,IpPermission)
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = ACTION, values = "RevokeSecurityGroupIngress")
|
||||
ListenableFuture<Void> revokeSecurityGroupIngressInRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||
@FormParam("GroupId") String groupId, @BinderParam(BindIpPermissionToIndexedFormParams.class) IpPermission perm);
|
||||
|
||||
/**
|
||||
* @see AWSSecurityGroupClient#revokeSecurityGroupIngressInRegion(@Nullable
|
||||
* Region, String,Iterable)
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = ACTION, values = "RevokeSecurityGroupIngress")
|
||||
ListenableFuture<Void> revokeSecurityGroupIngressInRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||
@FormParam("GroupId") String groupId,
|
||||
@BinderParam(BindIpPermissionsToIndexedFormParams.class) Iterable<IpPermission> perms);
|
||||
|
||||
/**
|
||||
* @see AWSSecurityGroupClient#deleteSecurityGroupInRegionById
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = ACTION, values = "DeleteSecurityGroup")
|
||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||
ListenableFuture<Void> deleteSecurityGroupInRegionById(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region, @FormParam("GroupId") String name);
|
||||
|
||||
/**
|
||||
* @see AWSSecurityGroupClient#describeSecurityGroupsInRegionById
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = ACTION, values = "DescribeSecurityGroups")
|
||||
@XMLResponseParser(DescribeSecurityGroupsResponseHandler.class)
|
||||
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||
ListenableFuture<? extends Set<SecurityGroup>> describeSecurityGroupsInRegionById(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region,
|
||||
@BinderParam(BindGroupIdsToIndexedFormParams.class) String... securityGroupNames);
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.aws.ec2.services;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.aws.ec2.options.CreateSecurityGroupOptions;
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.ec2.domain.IpPermission;
|
||||
import org.jclouds.ec2.domain.SecurityGroup;
|
||||
import org.jclouds.ec2.services.SecurityGroupClient;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
|
||||
/**
|
||||
* Provides access to EC2 via their REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Beta
|
||||
@Timeout(duration = 90, timeUnit = TimeUnit.SECONDS)
|
||||
public interface AWSSecurityGroupClient extends SecurityGroupClient {
|
||||
|
||||
String createSecurityGroupInRegionAndReturnId(@Nullable String region, String name, String desc,
|
||||
CreateSecurityGroupOptions... options);
|
||||
|
||||
void authorizeSecurityGroupIngressInRegion(@Nullable String region, String groupId, IpPermission perm);
|
||||
|
||||
void authorizeSecurityGroupIngressInRegion(@Nullable String region, String groupId, Iterable<IpPermission> perm);
|
||||
|
||||
void revokeSecurityGroupIngressInRegion(@Nullable String region, String groupId, IpPermission perm);
|
||||
|
||||
void revokeSecurityGroupIngressInRegion(@Nullable String region, String groupId, Iterable<IpPermission> perm);
|
||||
|
||||
Set<SecurityGroup> describeSecurityGroupsInRegionById(@Nullable String region, String... securityGroupIds);
|
||||
|
||||
void deleteSecurityGroupInRegionById(@Nullable String region, String name);
|
||||
}
|
|
@ -22,10 +22,10 @@ import java.util.Set;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.ec2.domain.AWSRunningInstance;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.Reservation;
|
||||
import org.jclouds.ec2.domain.RunningInstance;
|
||||
import org.jclouds.ec2.domain.RunningInstance.Builder;
|
||||
import org.jclouds.location.Region;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
@ -40,12 +40,12 @@ import com.google.inject.Provider;
|
|||
* @see <a href="http: />
|
||||
*/
|
||||
public class AWSDescribeInstancesResponseHandler extends
|
||||
BaseAWSReservationHandler<Set<Reservation<? extends RunningInstance>>> {
|
||||
BaseAWSReservationHandler<Set<Reservation<? extends RunningInstance>>> {
|
||||
private Set<Reservation<? extends RunningInstance>> reservations = Sets.newLinkedHashSet();
|
||||
|
||||
@Inject
|
||||
AWSDescribeInstancesResponseHandler(DateService dateService, @Region String defaultRegion,
|
||||
Provider<Builder> builderProvider) {
|
||||
Provider<AWSRunningInstance.Builder> builderProvider) {
|
||||
super(dateService, defaultRegion, builderProvider);
|
||||
}
|
||||
|
||||
|
@ -66,5 +66,8 @@ public class AWSDescribeInstancesResponseHandler extends
|
|||
super.inItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected boolean endOfInstanceItem() {
|
||||
return itemDepth == 2 && inInstancesSet;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,10 @@ package org.jclouds.aws.ec2.xml;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.ec2.domain.AWSRunningInstance;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.Reservation;
|
||||
import org.jclouds.ec2.domain.RunningInstance;
|
||||
import org.jclouds.ec2.domain.RunningInstance.Builder;
|
||||
import org.jclouds.location.Region;
|
||||
|
||||
import com.google.inject.Provider;
|
||||
|
@ -39,7 +39,8 @@ import com.google.inject.Provider;
|
|||
public class AWSRunInstancesResponseHandler extends BaseAWSReservationHandler<Reservation<? extends RunningInstance>> {
|
||||
|
||||
@Inject
|
||||
AWSRunInstancesResponseHandler(DateService dateService, @Region String defaultRegion, Provider<Builder> builderProvider) {
|
||||
AWSRunInstancesResponseHandler(DateService dateService, @Region String defaultRegion,
|
||||
Provider<AWSRunningInstance.Builder> builderProvider) {
|
||||
super(dateService, defaultRegion, builderProvider);
|
||||
}
|
||||
|
||||
|
@ -48,4 +49,7 @@ public class AWSRunInstancesResponseHandler extends BaseAWSReservationHandler<Re
|
|||
return newReservation();
|
||||
}
|
||||
|
||||
protected boolean endOfInstanceItem() {
|
||||
return itemDepth == 1 && inInstancesSet;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,53 +18,227 @@
|
|||
*/
|
||||
package org.jclouds.aws.ec2.xml;
|
||||
|
||||
import static org.jclouds.util.SaxUtils.currentOrNull;
|
||||
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.aws.ec2.domain.AWSRunningInstance;
|
||||
import org.jclouds.aws.ec2.domain.MonitoringState;
|
||||
import org.jclouds.aws.util.AWSUtils;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.domain.RunningInstance.Builder;
|
||||
import org.jclouds.ec2.xml.BaseReservationHandler;
|
||||
import org.jclouds.ec2.domain.Attachment;
|
||||
import org.jclouds.ec2.domain.BlockDevice;
|
||||
import org.jclouds.ec2.domain.InstanceState;
|
||||
import org.jclouds.ec2.domain.Reservation;
|
||||
import org.jclouds.ec2.domain.RootDeviceType;
|
||||
import org.jclouds.ec2.domain.RunningInstance;
|
||||
import org.jclouds.http.functions.ParseSax.HandlerForGeneratedRequestWithResult;
|
||||
import org.jclouds.location.Region;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public abstract class BaseAWSReservationHandler<T> extends BaseReservationHandler<T> {
|
||||
public abstract class BaseAWSReservationHandler<T> extends HandlerForGeneratedRequestWithResult<T> {
|
||||
|
||||
public BaseAWSReservationHandler(DateService dateService, String defaultRegion, Provider<Builder> builderProvider) {
|
||||
super(dateService, defaultRegion, builderProvider);
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
protected final DateService dateService;
|
||||
protected final String defaultRegion;
|
||||
protected final Provider<AWSRunningInstance.Builder> builderProvider;
|
||||
|
||||
@Inject
|
||||
public BaseAWSReservationHandler(DateService dateService, @Region String defaultRegion,
|
||||
Provider<AWSRunningInstance.Builder> builderProvider) {
|
||||
this.dateService = dateService;
|
||||
this.defaultRegion = defaultRegion;
|
||||
this.builderProvider = builderProvider;
|
||||
this.builder = builderProvider.get();
|
||||
}
|
||||
|
||||
protected String currentOrNull() {
|
||||
String returnVal = currentText.toString().trim();
|
||||
return returnVal.equals("") ? null : returnVal;
|
||||
protected StringBuilder currentText = new StringBuilder();
|
||||
|
||||
protected AWSRunningInstance.Builder builder;
|
||||
|
||||
protected int itemDepth;
|
||||
boolean inInstancesSet;
|
||||
// attachments
|
||||
private String volumeId;
|
||||
private Attachment.Status attachmentStatus;
|
||||
private Date attachTime;
|
||||
private boolean deleteOnTermination;
|
||||
private String deviceName;
|
||||
|
||||
// reservation stuff
|
||||
private String groupId;
|
||||
private Map<String, String> reservationGroupIdToNames = Maps.newLinkedHashMap();
|
||||
private String ownerId;
|
||||
private String requesterId;
|
||||
private String reservationId;
|
||||
|
||||
private Set<RunningInstance> instances = Sets.newLinkedHashSet();
|
||||
|
||||
protected int depth = 0;
|
||||
|
||||
private boolean inPlacement;
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||
if (equalsOrSuffix(qName, "item")) {
|
||||
itemDepth++;
|
||||
} else if (equalsOrSuffix(qName, "instancesSet")) {
|
||||
inInstancesSet = true;
|
||||
} else if (equalsOrSuffix(qName, "placement")) {
|
||||
inPlacement = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
if (qName.equals("state")) {
|
||||
builder().monitoringState(MonitoringState.fromValue(currentOrNull()));
|
||||
} else if (qName.equals("groupName")) {
|
||||
builder().placementGroup(currentOrNull());
|
||||
} else if (qName.equals("subnetId")) {
|
||||
builder().subnetId(currentOrNull());
|
||||
} else if (qName.equals("spotInstanceRequestId")) {
|
||||
builder().spotInstanceRequestId(currentOrNull());
|
||||
} else if (qName.equals("vpcId")) {
|
||||
builder().vpcId(currentOrNull());
|
||||
} else if (qName.equals("productCode")) {
|
||||
builder().productCode(currentOrNull());
|
||||
if (equalsOrSuffix(qName, "item")) {
|
||||
inItem();
|
||||
itemDepth--;
|
||||
} else if (equalsOrSuffix(qName, "state")) {
|
||||
builder.monitoringState(MonitoringState.fromValue(currentOrNull(currentText)));
|
||||
} else if (equalsOrSuffix(qName, "groupId")) {
|
||||
groupId = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "groupName") && inPlacement) {
|
||||
builder.placementGroup(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "groupName")) {
|
||||
switch (itemDepth) {
|
||||
case 2:
|
||||
builder.securityGroupIdToName(groupId, currentOrNull(currentText));
|
||||
break;
|
||||
case 3:
|
||||
reservationGroupIdToNames.put(groupId, currentOrNull(currentText));
|
||||
break;
|
||||
}
|
||||
groupId = null;
|
||||
} else if (equalsOrSuffix(qName, "subnetId")) {
|
||||
builder.subnetId(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "spotInstanceRequestId")) {
|
||||
builder.spotInstanceRequestId(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "vpcId")) {
|
||||
builder.vpcId(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "productCode")) {
|
||||
builder.productCode(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "instancesSet")) {
|
||||
inInstancesSet = false;
|
||||
} else if (equalsOrSuffix(qName, "placement")) {
|
||||
inPlacement = false;
|
||||
} else if (equalsOrSuffix(qName, "ownerId")) {
|
||||
ownerId = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "requesterId")) {
|
||||
requesterId = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "reservationId")) {
|
||||
reservationId = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "amiLaunchIndex")) {
|
||||
builder.amiLaunchIndex(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "dnsName")) {
|
||||
builder.dnsName(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "imageId")) {
|
||||
builder.imageId(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "instanceId")) {
|
||||
builder.instanceId(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "name")) {
|
||||
builder.instanceState(InstanceState.fromValue(currentOrNull(currentText)));
|
||||
} else if (equalsOrSuffix(qName, "instanceType")) {
|
||||
builder.instanceType(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "ipAddress")) {
|
||||
builder.ipAddress(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "kernelId")) {
|
||||
builder.kernelId(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "keyName")) {
|
||||
builder.keyName(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "launchTime")) {
|
||||
builder.launchTime(parseDate());
|
||||
} else if (equalsOrSuffix(qName, "availabilityZone")) {
|
||||
builder.availabilityZone(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "virtualizationType")) {
|
||||
builder.virtualizationType(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "platform")) {
|
||||
builder.platform(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "privateDnsName")) {
|
||||
builder.privateDnsName(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "privateIpAddress")) {
|
||||
builder.privateIpAddress(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "ramdiskId")) {
|
||||
builder.ramdiskId(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "reason")) {
|
||||
builder.reason(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "rootDeviceType")) {
|
||||
builder.rootDeviceType(RootDeviceType.fromValue(currentOrNull(currentText)));
|
||||
} else if (equalsOrSuffix(qName, "rootDeviceName")) {
|
||||
builder.rootDeviceName(currentOrNull(currentText));
|
||||
} else if (equalsOrSuffix(qName, "deviceName")) {
|
||||
deviceName = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "volumeId")) {
|
||||
volumeId = currentOrNull(currentText);
|
||||
} else if (equalsOrSuffix(qName, "status")) {
|
||||
attachmentStatus = Attachment.Status.fromValue(currentText.toString().trim());
|
||||
} else if (equalsOrSuffix(qName, "attachTime")) {
|
||||
attachTime = dateService.iso8601DateParse(currentText.toString().trim());
|
||||
} else if (equalsOrSuffix(qName, "deleteOnTermination")) {
|
||||
deleteOnTermination = Boolean.parseBoolean(currentText.toString().trim());
|
||||
} else if (equalsOrSuffix(qName, "ebs")) {
|
||||
builder.device(deviceName, new BlockDevice(volumeId, attachmentStatus, attachTime, deleteOnTermination));
|
||||
this.deviceName = null;
|
||||
this.volumeId = null;
|
||||
this.attachmentStatus = null;
|
||||
this.attachTime = null;
|
||||
this.deleteOnTermination = true;
|
||||
}
|
||||
super.endElement(uri, name, qName);
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AWSRunningInstance.Builder builder() {
|
||||
return AWSRunningInstance.Builder.class.cast(builder);
|
||||
protected Date parseDate() {
|
||||
return dateService.iso8601DateParse(currentOrNull(currentText));
|
||||
}
|
||||
|
||||
protected void inItem() {
|
||||
if (endOfInstanceItem()) {
|
||||
refineBuilderBeforeAddingInstance();
|
||||
instances.add(builder.build());
|
||||
builder = builderProvider.get();
|
||||
}
|
||||
}
|
||||
|
||||
protected void refineBuilderBeforeAddingInstance() {
|
||||
String region = getRequest() != null ? AWSUtils.findRegionInArgsOrNull(getRequest()) : null;
|
||||
builder.region((region == null) ? defaultRegion : region);
|
||||
}
|
||||
|
||||
protected abstract boolean endOfInstanceItem();
|
||||
|
||||
public void characters(char ch[], int start, int length) {
|
||||
super.characters(ch, start, length);
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
|
||||
protected Reservation<? extends RunningInstance> newReservation() {
|
||||
String region = getRequest() != null ? AWSUtils.findRegionInArgsOrNull(getRequest()) : null;
|
||||
if (region == null)
|
||||
region = defaultRegion;
|
||||
Reservation<? extends RunningInstance> info = new Reservation<RunningInstance>(region,
|
||||
reservationGroupIdToNames.values(), instances, ownerId, requesterId, reservationId);
|
||||
this.reservationGroupIdToNames = Maps.newLinkedHashMap();
|
||||
this.instances = Sets.newLinkedHashSet();
|
||||
this.ownerId = null;
|
||||
this.requesterId = null;
|
||||
this.reservationId = null;
|
||||
return info;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.aws.ec2.xml;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class CreateSecurityGroupResponseHandler extends ParseSax.HandlerWithResult<String> {
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
String id;
|
||||
|
||||
public String getResult() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
if (qName.equals("groupId")) {
|
||||
id = currentText.toString().trim();
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
public void characters(char ch[], int start, int length) {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
}
|
|
@ -62,6 +62,8 @@ public class LaunchSpecificationHandler extends HandlerForGeneratedRequestWithRe
|
|||
|
||||
private boolean inBlockDeviceMapping;
|
||||
|
||||
private String groupId;
|
||||
|
||||
public void startElement(String uri, String name, String qName, Attributes attrs) {
|
||||
if (qName.equals("blockDeviceMapping")) {
|
||||
inBlockDeviceMapping = true;
|
||||
|
@ -96,7 +98,10 @@ public class LaunchSpecificationHandler extends HandlerForGeneratedRequestWithRe
|
|||
if (deleteOnTermination != null)
|
||||
blockDeviceMappingBuilder.deleteOnTermination(Boolean.parseBoolean(deleteOnTermination));
|
||||
} else if (qName.equals("groupId")) {
|
||||
builder.groupId(currentOrNull());
|
||||
groupId = currentOrNull();
|
||||
} else if (qName.equals("groupName")) {
|
||||
builder.securityGroupIdToName(groupId, currentOrNull());
|
||||
groupId = null;
|
||||
} else if (qName.equals("imageId")) {
|
||||
builder.imageId(currentOrNull());
|
||||
} else if (qName.equals("instanceType")) {
|
||||
|
|
|
@ -85,6 +85,8 @@ public class SpotInstanceHandler extends ParseSax.HandlerForGeneratedRequestWith
|
|||
builder.id(currentOrNull());
|
||||
} else if (qName.equals("instanceId")) {
|
||||
builder.instanceId(currentOrNull());
|
||||
} else if (qName.equals("launchedAvailabilityZone")) {
|
||||
builder.launchedAvailabilityZone(currentOrNull());
|
||||
} else if (qName.equals("availabilityZoneGroup")) {
|
||||
builder.availabilityZoneGroup(currentOrNull());
|
||||
} else if (qName.equals("launchGroup")) {
|
||||
|
|
|
@ -56,4 +56,13 @@ public class BindLaunchSpecificationToFormParamsTest {
|
|||
"LaunchSpecification.ImageId", "ami-123", "LaunchSpecification.UserData",
|
||||
Base64.encodeBytes("hello".getBytes())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testApplyWithSecurityId() throws UnknownHostException {
|
||||
LaunchSpecification spec = LaunchSpecification.builder().instanceType(InstanceType.T1_MICRO).imageId("ami-123")
|
||||
.securityGroupId("sid-foo").build();
|
||||
|
||||
assertEquals(binder.apply(spec), ImmutableMap.of("LaunchSpecification.InstanceType", "t1.micro",
|
||||
"LaunchSpecification.ImageId", "ami-123", "LaunchSpecification.SecurityGroupId.1", "sid-foo"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,10 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.aws.ec2.AWSEC2Client;
|
||||
import org.jclouds.aws.ec2.domain.AWSRunningInstance;
|
||||
import org.jclouds.aws.ec2.domain.MonitoringState;
|
||||
import org.jclouds.aws.ec2.services.AWSSecurityGroupClient;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.options.TemplateOptions;
|
||||
import org.jclouds.compute.predicates.NodePredicates;
|
||||
|
@ -35,7 +37,7 @@ import org.jclouds.ec2.domain.KeyPair;
|
|||
import org.jclouds.ec2.domain.SecurityGroup;
|
||||
import org.jclouds.ec2.services.InstanceClient;
|
||||
import org.jclouds.ec2.services.KeyPairClient;
|
||||
import org.jclouds.ec2.services.SecurityGroupClient;
|
||||
import org.jclouds.ec2.util.IpPermissions;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
|
@ -57,7 +59,7 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
|||
@Override
|
||||
@Test(enabled = true, dependsOnMethods = "testCompareSizes")
|
||||
public void testExtendedOptionsAndLogin() throws Exception {
|
||||
SecurityGroupClient securityGroupClient = EC2Client.class.cast(context.getProviderSpecificContext().getApi())
|
||||
AWSSecurityGroupClient securityGroupClient = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi())
|
||||
.getSecurityGroupServices();
|
||||
|
||||
KeyPairClient keyPairClient = EC2Client.class.cast(context.getProviderSpecificContext().getApi())
|
||||
|
@ -72,7 +74,6 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
|||
|
||||
// Date before = new Date();
|
||||
|
||||
options.as(AWSEC2TemplateOptions.class).securityGroups(group);
|
||||
options.as(AWSEC2TemplateOptions.class).keyPair(group);
|
||||
options.as(AWSEC2TemplateOptions.class).enableMonitoring();
|
||||
options.as(AWSEC2TemplateOptions.class).spotPrice(0.3f);
|
||||
|
@ -83,8 +84,12 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
|
|||
|
||||
// create a security group that allows ssh in so that our scripts later
|
||||
// will work
|
||||
securityGroupClient.createSecurityGroupInRegion(null, group, group);
|
||||
securityGroupClient.authorizeSecurityGroupIngressInRegion(null, group, IpProtocol.TCP, 22, 22, "0.0.0.0/0");
|
||||
String groupId = securityGroupClient.createSecurityGroupInRegionAndReturnId(null, group, group);
|
||||
|
||||
securityGroupClient.authorizeSecurityGroupIngressInRegion(null, groupId,
|
||||
IpPermissions.permit(IpProtocol.TCP).port(22));
|
||||
|
||||
options.as(AWSEC2TemplateOptions.class).securityGroupIds(groupId);
|
||||
|
||||
// create a keypair to pass in as well
|
||||
KeyPair result = keyPairClient.createKeyPairInRegion(null, group);
|
||||
|
|
|
@ -85,7 +85,7 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
|||
.build();
|
||||
|
||||
assert (template.getImage().getProviderId().startsWith("ami-")) : template;
|
||||
assertEquals(template.getImage().getOperatingSystem().getVersion(), "11.04");
|
||||
assertEquals(template.getImage().getOperatingSystem().getVersion(), "11.10");
|
||||
assertEquals(template.getImage().getOperatingSystem().is64Bit(), false);
|
||||
assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
|
||||
assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
|
||||
|
@ -146,7 +146,7 @@ public class AWSEC2TemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
|||
fastestTemplate = context.getComputeService().templateBuilder().fastest().build();
|
||||
assert (fastestTemplate.getImage().getProviderId().startsWith("ami-")) : fastestTemplate;
|
||||
assertEquals(fastestTemplate.getHardware().getProviderId(), InstanceType.CC1_4XLARGE);
|
||||
assertEquals(fastestTemplate.getImage().getOperatingSystem().getVersion(), "11.04");
|
||||
assertEquals(fastestTemplate.getImage().getOperatingSystem().getVersion(), "11.10");
|
||||
assertEquals(fastestTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
||||
assertEquals(fastestTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
|
||||
assertEquals(fastestTemplate.getImage().getUserMetadata().get("rootDeviceType"), "ebs");
|
||||
|
|
|
@ -25,6 +25,7 @@ import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.inboundP
|
|||
import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.installPrivateKey;
|
||||
import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.keyPair;
|
||||
import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.noKeyPair;
|
||||
import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.securityGroupIds;
|
||||
import static org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions.Builder.securityGroups;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
|
@ -37,7 +38,8 @@ import org.testng.annotations.Test;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Tests possible uses of AWSEC2TemplateOptions and AWSEC2TemplateOptions.Builder.*
|
||||
* Tests possible uses of AWSEC2TemplateOptions and
|
||||
* AWSEC2TemplateOptions.Builder.*
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -48,6 +50,63 @@ public class AWSEC2TemplateOptionsTest {
|
|||
assertEquals(options.as(AWSEC2TemplateOptions.class), options);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testsecurityGroupIdsIterableBadFormat() {
|
||||
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
|
||||
options.securityGroupIds(ImmutableSet.of("groupId1", ""));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testsecurityGroupIdsIterableEmptyNotOk() {
|
||||
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
|
||||
options.securityGroupIds(ImmutableSet.<String> of());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testsecurityGroupIdsIterable() {
|
||||
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
|
||||
options.securityGroupIds(ImmutableSet.of("groupId1", "groupId2"));
|
||||
assertEquals(options.getGroupIds(), ImmutableSet.of("groupId1", "groupId2"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testsecurityGroupIdsIterableStatic() {
|
||||
AWSEC2TemplateOptions options = securityGroupIds(ImmutableSet.of("groupId1", "groupId2"));
|
||||
assertEquals(options.getGroupIds(), ImmutableSet.of("groupId1", "groupId2"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testsecurityGroupIdsVarArgsBadFormat() {
|
||||
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
|
||||
options.securityGroupIds("mygroupId", "");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testsecurityGroupIdsVarArgs() {
|
||||
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
|
||||
options.securityGroupIds("groupId1", "groupId2");
|
||||
assertEquals(options.getGroupIds(), ImmutableSet.of("groupId1", "groupId2"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testsecurityGroupIdsVarArgsEmptyNotOk() {
|
||||
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
|
||||
options.securityGroupIds();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultGroupIdsVarArgsEmpty() {
|
||||
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
|
||||
assertEquals(options.getGroupIds(), ImmutableSet.of());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testsecurityGroupIdsVarArgsStatic() {
|
||||
AWSEC2TemplateOptions options = securityGroupIds("groupId1", "groupId2");
|
||||
assertEquals(options.getGroupIds(), ImmutableSet.of("groupId1", "groupId2"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testsecurityGroupsIterableBadFormat() {
|
||||
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
|
||||
|
@ -64,14 +123,14 @@ public class AWSEC2TemplateOptionsTest {
|
|||
public void testsecurityGroupsIterable() {
|
||||
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
|
||||
options.securityGroups(ImmutableSet.of("group1", "group2"));
|
||||
assertEquals(options.getGroupIds(), ImmutableSet.of("group1", "group2"));
|
||||
assertEquals(options.getGroups(), ImmutableSet.of("group1", "group2"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testsecurityGroupsIterableStatic() {
|
||||
AWSEC2TemplateOptions options = securityGroups(ImmutableSet.of("group1", "group2"));
|
||||
assertEquals(options.getGroupIds(), ImmutableSet.of("group1", "group2"));
|
||||
assertEquals(options.getGroups(), ImmutableSet.of("group1", "group2"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
|
@ -84,8 +143,7 @@ public class AWSEC2TemplateOptionsTest {
|
|||
public void testsecurityGroupsVarArgs() {
|
||||
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
|
||||
options.securityGroups("group1", "group2");
|
||||
assertEquals(options.getGroupIds(), ImmutableSet.of("group1", "group2"));
|
||||
|
||||
assertEquals(options.getGroups(), ImmutableSet.of("group1", "group2"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
|
@ -97,13 +155,13 @@ public class AWSEC2TemplateOptionsTest {
|
|||
@Test
|
||||
public void testDefaultGroupsVarArgsEmpty() {
|
||||
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
|
||||
assertEquals(options.getGroupIds(), ImmutableSet.of());
|
||||
assertEquals(options.getGroups(), ImmutableSet.of());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testsecurityGroupsVarArgsStatic() {
|
||||
AWSEC2TemplateOptions options = securityGroups("group1", "group2");
|
||||
assertEquals(options.getGroupIds(), ImmutableSet.of("group1", "group2"));
|
||||
assertEquals(options.getGroups(), ImmutableSet.of("group1", "group2"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
|
|
|
@ -104,6 +104,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, group, options)).andReturn(
|
||||
systemGeneratedKeyPairName);
|
||||
expect(strategy.getSecurityGroupsForTagAndOptions(region, group, options)).andReturn(generatedGroups);
|
||||
expect(options.getGroupIds()).andReturn(ImmutableSet.<String>of());
|
||||
expect(options.getSubnetId()).andReturn(null);
|
||||
expect(options.getUserData()).andReturn(null);
|
||||
expect(options.isMonitoringEnabled()).andReturn(false);
|
||||
|
@ -167,6 +168,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
expect(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, group, options)).andReturn(
|
||||
generatedGroup);
|
||||
expect(strategy.getSecurityGroupsForTagAndOptions(region, group, options)).andReturn(generatedGroups);
|
||||
expect(options.getGroupIds()).andReturn(ImmutableSet.<String>of());
|
||||
expect(options.getSubnetId()).andReturn(null);
|
||||
expect(options.getUserData()).andReturn(null);
|
||||
expect(options.isMonitoringEnabled()).andReturn(false);
|
||||
|
@ -231,6 +233,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
expect(strategy.createNewPlacementGroupUnlessUserSpecifiedOtherwise(region, group, options)).andReturn(
|
||||
generatedGroup);
|
||||
expect(strategy.getSecurityGroupsForTagAndOptions(region, group, options)).andReturn(generatedGroups);
|
||||
expect(options.getGroupIds()).andReturn(ImmutableSet.<String>of());
|
||||
expect(options.getSubnetId()).andReturn(null);
|
||||
expect(options.getUserData()).andReturn(null);
|
||||
expect(options.isMonitoringEnabled()).andReturn(false);
|
||||
|
@ -290,6 +293,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
expect(options.getBlockDeviceMappings()).andReturn(ImmutableSet.<BlockDeviceMapping> of()).atLeastOnce();
|
||||
expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, group, options)).andReturn(
|
||||
systemGeneratedKeyPairName);
|
||||
expect(options.getGroupIds()).andReturn(ImmutableSet.<String>of());
|
||||
expect(options.getSubnetId()).andReturn("1");
|
||||
expect(options.getUserData()).andReturn(null);
|
||||
expect(options.isMonitoringEnabled()).andReturn(false);
|
||||
|
@ -351,6 +355,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, group, options)).andReturn(
|
||||
systemGeneratedKeyPairName);
|
||||
expect(strategy.getSecurityGroupsForTagAndOptions(region, group, options)).andReturn(generatedGroups);
|
||||
expect(options.getGroupIds()).andReturn(ImmutableSet.<String>of());
|
||||
expect(options.getSubnetId()).andReturn(null);
|
||||
expect(options.getUserData()).andReturn("hello".getBytes());
|
||||
expect(options.isMonitoringEnabled()).andReturn(false);
|
||||
|
@ -588,7 +593,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
String region = Region.AP_SOUTHEAST_1;
|
||||
String group = "group";
|
||||
String generatedMarkerGroup = "jclouds#group#" + Region.AP_SOUTHEAST_1;
|
||||
Set<String> groupIds = ImmutableSet.<String> of();
|
||||
Set<String> groupNames = ImmutableSet.<String> of();
|
||||
int[] ports = new int[] {};
|
||||
boolean shouldAuthorizeSelf = true;
|
||||
boolean groupExisted = false;
|
||||
|
@ -599,7 +604,8 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
|
||||
|
||||
// setup expectations
|
||||
expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce();
|
||||
expect(options.getGroupIds()).andReturn(ImmutableSet.<String>of());
|
||||
expect(options.getGroups()).andReturn(groupNames).atLeastOnce();
|
||||
expect(options.getInboundPorts()).andReturn(ports).atLeastOnce();
|
||||
RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
|
||||
ports, shouldAuthorizeSelf);
|
||||
|
@ -624,7 +630,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
String region = Region.AP_SOUTHEAST_1;
|
||||
String group = "group";
|
||||
String generatedMarkerGroup = "jclouds#group#" + Region.AP_SOUTHEAST_1;
|
||||
Set<String> groupIds = ImmutableSet.<String> of();
|
||||
Set<String> groupNames = ImmutableSet.<String> of();
|
||||
int[] ports = new int[] { 22, 80 };
|
||||
boolean shouldAuthorizeSelf = true;
|
||||
boolean groupExisted = false;
|
||||
|
@ -635,7 +641,8 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
|
||||
|
||||
// setup expectations
|
||||
expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce();
|
||||
expect(options.getGroupIds()).andReturn(ImmutableSet.<String>of());
|
||||
expect(options.getGroups()).andReturn(groupNames).atLeastOnce();
|
||||
expect(options.getInboundPorts()).andReturn(ports).atLeastOnce();
|
||||
RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
|
||||
ports, shouldAuthorizeSelf);
|
||||
|
@ -660,7 +667,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
String region = Region.AP_SOUTHEAST_1;
|
||||
String group = "group";
|
||||
String generatedMarkerGroup = "jclouds#group#" + Region.AP_SOUTHEAST_1;
|
||||
Set<String> groupIds = ImmutableSet.<String> of();
|
||||
Set<String> groupNames = ImmutableSet.<String> of();
|
||||
int[] ports = new int[] {};
|
||||
boolean shouldAuthorizeSelf = true;
|
||||
boolean groupExisted = true;
|
||||
|
@ -671,7 +678,8 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
|
||||
|
||||
// setup expectations
|
||||
expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce();
|
||||
expect(options.getGroupIds()).andReturn(ImmutableSet.<String>of());
|
||||
expect(options.getGroups()).andReturn(groupNames).atLeastOnce();
|
||||
expect(options.getInboundPorts()).andReturn(ports).atLeastOnce();
|
||||
RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
|
||||
ports, shouldAuthorizeSelf);
|
||||
|
@ -694,7 +702,7 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
String region = Region.AP_SOUTHEAST_1;
|
||||
String group = "group";
|
||||
String generatedMarkerGroup = "jclouds#group#" + Region.AP_SOUTHEAST_1;
|
||||
Set<String> groupIds = ImmutableSet.<String> of("group1", "group2");
|
||||
Set<String> groupNames = ImmutableSet.<String> of("group1", "group2");
|
||||
int[] ports = new int[] {};
|
||||
boolean shouldAuthorizeSelf = true;
|
||||
boolean groupExisted = true;
|
||||
|
@ -705,7 +713,8 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
|
||||
|
||||
// setup expectations
|
||||
expect(options.getGroupIds()).andReturn(groupIds).atLeastOnce();
|
||||
expect(options.getGroupIds()).andReturn(ImmutableSet.<String>of());
|
||||
expect(options.getGroups()).andReturn(groupNames).atLeastOnce();
|
||||
RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
|
||||
ports, shouldAuthorizeSelf); // note
|
||||
// this
|
||||
|
@ -727,6 +736,44 @@ public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsT
|
|||
verifyStrategy(strategy);
|
||||
}
|
||||
|
||||
public void testGetSecurityGroupsForTagAndOptions_reusesGroupByDefaultWhenNoPortsAreSpecifiedWhenDoesExistAndAcceptsUserSuppliedGroupIds() {
|
||||
// setup constants
|
||||
String region = Region.AP_SOUTHEAST_1;
|
||||
String group = "group";
|
||||
String generatedMarkerGroup = "jclouds#group#" + Region.AP_SOUTHEAST_1;
|
||||
Set<String> groupNames = ImmutableSet.<String> of();
|
||||
int[] ports = new int[] {};
|
||||
boolean shouldAuthorizeSelf = true;
|
||||
boolean groupExisted = true;
|
||||
Set<String> returnVal = ImmutableSet.<String> of(generatedMarkerGroup);
|
||||
|
||||
// create mocks
|
||||
CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy();
|
||||
AWSEC2TemplateOptions options = createMock(AWSEC2TemplateOptions.class);
|
||||
|
||||
// setup expectations
|
||||
expect(options.getGroupIds()).andReturn(ImmutableSet.<String>of("group1", "group2"));
|
||||
expect(options.getGroups()).andReturn(groupNames).atLeastOnce();
|
||||
RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup,
|
||||
ports, shouldAuthorizeSelf); // note
|
||||
// this
|
||||
// works
|
||||
// since
|
||||
// there's
|
||||
// no equals on portsq
|
||||
expect(strategy.securityGroupMap.containsKey(regionNameAndIngressRules)).andReturn(groupExisted);
|
||||
|
||||
// replay mocks
|
||||
replay(options);
|
||||
replayStrategy(strategy);
|
||||
|
||||
// run
|
||||
assertEquals(strategy.getSecurityGroupsForTagAndOptions(region, group, options), returnVal);
|
||||
|
||||
// verify mocks
|
||||
verify(options);
|
||||
verifyStrategy(strategy);
|
||||
}
|
||||
public void testCreateNewPlacementGroupUnlessUserSpecifiedOtherwise_reusesKeyWhenToldTo() {
|
||||
// setup constants
|
||||
String region = Region.AP_SOUTHEAST_1;
|
||||
|
|
|
@ -43,7 +43,7 @@ public class SpotInstanceRequestToAWSRunningInstanceTest {
|
|||
SpotInstanceRequest input = SpotInstanceRequest.builder().region("us-east-1").id("sir-228e6406")
|
||||
.spotPrice(0.001f).type(SpotInstanceRequest.Type.ONE_TIME).state(SpotInstanceRequest.State.OPEN)
|
||||
.launchSpecification(
|
||||
LaunchSpecification.builder().imageId("ami-595a0a1c").groupId("default").instanceType(
|
||||
LaunchSpecification.builder().imageId("ami-595a0a1c").securityGroupName("default").instanceType(
|
||||
"m1.large").mapNewVolumeToDevice("/dev/sda1", 1, true).mapEBSSnapshotToDevice(
|
||||
"/dev/sda2", "snap-1ea27576", 1, true).mapEphemeralDeviceToDevice("/dev/sda3", "vre1")
|
||||
.monitoringEnabled(false).build()).createTime(
|
||||
|
|
|
@ -25,6 +25,7 @@ import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withKer
|
|||
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withKeyName;
|
||||
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withRamdisk;
|
||||
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withSecurityGroup;
|
||||
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withSecurityGroupId;
|
||||
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withSubnetId;
|
||||
import static org.jclouds.aws.ec2.options.AWSRunInstancesOptions.Builder.withUserData;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
@ -98,6 +99,31 @@ public class AWSRunInstancesOptionsTest {
|
|||
public void testWithSecurityGroupNPE() {
|
||||
withSecurityGroup(null);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWithSecurityGroupId() {
|
||||
AWSRunInstancesOptions options = new AWSRunInstancesOptions();
|
||||
options.withSecurityGroupId("test");
|
||||
assertEquals(options.buildFormParameters().get("SecurityGroupId.1"), Collections.singletonList("test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullWithSecurityGroupId() {
|
||||
AWSRunInstancesOptions options = new AWSRunInstancesOptions();
|
||||
assertEquals(options.buildFormParameters().get("SecurityGroupId"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithSecurityGroupIdStatic() {
|
||||
AWSRunInstancesOptions options = withSecurityGroupId("test");
|
||||
assertEquals(options.buildFormParameters().get("SecurityGroupId.1"), Collections.singletonList("test"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testWithSecurityGroupIdNPE() {
|
||||
withSecurityGroupId(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullWithAdditionalInfo() {
|
||||
|
|
|
@ -144,7 +144,7 @@ public class AMIClientLiveTest {
|
|||
.put("root-device-type", "ebs")//
|
||||
.build()).ownedBy("137112412989", "099720109477"));
|
||||
assertNotNull(twoResults);
|
||||
assertEquals(twoResults.size(), 28);
|
||||
assertEquals(twoResults.size(), 26);
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
|
|
|
@ -63,7 +63,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=CreateImage&InstanceId=instanceId&Name=name",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=CreateImage&InstanceId=instanceId&Name=name",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
||||
|
@ -82,7 +82,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
|
|||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-11-15&Action=CreateImage&InstanceId=instanceId&Name=name&Description=description&NoReboot=true",
|
||||
"Version=2011-05-15&Action=CreateImage&InstanceId=instanceId&Name=name&Description=description&NoReboot=true",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -99,14 +99,9 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=DescribeImages", "application/x-www-form-urlencoded",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=DescribeImages", "application/x-www-form-urlencoded",
|
||||
false);
|
||||
filter.filter(request);
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Action=DescribeImages&Signature=1gIaOJ%2F0Wc8ZFl8GeinQzYAfD%2FOQCKLH32VLcOippGY%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&Version=2010-11-15&AWSAccessKeyId=identity",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, DescribeImagesResponseHandler.class);
|
||||
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
|
||||
|
@ -126,7 +121,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
|
|||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-11-15&Action=DescribeImages&Filter.1.Name=state&Filter.1.Value.1=available&Filter.2.Name=image-type&Filter.2.Value.1=machine&ExecutableBy=me&Owner.1=fred&Owner.2=nancy&ImageId.1=1&ImageId.2=2",
|
||||
"Version=2011-05-15&Action=DescribeImages&Filter.1.Name=state&Filter.1.Value.1=available&Filter.2.Name=image-type&Filter.2.Value.1=machine&ExecutableBy=me&Owner.1=fred&Owner.2=nancy&ImageId.1=1&ImageId.2=2",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -142,7 +137,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=DeregisterImage&ImageId=imageId",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=DeregisterImage&ImageId=imageId",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
|
@ -159,7 +154,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=RegisterImage&ImageLocation=pathToManifest&Name=name",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=RegisterImage&ImageLocation=pathToManifest&Name=name",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
||||
|
@ -177,7 +172,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
|
|||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2010-11-15&Action=RegisterImage&ImageLocation=pathToManifest&Name=name&Description=description",
|
||||
"Version=2011-05-15&Action=RegisterImage&ImageLocation=pathToManifest&Name=name&Description=description",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -196,7 +191,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
|
|||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-11-15&Action=RegisterImage&RootDeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.Ebs.SnapshotId=snapshotId&Name=imageName",
|
||||
"Version=2011-05-15&Action=RegisterImage&RootDeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.Ebs.SnapshotId=snapshotId&Name=imageName",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
||||
|
@ -221,7 +216,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
|
|||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-11-15&Action=RegisterImage&RootDeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.Ebs.SnapshotId=snapshotId&Name=imageName&Description=description&BlockDeviceMapping.1.Ebs.DeleteOnTermination=false&BlockDeviceMapping.1.DeviceName=%2Fdev%2Fdevice&BlockDeviceMapping.1.Ebs.SnapshotId=snapshot&BlockDeviceMapping.2.Ebs.DeleteOnTermination=false&BlockDeviceMapping.2.DeviceName=%2Fdev%2Fnewdevice&BlockDeviceMapping.2.VirtualName=newblock&BlockDeviceMapping.2.Ebs.VolumeSize=100",
|
||||
"Version=2011-05-15&Action=RegisterImage&RootDeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.Ebs.SnapshotId=snapshotId&Name=imageName&Description=description&BlockDeviceMapping.1.Ebs.DeleteOnTermination=false&BlockDeviceMapping.1.DeviceName=%2Fdev%2Fdevice&BlockDeviceMapping.1.Ebs.SnapshotId=snapshot&BlockDeviceMapping.2.Ebs.DeleteOnTermination=false&BlockDeviceMapping.2.DeviceName=%2Fdev%2Fnewdevice&BlockDeviceMapping.2.VirtualName=newblock&BlockDeviceMapping.2.Ebs.VolumeSize=100",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -238,7 +233,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
|
|||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2010-11-15&Action=DescribeImageAttribute&Attribute=productCodes&ImageId=imageId",
|
||||
"Version=2011-05-15&Action=DescribeImageAttribute&Attribute=productCodes&ImageId=imageId",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -256,7 +251,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
|
|||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2010-11-15&Action=DescribeImageAttribute&Attribute=blockDeviceMapping&ImageId=imageId",
|
||||
"Version=2011-05-15&Action=DescribeImageAttribute&Attribute=blockDeviceMapping&ImageId=imageId",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -274,7 +269,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
|
|||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2010-11-15&Action=DescribeImageAttribute&Attribute=launchPermission&ImageId=imageId",
|
||||
"Version=2011-05-15&Action=DescribeImageAttribute&Attribute=launchPermission&ImageId=imageId",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -294,14 +289,9 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
|
|||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-11-15&Action=ModifyImageAttribute&OperationType=add&Attribute=launchPermission&ImageId=imageId&UserGroup.1=all&UserId.1=bob&UserId.2=sue",
|
||||
"Version=2011-05-15&Action=ModifyImageAttribute&OperationType=add&Attribute=launchPermission&ImageId=imageId&UserGroup.1=all&UserId.1=bob&UserId.2=sue",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
filter.filter(request);
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Action=ModifyImageAttribute&Attribute=launchPermission&ImageId=imageId&OperationType=add&Signature=UvMbUlLld2h7MpNmuc9JSuOjDw4DS6PSNQVlBdBc%2FBQ%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&UserGroup.1=all&UserId.1=bob&UserId.2=sue&Version=2010-11-15&AWSAccessKeyId=identity",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
@ -319,7 +309,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
|
|||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-11-15&Action=ModifyImageAttribute&OperationType=remove&Attribute=launchPermission&ImageId=imageId&UserGroup.1=all&UserId.1=bob&UserId.2=sue",
|
||||
"Version=2011-05-15&Action=ModifyImageAttribute&OperationType=remove&Attribute=launchPermission&ImageId=imageId&UserGroup.1=all&UserId.1=bob&UserId.2=sue",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
|
@ -336,7 +326,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
|
|||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2010-11-15&Action=ResetImageAttribute&Attribute=launchPermission&ImageId=imageId",
|
||||
"Version=2011-05-15&Action=ResetImageAttribute&Attribute=launchPermission&ImageId=imageId",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
|
@ -354,7 +344,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
|
|||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-11-15&Action=ModifyImageAttribute&OperationType=add&Attribute=productCodes&ImageId=imageId&ProductCode.1=code1&ProductCode.2=code2",
|
||||
"Version=2011-05-15&Action=ModifyImageAttribute&OperationType=add&Attribute=productCodes&ImageId=imageId&ProductCode.1=code1&ProductCode.2=code2",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
|
@ -373,7 +363,7 @@ public class AWSAMIAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSAMIAsync
|
|||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-11-15&Action=ModifyImageAttribute&OperationType=remove&Attribute=productCodes&ImageId=imageId&ProductCode.1=code1&ProductCode.2=code2",
|
||||
"Version=2011-05-15&Action=ModifyImageAttribute&OperationType=remove&Attribute=productCodes&ImageId=imageId&ProductCode.1=code1&ProductCode.2=code2",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
|
|
|
@ -52,7 +52,8 @@ import com.google.inject.TypeLiteral;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during
|
||||
// surefire
|
||||
@Test(groups = "unit", testName = "AWSInstanceAsyncClientTest")
|
||||
public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSInstanceAsyncClient> {
|
||||
public void testDescribeInstances() throws SecurityException, NoSuchMethodException, IOException {
|
||||
|
@ -61,7 +62,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=DescribeInstances", "application/x-www-form-urlencoded",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=DescribeInstances", "application/x-www-form-urlencoded",
|
||||
false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -77,7 +78,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=DescribeInstances&InstanceId.1=1&InstanceId.2=2",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=DescribeInstances&InstanceId.1=1&InstanceId.2=2",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -94,7 +95,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=TerminateInstances&InstanceId.1=1&InstanceId.2=2",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=TerminateInstances&InstanceId.1=1&InstanceId.2=2",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -112,11 +113,11 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
try {
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=RunInstances&ImageId=ami-voo&MinCount=1&MaxCount=1",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=RunInstances&ImageId=ami-voo&MinCount=1&MaxCount=1",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
} catch (AssertionError e) {
|
||||
// mvn 3.0 osx 10.6.5 somehow sorts differently
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=RunInstances&ImageId=ami-voo&MaxCount=1&MinCount=1",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=RunInstances&ImageId=ami-voo&MaxCount=1&MinCount=1",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
}
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -144,13 +145,13 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
try {
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-11-15&Action=RunInstances&ImageId=ami-voo&MinCount=1&MaxCount=5&KernelId=kernelId&Monitoring.Enabled=true&SecurityGroup.1=group1&SecurityGroup.2=group2&Placement.AvailabilityZone=us-east-1a",
|
||||
"Version=2011-05-15&Action=RunInstances&ImageId=ami-voo&MinCount=1&MaxCount=5&KernelId=kernelId&Monitoring.Enabled=true&SecurityGroup.1=group1&SecurityGroup.2=group2&Placement.AvailabilityZone=us-east-1a",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
} catch (AssertionError e) {
|
||||
// mvn 3.0 osx 10.6.5 somehow sorts differently
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-11-15&Action=RunInstances&ImageId=ami-voo&MaxCount=5&MinCount=1&KernelId=kernelId&Monitoring.Enabled=true&SecurityGroup.1=group1&SecurityGroup.2=group2&Placement.AvailabilityZone=us-east-1a",
|
||||
"Version=2011-05-15&Action=RunInstances&ImageId=ami-voo&MaxCount=5&MinCount=1&KernelId=kernelId&Monitoring.Enabled=true&SecurityGroup.1=group1&SecurityGroup.2=group2&Placement.AvailabilityZone=us-east-1a",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
}
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -167,7 +168,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=StopInstances&Force=true&InstanceId.1=1&InstanceId.2=2",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=StopInstances&Force=true&InstanceId.1=1&InstanceId.2=2",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -184,7 +185,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=RebootInstances&InstanceId.1=1&InstanceId.2=2",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=RebootInstances&InstanceId.1=1&InstanceId.2=2",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
|
@ -201,7 +202,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=StartInstances&InstanceId.1=1&InstanceId.2=2",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=StartInstances&InstanceId.1=1&InstanceId.2=2",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -219,7 +220,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2010-11-15&Action=DescribeInstanceAttribute&Attribute=userData&InstanceId=1",
|
||||
"Version=2011-05-15&Action=DescribeInstanceAttribute&Attribute=userData&InstanceId=1",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -237,7 +238,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2010-11-15&Action=DescribeInstanceAttribute&Attribute=rootDeviceName&InstanceId=1",
|
||||
"Version=2011-05-15&Action=DescribeInstanceAttribute&Attribute=rootDeviceName&InstanceId=1",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -255,7 +256,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2010-11-15&Action=DescribeInstanceAttribute&Attribute=ramdisk&InstanceId=1",
|
||||
"Version=2011-05-15&Action=DescribeInstanceAttribute&Attribute=ramdisk&InstanceId=1",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -274,7 +275,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2010-11-15&Action=DescribeInstanceAttribute&Attribute=disableApiTermination&InstanceId=1",
|
||||
"Version=2011-05-15&Action=DescribeInstanceAttribute&Attribute=disableApiTermination&InstanceId=1",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -291,7 +292,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=DescribeInstanceAttribute&Attribute=kernel&InstanceId=1",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=DescribeInstanceAttribute&Attribute=kernel&InstanceId=1",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -309,7 +310,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2010-11-15&Action=DescribeInstanceAttribute&Attribute=instanceType&InstanceId=1",
|
||||
"Version=2011-05-15&Action=DescribeInstanceAttribute&Attribute=instanceType&InstanceId=1",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -329,7 +330,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-11-15&Action=DescribeInstanceAttribute&Attribute=instanceInitiatedShutdownBehavior&InstanceId=1",
|
||||
"Version=2011-05-15&Action=DescribeInstanceAttribute&Attribute=instanceInitiatedShutdownBehavior&InstanceId=1",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -348,7 +349,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2010-11-15&Action=DescribeInstanceAttribute&Attribute=blockDeviceMapping&InstanceId=1",
|
||||
"Version=2011-05-15&Action=DescribeInstanceAttribute&Attribute=blockDeviceMapping&InstanceId=1",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -366,12 +367,12 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2010-11-15&Action=ModifyInstanceAttribute&Attribute=userData&Value=dGVzdA%3D%3D&InstanceId=1",
|
||||
"Version=2011-05-15&Action=ModifyInstanceAttribute&Attribute=userData&Value=dGVzdA%3D%3D&InstanceId=1",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
filter.filter(request);// ensure encoding worked properly
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Action=ModifyInstanceAttribute&Attribute=userData&InstanceId=1&Signature=B15Bj0yiAMTwpHE%2B9LNNscM4fzFwv0t0adnYbFjgNDk%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&Value=dGVzdA%3D%3D&Version=2010-11-15&AWSAccessKeyId=identity",
|
||||
"Action=ModifyInstanceAttribute&Attribute=userData&InstanceId=1&Signature=nArJlrtyAfgqDnXxv%2B2y0r9O%2BIfUcitpQMjfQR0oeRM%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&Value=dGVzdA%3D%3D&Version=2011-05-15&AWSAccessKeyId=identity",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
|
@ -388,7 +389,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2010-11-15&Action=ModifyInstanceAttribute&Attribute=ramdisk&Value=test&InstanceId=1",
|
||||
"Version=2011-05-15&Action=ModifyInstanceAttribute&Attribute=ramdisk&Value=test&InstanceId=1",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
|
@ -405,7 +406,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2010-11-15&Action=ModifyInstanceAttribute&Attribute=kernel&Value=test&InstanceId=1",
|
||||
"Version=2011-05-15&Action=ModifyInstanceAttribute&Attribute=kernel&Value=test&InstanceId=1",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
|
@ -424,7 +425,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-11-15&Action=ModifyInstanceAttribute&Attribute=disableApiTermination&Value=true&InstanceId=1",
|
||||
"Version=2011-05-15&Action=ModifyInstanceAttribute&Attribute=disableApiTermination&Value=true&InstanceId=1",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
|
@ -442,7 +443,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2010-11-15&Action=ModifyInstanceAttribute&Attribute=instanceType&Value=c1.medium&InstanceId=1",
|
||||
"Version=2011-05-15&Action=ModifyInstanceAttribute&Attribute=instanceType&Value=c1.medium&InstanceId=1",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
|
@ -462,7 +463,7 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-11-15&Action=ModifyInstanceAttribute&Attribute=instanceInitiatedShutdownBehavior&Value=terminate&InstanceId=1",
|
||||
"Version=2011-05-15&Action=ModifyInstanceAttribute&Attribute=instanceInitiatedShutdownBehavior&Value=terminate&InstanceId=1",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
|
@ -485,12 +486,12 @@ public class AWSInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSIns
|
|||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-11-15&Action=ModifyInstanceAttribute&InstanceId=1&BlockDeviceMapping.1.Ebs.VolumeId=vol-test1&BlockDeviceMapping.1.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.1.Ebs.DeleteOnTermination=true",
|
||||
"Version=2011-05-15&Action=ModifyInstanceAttribute&InstanceId=1&BlockDeviceMapping.1.Ebs.VolumeId=vol-test1&BlockDeviceMapping.1.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.1.Ebs.DeleteOnTermination=true",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
filter.filter(request);// ensure encoding worked properly
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Action=ModifyInstanceAttribute&BlockDeviceMapping.1.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.1.Ebs.DeleteOnTermination=true&BlockDeviceMapping.1.Ebs.VolumeId=vol-test1&InstanceId=1&Signature=Cf8vx1IzPe%2FFYd7SRJBjztSOB3FQTW9yYtPxQ3OUHF0%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&Version=2010-11-15&AWSAccessKeyId=identity",
|
||||
"Action=ModifyInstanceAttribute&BlockDeviceMapping.1.DeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.1.Ebs.DeleteOnTermination=true&BlockDeviceMapping.1.Ebs.VolumeId=vol-test1&InstanceId=1&Signature=qqJpPk8UmhPY9Jica0JSADEZiY3eHf9WETm%2B5tLT0NE%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&Version=2011-05-15&AWSAccessKeyId=identity",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
|
|
|
@ -59,10 +59,9 @@ public class AWSInstanceClientLiveTest {
|
|||
protected void setupCredentials() {
|
||||
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
||||
credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
|
||||
+ ".credential");
|
||||
endpoint = checkNotNull(System.getProperty("test." + provider + ".endpoint"), "test." + provider + ".endpoint");
|
||||
apiversion = checkNotNull(System.getProperty("test." + provider + ".apiversion"), "test." + provider
|
||||
+ ".apiversion");
|
||||
+ ".credential");
|
||||
endpoint = System.getProperty("test." + provider + ".endpoint");
|
||||
apiversion = System.getProperty("test." + provider + ".apiversion");
|
||||
}
|
||||
|
||||
protected Properties setupProperties() {
|
||||
|
@ -71,8 +70,10 @@ public class AWSInstanceClientLiveTest {
|
|||
overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
|
||||
overrides.setProperty(provider + ".identity", identity);
|
||||
overrides.setProperty(provider + ".credential", credential);
|
||||
overrides.setProperty(provider + ".endpoint", endpoint);
|
||||
overrides.setProperty(provider + ".apiversion", apiversion);
|
||||
if (endpoint != null)
|
||||
overrides.setProperty(provider + ".endpoint", endpoint);
|
||||
if (apiversion != null)
|
||||
overrides.setProperty(provider + ".apiversion", apiversion);
|
||||
return overrides;
|
||||
}
|
||||
|
||||
|
@ -81,7 +82,7 @@ public class AWSInstanceClientLiveTest {
|
|||
setupCredentials();
|
||||
Properties overrides = setupProperties();
|
||||
context = new ComputeServiceContextFactory().createContext(provider,
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext();
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getProviderSpecificContext();
|
||||
client = context.getApi().getInstanceServices();
|
||||
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSKeyP
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=CreateKeyPair&KeyName=mykey",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=CreateKeyPair&KeyName=mykey",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -65,7 +65,7 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSKeyP
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=ImportKeyPair&PublicKeyMaterial=c3NoLXJzYSBBQQ%3D%3D&KeyName=mykey",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=ImportKeyPair&PublicKeyMaterial=c3NoLXJzYSBBQQ%3D%3D&KeyName=mykey",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -81,7 +81,7 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSKeyP
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=DeleteKeyPair&KeyName=mykey",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=DeleteKeyPair&KeyName=mykey",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
|
@ -98,7 +98,7 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSKeyP
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=DescribeKeyPairs", "application/x-www-form-urlencoded",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=DescribeKeyPairs", "application/x-www-form-urlencoded",
|
||||
false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -115,7 +115,7 @@ public class AWSKeyPairAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSKeyP
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=DescribeKeyPairs&KeyName.1=1&KeyName.2=2",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=DescribeKeyPairs&KeyName.1=1&KeyName.2=2",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
|
|
@ -0,0 +1,209 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.aws.ec2.services;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.aws.ec2.options.CreateSecurityGroupOptions;
|
||||
import org.jclouds.aws.ec2.xml.CreateSecurityGroupResponseHandler;
|
||||
import org.jclouds.ec2.domain.IpPermission;
|
||||
import org.jclouds.ec2.domain.IpProtocol;
|
||||
import org.jclouds.ec2.util.IpPermissions;
|
||||
import org.jclouds.ec2.xml.DescribeSecurityGroupsResponseHandler;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code AWSSecurityGroupAsyncClient}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during
|
||||
// surefire
|
||||
@Test(groups = "unit", testName = "AWSSecurityGroupAsyncClientTest")
|
||||
public class AWSSecurityGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest<AWSSecurityGroupAsyncClient> {
|
||||
public AWSSecurityGroupAsyncClientTest() {
|
||||
provider = "aws-ec2";
|
||||
}
|
||||
|
||||
public void testDeleteSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AWSSecurityGroupAsyncClient.class.getMethod("deleteSecurityGroupInRegionById", String.class,
|
||||
String.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "id");
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=DeleteSecurityGroup&GroupId=id",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testDescribeSecurityGroups() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AWSSecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegionById", String.class,
|
||||
String[].class);
|
||||
HttpRequest request = processor.createRequest(method, (String) null);
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=DescribeSecurityGroups",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, DescribeSecurityGroupsResponseHandler.class);
|
||||
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testDescribeSecurityGroupsArgs() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AWSSecurityGroupAsyncClient.class.getMethod("describeSecurityGroupsInRegionById", String.class,
|
||||
String[].class);
|
||||
HttpRequest request = processor.createRequest(method, null, "1", "2");
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=DescribeSecurityGroups&GroupId.1=1&GroupId.2=2",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, DescribeSecurityGroupsResponseHandler.class);
|
||||
assertExceptionParserClassEquals(method, ReturnEmptySetOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testCreateSecurityGroup() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AWSSecurityGroupAsyncClient.class.getMethod("createSecurityGroupInRegionAndReturnId",
|
||||
String.class, String.class, String.class, CreateSecurityGroupOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, null, "name", "description");
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2011-05-15&Action=CreateSecurityGroup&GroupDescription=description&GroupName=name",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, CreateSecurityGroupResponseHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testAuthorizeSecurityGroupIpPermission() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AWSSecurityGroupAsyncClient.class.getMethod("authorizeSecurityGroupIngressInRegion",
|
||||
String.class, String.class, IpPermission.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "group", IpPermissions.permitAnyProtocol());
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2011-05-15&Action=AuthorizeSecurityGroupIngress&GroupId=group&IpPermissions.0.IpProtocol=-1&IpPermissions.0.FromPort=1&IpPermissions.0.ToPort=65535&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0%2F0",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testAuthorizeSecurityGroupIpPermissions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AWSSecurityGroupAsyncClient.class.getMethod("authorizeSecurityGroupIngressInRegion",
|
||||
String.class, String.class, Iterable.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "group", ImmutableSet.<IpPermission> of(IpPermissions
|
||||
.permit(IpProtocol.TCP).originatingFromCidrBlock("1.1.1.1/32"), IpPermissions.permitICMP().type(8).andCode(0)
|
||||
.originatingFromSecurityGroupId("groupId")));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2011-05-15&Action=AuthorizeSecurityGroupIngress&GroupId=group&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=1&IpPermissions.0.ToPort=65535&IpPermissions.0.IpRanges.0.CidrIp=1.1.1.1%2F32&IpPermissions.1.IpProtocol=icmp&IpPermissions.1.FromPort=8&IpPermissions.1.ToPort=0&IpPermissions.1.Groups.0.GroupId=groupId",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testRevokeSecurityGroupIpPermission() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AWSSecurityGroupAsyncClient.class.getMethod("revokeSecurityGroupIngressInRegion", String.class,
|
||||
String.class, IpPermission.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "group", IpPermissions.permitAnyProtocol());
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2011-05-15&Action=RevokeSecurityGroupIngress&GroupId=group&IpPermissions.0.IpProtocol=-1&IpPermissions.0.FromPort=1&IpPermissions.0.ToPort=65535&IpPermissions.0.IpRanges.0.CidrIp=0.0.0.0%2F0",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
public void testRevokeSecurityGroupIpPermissions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AWSSecurityGroupAsyncClient.class.getMethod("revokeSecurityGroupIngressInRegion", String.class,
|
||||
String.class, Iterable.class);
|
||||
HttpRequest request = processor.createRequest(method, null, "group", ImmutableSet.<IpPermission> of(IpPermissions
|
||||
.permit(IpProtocol.TCP).originatingFromCidrBlock("1.1.1.1/32"), IpPermissions.permitICMP().type(8).andCode(0)
|
||||
.originatingFromSecurityGroupId("groupId")));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2011-05-15&Action=RevokeSecurityGroupIngress&GroupId=group&IpPermissions.0.IpProtocol=tcp&IpPermissions.0.FromPort=1&IpPermissions.0.ToPort=65535&IpPermissions.0.IpRanges.0.CidrIp=1.1.1.1%2F32&IpPermissions.1.IpProtocol=icmp&IpPermissions.1.FromPort=8&IpPermissions.1.ToPort=0&IpPermissions.1.Groups.0.GroupId=groupId",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TypeLiteral<RestAnnotationProcessor<AWSSecurityGroupAsyncClient>> createTypeLiteral() {
|
||||
return new TypeLiteral<RestAnnotationProcessor<AWSSecurityGroupAsyncClient>>() {
|
||||
};
|
||||
}
|
||||
|
||||
}
|
|
@ -18,14 +18,21 @@
|
|||
*/
|
||||
package org.jclouds.aws.ec2.services;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.ec2.domain.IpPermission;
|
||||
import org.jclouds.ec2.domain.IpProtocol;
|
||||
import org.jclouds.ec2.domain.SecurityGroup;
|
||||
import org.jclouds.ec2.services.SecurityGroupClientLiveTest;
|
||||
import org.jclouds.ec2.util.IpPermissions;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
|
@ -36,27 +43,45 @@ public class AWSSecurityGroupClientLiveTest extends SecurityGroupClientLiveTest
|
|||
provider = "aws-ec2";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupCredentials() {
|
||||
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
||||
credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
|
||||
+ ".credential");
|
||||
endpoint = System.getProperty("test." + provider + ".endpoint", null);
|
||||
apiversion = System.getProperty("test." + provider + ".apiversion", null);
|
||||
}
|
||||
@Test
|
||||
void testAuthorizeSecurityGroupIngressIpPermission() throws InterruptedException {
|
||||
final String group1Name = PREFIX + "ingress11";
|
||||
String group2Name = PREFIX + "ingress12";
|
||||
cleanupAndSleep(group2Name);
|
||||
cleanupAndSleep(group1Name);
|
||||
try {
|
||||
String group1Id = AWSSecurityGroupClient.class.cast(client).createSecurityGroupInRegionAndReturnId(null,
|
||||
group1Name, group1Name);
|
||||
String group2Id = AWSSecurityGroupClient.class.cast(client).createSecurityGroupInRegionAndReturnId(null,
|
||||
group2Name, group2Name);
|
||||
Thread.sleep(100);// eventual consistent
|
||||
ensureGroupsExist(group1Name, group2Name);
|
||||
AWSSecurityGroupClient.class.cast(client).authorizeSecurityGroupIngressInRegion(null, group1Id,
|
||||
IpPermissions.permit(IpProtocol.TCP).port(80));
|
||||
assertEventually(new GroupHasPermission(client, group1Name, new TCPPort80AllIPs()));
|
||||
Set<SecurityGroup> oneResult = client.describeSecurityGroupsInRegion(null, group1Name);
|
||||
assertNotNull(oneResult);
|
||||
assertEquals(oneResult.size(), 1);
|
||||
final SecurityGroup group = oneResult.iterator().next();
|
||||
assertEquals(group.getName(), group1Name);
|
||||
IpPermissions group2CanHttpGroup1 = IpPermissions.permit(IpProtocol.TCP).fromPort(80)
|
||||
.originatingFromSecurityGroupId(group1Id);
|
||||
AWSSecurityGroupClient.class.cast(client).authorizeSecurityGroupIngressInRegion(null, group2Id,
|
||||
group2CanHttpGroup1);
|
||||
assertEventually(new GroupHasPermission(client, group2Name, new Predicate<IpPermission>() {
|
||||
@Override
|
||||
public boolean apply(IpPermission arg0) {
|
||||
return arg0.getUserIdGroupPairs().equals(ImmutableMultimap.of(group.getOwnerId(), group1Name))
|
||||
&& arg0.getFromPort() == 80 && arg0.getToPort() == 80 && arg0.getIpProtocol() == IpProtocol.TCP;
|
||||
}
|
||||
}));
|
||||
|
||||
@Override
|
||||
protected Properties setupProperties() {
|
||||
Properties overrides = new Properties();
|
||||
overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
|
||||
overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
|
||||
overrides.setProperty(provider + ".identity", identity);
|
||||
overrides.setProperty(provider + ".credential", credential);
|
||||
if (endpoint != null)
|
||||
overrides.setProperty(provider + ".endpoint", endpoint);
|
||||
if (apiversion != null)
|
||||
overrides.setProperty(provider + ".apiversion", apiversion);
|
||||
return overrides;
|
||||
AWSSecurityGroupClient.class.cast(client).revokeSecurityGroupIngressInRegion(null, group2Id,
|
||||
group2CanHttpGroup1);
|
||||
assertEventually(new GroupHasNoPermissions(client, group2Name));
|
||||
} finally {
|
||||
client.deleteSecurityGroupInRegion(null, group2Name);
|
||||
client.deleteSecurityGroupInRegion(null, group1Name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class MonitoringAsyncClientTest extends BaseAWSEC2AsyncClientTest<Monitor
|
|||
HttpRequest request = processor.createRequest(method, null, "instance1", "instance2");
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
String payload = "Version=2010-11-15&Action=UnmonitorInstances&InstanceId.0=instance1&InstanceId.1=instance2";
|
||||
String payload = "Version=2011-05-15&Action=UnmonitorInstances&InstanceId.0=instance1&InstanceId.1=instance2";
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, payload, "application/x-www-form-urlencoded", false);
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class MonitoringAsyncClientTest extends BaseAWSEC2AsyncClientTest<Monitor
|
|||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request,
|
||||
"Version=2010-11-15&Action=MonitorInstances&InstanceId.0=instance1&InstanceId.1=instance2",
|
||||
"Version=2011-05-15&Action=MonitorInstances&InstanceId.0=instance1&InstanceId.1=instance2",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
|
|
@ -48,7 +48,7 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest<Pla
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=DeletePlacementGroup&GroupName=name",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=DeletePlacementGroup&GroupName=name",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
|
@ -65,7 +65,7 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest<Pla
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=CreatePlacementGroup&Strategy=cluster&GroupName=name",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=CreatePlacementGroup&Strategy=cluster&GroupName=name",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
|
@ -82,7 +82,7 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest<Pla
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=CreatePlacementGroup&Strategy=cluster&GroupName=name",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=CreatePlacementGroup&Strategy=cluster&GroupName=name",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
|
@ -99,7 +99,7 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest<Pla
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=DescribePlacementGroups",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=DescribePlacementGroups",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -116,7 +116,7 @@ public class PlacementGroupAsyncClientTest extends BaseAWSEC2AsyncClientTest<Pla
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=DescribePlacementGroups&GroupName.1=1&GroupName.2=2",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=DescribePlacementGroups&GroupName.1=1&GroupName.2=2",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
|
|
@ -55,7 +55,7 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<SpotI
|
|||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-11-15&Action=RequestSpotInstances&LaunchSpecification.ImageId=m1.small&SpotPrice=0.01&LaunchSpecification.InstanceType=ami-voo",
|
||||
"Version=2011-05-15&Action=RequestSpotInstances&LaunchSpecification.ImageId=m1.small&SpotPrice=0.01&LaunchSpecification.InstanceType=ami-voo",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -70,14 +70,14 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<SpotI
|
|||
float.class, int.class, LaunchSpecification.class, RequestSpotInstancesOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, "eu-west-1", 0.01, 3,
|
||||
LaunchSpecification.builder().instanceType("m1.small").imageId("ami-voo").availabilityZone("eu-west-1a")
|
||||
.kernelId("kernelId").groupId("group1").build(), new RequestSpotInstancesOptions().validFrom(from)
|
||||
.kernelId("kernelId").securityGroupName("group1").build(), new RequestSpotInstancesOptions().validFrom(from)
|
||||
.validUntil(to).availabilityZoneGroup("availabilityZoneGroup").launchGroup("launchGroup"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://ec2.eu-west-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.eu-west-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-11-15&Action=RequestSpotInstances&InstanceCount=3&SpotPrice=0.01&ValidFrom=1970-05-23T21%3A21%3A18Z&ValidUntil=2009-02-13T23%3A31%3A31Z&AvailabilityZoneGroup=availabilityZoneGroup&LaunchGroup=launchGroup&LaunchSpecification.ImageId=ami-voo&LaunchSpecification.Placement.AvailabilityZone=eu-west-1a&LaunchSpecification.SecurityGroup.1=group1&LaunchSpecification.InstanceType=m1.small&LaunchSpecification.KernelId=kernelId",
|
||||
"Version=2011-05-15&Action=RequestSpotInstances&InstanceCount=3&SpotPrice=0.01&ValidFrom=1970-05-23T21%3A21%3A18Z&ValidUntil=2009-02-13T23%3A31%3A31Z&AvailabilityZoneGroup=availabilityZoneGroup&LaunchGroup=launchGroup&LaunchSpecification.ImageId=ami-voo&LaunchSpecification.Placement.AvailabilityZone=eu-west-1a&LaunchSpecification.SecurityGroup.1=group1&LaunchSpecification.InstanceType=m1.small&LaunchSpecification.KernelId=kernelId",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -94,7 +94,7 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<SpotI
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=CancelSpotInstanceRequests&SpotInstanceRequestId.1=id",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=CancelSpotInstanceRequests&SpotInstanceRequestId.1=id",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
|
@ -111,7 +111,7 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<SpotI
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=DescribeSpotInstanceRequests",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=DescribeSpotInstanceRequests",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -130,7 +130,7 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<SpotI
|
|||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-11-15&Action=DescribeSpotInstanceRequests&SpotInstanceRequestId.1=1&SpotInstanceRequestId.2=2",
|
||||
"Version=2011-05-15&Action=DescribeSpotInstanceRequests&SpotInstanceRequestId.1=1&SpotInstanceRequestId.2=2",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -147,7 +147,7 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<SpotI
|
|||
|
||||
assertRequestLineEquals(request, "POST https://ec2.us-east-1.amazonaws.com/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(request, "Version=2010-11-15&Action=DescribeSpotPriceHistory",
|
||||
assertPayloadEquals(request, "Version=2011-05-15&Action=DescribeSpotPriceHistory",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -170,7 +170,7 @@ public class SpotInstanceAsyncClientTest extends BaseAWSEC2AsyncClientTest<SpotI
|
|||
assertNonPayloadHeadersEqual(request, "Host: ec2.us-east-1.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
"Version=2010-11-15&Action=DescribeSpotPriceHistory&StartTime=1970-05-23T21%3A21%3A18.910Z&EndTime=2009-02-13T23%3A31%3A31.011Z&ProductDescription=description&InstanceType.1=m1.small",
|
||||
"Version=2011-05-15&Action=DescribeSpotPriceHistory&StartTime=1970-05-23T21%3A21%3A18.910Z&EndTime=2009-02-13T23%3A31%3A31.011Z&ProductDescription=description&InstanceType.1=m1.small",
|
||||
"application/x-www-form-urlencoded", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
|
|
@ -51,7 +51,8 @@ import com.google.inject.Injector;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during
|
||||
// surefire
|
||||
@Test(groups = "unit", testName = "AWSDescribeInstancesResponseHandlerTest")
|
||||
public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
||||
|
||||
|
@ -68,72 +69,91 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest
|
|||
public void testWhenRunning() throws UnknownHostException {
|
||||
|
||||
Set<Reservation<AWSRunningInstance>> contents = ImmutableSet.of(new Reservation<AWSRunningInstance>(
|
||||
defaultRegion, ImmutableSet.of("adriancole.ec2ingress"), ImmutableSet
|
||||
.of(new AWSRunningInstance.Builder().region(defaultRegion).groupId("adriancole.ec2ingress")
|
||||
.amiLaunchIndex("0").dnsName("ec2-174-129-81-68.compute-1.amazonaws.com").imageId(
|
||||
"ami-82e4b5c7").instanceId("i-0799056f").instanceState(InstanceState.RUNNING)
|
||||
.instanceType(InstanceType.M1_SMALL).ipAddress("174.129.81.68").kernelId(
|
||||
"aki-a71cf9ce").keyName("adriancole.ec21").launchTime(
|
||||
dateService.iso8601DateParse("2009-11-09T03:00:34.000Z")).monitoringState(
|
||||
MonitoringState.DISABLED).availabilityZone("us-east-1c")
|
||||
.virtualizationType("paravirtual").privateDnsName("ip-10-243-42-70.ec2.internal")
|
||||
.privateIpAddress("10.243.42.70").ramdiskId("ari-a51cf9cc").rootDeviceType(
|
||||
RootDeviceType.INSTANCE_STORE).build()), "993194456877", null, "r-a3c508cb"));
|
||||
defaultRegion, ImmutableSet.of("adriancole.ec2ingress"), ImmutableSet.of(new AWSRunningInstance.Builder()
|
||||
.region(defaultRegion).groupId("adriancole.ec2ingress").amiLaunchIndex("0")
|
||||
.dnsName("ec2-174-129-81-68.compute-1.amazonaws.com").imageId("ami-82e4b5c7")
|
||||
.instanceId("i-0799056f").instanceState(InstanceState.RUNNING).instanceType(InstanceType.M1_SMALL)
|
||||
.ipAddress("174.129.81.68").kernelId("aki-a71cf9ce").keyName("adriancole.ec21")
|
||||
.launchTime(dateService.iso8601DateParse("2009-11-09T03:00:34.000Z"))
|
||||
.monitoringState(MonitoringState.DISABLED).availabilityZone("us-east-1c")
|
||||
.virtualizationType("paravirtual").privateDnsName("ip-10-243-42-70.ec2.internal")
|
||||
.privateIpAddress("10.243.42.70").ramdiskId("ari-a51cf9cc")
|
||||
.rootDeviceType(RootDeviceType.INSTANCE_STORE).build()), "993194456877", null, "r-a3c508cb"));
|
||||
|
||||
Set<Reservation<? extends RunningInstance>> result = parseAWSRunningInstances("/describe_instances_running.xml");
|
||||
|
||||
assertEquals(result, contents);
|
||||
assertEquals(result.toString(), contents.toString());
|
||||
}
|
||||
|
||||
public void testParseNoNPE() {
|
||||
parseAWSRunningInstances("/describe_instances_1.xml");
|
||||
parseAWSRunningInstances("/describe_instances_2.xml");
|
||||
parseAWSRunningInstances("/describe_instances_3.xml");
|
||||
}
|
||||
|
||||
public void testApplyInputStream() {
|
||||
Set<Reservation<AWSRunningInstance>> contents = ImmutableSet.of(new Reservation<AWSRunningInstance>(
|
||||
defaultRegion, ImmutableSet.of("default"), ImmutableSet.of(new AWSRunningInstance.Builder().region(
|
||||
defaultRegion).groupId("default").amiLaunchIndex("23").dnsName(
|
||||
"ec2-72-44-33-4.compute-1.amazonaws.com").imageId("ami-6ea54007").instanceId("i-28a64341")
|
||||
.instanceState(InstanceState.RUNNING).instanceType(InstanceType.M1_LARGE).kernelId(
|
||||
"aki-ba3adfd3").keyName("example-key-name").launchTime(
|
||||
dateService.iso8601DateParse("2007-08-07T11:54:42.000Z")).monitoringState(
|
||||
MonitoringState.DISABLED).availabilityZone("us-east-1b")
|
||||
.virtualizationType("paravirtual").privateDnsName("10-251-50-132.ec2.internal").productCode(
|
||||
"774F4FF8").ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE)
|
||||
.build(), new AWSRunningInstance.Builder().region(defaultRegion).groupId("default")
|
||||
.amiLaunchIndex("23").dnsName("ec2-72-44-33-6.compute-1.amazonaws.com").imageId("ami-6ea54007")
|
||||
.instanceId("i-28a64435").instanceState(InstanceState.RUNNING).instanceType(
|
||||
InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name")
|
||||
.launchTime(dateService.iso8601DateParse("2007-08-07T11:54:42.000Z")).monitoringState(
|
||||
MonitoringState.DISABLED).availabilityZone("us-east-1b")
|
||||
.virtualizationType("paravirtual").privateDnsName("10-251-50-134.ec2.internal").productCode(
|
||||
"774F4FF8").ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE)
|
||||
.build()), "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM", null, "r-44a5402d"));
|
||||
defaultRegion, ImmutableSet.of("default"), ImmutableSet.of(
|
||||
new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("23")
|
||||
.dnsName("ec2-72-44-33-4.compute-1.amazonaws.com").imageId("ami-6ea54007")
|
||||
.instanceId("i-28a64341").instanceState(InstanceState.RUNNING)
|
||||
.instanceType(InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name")
|
||||
.launchTime(dateService.iso8601DateParse("2007-08-07T11:54:42.000Z"))
|
||||
.monitoringState(MonitoringState.DISABLED).availabilityZone("us-east-1b")
|
||||
.virtualizationType("paravirtual").privateDnsName("10-251-50-132.ec2.internal")
|
||||
.productCode("774F4FF8").ramdiskId("ari-badbad00")
|
||||
.rootDeviceType(RootDeviceType.INSTANCE_STORE).build(),
|
||||
new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("23")
|
||||
.dnsName("ec2-72-44-33-6.compute-1.amazonaws.com").imageId("ami-6ea54007")
|
||||
.instanceId("i-28a64435").instanceState(InstanceState.RUNNING)
|
||||
.instanceType(InstanceType.M1_LARGE).kernelId("aki-ba3adfd3").keyName("example-key-name")
|
||||
.launchTime(dateService.iso8601DateParse("2007-08-07T11:54:42.000Z"))
|
||||
.monitoringState(MonitoringState.DISABLED).availabilityZone("us-east-1b")
|
||||
.virtualizationType("paravirtual").privateDnsName("10-251-50-134.ec2.internal")
|
||||
.productCode("774F4FF8").ramdiskId("ari-badbad00")
|
||||
.rootDeviceType(RootDeviceType.INSTANCE_STORE).build()), "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM",
|
||||
null, "r-44a5402d"));
|
||||
|
||||
Set<Reservation<? extends RunningInstance>> result = parseAWSRunningInstances("/describe_instances.xml");
|
||||
|
||||
assertEquals(result, contents);
|
||||
assertEquals(result.toString(), contents.toString());
|
||||
}
|
||||
|
||||
public void testEBS() throws UnknownHostException {
|
||||
|
||||
Set<Reservation<AWSRunningInstance>> contents = ImmutableSet.of(new Reservation<AWSRunningInstance>(
|
||||
defaultRegion, ImmutableSet.of("adriancole.ec2ebsingress"), ImmutableSet
|
||||
.of(new AWSRunningInstance.Builder().region(defaultRegion).groupId("adriancole.ec2ebsingress")
|
||||
.amiLaunchIndex("0").dnsName("ec2-75-101-203-146.compute-1.amazonaws.com").imageId(
|
||||
"ami-849875ed").instanceId("i-e564438d").instanceState(InstanceState.RUNNING)
|
||||
.instanceType(InstanceType.M1_SMALL).ipAddress("75.101.203.146").kernelId(
|
||||
"aki-a71cf9ce").keyName("adriancole.ec2ebs1").launchTime(
|
||||
dateService.iso8601DateParse("2009-12-30T04:06:23.000Z")).monitoringState(
|
||||
MonitoringState.DISABLED).availabilityZone("us-east-1b")
|
||||
.placementGroup("placement").virtualizationType("hvm").privateDnsName(
|
||||
"domU-12-31-39-09-CE-53.compute-1.internal").privateIpAddress(
|
||||
"10.210.209.157").ramdiskId("ari-a51cf9cc")
|
||||
.rootDeviceType(RootDeviceType.EBS).rootDeviceName("/dev/sda1").device(
|
||||
"/dev/sda1",
|
||||
new BlockDevice("vol-dc6ca8b5", Attachment.Status.ATTACHED, dateService
|
||||
.iso8601DateParse("2009-12-30T04:06:29.000Z"), true)).build()),
|
||||
"993194456877", null, "r-596dd731"));
|
||||
defaultRegion, ImmutableSet.of("adriancole.ec2ebsingress"), ImmutableSet
|
||||
.of(new AWSRunningInstance.Builder()
|
||||
.region(defaultRegion)
|
||||
.groupId("adriancole.ec2ebsingress")
|
||||
.amiLaunchIndex("0")
|
||||
.dnsName("ec2-75-101-203-146.compute-1.amazonaws.com")
|
||||
.imageId("ami-849875ed")
|
||||
.instanceId("i-e564438d")
|
||||
.instanceState(InstanceState.RUNNING)
|
||||
.instanceType(InstanceType.M1_SMALL)
|
||||
.ipAddress("75.101.203.146")
|
||||
.kernelId("aki-a71cf9ce")
|
||||
.keyName("adriancole.ec2ebs1")
|
||||
.launchTime(dateService.iso8601DateParse("2009-12-30T04:06:23.000Z"))
|
||||
.monitoringState(MonitoringState.DISABLED)
|
||||
.availabilityZone("us-east-1b")
|
||||
.placementGroup("placement")
|
||||
.virtualizationType("hvm")
|
||||
.privateDnsName("domU-12-31-39-09-CE-53.compute-1.internal")
|
||||
.privateIpAddress("10.210.209.157")
|
||||
.ramdiskId("ari-a51cf9cc")
|
||||
.rootDeviceType(RootDeviceType.EBS)
|
||||
.rootDeviceName("/dev/sda1")
|
||||
.device(
|
||||
"/dev/sda1",
|
||||
new BlockDevice("vol-dc6ca8b5", Attachment.Status.ATTACHED, dateService
|
||||
.iso8601DateParse("2009-12-30T04:06:29.000Z"), true)).build()), "993194456877",
|
||||
null, "r-596dd731"));
|
||||
|
||||
Set<Reservation<? extends RunningInstance>> result = parseAWSRunningInstances("/describe_instances_ebs.xml");
|
||||
|
||||
assertEquals(result, contents);
|
||||
assertEquals(result.toString(), contents.toString());
|
||||
}
|
||||
|
||||
static ParseSax<Set<Reservation<? extends RunningInstance>>> createParser() {
|
||||
|
@ -147,8 +167,8 @@ public class AWSDescribeInstancesResponseHandlerTest extends BaseEC2HandlerTest
|
|||
|
||||
});
|
||||
ParseSax<Set<Reservation<? extends RunningInstance>>> parser = (ParseSax<Set<Reservation<? extends RunningInstance>>>) injector
|
||||
.getInstance(ParseSax.Factory.class).create(
|
||||
injector.getInstance(AWSDescribeInstancesResponseHandler.class));
|
||||
.getInstance(ParseSax.Factory.class)
|
||||
.create(injector.getInstance(AWSDescribeInstancesResponseHandler.class));
|
||||
return parser;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,8 @@ import com.google.inject.Guice;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during
|
||||
// surefire
|
||||
@Test(groups = "unit", testName = "RunInstancesResponseHandlerTest")
|
||||
public class AWSRunInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
||||
|
||||
|
@ -78,32 +79,40 @@ public class AWSRunInstancesResponseHandlerTest extends BaseEC2HandlerTest {
|
|||
InputStream is = getClass().getResourceAsStream("/run_instances.xml");
|
||||
|
||||
Reservation<? extends AWSRunningInstance> expected = new Reservation<AWSRunningInstance>(defaultRegion,
|
||||
ImmutableSet.of("default"), ImmutableSet.of(
|
||||
ImmutableSet.of("default"), ImmutableSet.of(
|
||||
|
||||
new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("0").imageId(
|
||||
"ami-60a54009").instanceId("i-2ba64342").instanceState(InstanceState.PENDING).instanceType(
|
||||
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
||||
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).monitoringState(
|
||||
MonitoringState.ENABLED).availabilityZone("us-east-1b").build(),
|
||||
new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("0")
|
||||
.imageId("ami-60a54009").instanceId("i-2ba64342").instanceState(InstanceState.PENDING)
|
||||
.instanceType(InstanceType.M1_SMALL).keyName("example-key-name")
|
||||
.launchTime(dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))
|
||||
.monitoringState(MonitoringState.ENABLED).availabilityZone("us-east-1b").build(),
|
||||
|
||||
new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("1").imageId(
|
||||
"ami-60a54009").instanceId("i-2bc64242").instanceState(InstanceState.PENDING).instanceType(
|
||||
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
||||
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).monitoringState(
|
||||
MonitoringState.ENABLED).availabilityZone("us-east-1b").build(),
|
||||
new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("1")
|
||||
.imageId("ami-60a54009").instanceId("i-2bc64242").instanceState(InstanceState.PENDING)
|
||||
.instanceType(InstanceType.M1_SMALL).keyName("example-key-name")
|
||||
.launchTime(dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))
|
||||
.monitoringState(MonitoringState.ENABLED).availabilityZone("us-east-1b").build(),
|
||||
|
||||
new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("2").imageId(
|
||||
"ami-60a54009").instanceId("i-2be64332").instanceState(InstanceState.PENDING).instanceType(
|
||||
InstanceType.M1_SMALL).keyName("example-key-name").launchTime(
|
||||
dateService.iso8601DateParse("2007-08-07T11:51:50.000Z")).monitoringState(
|
||||
MonitoringState.ENABLED).availabilityZone("us-east-1b").build())
|
||||
new AWSRunningInstance.Builder().region(defaultRegion).groupId("default").amiLaunchIndex("2")
|
||||
.imageId("ami-60a54009").instanceId("i-2be64332").instanceState(InstanceState.PENDING)
|
||||
.instanceType(InstanceType.M1_SMALL).keyName("example-key-name")
|
||||
.launchTime(dateService.iso8601DateParse("2007-08-07T11:51:50.000Z"))
|
||||
.monitoringState(MonitoringState.ENABLED).availabilityZone("us-east-1b").build())
|
||||
|
||||
, "AIDADH4IGTRXXKCD", null, "r-47a5402e");
|
||||
, "AIDADH4IGTRXXKCD", null, "r-47a5402e");
|
||||
|
||||
AWSRunInstancesResponseHandler handler = injector.getInstance(AWSRunInstancesResponseHandler.class);
|
||||
addDefaultRegionToHandler(handler);
|
||||
Reservation<? extends RunningInstance> result = factory.create(handler).parse(is);
|
||||
assertEquals(result, expected);
|
||||
assertEquals(result.toString(), expected.toString());
|
||||
}
|
||||
|
||||
public void testApplyInputStreamDoesntNPE() {
|
||||
|
||||
InputStream is = getClass().getResourceAsStream("/run_instances_1.xml");
|
||||
AWSRunInstancesResponseHandler handler = injector.getInstance(AWSRunInstancesResponseHandler.class);
|
||||
addDefaultRegionToHandler(handler);
|
||||
factory.create(handler).parse(is);
|
||||
}
|
||||
|
||||
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
||||
|
|
|
@ -46,7 +46,8 @@ import com.google.inject.Guice;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during
|
||||
// surefire
|
||||
@Test(groups = "unit", testName = "SpotInstanceHandlerTest")
|
||||
public class SpotInstanceHandlerTest extends BaseEC2HandlerTest {
|
||||
|
||||
|
@ -80,8 +81,8 @@ public class SpotInstanceHandlerTest extends BaseEC2HandlerTest {
|
|||
.type(SpotInstanceRequest.Type.ONE_TIME)
|
||||
.state(SpotInstanceRequest.State.OPEN)
|
||||
.launchSpecification(
|
||||
LaunchSpecification.builder().imageId("ami-595a0a1c").groupId("default").instanceType("m1.large")
|
||||
.mapNewVolumeToDevice("/dev/sda1", 1, true)
|
||||
LaunchSpecification.builder().imageId("ami-595a0a1c").securityGroupIdToName("sg-83e1c4ea", "default")
|
||||
.instanceType("m1.large").mapNewVolumeToDevice("/dev/sda1", 1, true)
|
||||
.mapEBSSnapshotToDevice("/dev/sda2", "snap-1ea27576", 1, true)
|
||||
.mapEphemeralDeviceToDevice("/dev/sda3", "vre1").monitoringEnabled(false).build())
|
||||
.createTime(new SimpleDateFormatDateService().iso8601DateParse("2011-03-08T03:30:36.000Z"))
|
||||
|
@ -89,6 +90,31 @@ public class SpotInstanceHandlerTest extends BaseEC2HandlerTest {
|
|||
SpotInstanceHandler handler = injector.getInstance(SpotInstanceHandler.class);
|
||||
addDefaultRegionToHandler(handler);
|
||||
SpotInstanceRequest result = factory.create(handler).parse(is);
|
||||
assertEquals(result.toString(), expected.toString());
|
||||
}
|
||||
|
||||
public void testApplyInputStream1() {
|
||||
|
||||
InputStream is = getClass().getResourceAsStream("/describe_spot_instance.xml");
|
||||
|
||||
SpotInstanceRequest expected = SpotInstanceRequest
|
||||
.builder()
|
||||
.region("us-east-1")
|
||||
.id("sir-1ede0012")
|
||||
.instanceId("i-ef308e8e")
|
||||
.spotPrice(0.300000f)
|
||||
.type(SpotInstanceRequest.Type.ONE_TIME)
|
||||
.state(SpotInstanceRequest.State.ACTIVE)
|
||||
.launchedAvailabilityZone("us-east-1b")
|
||||
.launchSpecification(
|
||||
LaunchSpecification.builder().imageId("ami-8e1fece7")
|
||||
.securityGroupIdToName("sg-83e1c4eb", "jclouds#adriancole-ec2unssh#us-east-1").instanceType("t1.micro")
|
||||
.monitoringEnabled(false).keyName("jclouds#adriancole-ec2unssh").build())
|
||||
.createTime(new SimpleDateFormatDateService().iso8601DateParse("2011-07-29T05:27:39.000Z"))
|
||||
.productDescription("Linux/UNIX").build();
|
||||
SpotInstanceHandler handler = injector.getInstance(SpotInstanceHandler.class);
|
||||
addDefaultRegionToHandler(handler);
|
||||
SpotInstanceRequest result = factory.create(handler).parse(is);
|
||||
assertEquals(result, expected);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,8 @@ import com.google.inject.Guice;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during
|
||||
// surefire
|
||||
@Test(groups = "unit", testName = "SpotInstancesHandlerTest")
|
||||
public class SpotInstancesHandlerTest extends BaseEC2HandlerTest {
|
||||
|
||||
|
@ -66,25 +67,29 @@ public class SpotInstancesHandlerTest extends BaseEC2HandlerTest {
|
|||
dateService = injector.getInstance(DateService.class);
|
||||
assert dateService != null;
|
||||
}
|
||||
|
||||
public void testDescribe() {
|
||||
|
||||
InputStream is = getClass().getResourceAsStream("/describe_spot_instance_requests.xml");
|
||||
SpotInstancesHandler handler = injector
|
||||
.getInstance(SpotInstancesHandler.class);
|
||||
SpotInstancesHandler handler = injector.getInstance(SpotInstancesHandler.class);
|
||||
addDefaultRegionToHandler(handler);
|
||||
Set<SpotInstanceRequest> result = factory.create(handler).parse(is);
|
||||
assertEquals(result.size(), 18);
|
||||
}
|
||||
public void testRequest() {
|
||||
|
||||
public void testRequest() {
|
||||
InputStream is = getClass().getResourceAsStream("/request_spot_instances.xml");
|
||||
SpotInstancesHandler handler = injector
|
||||
.getInstance(SpotInstancesHandler.class);
|
||||
SpotInstancesHandler handler = injector.getInstance(SpotInstancesHandler.class);
|
||||
addDefaultRegionToHandler(handler);
|
||||
Set<SpotInstanceRequest> result = factory.create(handler).parse(is);
|
||||
assertEquals(result.size(), 3);
|
||||
}
|
||||
|
||||
public void testParseNoNPE() {
|
||||
factory.create(injector.getInstance(SpotInstancesHandler.class)).parse(
|
||||
getClass().getResourceAsStream("/describe_spot_instances_1.xml"));
|
||||
}
|
||||
|
||||
private void addDefaultRegionToHandler(ParseSax.HandlerWithResult<?> handler) {
|
||||
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
|
||||
expect(request.getArgs()).andReturn(ImmutableList.<Object> of()).atLeastOnce();
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||
<requestId>b3e1c7ee-1f34-4582-9493-695c9425c679</requestId>
|
||||
<reservationSet>
|
||||
<item>
|
||||
<reservationId>r-51cb663e</reservationId>
|
||||
<ownerId>993194456877</ownerId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-15f4d17c</groupId>
|
||||
<groupName>jclouds#ec2-e#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-059c2564</instanceId>
|
||||
<imageId>ami-eb71b682</imageId>
|
||||
<instanceState>
|
||||
<code>0</code>
|
||||
<name>pending</name>
|
||||
</instanceState>
|
||||
<privateDnsName/>
|
||||
<dnsName/>
|
||||
<reason/>
|
||||
<keyName>jclouds#ec2-e#us-east-1#85</keyName>
|
||||
<amiLaunchIndex>0</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>m1.small</instanceType>
|
||||
<launchTime>2011-07-29T08:29:49.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1c</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-407d9529</kernelId>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-15f4d17c</groupId>
|
||||
<groupName>jclouds#ec2-e#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<architecture>i386</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping/>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
</instancesSet>
|
||||
</item>
|
||||
</reservationSet>
|
||||
</DescribeInstancesResponse>
|
|
@ -0,0 +1,986 @@
|
|||
<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||
<requestId>b2238f71-750f-4eed-8f5c-eb4e6f66b687</requestId>
|
||||
<reservationSet>
|
||||
<item>
|
||||
<reservationId>r-7f54f610</reservationId>
|
||||
<ownerId>993194456877</ownerId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-1df4d174</groupId>
|
||||
<groupName>jclouds#ec2-#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-8f348aee</instanceId>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<instanceState>
|
||||
<code>48</code>
|
||||
<name>terminated</name>
|
||||
</instanceState>
|
||||
<privateDnsName/>
|
||||
<dnsName/>
|
||||
<reason>User initiated (2011-07-29 08:04:49 GMT)</reason>
|
||||
<keyName>jclouds#ec2-#us-east-1#95</keyName>
|
||||
<amiLaunchIndex>0</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<launchTime>2011-07-29T05:35:18.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1b</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-427d952b</kernelId>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-1df4d174</groupId>
|
||||
<groupName>jclouds#ec2-#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<stateReason>
|
||||
<code>Client.UserInitiatedShutdown</code>
|
||||
<message>Client.UserInitiatedShutdown: User initiated shutdown</message>
|
||||
</stateReason>
|
||||
<architecture>x86_64</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping/>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
<item>
|
||||
<instanceId>i-91348af0</instanceId>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<instanceState>
|
||||
<code>48</code>
|
||||
<name>terminated</name>
|
||||
</instanceState>
|
||||
<privateDnsName/>
|
||||
<dnsName/>
|
||||
<reason>User initiated (2011-07-29 08:14:38 GMT)</reason>
|
||||
<keyName>jclouds#ec2-#us-east-1#95</keyName>
|
||||
<amiLaunchIndex>1</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<launchTime>2011-07-29T05:35:18.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1b</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-427d952b</kernelId>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-1df4d174</groupId>
|
||||
<groupName>jclouds#ec2-#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<stateReason>
|
||||
<code>Client.UserInitiatedShutdown</code>
|
||||
<message>Client.UserInitiatedShutdown: User initiated shutdown</message>
|
||||
</stateReason>
|
||||
<architecture>x86_64</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping/>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
</instancesSet>
|
||||
</item>
|
||||
<item>
|
||||
<reservationId>r-7be24f14</reservationId>
|
||||
<ownerId>993194456877</ownerId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-dbf5d0b2</groupId>
|
||||
<groupName>jclouds#ec2-o#us-east-1</groupName>
|
||||
</item>
|
||||
<item>
|
||||
<groupId>sg-d9f5d0b0</groupId>
|
||||
<groupName>ec2-o</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-43b00922</instanceId>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<instanceState>
|
||||
<code>48</code>
|
||||
<name>terminated</name>
|
||||
</instanceState>
|
||||
<privateDnsName/>
|
||||
<dnsName/>
|
||||
<reason>User initiated (2011-07-29 08:03:24 GMT)</reason>
|
||||
<keyName>ec2-o</keyName>
|
||||
<amiLaunchIndex>0</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<launchTime>2011-07-29T07:57:49.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1c</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-427d952b</kernelId>
|
||||
<monitoring>
|
||||
<state>enabled</state>
|
||||
</monitoring>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-dbf5d0b2</groupId>
|
||||
<groupName>jclouds#ec2-o#us-east-1</groupName>
|
||||
</item>
|
||||
<item>
|
||||
<groupId>sg-d9f5d0b0</groupId>
|
||||
<groupName>ec2-o</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<stateReason>
|
||||
<code>Client.UserInitiatedShutdown</code>
|
||||
<message>Client.UserInitiatedShutdown: User initiated shutdown</message>
|
||||
</stateReason>
|
||||
<architecture>x86_64</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping/>
|
||||
<instanceLifecycle>spot</instanceLifecycle>
|
||||
<spotInstanceRequestId>sir-cc233214</spotInstanceRequestId>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
</instancesSet>
|
||||
<requesterId>854251627541</requesterId>
|
||||
</item>
|
||||
<item>
|
||||
<reservationId>r-7bfe5314</reservationId>
|
||||
<ownerId>993194456877</ownerId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-25f4d14c</groupId>
|
||||
<groupName>jclouds#ec2-r#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-ddb70ebc</instanceId>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<instanceState>
|
||||
<code>48</code>
|
||||
<name>terminated</name>
|
||||
</instanceState>
|
||||
<privateDnsName/>
|
||||
<dnsName/>
|
||||
<reason>User initiated (2011-07-29 08:04:22 GMT)</reason>
|
||||
<keyName>jclouds#ec2-r#us-east-1#3</keyName>
|
||||
<amiLaunchIndex>0</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<launchTime>2011-07-29T08:04:18.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1b</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-427d952b</kernelId>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-25f4d14c</groupId>
|
||||
<groupName>jclouds#ec2-r#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<stateReason>
|
||||
<code>Client.UserInitiatedShutdown</code>
|
||||
<message>Client.UserInitiatedShutdown: User initiated shutdown</message>
|
||||
</stateReason>
|
||||
<architecture>x86_64</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping/>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
</instancesSet>
|
||||
</item>
|
||||
<item>
|
||||
<reservationId>r-7bf95414</reservationId>
|
||||
<ownerId>993194456877</ownerId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-1df4d174</groupId>
|
||||
<groupName>jclouds#ec2-#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-e9a91088</instanceId>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<instanceState>
|
||||
<code>48</code>
|
||||
<name>terminated</name>
|
||||
</instanceState>
|
||||
<privateDnsName/>
|
||||
<dnsName/>
|
||||
<reason>User initiated (2011-07-29 08:14:38 GMT)</reason>
|
||||
<keyName>jclouds#ec2-#us-east-1#73</keyName>
|
||||
<amiLaunchIndex>0</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<launchTime>2011-07-29T08:05:48.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1b</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-427d952b</kernelId>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-1df4d174</groupId>
|
||||
<groupName>jclouds#ec2-#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<stateReason>
|
||||
<code>Client.UserInitiatedShutdown</code>
|
||||
<message>Client.UserInitiatedShutdown: User initiated shutdown</message>
|
||||
</stateReason>
|
||||
<architecture>x86_64</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping/>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
<item>
|
||||
<instanceId>i-eba9108a</instanceId>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<instanceState>
|
||||
<code>48</code>
|
||||
<name>terminated</name>
|
||||
</instanceState>
|
||||
<privateDnsName/>
|
||||
<dnsName/>
|
||||
<reason>User initiated (2011-07-29 08:14:38 GMT)</reason>
|
||||
<keyName>jclouds#ec2-#us-east-1#73</keyName>
|
||||
<amiLaunchIndex>1</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<launchTime>2011-07-29T08:05:48.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1b</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-427d952b</kernelId>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-1df4d174</groupId>
|
||||
<groupName>jclouds#ec2-#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<stateReason>
|
||||
<code>Client.UserInitiatedShutdown</code>
|
||||
<message>Client.UserInitiatedShutdown: User initiated shutdown</message>
|
||||
</stateReason>
|
||||
<architecture>x86_64</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping/>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
</instancesSet>
|
||||
</item>
|
||||
<item>
|
||||
<reservationId>r-5df95432</reservationId>
|
||||
<ownerId>993194456877</ownerId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-1ff4d176</groupId>
|
||||
<groupName>jclouds#ec2-block#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-c9a910a8</instanceId>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<instanceState>
|
||||
<code>48</code>
|
||||
<name>terminated</name>
|
||||
</instanceState>
|
||||
<privateDnsName/>
|
||||
<dnsName/>
|
||||
<reason>User initiated (2011-07-29 08:06:01 GMT)</reason>
|
||||
<keyName>jclouds#ec2-block#us-east-1#61</keyName>
|
||||
<amiLaunchIndex>0</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<launchTime>2011-07-29T08:05:58.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1b</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-427d952b</kernelId>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-1ff4d176</groupId>
|
||||
<groupName>jclouds#ec2-block#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<stateReason>
|
||||
<code>Client.UserInitiatedShutdown</code>
|
||||
<message>Client.UserInitiatedShutdown: User initiated shutdown</message>
|
||||
</stateReason>
|
||||
<architecture>x86_64</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping/>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
</instancesSet>
|
||||
</item>
|
||||
<item>
|
||||
<reservationId>r-f3f9549c</reservationId>
|
||||
<ownerId>993194456877</ownerId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-15f4d17c</groupId>
|
||||
<groupName>jclouds#ec2-e#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-77a81116</instanceId>
|
||||
<imageId>ami-eb71b682</imageId>
|
||||
<instanceState>
|
||||
<code>48</code>
|
||||
<name>terminated</name>
|
||||
</instanceState>
|
||||
<privateDnsName/>
|
||||
<dnsName/>
|
||||
<reason>User initiated (2011-07-29 08:06:19 GMT)</reason>
|
||||
<keyName>jclouds#ec2-e#us-east-1#6</keyName>
|
||||
<amiLaunchIndex>0</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>m1.small</instanceType>
|
||||
<launchTime>2011-07-29T08:06:15.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1b</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-407d9529</kernelId>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-15f4d17c</groupId>
|
||||
<groupName>jclouds#ec2-e#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<stateReason>
|
||||
<code>Client.UserInitiatedShutdown</code>
|
||||
<message>Client.UserInitiatedShutdown: User initiated shutdown</message>
|
||||
</stateReason>
|
||||
<architecture>i386</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping/>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
</instancesSet>
|
||||
</item>
|
||||
<item>
|
||||
<reservationId>r-2df85542</reservationId>
|
||||
<ownerId>993194456877</ownerId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-43eacf2a</groupId>
|
||||
<groupName>jclouds#ec2-s#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-a5a811c4</instanceId>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<instanceState>
|
||||
<code>48</code>
|
||||
<name>terminated</name>
|
||||
</instanceState>
|
||||
<privateDnsName/>
|
||||
<dnsName/>
|
||||
<reason>User initiated (2011-07-29 08:06:59 GMT)</reason>
|
||||
<keyName>jclouds#ec2-s#us-east-1#40</keyName>
|
||||
<amiLaunchIndex>0</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<launchTime>2011-07-29T08:06:55.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1b</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-427d952b</kernelId>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-43eacf2a</groupId>
|
||||
<groupName>jclouds#ec2-s#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<stateReason>
|
||||
<code>Client.UserInitiatedShutdown</code>
|
||||
<message>Client.UserInitiatedShutdown: User initiated shutdown</message>
|
||||
</stateReason>
|
||||
<architecture>x86_64</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping/>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
</instancesSet>
|
||||
</item>
|
||||
<item>
|
||||
<reservationId>r-bffb56d0</reservationId>
|
||||
<ownerId>993194456877</ownerId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-65eacf0c</groupId>
|
||||
<groupName>jclouds#adriancole-ec2unssh#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-1faa137e</instanceId>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<instanceState>
|
||||
<code>48</code>
|
||||
<name>terminated</name>
|
||||
</instanceState>
|
||||
<privateDnsName/>
|
||||
<dnsName/>
|
||||
<reason>User initiated (2011-07-29 08:10:04 GMT)</reason>
|
||||
<keyName>jclouds#adriancole-ec2unssh</keyName>
|
||||
<amiLaunchIndex>0</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<launchTime>2011-07-29T08:09:14.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1c</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-427d952b</kernelId>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-65eacf0c</groupId>
|
||||
<groupName>jclouds#adriancole-ec2unssh#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<stateReason>
|
||||
<code>Client.UserInitiatedShutdown</code>
|
||||
<message>Client.UserInitiatedShutdown: User initiated shutdown</message>
|
||||
</stateReason>
|
||||
<architecture>x86_64</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping/>
|
||||
<instanceLifecycle>spot</instanceLifecycle>
|
||||
<spotInstanceRequestId>sir-cf9dd211</spotInstanceRequestId>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
</instancesSet>
|
||||
<requesterId>854251627541</requesterId>
|
||||
</item>
|
||||
<item>
|
||||
<reservationId>r-c3cf62ac</reservationId>
|
||||
<ownerId>993194456877</ownerId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-dbf5d0b2</groupId>
|
||||
<groupName>jclouds#ec2-o#us-east-1</groupName>
|
||||
</item>
|
||||
<item>
|
||||
<groupId>sg-d9f5d0b0</groupId>
|
||||
<groupName>ec2-o</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-15982174</instanceId>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<instanceState>
|
||||
<code>48</code>
|
||||
<name>terminated</name>
|
||||
</instanceState>
|
||||
<privateDnsName/>
|
||||
<dnsName/>
|
||||
:
|
||||
<reason>User initiated (2011-07-29 08:27:01 GMT)</reason>
|
||||
<keyName>ec2-o</keyName>
|
||||
<amiLaunchIndex>0</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<launchTime>2011-07-29T08:25:33.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1c</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-427d952b</kernelId>
|
||||
<monitoring>
|
||||
<state>enabled</state>
|
||||
</monitoring>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-dbf5d0b2</groupId>
|
||||
<groupName>jclouds#ec2-o#us-east-1</groupName>
|
||||
</item>
|
||||
<item>
|
||||
<groupId>sg-d9f5d0b0</groupId>
|
||||
<groupName>ec2-o</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<stateReason>
|
||||
<code>Client.UserInitiatedShutdown</code>
|
||||
<message>Client.UserInitiatedShutdown: User initiated shutdown</message>
|
||||
</stateReason>
|
||||
<architecture>x86_64</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping/>
|
||||
<instanceLifecycle>spot</instanceLifecycle>
|
||||
<spotInstanceRequestId>sir-6bba1e14</spotInstanceRequestId>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
</instancesSet>
|
||||
<requesterId>854251627541</requesterId>
|
||||
</item>
|
||||
<item>
|
||||
<reservationId>r-b1c964de</reservationId>
|
||||
<ownerId>993194456877</ownerId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-25f4d14c</groupId>
|
||||
<groupName>jclouds#ec2-r#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-b19a23d0</instanceId>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<instanceState>
|
||||
<code>48</code>
|
||||
<name>terminated</name>
|
||||
</instanceState>
|
||||
<privateDnsName/>
|
||||
<dnsName/>
|
||||
<reason>User initiated (2011-07-29 08:28:17 GMT)</reason>
|
||||
<keyName>jclouds#ec2-r#us-east-1#63</keyName>
|
||||
<amiLaunchIndex>0</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<launchTime>2011-07-29T08:28:06.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1c</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-427d952b</kernelId>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-25f4d14c</groupId>
|
||||
<groupName>jclouds#ec2-r#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<stateReason>
|
||||
<code>Client.UserInitiatedShutdown</code>
|
||||
<message>Client.UserInitiatedShutdown: User initiated shutdown</message>
|
||||
</stateReason>
|
||||
<architecture>x86_64</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping/>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
</instancesSet>
|
||||
</item>
|
||||
<item>
|
||||
<reservationId>r-87c865e8</reservationId>
|
||||
<ownerId>993194456877</ownerId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-1df4d174</groupId>
|
||||
<groupName>jclouds#ec2-#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-679c2506</instanceId>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<instanceState>
|
||||
<code>16</code>
|
||||
<name>running</name>
|
||||
</instanceState>
|
||||
<privateDnsName>domU-12-31-39-09-F9-1C.compute-1.internal</privateDnsName>
|
||||
<dnsName>ec2-50-19-39-139.compute-1.amazonaws.com</dnsName>
|
||||
<reason/>
|
||||
<keyName>jclouds#ec2-#us-east-1#99</keyName>
|
||||
<amiLaunchIndex>0</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<launchTime>2011-07-29T08:29:21.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1b</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-427d952b</kernelId>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<privateIpAddress>10.210.254.234</privateIpAddress>
|
||||
<ipAddress>50.19.39.139</ipAddress>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-1df4d174</groupId>
|
||||
<groupName>jclouds#ec2-#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<architecture>x86_64</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping>
|
||||
<item>
|
||||
<deviceName>/dev/sda1</deviceName>
|
||||
<ebs>
|
||||
<volumeId>vol-6d7b6306</volumeId>
|
||||
<status>attached</status>
|
||||
<attachTime>2011-07-29T08:29:39.000Z</attachTime>
|
||||
<deleteOnTermination>true</deleteOnTermination>
|
||||
</ebs>
|
||||
</item>
|
||||
</blockDeviceMapping>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
<item>
|
||||
<instanceId>i-699c2508</instanceId>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<instanceState>
|
||||
<code>16</code>
|
||||
<name>running</name>
|
||||
</instanceState>
|
||||
<privateDnsName>domU-12-31-39-09-86-A9.compute-1.internal</privateDnsName>
|
||||
<dnsName>ec2-184-72-215-58.compute-1.amazonaws.com</dnsName>
|
||||
<reason/>
|
||||
<keyName>jclouds#ec2-#us-east-1#99</keyName>
|
||||
<amiLaunchIndex>1</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<launchTime>2011-07-29T08:29:21.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1b</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-427d952b</kernelId>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<privateIpAddress>10.210.137.83</privateIpAddress>
|
||||
<ipAddress>184.72.215.58</ipAddress>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-1df4d174</groupId>
|
||||
<groupName>jclouds#ec2-#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<architecture>x86_64</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping>
|
||||
<item>
|
||||
<deviceName>/dev/sda1</deviceName>
|
||||
<ebs>
|
||||
<volumeId>vol-617b630a</volumeId>
|
||||
<status>attached</status>
|
||||
<attachTime>2011-07-29T08:29:42.000Z</attachTime>
|
||||
<deleteOnTermination>true</deleteOnTermination>
|
||||
</ebs>
|
||||
</item>
|
||||
</blockDeviceMapping>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
</instancesSet>
|
||||
</item>
|
||||
<item>
|
||||
<reservationId>r-61cb660e</reservationId>
|
||||
<ownerId>993194456877</ownerId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-1ff4d176</groupId>
|
||||
<groupName>jclouds#ec2-block#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-539c2532</instanceId>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<instanceState>
|
||||
<code>48</code>
|
||||
<name>terminated</name>
|
||||
</instanceState>
|
||||
<privateDnsName/>
|
||||
<dnsName/>
|
||||
<reason>User initiated (2011-07-29 08:29:36 GMT)</reason>
|
||||
<keyName>jclouds#ec2-block#us-east-1#48</keyName>
|
||||
<amiLaunchIndex>0</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<launchTime>2011-07-29T08:29:32.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1b</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-427d952b</kernelId>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-1ff4d176</groupId>
|
||||
<groupName>jclouds#ec2-block#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<stateReason>
|
||||
<code>Client.UserInitiatedShutdown</code>
|
||||
<message>Client.UserInitiatedShutdown: User initiated shutdown</message>
|
||||
</stateReason>
|
||||
<architecture>x86_64</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping/>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
</instancesSet>
|
||||
</item>
|
||||
<item>
|
||||
<reservationId>r-51cb663e</reservationId>
|
||||
<ownerId>993194456877</ownerId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-15f4d17c</groupId>
|
||||
<groupName>jclouds#ec2-e#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-059c2564</instanceId>
|
||||
<imageId>ami-eb71b682</imageId>
|
||||
<instanceState>
|
||||
<code>0</code>
|
||||
<name>pending</name>
|
||||
</instanceState>
|
||||
<dnsName>ec2-184-72-215-58.compute-1.amazonaws.com</dnsName>
|
||||
<reason/>
|
||||
<keyName>jclouds#ec2-#us-east-1#99</keyName>
|
||||
<amiLaunchIndex>1</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<launchTime>2011-07-29T08:29:21.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1b</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-427d952b</kernelId>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<privateIpAddress>10.210.137.83</privateIpAddress>
|
||||
<ipAddress>184.72.215.58</ipAddress>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-1df4d174</groupId>
|
||||
<groupName>jclouds#ec2-#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<architecture>x86_64</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping>
|
||||
<item>
|
||||
<deviceName>/dev/sda1</deviceName>
|
||||
<ebs>
|
||||
<volumeId>vol-617b630a</volumeId>
|
||||
<status>attached</status>
|
||||
<attachTime>2011-07-29T08:29:42.000Z</attachTime>
|
||||
<deleteOnTermination>true</deleteOnTermination>
|
||||
</ebs>
|
||||
</item>
|
||||
</blockDeviceMapping>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
</instancesSet>
|
||||
</item>
|
||||
<item>
|
||||
<reservationId>r-61cb660e</reservationId>
|
||||
<ownerId>993194456877</ownerId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-1ff4d176</groupId>
|
||||
<groupName>jclouds#ec2-block#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-539c2532</instanceId>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<instanceState>
|
||||
<code>48</code>
|
||||
<name>terminated</name>
|
||||
</instanceState>
|
||||
<privateDnsName/>
|
||||
<dnsName/>
|
||||
<reason>User initiated (2011-07-29 08:29:36 GMT)</reason>
|
||||
<keyName>jclouds#ec2-block#us-east-1#48</keyName>
|
||||
<amiLaunchIndex>0</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<launchTime>2011-07-29T08:29:32.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1b</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-427d952b</kernelId>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-1ff4d176</groupId>
|
||||
<groupName>jclouds#ec2-block#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<stateReason>
|
||||
<code>Client.UserInitiatedShutdown</code>
|
||||
<message>Client.UserInitiatedShutdown: User initiated shutdown</message>
|
||||
</stateReason>
|
||||
<architecture>x86_64</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping/>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
</instancesSet>
|
||||
</item>
|
||||
<item>
|
||||
<reservationId>r-51cb663e</reservationId>
|
||||
<ownerId>993194456877</ownerId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-15f4d17c</groupId>
|
||||
<groupName>jclouds#ec2-e#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-059c2564</instanceId>
|
||||
<imageId>ami-eb71b682</imageId>
|
||||
<instanceState>
|
||||
<code>0</code>
|
||||
<name>pending</name>
|
||||
</instanceState>
|
||||
<privateDnsName/>
|
||||
<dnsName/>
|
||||
<reason/>
|
||||
<keyName>jclouds#ec2-e#us-east-1#85</keyName>
|
||||
<amiLaunchIndex>0</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>m1.small</instanceType>
|
||||
<launchTime>2011-07-29T08:29:49.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1c</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-407d9529</kernelId>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-15f4d17c</groupId>
|
||||
<groupName>jclouds#ec2-e#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<architecture>i386</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping/>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
</instancesSet>
|
||||
</item>
|
||||
</reservationSet>
|
||||
</DescribeInstancesResponse>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||
<requestId>440faed2-0331-488d-a04d-d8c9aba85307</requestId>
|
||||
<reservationSet/>
|
||||
</DescribeInstancesResponse>
|
|
@ -0,0 +1,67 @@
|
|||
<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||
<requestId>e32bb361-415e-484b-8651-5fd0c0a85fab</requestId>
|
||||
<reservationSet>
|
||||
<item>
|
||||
<reservationId>r-6d62c002</reservationId>
|
||||
<ownerId>993194456877</ownerId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-1f1c3976</groupId>
|
||||
<groupName>jclouds#ec2-s#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-5f833d3e</instanceId>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<instanceState>
|
||||
<code>16</code>
|
||||
<name>running</name>
|
||||
</instanceState>
|
||||
<privateDnsName>domU-12-31-38-04-25-D8.compute-1.internal</privateDnsName>
|
||||
<dnsName>ec2-50-16-149-221.compute-1.amazonaws.com</dnsName>
|
||||
<reason/>
|
||||
<keyName>jclouds#ec2-s#us-east-1#38</keyName>
|
||||
<amiLaunchIndex>0</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<launchTime>2011-07-29T04:08:19.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1d</availabilityZone>
|
||||
<groupName/>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<kernelId>aki-427d952b</kernelId>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<privateIpAddress>10.220.38.38</privateIpAddress>
|
||||
<ipAddress>50.16.149.221</ipAddress>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-1f1c3976</groupId>
|
||||
<groupName>jclouds#ec2-s#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<architecture>x86_64</architecture>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping>
|
||||
<item>
|
||||
<deviceName>/dev/sda1</deviceName>
|
||||
<ebs>
|
||||
<volumeId>vol-4bc3da20</volumeId>
|
||||
<status>attached</status>
|
||||
<attachTime>2011-07-29T04:08:40.000Z</attachTime>
|
||||
<deleteOnTermination>true</deleteOnTermination>
|
||||
</ebs>
|
||||
</item>
|
||||
</blockDeviceMapping>
|
||||
<virtualizationType>paravirtual</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
</instancesSet>
|
||||
</item>
|
||||
</reservationSet>
|
||||
</DescribeInstancesResponse>
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<DescribeSpotInstanceRequestsResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||
<requestId>d9da716a-5cd4-492e-83b9-6777ac16d6cf</requestId>
|
||||
<spotInstanceRequestSet>
|
||||
<item>
|
||||
<spotInstanceRequestId>sir-1ede0012</spotInstanceRequestId>
|
||||
<spotPrice>0.300000</spotPrice>
|
||||
<type>one-time</type>
|
||||
<state>active</state>
|
||||
<launchSpecification>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<keyName>jclouds#adriancole-ec2unssh</keyName>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-83e1c4eb</groupId>
|
||||
<groupName>jclouds#adriancole-ec2unssh#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<blockDeviceMapping/>
|
||||
<monitoring>
|
||||
<enabled>false</enabled>
|
||||
</monitoring>
|
||||
</launchSpecification>
|
||||
<instanceId>i-ef308e8e</instanceId>
|
||||
<createTime>2011-07-29T05:27:39.000Z</createTime>
|
||||
<productDescription>Linux/UNIX</productDescription>
|
||||
<launchedAvailabilityZone>us-east-1b</launchedAvailabilityZone>
|
||||
</item>
|
||||
</spotInstanceRequestSet>
|
||||
</DescribeSpotInstanceRequestsResponse>
|
|
@ -1,4 +1,4 @@
|
|||
<DescribeSpotInstanceRequestsResponse xmlns="http://ec2.amazonaws.com/doc/2010-11-15/">
|
||||
<DescribeSpotInstanceRequestsResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||
<requestId>7c4dd2bd-106d-4cd3-987c-35ee819180a6</requestId>
|
||||
<spotInstanceRequestSet>
|
||||
<item>
|
||||
|
@ -10,7 +10,8 @@
|
|||
<imageId>ami-595a0a1c</imageId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>default</groupId>
|
||||
<groupId>sg-83e1c4ea</groupId>
|
||||
<groupName>default</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
|
@ -31,7 +32,8 @@
|
|||
<imageId>ami-595a0a1c</imageId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>default</groupId>
|
||||
<groupId>sg-83e1c4ea</groupId>
|
||||
<groupName>default</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
|
@ -52,7 +54,8 @@
|
|||
<imageId>ami-595a0a1c</imageId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>default</groupId>
|
||||
<groupId>sg-83e1c4ea</groupId>
|
||||
<groupName>default</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
|
@ -77,7 +80,8 @@
|
|||
<keyName>default</keyName>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>quick-start-1</groupId>
|
||||
<groupId>sg-83e1c4eb</groupId>
|
||||
<groupName>quick-start-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
|
@ -102,9 +106,9 @@
|
|||
<keyName>default</keyName>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>quick-start-1</groupId>
|
||||
</item>
|
||||
</groupSet>
|
||||
<groupId>sg-83e1c4eb</groupId>
|
||||
<groupName>quick-start-1</groupName>
|
||||
</item> </groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<blockDeviceMapping/>
|
||||
<monitoring>
|
||||
|
@ -123,7 +127,8 @@
|
|||
<imageId>ami-595a0a1c</imageId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>default</groupId>
|
||||
<groupId>sg-83e1c4ea</groupId>
|
||||
<groupName>default</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
|
@ -144,7 +149,8 @@
|
|||
<imageId>ami-595a0a1c</imageId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>default</groupId>
|
||||
<groupId>sg-83e1c4ea</groupId>
|
||||
<groupName>default</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
|
@ -165,7 +171,8 @@
|
|||
<imageId>ami-595a0a1c</imageId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>default</groupId>
|
||||
<groupId>sg-83e1c4ea</groupId>
|
||||
<groupName>default</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
|
@ -190,9 +197,9 @@
|
|||
<keyName>default</keyName>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>quick-start-1</groupId>
|
||||
</item>
|
||||
</groupSet>
|
||||
<groupId>sg-83e1c4eb</groupId>
|
||||
<groupName>quick-start-1</groupName>
|
||||
</item> </groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<blockDeviceMapping/>
|
||||
<monitoring>
|
||||
|
@ -215,9 +222,9 @@
|
|||
<keyName>default</keyName>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>quick-start-1</groupId>
|
||||
</item>
|
||||
</groupSet>
|
||||
<groupId>sg-83e1c4eb</groupId>
|
||||
<groupName>quick-start-1</groupName>
|
||||
</item> </groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<blockDeviceMapping/>
|
||||
<monitoring>
|
||||
|
@ -236,7 +243,8 @@
|
|||
<imageId>ami-595a0a1c</imageId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>default</groupId>
|
||||
<groupId>sg-83e1c4ea</groupId>
|
||||
<groupName>default</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
|
@ -257,7 +265,8 @@
|
|||
<imageId>ami-595a0a1c</imageId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>default</groupId>
|
||||
<groupId>sg-83e1c4ea</groupId>
|
||||
<groupName>default</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
|
@ -282,9 +291,9 @@
|
|||
<keyName>default</keyName>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>quick-start-1</groupId>
|
||||
</item>
|
||||
</groupSet>
|
||||
<groupId>sg-83e1c4eb</groupId>
|
||||
<groupName>quick-start-1</groupName>
|
||||
</item> </groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<blockDeviceMapping/>
|
||||
<monitoring>
|
||||
|
@ -307,9 +316,9 @@
|
|||
<keyName>default</keyName>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>quick-start-1</groupId>
|
||||
</item>
|
||||
</groupSet>
|
||||
<groupId>sg-83e1c4eb</groupId>
|
||||
<groupName>quick-start-1</groupName>
|
||||
</item> </groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<blockDeviceMapping/>
|
||||
<monitoring>
|
||||
|
@ -332,9 +341,10 @@
|
|||
<keyName>default</keyName>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>quick-start-1</groupId>
|
||||
<groupId>sg-83e1c4eb</groupId>
|
||||
<groupName>quick-start-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<blockDeviceMapping/>
|
||||
<monitoring>
|
||||
|
@ -353,7 +363,8 @@
|
|||
<imageId>ami-595a0a1c</imageId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>default</groupId>
|
||||
<groupId>sg-83e1c4ea</groupId>
|
||||
<groupName>default</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
|
@ -376,9 +387,9 @@
|
|||
<keyName>default</keyName>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>quick-start-1</groupId>
|
||||
</item>
|
||||
</groupSet>
|
||||
<groupId>sg-83e1c4eb</groupId>
|
||||
<groupName>quick-start-1</groupName>
|
||||
</item> </groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<blockDeviceMapping/>
|
||||
<monitoring>
|
||||
|
@ -397,7 +408,8 @@
|
|||
<imageId>ami-595a0a1c</imageId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>default</groupId>
|
||||
<groupId>sg-83e1c4ea</groupId>
|
||||
<groupName>default</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
|
|
|
@ -0,0 +1,207 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<DescribeSpotInstanceRequestsResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||
<requestId>f2247378-7df0-4725-b55f-8ef58b557dcd</requestId>
|
||||
<spotInstanceRequestSet>
|
||||
<item>
|
||||
<spotInstanceRequestId>sir-f4d44212</spotInstanceRequestId>
|
||||
<spotPrice>0.300000</spotPrice>
|
||||
<type>one-time</type>
|
||||
<state>cancelled</state>
|
||||
<launchSpecification>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<keyName>ec2-o</keyName>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupName>jclouds#ec2-o#us-east-1</groupName>
|
||||
</item>
|
||||
<item>
|
||||
<groupName>ec2-o</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<blockDeviceMapping/>
|
||||
<monitoring>
|
||||
<enabled>true</enabled>
|
||||
</monitoring>
|
||||
</launchSpecification>
|
||||
<createTime>2011-07-29T04:01:12.000Z</createTime>
|
||||
<productDescription>Linux/UNIX</productDescription>
|
||||
<launchedAvailabilityZone>us-east-1b</launchedAvailabilityZone>
|
||||
</item>
|
||||
<item>
|
||||
<spotInstanceRequestId>sir-43408412</spotInstanceRequestId>
|
||||
<spotPrice>0.300000</spotPrice>
|
||||
<type>one-time</type>
|
||||
<state>cancelled</state>
|
||||
<launchSpecification>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<keyName>jclouds#adriancole-ec2unssh</keyName>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupName>jclouds#adriancole-ec2unssh#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<blockDeviceMapping/>
|
||||
<monitoring>
|
||||
<enabled>false</enabled>
|
||||
</monitoring>
|
||||
</launchSpecification>
|
||||
<createTime>2011-07-29T04:02:53.000Z</createTime>
|
||||
<productDescription>Linux/UNIX</productDescription>
|
||||
<launchedAvailabilityZone>us-east-1b</launchedAvailabilityZone>
|
||||
</item>
|
||||
<item>
|
||||
<spotInstanceRequestId>sir-e4c3fa14</spotInstanceRequestId>
|
||||
<spotPrice>0.300000</spotPrice>
|
||||
<type>one-time</type>
|
||||
<state>closed</state>
|
||||
<launchSpecification>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<keyName>ec2-o</keyName>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupName>jclouds#ec2-o#us-east-1</groupName>
|
||||
</item>
|
||||
<item>
|
||||
<groupName>ec2-o</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<blockDeviceMapping/>
|
||||
<monitoring>
|
||||
<enabled>true</enabled>
|
||||
</monitoring>
|
||||
</launchSpecification>
|
||||
<createTime>2011-07-29T05:25:49.000Z</createTime>
|
||||
<productDescription>Linux/UNIX</productDescription>
|
||||
<launchedAvailabilityZone>us-east-1c</launchedAvailabilityZone>
|
||||
</item>
|
||||
<item>
|
||||
<spotInstanceRequestId>sir-1ede0012</spotInstanceRequestId>
|
||||
<spotPrice>0.300000</spotPrice>
|
||||
<type>one-time</type>
|
||||
<state>closed</state>
|
||||
<launchSpecification>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<keyName>jclouds#adriancole-ec2unssh</keyName>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupName>jclouds#adriancole-ec2unssh#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<blockDeviceMapping/>
|
||||
<monitoring>
|
||||
<enabled>false</enabled>
|
||||
</monitoring>
|
||||
</launchSpecification>
|
||||
<createTime>2011-07-29T05:27:39.000Z</createTime>
|
||||
<productDescription>Linux/UNIX</productDescription>
|
||||
<launchedAvailabilityZone>us-east-1b</launchedAvailabilityZone>
|
||||
</item>
|
||||
<item>
|
||||
<spotInstanceRequestId>sir-596fa211</spotInstanceRequestId>
|
||||
<spotPrice>0.300000</spotPrice>
|
||||
<type>one-time</type>
|
||||
<state>closed</state>
|
||||
<launchSpecification>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<keyName>ec2-o</keyName>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupName>jclouds#ec2-o#us-east-1</groupName>
|
||||
</item>
|
||||
<item>
|
||||
<groupName>ec2-o</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<blockDeviceMapping/>
|
||||
<monitoring>
|
||||
<enabled>true</enabled>
|
||||
</monitoring>
|
||||
</launchSpecification>
|
||||
<createTime>2011-07-29T06:22:37.000Z</createTime>
|
||||
<productDescription>Linux/UNIX</productDescription>
|
||||
<launchedAvailabilityZone>us-east-1b</launchedAvailabilityZone>
|
||||
</item>
|
||||
<item>
|
||||
<spotInstanceRequestId>sir-cc233214</spotInstanceRequestId>
|
||||
<spotPrice>0.300000</spotPrice>
|
||||
<type>one-time</type>
|
||||
<state>closed</state>
|
||||
<launchSpecification>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<keyName>ec2-o</keyName>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupName>jclouds#ec2-o#us-east-1</groupName>
|
||||
</item>
|
||||
<item>
|
||||
<groupName>ec2-o</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<blockDeviceMapping/>
|
||||
<monitoring>
|
||||
<enabled>true</enabled>
|
||||
</monitoring>
|
||||
</launchSpecification>
|
||||
<createTime>2011-07-29T07:48:03.000Z</createTime>
|
||||
<productDescription>Linux/UNIX</productDescription>
|
||||
<launchedAvailabilityZone>us-east-1c</launchedAvailabilityZone>
|
||||
</item>
|
||||
<item>
|
||||
<spotInstanceRequestId>sir-cf9dd211</spotInstanceRequestId>
|
||||
<spotPrice>0.300000</spotPrice>
|
||||
<type>one-time</type>
|
||||
<state>active</state>
|
||||
<launchSpecification>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<keyName>jclouds#adriancole-ec2unssh</keyName>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupName>jclouds#adriancole-ec2unssh#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<blockDeviceMapping/>
|
||||
<monitoring>
|
||||
<enabled>false</enabled>
|
||||
</monitoring>
|
||||
</launchSpecification>
|
||||
<instanceId>i-1faa137e</instanceId>
|
||||
<createTime>2011-07-29T08:05:45.000Z</createTime>
|
||||
<productDescription>Linux/UNIX</productDescription>
|
||||
<launchedAvailabilityZone>us-east-1c</launchedAvailabilityZone>
|
||||
</item>
|
||||
<item>
|
||||
<spotInstanceRequestId>sir-6bba1e14</spotInstanceRequestId>
|
||||
<spotPrice>0.300000</spotPrice>
|
||||
<type>one-time</type>
|
||||
<state>active</state>
|
||||
<launchSpecification>
|
||||
<imageId>ami-8e1fece7</imageId>
|
||||
<keyName>ec2-o</keyName>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupName>jclouds#ec2-o#us-east-1</groupName>
|
||||
</item>
|
||||
<item>
|
||||
<groupName>ec2-o</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>t1.micro</instanceType>
|
||||
<blockDeviceMapping/>
|
||||
<monitoring>
|
||||
<enabled>true</enabled>
|
||||
</monitoring>
|
||||
</launchSpecification>
|
||||
<instanceId>i-15982174</instanceId>
|
||||
<createTime>2011-07-29T08:20:27.000Z</createTime>
|
||||
<productDescription>Linux/UNIX</productDescription>
|
||||
<launchedAvailabilityZone>us-east-1c</launchedAvailabilityZone>
|
||||
</item>
|
||||
</spotInstanceRequestSet>
|
||||
</DescribeSpotInstanceRequestsResponse>
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<DescribeSpotPriceHistoryResponse xmlns="http://ec2.amazonaws.com/doc/2010-11-15/">
|
||||
<DescribeSpotPriceHistoryResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||
<requestId>99777a75-2a2b-4296-a305-650c442d2d63</requestId>
|
||||
<spotPriceHistorySet>
|
||||
<item>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<RequestSpotInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2010-11-15/">
|
||||
<RequestSpotInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||
<requestId>02401e8e-a4f5-4285-8ea8-6d742fbaadd8</requestId>
|
||||
<spotInstanceRequestSet>
|
||||
<item>
|
||||
|
@ -11,7 +11,8 @@
|
|||
<imageId>ami-595a0a1c</imageId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>default</groupId>
|
||||
<groupId>sg-83e1c4ea</groupId>
|
||||
<groupName>default</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instanceType>m1.large</instanceType>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<RequestSpotInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2010-11-15/">
|
||||
<RequestSpotInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||
<requestId>2ffc645f-6835-4d23-bd18-f6f53c253067</requestId>
|
||||
<spotInstanceRequestSet>
|
||||
<item>
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2011-05-15/">
|
||||
<requestId>7faf9500-67ef-484b-9fa5-73b6df638bc8</requestId>
|
||||
<reservationId>r-d3b815bc</reservationId>
|
||||
<ownerId>993194456877</ownerId>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-3ffcd956</groupId>
|
||||
<groupName>jclouds#adriancoleec2cccluster#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-8949f0e8</instanceId>
|
||||
<imageId>ami-ab5b9cc2</imageId>
|
||||
<instanceState>
|
||||
<code>0</code>
|
||||
<name>pending</name>
|
||||
</instanceState>
|
||||
<privateDnsName/>
|
||||
<dnsName/>
|
||||
<reason/>
|
||||
<keyName>jclouds#adriancoleec2cccluster</keyName>
|
||||
<amiLaunchIndex>0</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType>cc1.4xlarge</instanceType>
|
||||
<launchTime>2011-07-29T09:46:48.000Z</launchTime>
|
||||
<placement>
|
||||
<availabilityZone>us-east-1d</availabilityZone>
|
||||
<groupName>jclouds#adriancoleec2cccluster#us-east-1</groupName>
|
||||
<tenancy>default</tenancy>
|
||||
</placement>
|
||||
<monitoring>
|
||||
<state>disabled</state>
|
||||
</monitoring>
|
||||
<groupSet>
|
||||
<item>
|
||||
<groupId>sg-3ffcd956</groupId>
|
||||
<groupName>jclouds#adriancoleec2cccluster#us-east-1</groupName>
|
||||
</item>
|
||||
</groupSet>
|
||||
<stateReason>
|
||||
<code>pending</code>
|
||||
<message>pending</message>
|
||||
</stateReason>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping/>
|
||||
<virtualizationType>hvm</virtualizationType>
|
||||
<clientToken/>
|
||||
<hypervisor>xen</hypervisor>
|
||||
</item>
|
||||
</instancesSet>
|
||||
</RunInstancesResponse>
|
Loading…
Reference in New Issue