mirror of https://github.com/apache/jclouds.git
Issue 29: brought Image Services in line with 11/30/2009 release
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2524 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
d60951fcf1
commit
57aea2d47b
|
@ -43,7 +43,7 @@ public class BindGroupNameToIndexedFormParams implements Binder {
|
|||
public void bindToRequest(HttpRequest request, Object input) {
|
||||
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
|
||||
"this binder is only valid for GeneratedHttpRequests!");
|
||||
EC2Utils.indexFormValuesWithPrefix((GeneratedHttpRequest<?>) request, "GroupName", input);
|
||||
EC2Utils.indexStringArrayToFormValuesWithPrefix((GeneratedHttpRequest<?>) request, "GroupName", input);
|
||||
}
|
||||
|
||||
}
|
|
@ -52,7 +52,7 @@ public class BindInetAddressesToIndexedFormParams implements Binder {
|
|||
for (int i = 0; i < addresses.length; i++) {
|
||||
addressStrings[i] = addresses[i].getHostAddress();
|
||||
}
|
||||
EC2Utils.indexFormValuesWithPrefix((GeneratedHttpRequest<?>) request, "PublicIp",
|
||||
EC2Utils.indexStringArrayToFormValuesWithPrefix((GeneratedHttpRequest<?>) request, "PublicIp",
|
||||
addressStrings);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public class BindInstanceIdsToIndexedFormParams implements Binder {
|
|||
public void bindToRequest(HttpRequest request, Object input) {
|
||||
checkArgument(checkNotNull(request, "input") instanceof GeneratedHttpRequest,
|
||||
"this binder is only valid for GeneratedHttpRequests!");
|
||||
EC2Utils.indexFormValuesWithPrefix((GeneratedHttpRequest<?>) request, "InstanceId", input);
|
||||
EC2Utils.indexStringArrayToFormValuesWithPrefix((GeneratedHttpRequest<?>) request, "InstanceId", input);
|
||||
}
|
||||
|
||||
}
|
|
@ -43,7 +43,7 @@ public class BindKeyNameToIndexedFormParams implements Binder {
|
|||
public void bindToRequest(HttpRequest request, Object input) {
|
||||
checkArgument(checkNotNull(request, "input") instanceof GeneratedHttpRequest,
|
||||
"this binder is only valid for GeneratedHttpRequests!");
|
||||
EC2Utils.indexFormValuesWithPrefix((GeneratedHttpRequest<?>) request, "KeyName", input);
|
||||
EC2Utils.indexStringArrayToFormValuesWithPrefix((GeneratedHttpRequest<?>) request, "KeyName", input);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rest.Binder;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
|
||||
/**
|
||||
* Binds the String [] to form parameters named with ProductCode.index
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @since 4.0
|
||||
*/
|
||||
public class BindProductCodesToIndexedFormParams implements Binder {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void bindToRequest(HttpRequest request, Object input) {
|
||||
checkArgument(checkNotNull(request, "input") instanceof GeneratedHttpRequest,
|
||||
"this binder is only valid for GeneratedHttpRequests!");
|
||||
EC2Utils.indexIterableToFormValuesWithPrefix((GeneratedHttpRequest<?>) request, "ProductCode", input);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rest.Binder;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* Binds the Iterable to query parameters named with UserGroup.index
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class BindUserGroupsToIndexedFormParams implements Binder {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void bindToRequest(HttpRequest request, Object input) {
|
||||
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
|
||||
"this binder is only valid for GeneratedHttpRequests!");
|
||||
checkArgument(checkNotNull(input, "input") instanceof Iterable<?>,
|
||||
"this binder is only valid for Iterable<?>: " + input.getClass());
|
||||
checkValidUserGroup(input);
|
||||
EC2Utils.indexIterableToFormValuesWithPrefix((GeneratedHttpRequest<?>) request, "UserGroup",
|
||||
input);
|
||||
}
|
||||
|
||||
private void checkValidUserGroup(Object input) {
|
||||
Iterable<?> values = (Iterable<?>) input;
|
||||
long size = Iterables.size(values);
|
||||
checkArgument(size == 0 || (size == 1 && Iterables.getOnlyElement(values).equals("all")),
|
||||
"only supported UserGroup is 'all'");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.aws.ec2.util.EC2Utils;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rest.Binder;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
|
||||
/**
|
||||
* Binds the String [] to form parameters named with UserId.index
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class BindUserIdsToIndexedFormParams implements Binder {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void bindToRequest(HttpRequest request, Object input) {
|
||||
checkArgument(checkNotNull(request, "input") instanceof GeneratedHttpRequest,
|
||||
"this binder is only valid for GeneratedHttpRequests!");
|
||||
EC2Utils.indexIterableToFormValuesWithPrefix((GeneratedHttpRequest<?>) request, "UserId",
|
||||
input);
|
||||
}
|
||||
|
||||
}
|
|
@ -25,8 +25,13 @@ package org.jclouds.aws.ec2.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.internal.Nullable;
|
||||
|
||||
/**
|
||||
|
@ -37,12 +42,40 @@ import com.google.inject.internal.Nullable;
|
|||
*/
|
||||
public class Image implements Comparable<Image> {
|
||||
|
||||
public Image(Architecture architecture, String imageId, String imageLocation,
|
||||
String imageOwnerId, ImageState imageState, ImageType imageType, boolean isPublic,
|
||||
@Nullable String kernelId, @Nullable String platform, Set<String> productCodes,
|
||||
@Nullable String ramdiskId) {
|
||||
private final Architecture architecture;
|
||||
@Nullable
|
||||
private final String name;
|
||||
@Nullable
|
||||
private final String description;
|
||||
private final String imageId;
|
||||
private final String imageLocation;
|
||||
private final String imageOwnerId;
|
||||
private final ImageState imageState;
|
||||
private final ImageType imageType;
|
||||
private final boolean isPublic;
|
||||
@Nullable
|
||||
private final String kernelId;
|
||||
@Nullable
|
||||
private final String platform;
|
||||
private final Set<String> productCodes = Sets.newHashSet();
|
||||
@Nullable
|
||||
private final String ramdiskId;
|
||||
private final RootDeviceType rootDeviceType;
|
||||
@Nullable
|
||||
private final String rootDeviceName;
|
||||
private final Map<String, EbsBlockDevice> ebsBlockDevices = Maps.newHashMap();
|
||||
|
||||
public Image(Architecture architecture, @Nullable String name, @Nullable String description,
|
||||
String imageId, String imageLocation, String imageOwnerId, ImageState imageState,
|
||||
ImageType imageType, boolean isPublic, Iterable<String> productCodes,
|
||||
@Nullable String kernelId, @Nullable String platform, @Nullable String ramdiskId,
|
||||
RootDeviceType rootDeviceType, String rootDeviceName,
|
||||
Map<String, EbsBlockDevice> ebsBlockDevices) {
|
||||
this.architecture = checkNotNull(architecture, "architecture");
|
||||
this.imageId = checkNotNull(imageId, "imageId");
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.rootDeviceName = rootDeviceName;
|
||||
this.imageLocation = checkNotNull(imageLocation, "imageLocation");
|
||||
this.imageOwnerId = checkNotNull(imageOwnerId, "imageOwnerId");
|
||||
this.imageState = checkNotNull(imageState, "imageState");
|
||||
|
@ -50,14 +83,16 @@ public class Image implements Comparable<Image> {
|
|||
this.isPublic = isPublic;
|
||||
this.kernelId = kernelId;
|
||||
this.platform = platform;
|
||||
this.productCodes = checkNotNull(productCodes, "productCodes");
|
||||
Iterables.addAll(this.productCodes, checkNotNull(productCodes, "productCodes"));
|
||||
this.ramdiskId = ramdiskId;
|
||||
this.rootDeviceType = checkNotNull(rootDeviceType, "rootDeviceType");
|
||||
this.ebsBlockDevices.putAll(checkNotNull(ebsBlockDevices, "ebsBlockDevices"));
|
||||
}
|
||||
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = -6965068835316857535L;
|
||||
|
||||
public enum ImageState {
|
||||
public static enum ImageState {
|
||||
/**
|
||||
* the image is successfully registered and available for launching
|
||||
*/
|
||||
|
@ -75,7 +110,26 @@ public class Image implements Comparable<Image> {
|
|||
}
|
||||
}
|
||||
|
||||
public enum Architecture {
|
||||
/**
|
||||
* The root device type used by the AMI. The AMI can use an Amazon EBS or instance store root
|
||||
* device.
|
||||
*/
|
||||
public static enum RootDeviceType {
|
||||
|
||||
INSTANCE_STORE,
|
||||
|
||||
EBS;
|
||||
|
||||
public String value() {
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
|
||||
}
|
||||
|
||||
public static RootDeviceType fromValue(String v) {
|
||||
return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, v));
|
||||
}
|
||||
}
|
||||
|
||||
public static enum Architecture {
|
||||
I386, X86_64;
|
||||
public String value() {
|
||||
return name().toLowerCase();
|
||||
|
@ -86,7 +140,7 @@ public class Image implements Comparable<Image> {
|
|||
}
|
||||
}
|
||||
|
||||
public enum ImageType {
|
||||
public static enum ImageType {
|
||||
|
||||
MACHINE, KERNEL, RAMDISK;
|
||||
public String value() {
|
||||
|
@ -99,19 +153,69 @@ public class Image implements Comparable<Image> {
|
|||
|
||||
}
|
||||
|
||||
private final Architecture architecture;
|
||||
private final String imageId;
|
||||
private final String imageLocation;
|
||||
private final String imageOwnerId;
|
||||
private final ImageState imageState;
|
||||
private final ImageType imageType;
|
||||
private final boolean isPublic;
|
||||
private final @Nullable
|
||||
String kernelId;
|
||||
private final @Nullable String platform;
|
||||
private final Set<String> productCodes;
|
||||
private final @Nullable
|
||||
String ramdiskId;
|
||||
public static class EbsBlockDevice {
|
||||
@Nullable
|
||||
private final String snapshotId;
|
||||
private final long volumeSize;
|
||||
private final boolean deleteOnTermination;
|
||||
|
||||
public EbsBlockDevice(@Nullable String snapshotId, long volumeSize,
|
||||
boolean deleteOnTermination) {
|
||||
this.snapshotId = snapshotId;
|
||||
this.volumeSize = volumeSize;
|
||||
this.deleteOnTermination = deleteOnTermination;
|
||||
}
|
||||
|
||||
public String getSnapshotId() {
|
||||
return snapshotId;
|
||||
}
|
||||
|
||||
public long getVolumeSize() {
|
||||
return volumeSize;
|
||||
}
|
||||
|
||||
public boolean isDeleteOnTermination() {
|
||||
return deleteOnTermination;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (deleteOnTermination ? 1231 : 1237);
|
||||
result = prime * result + ((snapshotId == null) ? 0 : snapshotId.hashCode());
|
||||
result = prime * result + (int) (volumeSize ^ (volumeSize >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
EbsBlockDevice other = (EbsBlockDevice) obj;
|
||||
if (deleteOnTermination != other.deleteOnTermination)
|
||||
return false;
|
||||
if (snapshotId == null) {
|
||||
if (other.snapshotId != null)
|
||||
return false;
|
||||
} else if (!snapshotId.equals(other.snapshotId))
|
||||
return false;
|
||||
if (volumeSize != other.volumeSize)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EbsBlockDevice [deleteOnTermination=" + deleteOnTermination + ", snapshotId="
|
||||
+ snapshotId + ", volumeSize=" + volumeSize + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The architecture of the image (i386 or x86_64).
|
||||
|
@ -205,6 +309,8 @@ public class Image implements Comparable<Image> {
|
|||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((architecture == null) ? 0 : architecture.hashCode());
|
||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((ebsBlockDevices == null) ? 0 : ebsBlockDevices.hashCode());
|
||||
result = prime * result + ((imageId == null) ? 0 : imageId.hashCode());
|
||||
result = prime * result + ((imageLocation == null) ? 0 : imageLocation.hashCode());
|
||||
result = prime * result + ((imageOwnerId == null) ? 0 : imageOwnerId.hashCode());
|
||||
|
@ -212,9 +318,12 @@ public class Image implements Comparable<Image> {
|
|||
result = prime * result + ((imageType == null) ? 0 : imageType.hashCode());
|
||||
result = prime * result + (isPublic ? 1231 : 1237);
|
||||
result = prime * result + ((kernelId == null) ? 0 : kernelId.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((platform == null) ? 0 : platform.hashCode());
|
||||
result = prime * result + ((productCodes == null) ? 0 : productCodes.hashCode());
|
||||
result = prime * result + ((ramdiskId == null) ? 0 : ramdiskId.hashCode());
|
||||
result = prime * result + ((rootDeviceName == null) ? 0 : rootDeviceName.hashCode());
|
||||
result = prime * result + ((rootDeviceType == null) ? 0 : rootDeviceType.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -232,6 +341,16 @@ public class Image implements Comparable<Image> {
|
|||
return false;
|
||||
} else if (!architecture.equals(other.architecture))
|
||||
return false;
|
||||
if (description == null) {
|
||||
if (other.description != null)
|
||||
return false;
|
||||
} else if (!description.equals(other.description))
|
||||
return false;
|
||||
if (ebsBlockDevices == null) {
|
||||
if (other.ebsBlockDevices != null)
|
||||
return false;
|
||||
} else if (!ebsBlockDevices.equals(other.ebsBlockDevices))
|
||||
return false;
|
||||
if (imageId == null) {
|
||||
if (other.imageId != null)
|
||||
return false;
|
||||
|
@ -264,6 +383,11 @@ public class Image implements Comparable<Image> {
|
|||
return false;
|
||||
} else if (!kernelId.equals(other.kernelId))
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (platform == null) {
|
||||
if (other.platform != null)
|
||||
return false;
|
||||
|
@ -279,7 +403,53 @@ public class Image implements Comparable<Image> {
|
|||
return false;
|
||||
} else if (!ramdiskId.equals(other.ramdiskId))
|
||||
return false;
|
||||
if (rootDeviceName == null) {
|
||||
if (other.rootDeviceName != null)
|
||||
return false;
|
||||
} else if (!rootDeviceName.equals(other.rootDeviceName))
|
||||
return false;
|
||||
if (rootDeviceType == null) {
|
||||
if (other.rootDeviceType != null)
|
||||
return false;
|
||||
} else if (!rootDeviceType.equals(other.rootDeviceType))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The root device type used by the AMI. The AMI can use an Amazon EBS or instance store
|
||||
* root device.
|
||||
*/
|
||||
public RootDeviceType getRootDeviceType() {
|
||||
return rootDeviceType;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getRootDeviceName() {
|
||||
return rootDeviceName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Image [architecture=" + architecture + ", description=" + description
|
||||
+ ", ebsBlockDevices=" + ebsBlockDevices + ", imageId=" + imageId
|
||||
+ ", imageLocation=" + imageLocation + ", imageOwnerId=" + imageOwnerId
|
||||
+ ", imageState=" + imageState + ", imageType=" + imageType + ", isPublic="
|
||||
+ isPublic + ", kernelId=" + kernelId + ", name=" + name + ", platform=" + platform
|
||||
+ ", productCodes=" + productCodes + ", ramdiskId=" + ramdiskId
|
||||
+ ", rootDeviceName=" + rootDeviceName + ", rootDeviceType=" + rootDeviceType + "]";
|
||||
}
|
||||
|
||||
public Map<String, EbsBlockDevice> getEbsBlockDevices() {
|
||||
return ebsBlockDevices;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-LaunchPermissionItemType.html"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class LaunchPermission {
|
||||
private final Set<String> groups = Sets.newHashSet();
|
||||
private final Set<String> userIds = Sets.newHashSet();
|
||||
|
||||
public LaunchPermission(Iterable<String> userIds, Iterable<String> groups) {
|
||||
Iterables.addAll(this.userIds, checkNotNull(userIds, "userIds"));
|
||||
Iterables.addAll(this.groups, checkNotNull(groups, "groups"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((groups == null) ? 0 : groups.hashCode());
|
||||
result = prime * result + ((userIds == null) ? 0 : userIds.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;
|
||||
LaunchPermission other = (LaunchPermission) obj;
|
||||
if (groups == null) {
|
||||
if (other.groups != null)
|
||||
return false;
|
||||
} else if (!groups.equals(other.groups))
|
||||
return false;
|
||||
if (userIds == null) {
|
||||
if (other.userIds != null)
|
||||
return false;
|
||||
} else if (!userIds.equals(other.userIds))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Name of the group. Currently supports \"all.\"
|
||||
*/
|
||||
public Set<String> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return AWS Access Key ID.
|
||||
*/
|
||||
public Set<String> getUserIds() {
|
||||
return userIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LaunchPermission [groups=" + groups + ", userIds=" + userIds + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -110,7 +110,7 @@ public class RunningInstance implements Comparable<RunningInstance> {
|
|||
* more information, go to the Metadata section of the Amazon Elastic Compute Cloud Developer
|
||||
* Guide.
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/2009-08-15/DeveloperGuide/" />
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/2009-11-30/DeveloperGuide/" />
|
||||
*/
|
||||
public String getAmiLaunchIndex() {
|
||||
return amiLaunchIndex;
|
||||
|
|
|
@ -0,0 +1,243 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.aws.ec2.domain.Image.Architecture;
|
||||
|
||||
/**
|
||||
* Contains options supported in the Form API for the RegisterImage operation. <h2>
|
||||
* Usage</h2> The recommended way to instantiate a RegisterImageBackedByEbsOptions object is to statically
|
||||
* import RegisterImageBackedByEbsOptions.Builder.* and invoke a static creation method followed by an instance
|
||||
* mutator (if needed):
|
||||
* <p/>
|
||||
* <code>
|
||||
* import static org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions.Builder.*
|
||||
* <p/>
|
||||
* EC2Client connection = // get connection
|
||||
* String imageId = connection.getImageServices().registerImageBackedByEbs(...addEphemeralBlockDeviceFromSnapshot("/dev/sda2","virtual-1","snapshot-id"));
|
||||
* <code>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-RegisterImage.html"
|
||||
* />
|
||||
*/
|
||||
public class RegisterImageBackedByEbsOptions extends RegisterImageOptions {
|
||||
|
||||
private int deviceIndex = 1;
|
||||
|
||||
/**
|
||||
*
|
||||
* adds a block device to the image from an ebs snapshot. This device is deleted on instance
|
||||
* termination.
|
||||
*
|
||||
* @param name
|
||||
* The device name (e.g., /dev/sdh).
|
||||
* @param virtualName
|
||||
* The virtual device name. (nullable)
|
||||
* @param snapshotId
|
||||
* The ID of the snapshot.
|
||||
*/
|
||||
public RegisterImageBackedByEbsOptions addEphemeralBlockDeviceFromSnapshot(String deviceName,
|
||||
@Nullable String virtualName, String snapshotId) {
|
||||
formParameters.put("BlockDeviceMapping." + deviceIndex + ".DeviceName", checkNotNull(
|
||||
deviceName, "deviceName"));
|
||||
if (virtualName != null)
|
||||
formParameters.put("BlockDeviceMapping." + deviceIndex + ".VirtualName", checkNotNull(
|
||||
virtualName, "virtualName"));
|
||||
formParameters.put("BlockDeviceMapping." + deviceIndex + ".Ebs.SnapshotId", checkNotNull(
|
||||
snapshotId, "snapshotId"));
|
||||
deviceIndex++;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* adds a new block device to the image. This device is deleted on instance termination.
|
||||
*
|
||||
* @param name
|
||||
* The device name (e.g., /dev/sdh).
|
||||
* @param virtualName
|
||||
* The virtual device name.
|
||||
* @param volumeSize
|
||||
* The size of the volume, in GiBs.
|
||||
*/
|
||||
public RegisterImageBackedByEbsOptions addNewEphemeralBlockDevice(String deviceName,
|
||||
@Nullable String virtualName, int volumeSize) {
|
||||
checkArgument(volumeSize > 0 && volumeSize < 1025, "volumeSize must be between 1 and 1024 gb");
|
||||
formParameters.put("BlockDeviceMapping." + deviceIndex + ".DeviceName", checkNotNull(
|
||||
deviceName, "deviceName"));
|
||||
if (virtualName != null)
|
||||
formParameters.put("BlockDeviceMapping." + deviceIndex + ".VirtualName", checkNotNull(
|
||||
virtualName, "virtualName"));
|
||||
formParameters.put("BlockDeviceMapping." + deviceIndex + ".Ebs.VolumeSize", volumeSize + "");
|
||||
deviceIndex++;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* adds a block device to the image from an ebs snapshot. This device is retained on instance
|
||||
* termination.
|
||||
*
|
||||
* @param name
|
||||
* The device name (e.g., /dev/sdh).
|
||||
* @param virtualName
|
||||
* The virtual device name. (nullable)
|
||||
* @param snapshotId
|
||||
* The ID of the snapshot.
|
||||
*/
|
||||
public RegisterImageBackedByEbsOptions addBlockDeviceFromSnapshot(String deviceName,
|
||||
@Nullable String virtualName, String snapshotId) {
|
||||
formParameters.put("BlockDeviceMapping." + deviceIndex + ".Ebs.DeleteOnTermination", "false");
|
||||
addEphemeralBlockDeviceFromSnapshot(deviceName, virtualName, snapshotId);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* adds a new block device to the image. This device is retained on instance termination.
|
||||
*
|
||||
* @param name
|
||||
* The device name (e.g., /dev/sdh).
|
||||
* @param virtualName
|
||||
* The virtual device name.
|
||||
* @param volumeSize
|
||||
* The size of the volume, in GiBs..
|
||||
*/
|
||||
public RegisterImageBackedByEbsOptions addNewBlockDevice(String deviceName,
|
||||
@Nullable String virtualName, int volumeSize) {
|
||||
formParameters.put("BlockDeviceMapping." + deviceIndex + ".Ebs.DeleteOnTermination", "false");
|
||||
addNewEphemeralBlockDevice(deviceName, virtualName, volumeSize);
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
/**
|
||||
* @see RegisterImageBackedByEbsOptions#asArchitecture(Architecture)
|
||||
*/
|
||||
public static RegisterImageBackedByEbsOptions asArchitecture(Architecture architecture) {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
return options.asArchitecture(architecture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see RegisterImageBackedByEbsOptions#withDescription(String)
|
||||
*/
|
||||
public static RegisterImageBackedByEbsOptions withDescription(String additionalInfo) {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
return options.withDescription(additionalInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see RegisterImageBackedByEbsOptions#withKernelId(String)
|
||||
*/
|
||||
public static RegisterImageBackedByEbsOptions withKernelId(String kernelId) {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
return options.withKernelId(kernelId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see RegisterImageBackedByEbsOptions#withRamdisk(String)
|
||||
*/
|
||||
public static RegisterImageBackedByEbsOptions withRamdisk(String ramdiskId) {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
return options.withRamdisk(ramdiskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see RegisterImageBackedByEbsOptions#addBlockDeviceFromSnapshot(String, String, String)
|
||||
*/
|
||||
public static RegisterImageBackedByEbsOptions addBlockDeviceFromSnapshot(String deviceName,
|
||||
@Nullable String virtualName, String snapshotId) {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
return options.addBlockDeviceFromSnapshot(deviceName, virtualName, snapshotId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see RegisterImageBackedByEbsOptions#addEphemeralBlockDeviceFromSnapshot(String, String,
|
||||
* String)
|
||||
*/
|
||||
public static RegisterImageBackedByEbsOptions addEphemeralBlockDeviceFromSnapshot(
|
||||
String deviceName, @Nullable String virtualName, String snapshotId) {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
return options.addEphemeralBlockDeviceFromSnapshot(deviceName, virtualName, snapshotId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see RegisterImageBackedByEbsOptions#addNewBlockDevice(String, String, int)
|
||||
*/
|
||||
public static RegisterImageBackedByEbsOptions addNewBlockDevice(String deviceName,
|
||||
@Nullable String virtualName, int volumeSize) {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
return options.addNewBlockDevice(deviceName, virtualName, volumeSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see RegisterImageBackedByEbsOptions#addNewEphemeralBlockDevice(String, String, int)
|
||||
*/
|
||||
public static RegisterImageBackedByEbsOptions addNewEphemeralBlockDevice(String deviceName,
|
||||
@Nullable String virtualName, int volumeSize) {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
return options.addNewEphemeralBlockDevice(deviceName, virtualName, volumeSize);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public RegisterImageBackedByEbsOptions asArchitecture(Architecture architecture) {
|
||||
return (RegisterImageBackedByEbsOptions) super.asArchitecture(architecture);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public RegisterImageBackedByEbsOptions withDescription(String info) {
|
||||
return (RegisterImageBackedByEbsOptions) super.withDescription(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public RegisterImageBackedByEbsOptions withKernelId(String kernelId) {
|
||||
return (RegisterImageBackedByEbsOptions) super.withKernelId(kernelId);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public RegisterImageBackedByEbsOptions withRamdisk(String ramDiskId) {
|
||||
return (RegisterImageBackedByEbsOptions) super.withRamdisk(ramDiskId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.aws.ec2.domain.Image.Architecture;
|
||||
import org.jclouds.aws.ec2.options.internal.BaseEC2RequestOptions;
|
||||
|
||||
/**
|
||||
* Contains options supported in the Form API for the RegisterImage operation. <h2>
|
||||
* Usage</h2> The recommended way to instantiate a RegisterImageOptions object is to statically
|
||||
* import RegisterImageOptions.Builder.* and invoke a static creation method followed by an instance
|
||||
* mutator (if needed):
|
||||
* <p/>
|
||||
* <code>
|
||||
* import static org.jclouds.aws.ec2.options.RegisterImageOptions.Builder.*
|
||||
* <p/>
|
||||
* EC2Client connection = // get connection
|
||||
* String imageId = connection.getImageServices().registerImageFromManifest(...withArchitecture(Architecture.I386).withDescription("description"));
|
||||
* <code>
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see <a
|
||||
* href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-RegisterImage.html"
|
||||
* />
|
||||
*/
|
||||
public class RegisterImageOptions extends BaseEC2RequestOptions {
|
||||
|
||||
/**
|
||||
* The architecture of the image.
|
||||
*/
|
||||
public RegisterImageOptions asArchitecture(Architecture architecture) {
|
||||
formParameters.put("Architecture", checkNotNull(architecture, "architecture").value());
|
||||
return this;
|
||||
}
|
||||
|
||||
String getArchitecture() {
|
||||
return getFirstFormOrNull("Architecture");
|
||||
}
|
||||
|
||||
/**
|
||||
*The description of the AMI. "Up to 255 characters."
|
||||
*/
|
||||
public RegisterImageOptions withDescription(String info) {
|
||||
formParameters.put("Description", checkNotNull(info, "info"));
|
||||
return this;
|
||||
}
|
||||
|
||||
String getDescription() {
|
||||
return getFirstFormOrNull("Description");
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the kernel to select.
|
||||
*/
|
||||
public RegisterImageOptions withKernelId(String kernelId) {
|
||||
formParameters.put("KernelId", checkNotNull(kernelId, "kernelId"));
|
||||
return this;
|
||||
}
|
||||
|
||||
String getKernelId() {
|
||||
return getFirstFormOrNull("KernelId");
|
||||
}
|
||||
|
||||
/**
|
||||
* The ID of the RAM disk to select. Some kernels require additional drivers at launch. Check the
|
||||
* kernel requirements for information on whether you need to specify a RAM disk. To find kernel
|
||||
* requirements, refer to the Resource Center and search for the kernel ID.
|
||||
*/
|
||||
public RegisterImageOptions withRamdisk(String ramDiskId) {
|
||||
formParameters.put("RamdiskId", checkNotNull(ramDiskId, "ramDiskId"));
|
||||
return this;
|
||||
}
|
||||
|
||||
String getRamdiskId() {
|
||||
return getFirstFormOrNull("RamdiskId");
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
/**
|
||||
* @see RegisterImageOptions#asArchitecture(Architecture)
|
||||
*/
|
||||
public static RegisterImageOptions asArchitecture(Architecture architecture) {
|
||||
RegisterImageOptions options = new RegisterImageOptions();
|
||||
return options.asArchitecture(architecture);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see RegisterImageOptions#withDescription(String)
|
||||
*/
|
||||
public static RegisterImageOptions withDescription(String additionalInfo) {
|
||||
RegisterImageOptions options = new RegisterImageOptions();
|
||||
return options.withDescription(additionalInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see RegisterImageOptions#withKernelId(String)
|
||||
*/
|
||||
public static RegisterImageOptions withKernelId(String kernelId) {
|
||||
RegisterImageOptions options = new RegisterImageOptions();
|
||||
return options.withKernelId(kernelId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see RegisterImageOptions#withRamdisk(String)
|
||||
*/
|
||||
public static RegisterImageOptions withRamdisk(String ramdiskId) {
|
||||
RegisterImageOptions options = new RegisterImageOptions();
|
||||
return options.withRamdisk(ramdiskId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -26,7 +26,8 @@ package org.jclouds.aws.ec2.services;
|
|||
import static org.jclouds.aws.ec2.reference.EC2Parameters.ACTION;
|
||||
import static org.jclouds.aws.ec2.reference.EC2Parameters.VERSION;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.ws.rs.FormParam;
|
||||
|
@ -34,12 +35,23 @@ import javax.ws.rs.POST;
|
|||
import javax.ws.rs.Path;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.ec2.binders.BindProductCodesToIndexedFormParams;
|
||||
import org.jclouds.aws.ec2.binders.BindUserGroupsToIndexedFormParams;
|
||||
import org.jclouds.aws.ec2.binders.BindUserIdsToIndexedFormParams;
|
||||
import org.jclouds.aws.ec2.domain.Image;
|
||||
import org.jclouds.aws.ec2.domain.ImageAttribute;
|
||||
import org.jclouds.aws.ec2.domain.LaunchPermission;
|
||||
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
|
||||
import org.jclouds.aws.ec2.filters.FormSigner;
|
||||
import org.jclouds.aws.ec2.options.CreateImageOptions;
|
||||
import org.jclouds.aws.ec2.options.DescribeImagesOptions;
|
||||
import org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions;
|
||||
import org.jclouds.aws.ec2.options.RegisterImageOptions;
|
||||
import org.jclouds.aws.ec2.xml.BlockDeviceMappingHandler;
|
||||
import org.jclouds.aws.ec2.xml.DescribeImagesResponseHandler;
|
||||
import org.jclouds.aws.ec2.xml.ImageIdHandler;
|
||||
import org.jclouds.aws.ec2.xml.LaunchPermissionHandler;
|
||||
import org.jclouds.aws.ec2.xml.ProductCodesHandler;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.Endpoint;
|
||||
import org.jclouds.rest.annotations.FormParams;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
|
@ -65,16 +77,7 @@ public interface AMIAsyncClient {
|
|||
@Path("/")
|
||||
@FormParams(keys = ACTION, values = "DescribeImages")
|
||||
@XMLResponseParser(DescribeImagesResponseHandler.class)
|
||||
Future<? extends SortedSet<Image>> describeImages(DescribeImagesOptions... options);
|
||||
|
||||
/**
|
||||
* @see AMIClient#describeImages
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = ACTION, values = "DescribeImageAttribute")
|
||||
Future<String> describeImageAttribute(@FormParam("ImageId") String imageId,
|
||||
@FormParam("Attribute") ImageAttribute attribute);
|
||||
Future<? extends Set<Image>> describeImages(DescribeImagesOptions... options);
|
||||
|
||||
/**
|
||||
* @see AMIClient#createImage
|
||||
|
@ -82,6 +85,121 @@ public interface AMIAsyncClient {
|
|||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = ACTION, values = "CreateImage")
|
||||
@XMLResponseParser(ImageIdHandler.class)
|
||||
Future<String> createImage(@FormParam("Name") String name,
|
||||
@FormParam("InstanceId") String instanceId, CreateImageOptions... options);
|
||||
|
||||
/**
|
||||
* @see AMIClient#deregisterImage
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = ACTION, values = "DeregisterImage")
|
||||
Future<Void> deregisterImage(@FormParam("ImageId") String imageId);
|
||||
|
||||
/**
|
||||
* @see AMIClient#registerImageFromManifest
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = ACTION, values = "RegisterImage")
|
||||
@XMLResponseParser(ImageIdHandler.class)
|
||||
Future<String> registerImageFromManifest(@FormParam("Name") String imageName,
|
||||
@FormParam("ImageLocation") String pathToManifest, RegisterImageOptions... options);
|
||||
|
||||
/**
|
||||
* @see AMIClient#registerImageBackedByEbs
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = { ACTION, "RootDeviceName", "BlockDeviceMapping.0.DeviceName" }, values = {
|
||||
"RegisterImage", "/dev/sda1", "/dev/sda1" })
|
||||
@XMLResponseParser(ImageIdHandler.class)
|
||||
Future<String> registerImageBackedByEbs(@FormParam("Name") String imageName,
|
||||
@FormParam("BlockDeviceMapping.0.Ebs.SnapshotId") String ebsSnapshotId,
|
||||
RegisterImageBackedByEbsOptions... options);
|
||||
|
||||
/**
|
||||
* @see AMIClient#resetLaunchPermissionsOnImage
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "ResetImageAttribute", "launchPermission" })
|
||||
Future<Void> resetLaunchPermissionsOnImage(@FormParam("ImageId") String imageId);
|
||||
|
||||
/**
|
||||
* @see AMIClient#addLaunchPermissionsToImage
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
||||
"add", "launchPermission" })
|
||||
Future<Void> addLaunchPermissionsToImage(
|
||||
@BinderParam(BindUserIdsToIndexedFormParams.class) Iterable<String> userIds,
|
||||
@BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable<String> userGroups,
|
||||
@FormParam("ImageId") String imageId);
|
||||
|
||||
/**
|
||||
* @see AMIClient#removeLaunchPermissionsToImage
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
||||
"remove", "launchPermission" })
|
||||
Future<Void> removeLaunchPermissionsFromImage(
|
||||
@BinderParam(BindUserIdsToIndexedFormParams.class) Iterable<String> userIds,
|
||||
@BinderParam(BindUserGroupsToIndexedFormParams.class) Iterable<String> userGroups,
|
||||
@FormParam("ImageId") String imageId);
|
||||
|
||||
/**
|
||||
* @see AMIClient#getLaunchPermissionForImage
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeImageAttribute",
|
||||
"launchPermission" })
|
||||
@XMLResponseParser(LaunchPermissionHandler.class)
|
||||
Future<LaunchPermission> getLaunchPermissionForImage(@FormParam("ImageId") String imageId);
|
||||
|
||||
/**
|
||||
* @see AMIClient#getProductCodesForImage
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeImageAttribute", "productCodes" })
|
||||
@XMLResponseParser(ProductCodesHandler.class)
|
||||
Future<? extends Set<String>> getProductCodesForImage(@FormParam("ImageId") String imageId);
|
||||
|
||||
/**
|
||||
* @see AMIClient#getBlockDeviceMappingsForImage
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = { ACTION, "Attribute" }, values = { "DescribeImageAttribute",
|
||||
"blockDeviceMapping" })
|
||||
@XMLResponseParser(BlockDeviceMappingHandler.class)
|
||||
Future<? extends Map<String, EbsBlockDevice>> getBlockDeviceMappingsForImage(
|
||||
@FormParam("ImageId") String imageId);
|
||||
|
||||
/**
|
||||
* @see AMIClient#addProductCodesToImage
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
||||
"add", "productCodes" })
|
||||
Future<Void> addProductCodesToImage(
|
||||
@BinderParam(BindProductCodesToIndexedFormParams.class) Iterable<String> productCodes,
|
||||
@FormParam("ImageId") String imageId);
|
||||
|
||||
/**
|
||||
* @see AMIClient#removeProductCodesToImage
|
||||
*/
|
||||
@POST
|
||||
@Path("/")
|
||||
@FormParams(keys = { ACTION, "OperationType", "Attribute" }, values = { "ModifyImageAttribute",
|
||||
"remove", "productCodes" })
|
||||
Future<Void> removeProductCodesFromImage(
|
||||
@BinderParam(BindProductCodesToIndexedFormParams.class) Iterable<String> productCodes,
|
||||
@FormParam("ImageId") String imageId);
|
||||
}
|
||||
|
|
|
@ -23,13 +23,17 @@
|
|||
*/
|
||||
package org.jclouds.aws.ec2.services;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.aws.ec2.domain.Image;
|
||||
import org.jclouds.aws.ec2.domain.ImageAttribute;
|
||||
import org.jclouds.aws.ec2.domain.LaunchPermission;
|
||||
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
|
||||
import org.jclouds.aws.ec2.options.CreateImageOptions;
|
||||
import org.jclouds.aws.ec2.options.DescribeImagesOptions;
|
||||
import org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions;
|
||||
import org.jclouds.aws.ec2.options.RegisterImageOptions;
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
|
||||
/**
|
||||
|
@ -54,16 +58,13 @@ public interface AMIClient {
|
|||
* @see DescribeImagesOptions
|
||||
*/
|
||||
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||
SortedSet<Image> describeImages(DescribeImagesOptions... options);
|
||||
Set<Image> describeImages(DescribeImagesOptions... options);
|
||||
|
||||
/**
|
||||
* Returns information about an attribute of an AMI. Only one attribute can be specified per
|
||||
* call.
|
||||
* Returns the {@link LaunchPermission}s of an image.
|
||||
*
|
||||
* @param imageId
|
||||
* The ID of the AMI for which an attribute will be described
|
||||
* @param attribute
|
||||
* the attribute to describe
|
||||
* @see #describeImages
|
||||
* @see #modifyImageAttribute
|
||||
* @see #resetImageAttribute
|
||||
|
@ -71,21 +72,218 @@ public interface AMIClient {
|
|||
* />
|
||||
* @see DescribeImagesOptions
|
||||
*/
|
||||
String describeImageAttribute(String imageId, ImageAttribute attribute);
|
||||
LaunchPermission getLaunchPermissionForImage(String imageId);
|
||||
|
||||
/**
|
||||
* Returns the Product Codes of an image.
|
||||
*
|
||||
* @param imageId
|
||||
* The ID of the AMI for which an attribute will be described
|
||||
* @see #describeImages
|
||||
* @see #modifyImageAttribute
|
||||
* @see #resetImageAttribute
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeImageAttribute.html"
|
||||
* />
|
||||
* @see DescribeImagesOptions
|
||||
*/
|
||||
Set<String> getProductCodesForImage(String imageId);
|
||||
|
||||
/**
|
||||
* Returns a map of device name to block device for the image.
|
||||
*
|
||||
* @param imageId
|
||||
* The ID of the AMI for which an attribute will be described
|
||||
* @see #describeImages
|
||||
* @see #modifyImageAttribute
|
||||
* @see #resetImageAttribute
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeImageAttribute.html"
|
||||
* />
|
||||
* @see DescribeImagesOptions
|
||||
*/
|
||||
Map<String, EbsBlockDevice> getBlockDeviceMappingsForImage(String imageId);
|
||||
|
||||
/**
|
||||
* Creates an AMI that uses an Amazon EBS root device from a "running" or "stopped" instance.
|
||||
*
|
||||
* @param name The name of the AMI that was provided during image creation. 3-128 alphanumeric characters, parenthesis (()), commas (,), slashes (/), dashes (-), or underscores(_)
|
||||
* @param instanceId The ID of the instance.
|
||||
* @param name
|
||||
* The name of the AMI that was provided during image creation. 3-128 alphanumeric
|
||||
* characters, parenthesis (()), commas (,), slashes (/), dashes (-), or underscores(_)
|
||||
* @param instanceId
|
||||
* The ID of the instance.
|
||||
* @return imageId
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeImages.html"
|
||||
* />
|
||||
* @see CreateImageOptions
|
||||
* @see InstanceClient#runInstances
|
||||
* @see InstanceClient#describeInstances
|
||||
* @see InstanceClient#terminateInstances
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateImage.html"
|
||||
* @see <a href=
|
||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateImage.html"
|
||||
* />
|
||||
*/
|
||||
String createImage(String name, String instanceId, CreateImageOptions... options);
|
||||
|
||||
/**
|
||||
*
|
||||
* Deregisters the specified AMI. Once deregistered, the AMI cannot be used to launch new
|
||||
* instances.
|
||||
*
|
||||
* @param imageId
|
||||
* Unique ID of the AMI which was assigned during registration. To register an AMI, use
|
||||
* RegisterImage. To view the AMI IDs of AMIs that belong to your account. use
|
||||
* DescribeImages.
|
||||
*
|
||||
* @see #describeImages
|
||||
* @see #registerImage
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DeregisterImage.html"
|
||||
* />
|
||||
*/
|
||||
void deregisterImage(String imageId);
|
||||
|
||||
/**
|
||||
* Registers an AMI with Amazon EC2. Images must be registered before they can be launched. To
|
||||
* launch instances, use the {@link InstanceClient#runInstances} operation.
|
||||
* <p/>
|
||||
* Each AMI is associated with an unique ID which is provided by the Amazon EC2 service through
|
||||
* this operation. If needed, you can deregister an AMI at any time.
|
||||
* <p/>
|
||||
* <h3>Note</h3> Any modifications to an AMI backed by Amazon S3 invalidates this registration.
|
||||
* If you make changes to an image, deregister the previous image and register the new image.
|
||||
*
|
||||
* @param name
|
||||
* The name of the AMI that was provided during image creation. 3-128 alphanumeric
|
||||
* characters, parenthesis (()), commas (,), slashes (/), dashes (-), or underscores(_)
|
||||
* @param pathToManifest
|
||||
* Full path to your AMI manifest in Amazon S3 storage.
|
||||
* @param options
|
||||
* Options to specify metadata such as architecture or secondary volumes to be
|
||||
* associated with this image.
|
||||
* @return imageId
|
||||
*
|
||||
* @see #describeImages
|
||||
* @see #deregisterImage
|
||||
* @see <a href=
|
||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RegisterImage.html"
|
||||
* />
|
||||
*/
|
||||
String registerImageFromManifest(String name, String pathToManifest,
|
||||
RegisterImageOptions... options);
|
||||
|
||||
/**
|
||||
* Registers an AMI with Amazon EC2. Images must be registered before they can be launched. To
|
||||
* launch instances, use the {@link InstanceClient#runInstances} operation. The root device name
|
||||
* is /dev/sda1
|
||||
* <p/>
|
||||
* Each AMI is associated with an unique ID which is provided by the Amazon EC2 service through
|
||||
* this operation. If needed, you can deregister an AMI at any time.
|
||||
* <p/>
|
||||
* <h3>Note</h3> AMIs backed by Amazon EBS are automatically registered when you create the
|
||||
* image. However, you can use this to register a snapshot of an instance backed by Amazon EBS.
|
||||
* <p/>
|
||||
* Amazon EBS snapshots are not guaranteed to be bootable.
|
||||
*
|
||||
* @param name
|
||||
* The name of the AMI that was provided during image creation. 3-128 alphanumeric
|
||||
* characters, parenthesis (()), commas (,), slashes (/), dashes (-), or underscores(_)
|
||||
*
|
||||
* @param ebsSnapshotId
|
||||
* The id of the root snapshot (e.g., snap-6eba6e06).
|
||||
* @param options
|
||||
* Options to specify metadata such as architecture or secondary volumes to be
|
||||
* associated with this image.
|
||||
* @return imageId
|
||||
*
|
||||
* @see #describeImages
|
||||
* @see #deregisterImage
|
||||
* @see <a href=
|
||||
* "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-RegisterImage.html"
|
||||
* />
|
||||
*/
|
||||
String registerImageBackedByEbs(String name, String ebsSnapshotId,
|
||||
RegisterImageBackedByEbsOptions... options);
|
||||
|
||||
/**
|
||||
* Adds {@code launchPermission}s to an AMI.
|
||||
*
|
||||
* @param userIds
|
||||
* AWS Access Key ID.
|
||||
* @param userGroups
|
||||
* Name of the groups. Currently supports \"all.\""
|
||||
* @param imageId
|
||||
* The AMI ID.
|
||||
*
|
||||
* @see #removeLaunchPermissionsFromImage
|
||||
* @see #describeImageAttribute
|
||||
* @see #resetImageAttribute
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
||||
* />
|
||||
*/
|
||||
void addLaunchPermissionsToImage(Iterable<String> userIds, Iterable<String> userGroups,
|
||||
String imageId);
|
||||
|
||||
/**
|
||||
* Resets the {@code launchPermission}s on an AMI.
|
||||
*
|
||||
* @param imageId
|
||||
* ID of the AMI on which the attribute will be reset.
|
||||
*
|
||||
* @see #addLaunchPermissionsToImage
|
||||
* @see #describeImageAttribute
|
||||
* @see #removeProductCodesFromImage
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ResetImageAttribute.html"
|
||||
* />
|
||||
*/
|
||||
void resetLaunchPermissionsOnImage(String imageId);
|
||||
|
||||
/**
|
||||
* Removes {@code launchPermission}s from an AMI.
|
||||
*
|
||||
* @param userIds
|
||||
* AWS Access Key ID.
|
||||
* @param userGroups
|
||||
* Name of the groups. Currently supports \"all.\""
|
||||
* @param imageId
|
||||
* The AMI ID.
|
||||
*
|
||||
* @see #addLaunchPermissionsToImage
|
||||
* @see #describeImageAttribute
|
||||
* @see #resetImageAttribute
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
||||
* />
|
||||
*/
|
||||
void removeLaunchPermissionsFromImage(Iterable<String> userIds, Iterable<String> userGroups,
|
||||
String imageId);
|
||||
|
||||
/**
|
||||
* Adds {@code productCode}s to an AMI.
|
||||
*
|
||||
* @param productCodes
|
||||
* Product Codes
|
||||
* @param imageId
|
||||
* The AMI ID.
|
||||
*
|
||||
* @see #removeProductCodesFromImage
|
||||
* @see #describeImageAttribute
|
||||
* @see #resetImageAttribute
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
||||
* />
|
||||
*/
|
||||
void addProductCodesToImage(Iterable<String> productCodes, String imageId);
|
||||
|
||||
/**
|
||||
* Removes {@code productCode}s from an AMI.
|
||||
*
|
||||
* @param productCodes
|
||||
* Product Codes
|
||||
* @param imageId
|
||||
* The AMI ID.
|
||||
*
|
||||
* @see #addProductCodesToImage
|
||||
* @see #describeImageAttribute
|
||||
* @see #resetImageAttribute
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyImageAttribute.html"
|
||||
* />
|
||||
*/
|
||||
void removeProductCodesFromImage(Iterable<String> productCodes, String imageId);
|
||||
}
|
||||
|
|
|
@ -33,13 +33,25 @@ import org.jclouds.rest.internal.GeneratedHttpRequest;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
public class EC2Utils {
|
||||
public static void indexFormValuesWithPrefix(GeneratedHttpRequest<?> request, String prefix,
|
||||
Object input) {
|
||||
public static void indexStringArrayToFormValuesWithPrefix(GeneratedHttpRequest<?> request,
|
||||
String prefix, Object input) {
|
||||
checkArgument(checkNotNull(input, "input") instanceof String[],
|
||||
"this binder is only valid for String[] : " + input.getClass());
|
||||
String[] values = (String[]) input;
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
request.addFormParam(prefix + "." + (i + 1), checkNotNull(values[i], prefix
|
||||
request.addFormParam(prefix + "." + (i + 1), checkNotNull(values[i], prefix.toLowerCase()
|
||||
+ "s[" + i + "]"));
|
||||
}
|
||||
}
|
||||
|
||||
public static void indexIterableToFormValuesWithPrefix(GeneratedHttpRequest<?> request,
|
||||
String prefix, Object input) {
|
||||
checkArgument(checkNotNull(input, "input") instanceof Iterable<?>,
|
||||
"this binder is only valid for Iterable<?>: " + input.getClass());
|
||||
Iterable<?> values = (Iterable<?>) input;
|
||||
int i = 0;
|
||||
for (Object o : values) {
|
||||
request.addFormParam(prefix + "." + (i++ + 1), checkNotNull(o.toString(), prefix
|
||||
.toLowerCase()
|
||||
+ "s[" + i + "]"));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 java.util.Map;
|
||||
|
||||
import org.jclouds.aws.ec2.domain.Image;
|
||||
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class BlockDeviceMappingHandler extends
|
||||
ParseSax.HandlerWithResult<Map<String, EbsBlockDevice>> {
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
|
||||
private Map<String, EbsBlockDevice> ebsBlockDevices = Maps.newHashMap();
|
||||
private String deviceName;
|
||||
private String snapshotId;
|
||||
private int volumeSize;
|
||||
private boolean deleteOnTermination = true;// correct default is true.
|
||||
|
||||
public Map<String, EbsBlockDevice> getResult() {
|
||||
return ebsBlockDevices;
|
||||
}
|
||||
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
if (qName.equals("deviceName")) {
|
||||
deviceName = currentText.toString().trim();
|
||||
} else if (qName.equals("snapshotId")) {
|
||||
snapshotId = currentText.toString().trim();
|
||||
} else if (qName.equals("volumeSize")) {
|
||||
volumeSize = Integer.parseInt(currentText.toString().trim());
|
||||
} else if (qName.equals("deleteOnTermination")) {
|
||||
deleteOnTermination = Boolean.parseBoolean(currentText.toString().trim());
|
||||
} else if (qName.equals("item")) {
|
||||
ebsBlockDevices.put(deviceName, new Image.EbsBlockDevice(snapshotId, volumeSize,
|
||||
deleteOnTermination));
|
||||
this.snapshotId = null;
|
||||
this.volumeSize = 0;
|
||||
this.deleteOnTermination = true;
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
public void characters(char ch[], int start, int length) {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
}
|
|
@ -23,68 +23,87 @@
|
|||
*/
|
||||
package org.jclouds.aws.ec2.xml;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.jclouds.aws.ec2.domain.Image;
|
||||
import org.jclouds.aws.ec2.domain.Image.Architecture;
|
||||
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
|
||||
import org.jclouds.aws.ec2.domain.Image.ImageState;
|
||||
import org.jclouds.aws.ec2.domain.Image.ImageType;
|
||||
import org.jclouds.aws.ec2.domain.Image.RootDeviceType;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.internal.Nullable;
|
||||
|
||||
/**
|
||||
* Parses the following XML document:
|
||||
* <p/>
|
||||
* DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2009-08-15/"
|
||||
* DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/"
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeImages.html"
|
||||
* />
|
||||
*/
|
||||
public class DescribeImagesResponseHandler extends ParseSax.HandlerWithResult<SortedSet<Image>> {
|
||||
public class DescribeImagesResponseHandler extends ParseSax.HandlerWithResult<Set<Image>> {
|
||||
@Resource
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
private SortedSet<Image> contents = Sets.newTreeSet();
|
||||
private Set<Image> contents = Sets.newHashSet();
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
|
||||
private Architecture architecture;
|
||||
private String name;
|
||||
private String description;
|
||||
private String imageId;
|
||||
private String imageLocation;
|
||||
private String imageOwnerId;
|
||||
private ImageState imageState;
|
||||
private ImageType imageType;
|
||||
private boolean isPublic;
|
||||
private @Nullable
|
||||
String kernelId;
|
||||
private String kernelId;
|
||||
private String platform;
|
||||
private Set<String> productCodes = Sets.newHashSet();
|
||||
private @Nullable
|
||||
String ramdiskId;
|
||||
private String ramdiskId;
|
||||
private boolean inProductCodes;
|
||||
private boolean inBlockDeviceMapping;
|
||||
private RootDeviceType rootDeviceType;
|
||||
private Map<String, EbsBlockDevice> ebsBlockDevices = Maps.newHashMap();
|
||||
private String deviceName;
|
||||
private String snapshotId;
|
||||
private int volumeSize;
|
||||
private boolean deleteOnTermination = true;// correct default is true.
|
||||
|
||||
public SortedSet<Image> getResult() {
|
||||
private String rootDeviceName;
|
||||
|
||||
public Set<Image> getResult() {
|
||||
return contents;
|
||||
}
|
||||
|
||||
public void startElement(String uri, String name, String qName, Attributes attrs) {
|
||||
if (qName.equals("productCodesSet")) {
|
||||
if (qName.equals("productCodes")) {
|
||||
inProductCodes = true;
|
||||
} else if (qName.equals("blockDeviceMapping")) {
|
||||
inBlockDeviceMapping = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
if (qName.equals("architecture")) {
|
||||
architecture = Architecture.fromValue(currentText.toString().trim());
|
||||
} else if (qName.equals("name")) {
|
||||
this.name = currentText.toString().trim();
|
||||
} else if (qName.equals("description")) {
|
||||
description = currentText.toString().trim();
|
||||
} else if (qName.equals("imageId")) {
|
||||
imageId = currentText.toString().trim();
|
||||
} else if (qName.equals("deviceName")) {
|
||||
deviceName = currentText.toString().trim();
|
||||
} else if (qName.equals("imageLocation")) {
|
||||
imageLocation = currentText.toString().trim();
|
||||
} else if (qName.equals("imageOwnerId")) {
|
||||
|
@ -101,19 +120,39 @@ public class DescribeImagesResponseHandler extends ParseSax.HandlerWithResult<So
|
|||
platform = currentText.toString().trim();
|
||||
} else if (qName.equals("productCode")) {
|
||||
productCodes.add(currentText.toString().trim());
|
||||
} else if (qName.equals("productCodesSet")) {
|
||||
} else if (qName.equals("productCodes")) {
|
||||
inProductCodes = false;
|
||||
} else if (qName.equals("blockDeviceMapping")) {
|
||||
inBlockDeviceMapping = false;
|
||||
} else if (qName.equals("snapshotId")) {
|
||||
snapshotId = currentText.toString().trim();
|
||||
} else if (qName.equals("volumeSize")) {
|
||||
volumeSize = Integer.parseInt(currentText.toString().trim());
|
||||
} else if (qName.equals("deleteOnTermination")) {
|
||||
deleteOnTermination = Boolean.parseBoolean(currentText.toString().trim());
|
||||
} else if (qName.equals("ramdiskId")) {
|
||||
ramdiskId = currentText.toString().trim();
|
||||
} else if (qName.equals("rootDeviceType")) {
|
||||
rootDeviceType = RootDeviceType.fromValue(currentText.toString().trim());
|
||||
} else if (qName.equals("rootDeviceName")) {
|
||||
rootDeviceName = currentText.toString().trim();
|
||||
} else if (qName.equals("item")) {
|
||||
if (!inProductCodes) {
|
||||
if (inBlockDeviceMapping) {
|
||||
ebsBlockDevices.put(deviceName, new Image.EbsBlockDevice(snapshotId, volumeSize,
|
||||
deleteOnTermination));
|
||||
this.snapshotId = null;
|
||||
this.volumeSize = 0;
|
||||
this.deleteOnTermination = true;
|
||||
} else if (!inProductCodes) {
|
||||
try {
|
||||
contents.add(new Image(architecture, imageId, imageLocation, imageOwnerId,
|
||||
imageState, imageType, isPublic, kernelId, platform, productCodes,
|
||||
ramdiskId));
|
||||
contents.add(new Image(architecture, this.name, description, imageId, imageLocation,
|
||||
imageOwnerId, imageState, imageType, isPublic, productCodes, kernelId,
|
||||
platform, ramdiskId, rootDeviceType, rootDeviceName, ebsBlockDevices));
|
||||
} catch (NullPointerException e) {
|
||||
logger.warn(e, "malformed image: %s", imageId);
|
||||
}
|
||||
this.name = null;
|
||||
this.description = null;
|
||||
this.architecture = null;
|
||||
this.imageId = null;
|
||||
this.imageLocation = null;
|
||||
|
@ -125,6 +164,9 @@ public class DescribeImagesResponseHandler extends ParseSax.HandlerWithResult<So
|
|||
this.platform = null;
|
||||
this.productCodes = Sets.newHashSet();
|
||||
this.ramdiskId = null;
|
||||
this.rootDeviceType = null;
|
||||
this.rootDeviceName = null;
|
||||
this.ebsBlockDevices = Maps.newHashMap();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.jclouds.http.functions.ParseSax;
|
|||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Parses: DescribeKeyPairsResponse xmlns="http://ec2.amazonaws.com/doc/2009-08-15/"
|
||||
* Parses: DescribeKeyPairsResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/"
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeKeyPairs.html"
|
||||
* />
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.xml.sax.Attributes;
|
|||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Parses: DescribeSecurityGroupsResponse xmlns="http://ec2.amazonaws.com/doc/2009-08-15/"
|
||||
* Parses: DescribeSecurityGroupsResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/"
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeSecurityGroups.html"
|
||||
* />
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-RegisterImage.html"
|
||||
* />
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-CreateImage.html"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ImageIdHandler extends ParseSax.HandlerWithResult<String> {
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private String imageId;
|
||||
|
||||
public String getResult() {
|
||||
return imageId;
|
||||
}
|
||||
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
|
||||
if (qName.equalsIgnoreCase("ImageId")) {
|
||||
this.imageId = currentText.toString().trim();
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
public void characters(char ch[], int start, int length) {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 java.util.Set;
|
||||
|
||||
import org.jclouds.aws.ec2.domain.LaunchPermission;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeImageAttribute.html"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class LaunchPermissionHandler extends ParseSax.HandlerWithResult<LaunchPermission> {
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private Set<String> userIds = Sets.newHashSet();
|
||||
private Set<String> groups = Sets.newHashSet();
|
||||
|
||||
public LaunchPermission getResult() {
|
||||
return new LaunchPermission(userIds, groups);
|
||||
}
|
||||
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
|
||||
if (qName.equalsIgnoreCase("group")) {
|
||||
groups.add(currentText.toString().trim());
|
||||
} else if (qName.equalsIgnoreCase("userId")) {
|
||||
userIds.add(currentText.toString().trim());
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
public void characters(char ch[], int start, int length) {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 java.util.Set;
|
||||
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
*
|
||||
* @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-query-DescribeImageAttribute.html"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ProductCodesHandler extends ParseSax.HandlerWithResult<Set<String>> {
|
||||
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private Set<String> productCodes = Sets.newHashSet();
|
||||
|
||||
public Set<String> getResult() {
|
||||
return productCodes;
|
||||
}
|
||||
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
|
||||
if (qName.equalsIgnoreCase("productCode")) {
|
||||
productCodes.add(currentText.toString().trim());
|
||||
}
|
||||
currentText = new StringBuilder();
|
||||
}
|
||||
|
||||
public void characters(char ch[], int start, int length) {
|
||||
currentText.append(ch, start, length);
|
||||
}
|
||||
}
|
|
@ -24,7 +24,6 @@
|
|||
package org.jclouds.aws.ec2;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.aws.ec2.options.DescribeImagesOptions.Builder.imageIds;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
|
@ -33,8 +32,6 @@ import java.util.SortedSet;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.jclouds.aws.ec2.domain.Image;
|
||||
import org.jclouds.aws.ec2.domain.ImageAttribute;
|
||||
import org.jclouds.aws.ec2.domain.IpPermission;
|
||||
import org.jclouds.aws.ec2.domain.IpProtocol;
|
||||
import org.jclouds.aws.ec2.domain.KeyPair;
|
||||
|
@ -59,7 +56,6 @@ public class EC2ClientLiveTest {
|
|||
|
||||
private EC2Client client;
|
||||
private String user;
|
||||
private String imageId = "ami-d7fe1fbe";
|
||||
|
||||
@BeforeGroups(groups = { "live" })
|
||||
public void setupClient() {
|
||||
|
@ -69,22 +65,6 @@ public class EC2ClientLiveTest {
|
|||
client = EC2ContextFactory.createContext(user, password, new Log4JLoggingModule()).getApi();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDescribeImages() {
|
||||
SortedSet<Image> allResults = client.getAMIServices().describeImages();
|
||||
assertNotNull(allResults);
|
||||
assert allResults.size() >= 2 : allResults.size();
|
||||
Iterator<Image> iterator = allResults.iterator();
|
||||
String id1 = iterator.next().getImageId();
|
||||
String id2 = iterator.next().getImageId();
|
||||
SortedSet<Image> twoResults = client.getAMIServices().describeImages(imageIds(id1, id2));
|
||||
assertNotNull(twoResults);
|
||||
assertEquals(twoResults.size(), 2);
|
||||
iterator = twoResults.iterator();
|
||||
assertEquals(iterator.next().getImageId(), id1);
|
||||
assertEquals(iterator.next().getImageId(), id2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDescribeAddresses() {
|
||||
SortedSet<PublicIpInstanceIdPair> allResults = client.getElasticIPAddressServices()
|
||||
|
@ -100,30 +80,6 @@ public class EC2ClientLiveTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testDescribeImages", enabled = false)
|
||||
void testDescribeImageAttribute() throws InterruptedException, ExecutionException,
|
||||
TimeoutException {
|
||||
SortedSet<Image> oneResult = client.getAMIServices().describeImages(imageIds(imageId));
|
||||
@SuppressWarnings("unused")
|
||||
Image expects = oneResult.last();
|
||||
|
||||
System.out.println(client.getAMIServices().describeImageAttribute(imageId,
|
||||
ImageAttribute.PRODUCT_CODES));
|
||||
|
||||
System.out.println(client.getAMIServices().describeImageAttribute(imageId,
|
||||
ImageAttribute.PRODUCT_CODES));
|
||||
System.out.println(client.getAMIServices().describeImageAttribute(imageId,
|
||||
ImageAttribute.RAMDISK));
|
||||
System.out.println(client.getAMIServices().describeImageAttribute(imageId,
|
||||
ImageAttribute.KERNEL));
|
||||
System.out.println(client.getAMIServices().describeImageAttribute(imageId,
|
||||
ImageAttribute.PLATFORM));
|
||||
System.out.println(client.getAMIServices().describeImageAttribute(imageId,
|
||||
ImageAttribute.LAUNCH_PERMISSION));
|
||||
System.out.println(client.getAMIServices().describeImageAttribute(imageId,
|
||||
ImageAttribute.BLOCK_DEVICE_MAPPING));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDescribeInstances() {
|
||||
SortedSet<Reservation> allResults = client.getInstanceServices().describeInstances();
|
||||
|
|
|
@ -52,8 +52,8 @@ public class FormSignerTest {
|
|||
"AWSAccessKeyId", "foo").put( "Action","DescribeImages").put(
|
||||
"Expires","2008-02-10T12:00:00Z").put("ImageId.1", "ami-2bb65342").put(
|
||||
"SignatureMethod", "HmacSHA256").put("SignatureVersion", "2").put("Version",
|
||||
"2009-08-15").build()),
|
||||
"AWSAccessKeyId=foo&Action=DescribeImages&Expires=2008-02-10T12%3A00%3A00Z&ImageId.1=ami-2bb65342&SignatureMethod=HmacSHA256&SignatureVersion=2&Version=2009-08-15");
|
||||
"2009-11-30").build()),
|
||||
"AWSAccessKeyId=foo&Action=DescribeImages&Expires=2008-02-10T12%3A00%3A00Z&ImageId.1=ami-2bb65342&SignatureMethod=HmacSHA256&SignatureVersion=2&Version=2009-11-30");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,337 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2119 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.1 (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.1
|
||||
*
|
||||
* 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 org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions.Builder.addBlockDeviceFromSnapshot;
|
||||
import static org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions.Builder.addEphemeralBlockDeviceFromSnapshot;
|
||||
import static org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions.Builder.addNewBlockDevice;
|
||||
import static org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions.Builder.addNewEphemeralBlockDevice;
|
||||
import static org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions.Builder.asArchitecture;
|
||||
import static org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions.Builder.withDescription;
|
||||
import static org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions.Builder.withKernelId;
|
||||
import static org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions.Builder.withRamdisk;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.jclouds.aws.ec2.domain.Image.Architecture;
|
||||
import org.jclouds.http.options.HttpRequestOptions;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
|
||||
/**
|
||||
* Tests possible uses of RegisterImageBackedByEbsOptions and
|
||||
* RegisterImageBackedByEbsOptions.Builder.*
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class RegisterImageBackedByEbsOptionsTest {
|
||||
|
||||
@Test
|
||||
public void testAssignability() {
|
||||
assert HttpRequestOptions.class.isAssignableFrom(RegisterImageBackedByEbsOptions.class);
|
||||
assert !String.class.isAssignableFrom(RegisterImageBackedByEbsOptions.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithDescription() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
options.withDescription("test");
|
||||
assertEquals(options.buildFormParameters().get("Description"), Collections
|
||||
.singletonList("test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullWithDescription() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
assertEquals(options.buildFormParameters().get("Description"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithDescriptionStatic() {
|
||||
RegisterImageBackedByEbsOptions options = withDescription("test");
|
||||
assertEquals(options.buildFormParameters().get("Description"), Collections
|
||||
.singletonList("test"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testWithDescriptionNPE() {
|
||||
withDescription(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithArchitecture() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
options.asArchitecture(Architecture.I386);
|
||||
assertEquals(options.buildFormParameters().get("Architecture"), Collections
|
||||
.singletonList("i386"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullWithArchitecture() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
assertEquals(options.buildFormParameters().get("Architecture"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithArchitectureStatic() {
|
||||
RegisterImageBackedByEbsOptions options = asArchitecture(Architecture.I386);
|
||||
assertEquals(options.buildFormParameters().get("Architecture"), Collections
|
||||
.singletonList("i386"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testWithArchitectureNPE() {
|
||||
asArchitecture(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithKernelId() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
options.withKernelId("test");
|
||||
assertEquals(options.buildFormParameters().get("KernelId"), Collections.singletonList("test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullWithKernelId() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
assertEquals(options.buildFormParameters().get("KernelId"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithKernelIdStatic() {
|
||||
RegisterImageBackedByEbsOptions options = withKernelId("test");
|
||||
assertEquals(options.buildFormParameters().get("KernelId"), Collections.singletonList("test"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testWithKernelIdNPE() {
|
||||
withKernelId(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithRamdisk() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
options.withRamdisk("test");
|
||||
assertEquals(options.buildFormParameters().get("RamdiskId"), Collections
|
||||
.singletonList("test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullWithRamdisk() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
assertEquals(options.buildFormParameters().get("RamdiskId"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithRamdiskStatic() {
|
||||
RegisterImageBackedByEbsOptions options = withRamdisk("test");
|
||||
assertEquals(options.buildFormParameters().get("RamdiskId"), Collections
|
||||
.singletonList("test"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testWithRamdiskNPE() {
|
||||
withRamdisk(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddBlockDeviceFromSnapshot() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
options.addBlockDeviceFromSnapshot("deviceName", "virtualName", "snapshotId");
|
||||
assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of(
|
||||
"BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false",
|
||||
"BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName",
|
||||
"virtualName", "BlockDeviceMapping.1.Ebs.SnapshotId", "snapshotId").entries());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddBlockDeviceFromSnapshotNullVirtualName() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
options.addBlockDeviceFromSnapshot("deviceName", null, "snapshotId");
|
||||
assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of(
|
||||
"BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false",
|
||||
"BlockDeviceMapping.1.DeviceName", "deviceName",
|
||||
"BlockDeviceMapping.1.Ebs.SnapshotId", "snapshotId").entries());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullAddBlockDeviceFromSnapshot() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
assertEquals(options.buildFormParameters(), ImmutableMultimap.<String, String> of());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddBlockDeviceFromSnapshotStatic() {
|
||||
RegisterImageBackedByEbsOptions options = addBlockDeviceFromSnapshot("deviceName",
|
||||
"virtualName", "snapshotId");
|
||||
assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of(
|
||||
"BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false",
|
||||
"BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName",
|
||||
"virtualName", "BlockDeviceMapping.1.Ebs.SnapshotId", "snapshotId").entries());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testAddBlockDeviceFromSnapshotNPE() {
|
||||
addBlockDeviceFromSnapshot(null, null, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddEphemeralBlockDeviceFromSnapshot() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
options.addEphemeralBlockDeviceFromSnapshot("deviceName", "virtualName", "snapshotId");
|
||||
assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of(
|
||||
"BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName",
|
||||
"virtualName", "BlockDeviceMapping.1.Ebs.SnapshotId", "snapshotId").entries());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddEphemeralBlockDeviceFromSnapshotNullVirtualName() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
options.addEphemeralBlockDeviceFromSnapshot("deviceName", null, "snapshotId");
|
||||
assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of(
|
||||
"BlockDeviceMapping.1.DeviceName", "deviceName",
|
||||
"BlockDeviceMapping.1.Ebs.SnapshotId", "snapshotId").entries());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullAddEphemeralBlockDeviceFromSnapshot() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
assertEquals(options.buildFormParameters(), ImmutableMultimap.<String, String> of());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddEphemeralBlockDeviceFromSnapshotStatic() {
|
||||
RegisterImageBackedByEbsOptions options = addEphemeralBlockDeviceFromSnapshot("deviceName",
|
||||
"virtualName", "snapshotId");
|
||||
assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of(
|
||||
"BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName",
|
||||
"virtualName", "BlockDeviceMapping.1.Ebs.SnapshotId", "snapshotId").entries());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testAddEphemeralBlockDeviceFromSnapshotNPE() {
|
||||
addEphemeralBlockDeviceFromSnapshot(null, null, null);
|
||||
}
|
||||
|
||||
// //////
|
||||
@Test
|
||||
public void testAddNewBlockDevice() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
options.addNewBlockDevice("deviceName", "virtualName", 1);
|
||||
assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of(
|
||||
"BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false",
|
||||
"BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName",
|
||||
"virtualName", "BlockDeviceMapping.1.Ebs.VolumeSize", "1").entries());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddNewBlockDeviceNullVirtualName() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
options.addNewBlockDevice("deviceName", null, 1);
|
||||
assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of(
|
||||
"BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false",
|
||||
"BlockDeviceMapping.1.DeviceName", "deviceName",
|
||||
"BlockDeviceMapping.1.Ebs.VolumeSize", "1").entries());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullAddNewBlockDevice() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
assertEquals(options.buildFormParameters(), ImmutableMultimap.<String, String> of());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddNewBlockDeviceStatic() {
|
||||
RegisterImageBackedByEbsOptions options = addNewBlockDevice("deviceName", "virtualName", 1);
|
||||
assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of(
|
||||
"BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false",
|
||||
"BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName",
|
||||
"virtualName", "BlockDeviceMapping.1.Ebs.VolumeSize", "1").entries());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testAddNewBlockDeviceNPE() {
|
||||
addNewBlockDevice(null, null, 1);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testAddNewBlockDeviceTooBig() {
|
||||
addNewBlockDevice("deviceName", "virtualName", 1025);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testAddNewBlockDeviceTooSmall() {
|
||||
addNewBlockDevice("deviceName", "virtualName", 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddNewEphemeralBlockDevice() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
options.addNewEphemeralBlockDevice("deviceName", "virtualName", 1);
|
||||
assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of(
|
||||
"BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName",
|
||||
"virtualName", "BlockDeviceMapping.1.Ebs.VolumeSize", "1").entries());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddNewEphemeralBlockDeviceNullVirtualName() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
options.addNewEphemeralBlockDevice("deviceName", null, 1);
|
||||
assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of(
|
||||
"BlockDeviceMapping.1.DeviceName", "deviceName",
|
||||
"BlockDeviceMapping.1.Ebs.VolumeSize", "1").entries());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullAddNewEphemeralBlockDevice() {
|
||||
RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions();
|
||||
assertEquals(options.buildFormParameters(), ImmutableMultimap.<String, String> of());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddNewEphemeralBlockDeviceStatic() {
|
||||
RegisterImageBackedByEbsOptions options = addNewEphemeralBlockDevice("deviceName",
|
||||
"virtualName", 1);
|
||||
assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.of(
|
||||
"BlockDeviceMapping.1.DeviceName", "deviceName", "BlockDeviceMapping.1.VirtualName",
|
||||
"virtualName", "BlockDeviceMapping.1.Ebs.VolumeSize", "1").entries());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testAddNewEphemeralBlockDeviceNPE() {
|
||||
addNewEphemeralBlockDevice(null, null, 1);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testAddNewEphemeralBlockDeviceTooBig() {
|
||||
addNewEphemeralBlockDevice("deviceName", "virtualName", 1025);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testAddNewEphemeralBlockDeviceTooSmall() {
|
||||
addNewEphemeralBlockDevice("deviceName", "virtualName", 0);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2119 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.1 (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.1
|
||||
*
|
||||
* 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 org.jclouds.aws.ec2.options.RegisterImageOptions.Builder.asArchitecture;
|
||||
import static org.jclouds.aws.ec2.options.RegisterImageOptions.Builder.withDescription;
|
||||
import static org.jclouds.aws.ec2.options.RegisterImageOptions.Builder.withKernelId;
|
||||
import static org.jclouds.aws.ec2.options.RegisterImageOptions.Builder.withRamdisk;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.jclouds.aws.ec2.domain.Image.Architecture;
|
||||
import org.jclouds.http.options.HttpRequestOptions;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Tests possible uses of RegisterImageOptions and RegisterImageOptions.Builder.*
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class RegisterImageOptionsTest {
|
||||
|
||||
@Test
|
||||
public void testAssignability() {
|
||||
assert HttpRequestOptions.class.isAssignableFrom(RegisterImageOptions.class);
|
||||
assert !String.class.isAssignableFrom(RegisterImageOptions.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithDescription() {
|
||||
RegisterImageOptions options = new RegisterImageOptions();
|
||||
options.withDescription("test");
|
||||
assertEquals(options.buildFormParameters().get("Description"), Collections
|
||||
.singletonList("test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullWithDescription() {
|
||||
RegisterImageOptions options = new RegisterImageOptions();
|
||||
assertEquals(options.buildFormParameters().get("Description"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithDescriptionStatic() {
|
||||
RegisterImageOptions options = withDescription("test");
|
||||
assertEquals(options.buildFormParameters().get("Description"), Collections
|
||||
.singletonList("test"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testWithDescriptionNPE() {
|
||||
withDescription(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithArchitecture() {
|
||||
RegisterImageOptions options = new RegisterImageOptions();
|
||||
options.asArchitecture(Architecture.I386);
|
||||
assertEquals(options.buildFormParameters().get("Architecture"), Collections
|
||||
.singletonList("i386"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullWithArchitecture() {
|
||||
RegisterImageOptions options = new RegisterImageOptions();
|
||||
assertEquals(options.buildFormParameters().get("Architecture"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithArchitectureStatic() {
|
||||
RegisterImageOptions options = asArchitecture(Architecture.I386);
|
||||
assertEquals(options.buildFormParameters().get("Architecture"), Collections
|
||||
.singletonList("i386"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testWithArchitectureNPE() {
|
||||
asArchitecture(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithKernelId() {
|
||||
RegisterImageOptions options = new RegisterImageOptions();
|
||||
options.withKernelId("test");
|
||||
assertEquals(options.buildFormParameters().get("KernelId"), Collections.singletonList("test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullWithKernelId() {
|
||||
RegisterImageOptions options = new RegisterImageOptions();
|
||||
assertEquals(options.buildFormParameters().get("KernelId"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithKernelIdStatic() {
|
||||
RegisterImageOptions options = withKernelId("test");
|
||||
assertEquals(options.buildFormParameters().get("KernelId"), Collections.singletonList("test"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testWithKernelIdNPE() {
|
||||
withKernelId(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithRamdisk() {
|
||||
RegisterImageOptions options = new RegisterImageOptions();
|
||||
options.withRamdisk("test");
|
||||
assertEquals(options.buildFormParameters().get("RamdiskId"), Collections
|
||||
.singletonList("test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullWithRamdisk() {
|
||||
RegisterImageOptions options = new RegisterImageOptions();
|
||||
assertEquals(options.buildFormParameters().get("RamdiskId"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithRamdiskStatic() {
|
||||
RegisterImageOptions options = withRamdisk("test");
|
||||
assertEquals(options.buildFormParameters().get("RamdiskId"), Collections
|
||||
.singletonList("test"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testWithRamdiskNPE() {
|
||||
withRamdisk(null);
|
||||
}
|
||||
|
||||
}
|
|
@ -32,15 +32,20 @@ import java.lang.reflect.Method;
|
|||
import java.net.URI;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2;
|
||||
import org.jclouds.aws.ec2.domain.ImageAttribute;
|
||||
import org.jclouds.aws.ec2.filters.FormSigner;
|
||||
import org.jclouds.aws.ec2.options.CreateImageOptions;
|
||||
import org.jclouds.aws.ec2.options.DescribeImagesOptions;
|
||||
import org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions;
|
||||
import org.jclouds.aws.ec2.options.RegisterImageOptions;
|
||||
import org.jclouds.aws.ec2.xml.BlockDeviceMappingHandler;
|
||||
import org.jclouds.aws.ec2.xml.DescribeImagesResponseHandler;
|
||||
import org.jclouds.aws.ec2.xml.ImageIdHandler;
|
||||
import org.jclouds.aws.ec2.xml.LaunchPermissionHandler;
|
||||
import org.jclouds.aws.ec2.xml.ProductCodesHandler;
|
||||
import org.jclouds.aws.reference.AWSConstants;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ReturnStringIf200;
|
||||
import org.jclouds.http.functions.ReturnVoidIf2xx;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.logging.Logger.LoggerFactory;
|
||||
import org.jclouds.rest.RestClientTest;
|
||||
|
@ -50,6 +55,7 @@ import org.jclouds.util.Jsr330;
|
|||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
|
@ -74,13 +80,8 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
|||
"Content-Length: 69\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||
assertPayloadEquals(httpMethod,
|
||||
"Version=2009-11-30&Action=CreateImage&Name=name&InstanceId=instanceId");
|
||||
filter.filter(httpMethod);
|
||||
assertPayloadEquals(
|
||||
httpMethod,
|
||||
"Action=CreateImage&InstanceId=instanceId&Name=name&Signature=DPCvwvxdNmWXHfiIB%2BRy%2F4gJDAruu6i8dQVirzkFGOU%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&Version=2009-11-30&AWSAccessKeyId=user");
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ReturnStringIf200.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
|
@ -100,10 +101,8 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
|||
httpMethod,
|
||||
"Version=2009-11-30&Action=CreateImage&Name=name&InstanceId=instanceId&Description=description&NoReboot=true");
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ReturnStringIf200.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
// assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
// assertSaxResponseParserClassEquals(method, CreateImageResponseHandler.class);
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
|
@ -151,24 +150,265 @@ public class AMIAsyncClientTest extends RestClientTest<AMIAsyncClient> {
|
|||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testDescribeImageAttribute() throws SecurityException, NoSuchMethodException,
|
||||
public void testDeregisterImage() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("deregisterImage", String.class);
|
||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, "imageId");
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 57\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||
assertPayloadEquals(httpMethod, "Version=2009-11-30&Action=DeregisterImage&ImageId=imageId");
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testRegisterImageFromManifest() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("describeImageAttribute", String.class,
|
||||
ImageAttribute.class);
|
||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, "imageId",
|
||||
ImageAttribute.BLOCK_DEVICE_MAPPING);
|
||||
Method method = AMIAsyncClient.class.getMethod("registerImageFromManifest", String.class,
|
||||
String.class, Array.newInstance(RegisterImageOptions.class, 0).getClass());
|
||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, "name",
|
||||
"pathToManifest");
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 78\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||
assertPayloadEquals(httpMethod,
|
||||
"Version=2009-11-30&Action=RegisterImage&Name=name&ImageLocation=pathToManifest");
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testRegisterImageFromManifestOptions() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("registerImageFromManifest", String.class,
|
||||
String.class, Array.newInstance(RegisterImageOptions.class, 0).getClass());
|
||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, "name",
|
||||
"pathToManifest", new RegisterImageOptions().withDescription("description"));
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 102\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
httpMethod,
|
||||
"Version=2009-11-30&Action=RegisterImage&Name=name&ImageLocation=pathToManifest&Description=description");
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testRegisterImageBackedByEBS() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = AMIAsyncClient.class
|
||||
.getMethod("registerImageBackedByEbs", String.class, String.class, Array
|
||||
.newInstance(RegisterImageBackedByEbsOptions.class, 0).getClass());
|
||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||
"imageName", "snapshotId");
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 176\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
httpMethod,
|
||||
"Version=2009-11-30&Action=RegisterImage&RootDeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.DeviceName=%2Fdev%2Fsda1&Name=imageName&BlockDeviceMapping.0.Ebs.SnapshotId=snapshotId");
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testRegisterImageBackedByEBSOptions() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class
|
||||
.getMethod("registerImageBackedByEbs", String.class, String.class, Array
|
||||
.newInstance(RegisterImageBackedByEbsOptions.class, 0).getClass());
|
||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||
"imageName", "snapshotId", new RegisterImageBackedByEbsOptions().withDescription(
|
||||
"description").addBlockDeviceFromSnapshot("/dev/device", null, "snapshot")
|
||||
.addNewBlockDevice("/dev/newdevice", "newblock", 100));
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 528\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
httpMethod,
|
||||
"Version=2009-11-30&Action=RegisterImage&RootDeviceName=%2Fdev%2Fsda1&BlockDeviceMapping.0.DeviceName=%2Fdev%2Fsda1&Name=imageName&BlockDeviceMapping.0.Ebs.SnapshotId=snapshotId&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");
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, ImageIdHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testGetLaunchPermissionForImage() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("getLaunchPermissionForImage", String.class);
|
||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, "imageId");
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 91\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||
assertPayloadEquals(httpMethod,
|
||||
"Version=2009-11-30&Action=DescribeImageAttribute&Attribute=launchPermission&ImageId=imageId");
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, LaunchPermissionHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testGetProductCodesForImage() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("getProductCodesForImage", String.class);
|
||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, "imageId");
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 87\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||
assertPayloadEquals(httpMethod,
|
||||
"Version=2009-11-30&Action=DescribeImageAttribute&Attribute=productCodes&ImageId=imageId");
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, ProductCodesHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testGetBlockDeviceMappingsForImage() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class
|
||||
.getMethod("getBlockDeviceMappingsForImage", String.class);
|
||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, "imageId");
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 93\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||
assertPayloadEquals(httpMethod,
|
||||
"Version=2009-11-30&Action=DescribeImageAttribute&ImageId=imageId&Attribute=blockDeviceMapping");
|
||||
"Version=2009-11-30&Action=DescribeImageAttribute&Attribute=blockDeviceMapping&ImageId=imageId");
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, BlockDeviceMappingHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testAddLaunchPermissionsToImage() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("addLaunchPermissionsToImage", Iterable.class,
|
||||
Iterable.class, String.class);
|
||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||
ImmutableList.of("bob", "sue"), ImmutableList.of("all"), "imageId");
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 107\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
httpMethod,
|
||||
"Version=2009-11-30&Action=ModifyImageAttribute&OperationType=add&Attribute=launchPermission&ImageId=imageId&UserId.1=bob&UserId.2=sue&UserGroup.1=all");
|
||||
filter.filter(httpMethod);
|
||||
assertPayloadEquals(
|
||||
httpMethod,
|
||||
"Action=DescribeImageAttribute&Attribute=blockDeviceMapping&ImageId=imageId&Signature=A1%2BcJegB6Et36%2BGC%2FEJ0puDJljBY9oeF2YYsH%2FDIxUA%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&Version=2009-11-30&AWSAccessKeyId=user");
|
||||
"Action=ModifyImageAttribute&Attribute=launchPermission&ImageId=imageId&OperationType=add&Signature=pWWwIIdcLSw0vrWFpRsCnHk93X3qYWVfcl%2FaXRhoFd8%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&UserGroup.1=all&UserId.1=bob&UserId.2=sue&Version=2009-11-30&AWSAccessKeyId=user");
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ReturnStringIf200.class);
|
||||
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testRemoveLaunchPermissionsFromImage() throws SecurityException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("removeLaunchPermissionsFromImage",
|
||||
Iterable.class, Iterable.class, String.class);
|
||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||
ImmutableList.of("bob", "sue"), ImmutableList.of("all"), "imageId");
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 110\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
httpMethod,
|
||||
"Version=2009-11-30&Action=ModifyImageAttribute&OperationType=remove&Attribute=launchPermission&ImageId=imageId&UserId.1=bob&UserId.2=sue&UserGroup.1=all");
|
||||
filter.filter(httpMethod);
|
||||
assertPayloadEquals(
|
||||
httpMethod,
|
||||
"Action=ModifyImageAttribute&Attribute=launchPermission&ImageId=imageId&OperationType=remove&Signature=hgjXXq6PXEuHCIsp5izCTJqS%2Biv2ZdnIv0VSV1kYy%2BE%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&UserGroup.1=all&UserId.1=bob&UserId.2=sue&Version=2009-11-30&AWSAccessKeyId=user");
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testResetLaunchPermissionsOnImage() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("resetLaunchPermissionsOnImage", String.class);
|
||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method, "imageId");
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 88\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||
assertPayloadEquals(httpMethod,
|
||||
"Version=2009-11-30&Action=ResetImageAttribute&Attribute=launchPermission&ImageId=imageId");
|
||||
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testAddProductCodesToImage() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("addProductCodesToImage", Iterable.class,
|
||||
String.class);
|
||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||
ImmutableList.of("code1", "code2"), "imageId");
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 103\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
httpMethod,
|
||||
"Version=2009-11-30&Action=ModifyImageAttribute&OperationType=add&Attribute=productCodes&ImageId=imageId&ProductCode.1=code1&ProductCode.2=code2");
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpMethod);
|
||||
}
|
||||
|
||||
public void testRemoveProductCodesFromImage() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = AMIAsyncClient.class.getMethod("removeProductCodesFromImage", Iterable.class,
|
||||
String.class);
|
||||
GeneratedHttpRequest<AMIAsyncClient> httpMethod = processor.createRequest(method,
|
||||
ImmutableList.of("code1", "code2"), "imageId");
|
||||
|
||||
assertRequestLineEquals(httpMethod, "POST https://ec2.amazonaws.com/ HTTP/1.1");
|
||||
assertHeadersEqual(httpMethod,
|
||||
"Content-Length: 106\nContent-Type: application/x-www-form-urlencoded\nHost: ec2.amazonaws.com\n");
|
||||
assertPayloadEquals(
|
||||
httpMethod,
|
||||
"Version=2009-11-30&Action=ModifyImageAttribute&OperationType=remove&Attribute=productCodes&ImageId=imageId&ProductCode.1=code1&ProductCode.2=code2");
|
||||
|
||||
assertResponseParserClassEquals(method, httpMethod, ReturnVoidIf2xx.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
|
|
|
@ -0,0 +1,198 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.aws.ec2.options.DescribeImagesOptions.Builder.imageIds;
|
||||
import static org.jclouds.aws.ec2.options.RegisterImageOptions.Builder.withDescription;
|
||||
import static org.jclouds.aws.ec2.options.RegisterImageBackedByEbsOptions.Builder.addNewBlockDevice;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||
import org.jclouds.aws.ec2.EC2Client;
|
||||
import org.jclouds.aws.ec2.EC2ContextFactory;
|
||||
import org.jclouds.aws.ec2.domain.Image;
|
||||
import org.jclouds.aws.ec2.domain.Image.ImageType;
|
||||
import org.jclouds.aws.ec2.domain.Image.RootDeviceType;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.testng.annotations.AfterTest;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.internal.ImmutableMap;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code AMIClient}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", sequential = true, testName = "ec2.AMIClientLiveTest")
|
||||
public class AMIClientLiveTest {
|
||||
|
||||
private AMIClient client;
|
||||
private String user;
|
||||
private String imageId = "ami-cdf819a4";
|
||||
private static final String DEFAULT_MANIFEST = "adrianimages/image.manifest.xml";
|
||||
private static final String DEFAULT_SNAPSHOT = "TODO";
|
||||
private RestContext<EC2AsyncClient, EC2Client> context;
|
||||
|
||||
private Set<String> imagesToDeregister = Sets.newHashSet();
|
||||
|
||||
@BeforeGroups(groups = { "live" })
|
||||
public void setupClient() {
|
||||
user = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user");
|
||||
String password = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key");
|
||||
|
||||
context = EC2ContextFactory.createContext(user, password, new Log4JLoggingModule());
|
||||
client = context.getApi().getAMIServices();
|
||||
}
|
||||
|
||||
public void testDescribeImages() {
|
||||
SortedSet<Image> allResults = Sets.newTreeSet(client.describeImages());
|
||||
assertNotNull(allResults);
|
||||
assert allResults.size() >= 2 : allResults.size();
|
||||
Iterator<Image> iterator = allResults.iterator();
|
||||
String id1 = iterator.next().getImageId();
|
||||
String id2 = iterator.next().getImageId();
|
||||
SortedSet<Image> twoResults = Sets.newTreeSet(client.describeImages(imageIds(id1, id2)));
|
||||
assertNotNull(twoResults);
|
||||
assertEquals(twoResults.size(), 2);
|
||||
iterator = twoResults.iterator();
|
||||
assertEquals(iterator.next().getImageId(), id1);
|
||||
assertEquals(iterator.next().getImageId(), id2);
|
||||
}
|
||||
|
||||
public void testRegisterImageFromManifest() {
|
||||
String imageRegisteredId = client.registerImageFromManifest("jcloudstest1", DEFAULT_MANIFEST);
|
||||
imagesToDeregister.add(imageRegisteredId);
|
||||
Image imageRegisteredFromManifest = Iterables.getOnlyElement(client
|
||||
.describeImages(imageIds(imageRegisteredId)));
|
||||
assertEquals(imageRegisteredFromManifest.getName(), "jcloudstest1");
|
||||
assertEquals(imageRegisteredFromManifest.getImageLocation(), DEFAULT_MANIFEST);
|
||||
assertEquals(imageRegisteredFromManifest.getImageType(), ImageType.MACHINE);
|
||||
assertEquals(imageRegisteredFromManifest.getRootDeviceType(), RootDeviceType.INSTANCE_STORE);
|
||||
assertEquals(imageRegisteredFromManifest.getRootDeviceName(), "/dev/sda1");
|
||||
}
|
||||
|
||||
public void testRegisterImageFromManifestOptions() {
|
||||
String imageRegisteredWithOptionsId = client.registerImageFromManifest("jcloudstest2",
|
||||
DEFAULT_MANIFEST, withDescription("adrian"));
|
||||
imagesToDeregister.add(imageRegisteredWithOptionsId);
|
||||
Image imageRegisteredFromManifestWithOptions = Iterables.getOnlyElement(client
|
||||
.describeImages(imageIds(imageRegisteredWithOptionsId)));
|
||||
assertEquals(imageRegisteredFromManifestWithOptions.getName(), "jcloudstest2");
|
||||
assertEquals(imageRegisteredFromManifestWithOptions.getImageLocation(), DEFAULT_MANIFEST);
|
||||
assertEquals(imageRegisteredFromManifestWithOptions.getImageType(), ImageType.MACHINE);
|
||||
assertEquals(imageRegisteredFromManifestWithOptions.getRootDeviceType(),
|
||||
RootDeviceType.INSTANCE_STORE);
|
||||
assertEquals(imageRegisteredFromManifestWithOptions.getRootDeviceName(), "/dev/sda1");
|
||||
assertEquals(imageRegisteredFromManifestWithOptions.getDescription(), "adrian");
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
// awaiting EBS functionality to be added to jclouds
|
||||
public void testRegisterImageBackedByEBS() {
|
||||
String imageRegisteredId = client.registerImageBackedByEbs("jcloudstest1", DEFAULT_MANIFEST);
|
||||
imagesToDeregister.add(imageRegisteredId);
|
||||
Image imageRegistered = Iterables.getOnlyElement(client
|
||||
.describeImages(imageIds(imageRegisteredId)));
|
||||
assertEquals(imageRegistered.getName(), "jcloudstest1");
|
||||
assertEquals(imageRegistered.getImageType(), ImageType.MACHINE);
|
||||
assertEquals(imageRegistered.getRootDeviceType(), RootDeviceType.EBS);
|
||||
assertEquals(imageRegistered.getRootDeviceName(), "/dev/sda1");
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
// awaiting EBS functionality to be added to jclouds
|
||||
public void testRegisterImageBackedByEBSOptions() {
|
||||
String imageRegisteredWithOptionsId = client.registerImageBackedByEbs("jcloudstest2",
|
||||
DEFAULT_SNAPSHOT, addNewBlockDevice("/dev/sda2", "myvirtual", 1).withDescription(
|
||||
"adrian"));
|
||||
imagesToDeregister.add(imageRegisteredWithOptionsId);
|
||||
Image imageRegisteredWithOptions = Iterables.getOnlyElement(client
|
||||
.describeImages(imageIds(imageRegisteredWithOptionsId)));
|
||||
assertEquals(imageRegisteredWithOptions.getName(), "jcloudstest2");
|
||||
assertEquals(imageRegisteredWithOptions.getImageType(), ImageType.MACHINE);
|
||||
assertEquals(imageRegisteredWithOptions.getRootDeviceType(), RootDeviceType.EBS);
|
||||
assertEquals(imageRegisteredWithOptions.getRootDeviceName(), "/dev/sda1");
|
||||
assertEquals(imageRegisteredWithOptions.getDescription(), "adrian");
|
||||
assertEquals(imageRegisteredWithOptions.getEbsBlockDevices().entrySet(), ImmutableMap.of(
|
||||
"/dev/sda1", new Image.EbsBlockDevice("/dev/sda1", 30, true), "/dev/sda2",
|
||||
new Image.EbsBlockDevice("/dev/sda2", 1, true)).entrySet());
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public void testCreateImage() {
|
||||
// TODO client.createImage(name, instanceId, options);
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public void testAddLaunchPermissionsToImage() {
|
||||
// TODO client.addLaunchPermissionsToImage(userIds, userGroups, imageId);
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public void testAddProductCodesToImage() {
|
||||
// TODO client.addProductCodesToImage(productCodes, imageId);
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public void testRemoveLaunchPermissionsFromImage() {
|
||||
// TODO client.removeLaunchPermissionsFromImage(userIds, userGroups, imageId);
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public void testResetLaunchPermissionsOnImage() {
|
||||
// TODO client.resetLaunchPermissionsOnImage(imageId);
|
||||
}
|
||||
|
||||
public void testGetLaunchPermissionForImage() {
|
||||
System.out.println(client.getLaunchPermissionForImage(imageId));
|
||||
}
|
||||
|
||||
public void testGetProductCodesForImage() {
|
||||
System.out.println(client.getProductCodesForImage(imageId));
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
// awaiting ebs support
|
||||
public void testGetBlockDeviceMappingsForImage() {
|
||||
System.out.println(client.getBlockDeviceMappingsForImage(imageId));
|
||||
}
|
||||
|
||||
@AfterTest
|
||||
public void deregisterImages() {
|
||||
for (String imageId : imagesToDeregister)
|
||||
client.deregisterImage(imageId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code BlockDeviceMappingHandler}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ec2.BlockDeviceMappingHandlerTest")
|
||||
public class BlockDeviceMappingHandlerTest extends BaseHandlerTest {
|
||||
public void testApplyInputStream() {
|
||||
|
||||
InputStream is = getClass().getResourceAsStream(
|
||||
"/ec2/describe_image_attribute_blockDeviceMapping.xml");
|
||||
|
||||
Map<String, EbsBlockDevice> expected = ImmutableMap.<String, EbsBlockDevice> of("/dev/sda1",
|
||||
new EbsBlockDevice("snap-d01272b9", 30, true), "xvdf", new EbsBlockDevice(
|
||||
"snap-d31272ba", 250, false));
|
||||
|
||||
Map<String, EbsBlockDevice> result = factory.create(
|
||||
injector.getInstance(BlockDeviceMappingHandler.class)).parse(is);
|
||||
|
||||
assertEquals(result, expected);
|
||||
}
|
||||
}
|
|
@ -26,15 +26,18 @@ package org.jclouds.aws.ec2.xml;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import org.jclouds.aws.ec2.domain.Image;
|
||||
import org.jclouds.aws.ec2.domain.Image.Architecture;
|
||||
import org.jclouds.aws.ec2.domain.Image.EbsBlockDevice;
|
||||
import org.jclouds.aws.ec2.domain.Image.ImageState;
|
||||
import org.jclouds.aws.ec2.domain.Image.ImageType;
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
|
@ -45,17 +48,54 @@ import com.google.common.collect.Sets;
|
|||
@Test(groups = "unit", testName = "ec2.DescribeImagesResponseHandlerTest")
|
||||
public class DescribeImagesResponseHandlerTest extends BaseHandlerTest {
|
||||
|
||||
public void testApplyInputStream() {
|
||||
public void testUNIX() {
|
||||
InputStream is = getClass().getResourceAsStream("/ec2/describe_images.xml");
|
||||
SortedSet<Image> contents = Sets.newTreeSet();
|
||||
|
||||
contents.add(new Image(Architecture.I386, "ami-be3adfd7",
|
||||
contents.add(new Image(Architecture.I386, null, null, "ami-be3adfd7",
|
||||
"ec2-public-images/fedora-8-i386-base-v1.04.manifest.xml", "206029621532",
|
||||
ImageState.AVAILABLE, ImageType.MACHINE, false, "aki-4438dd2d", null, Sets
|
||||
.<String> newHashSet(), "ari-4538dd2c"));
|
||||
ImageState.AVAILABLE, ImageType.MACHINE, false,
|
||||
Sets.<String> newHashSet("9961934F"), "aki-4438dd2d", null, "ari-4538dd2c",
|
||||
Image.RootDeviceType.INSTANCE_STORE, null, ImmutableMap
|
||||
.<String, EbsBlockDevice> of()));
|
||||
|
||||
SortedSet<Image> result = (SortedSet<Image>) factory.create(
|
||||
injector.getInstance(DescribeImagesResponseHandler.class)).parse(is);
|
||||
Set<Image> result = factory.create(injector.getInstance(DescribeImagesResponseHandler.class))
|
||||
.parse(is);
|
||||
|
||||
assertEquals(result, contents);
|
||||
}
|
||||
|
||||
public void testWindows() {
|
||||
InputStream is = getClass().getResourceAsStream("/ec2/describe_images_windows.xml");
|
||||
SortedSet<Image> contents = Sets.newTreeSet();
|
||||
|
||||
contents.add(new Image(Architecture.X86_64, null, null, "ami-02eb086b",
|
||||
"aws-solutions-amis/SqlSvrStd2003r2-x86_64-Win_SFWBasic5.1-v1.0.manifest.xml",
|
||||
"771350841976", ImageState.AVAILABLE, ImageType.MACHINE, true, Sets
|
||||
.<String> newHashSet("5771E9A6"), null, "windows", null,
|
||||
Image.RootDeviceType.INSTANCE_STORE, null, ImmutableMap
|
||||
.<String, EbsBlockDevice> of()));
|
||||
|
||||
Set<Image> result = factory.create(injector.getInstance(DescribeImagesResponseHandler.class))
|
||||
.parse(is);
|
||||
|
||||
assertEquals(result, contents);
|
||||
}
|
||||
|
||||
public void testEBS() {
|
||||
InputStream is = getClass().getResourceAsStream("/ec2/describe_images_ebs.xml");
|
||||
SortedSet<Image> contents = Sets.newTreeSet();
|
||||
|
||||
contents.add(new Image(Architecture.I386, "websrv_2009-12-10", "Web Server AMI",
|
||||
"ami-246f8d4d", "706093390852/websrv_2009-12-10", "706093390852",
|
||||
ImageState.AVAILABLE, ImageType.MACHINE, true, Sets.<String> newHashSet(), null,
|
||||
"windows", null, Image.RootDeviceType.EBS, "/dev/sda1", ImmutableMap
|
||||
.<String, EbsBlockDevice> of("/dev/sda1", new EbsBlockDevice(
|
||||
"snap-d01272b9", 30, true), "xvdf", new EbsBlockDevice(
|
||||
"snap-d31272ba", 250, false))));
|
||||
|
||||
Set<Image> result = factory.create(injector.getInstance(DescribeImagesResponseHandler.class))
|
||||
.parse(is);
|
||||
|
||||
assertEquals(result, contents);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.jclouds.aws.ec2.domain.LaunchPermission;
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code LaunchPermissionHandler}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ec2.LaunchPermissionHandlerTest")
|
||||
public class LaunchPermissionHandlerTest extends BaseHandlerTest {
|
||||
public void testApplyInputStream() {
|
||||
|
||||
InputStream is = getClass().getResourceAsStream(
|
||||
"/ec2/describe_image_attribute_launchPermission.xml");
|
||||
|
||||
LaunchPermission expected = new LaunchPermission(Sets.newHashSet("495219933132"), Sets
|
||||
.newHashSet("all"));
|
||||
|
||||
LaunchPermission result = factory.create(injector.getInstance(LaunchPermissionHandler.class))
|
||||
.parse(is);
|
||||
|
||||
assertEquals(result, expected);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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 static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.http.functions.BaseHandlerTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ProductCodesHandler}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ec2.ProductCodesHandlerTest")
|
||||
public class ProductCodesHandlerTest extends BaseHandlerTest {
|
||||
public void testApplyInputStream() {
|
||||
|
||||
InputStream is = getClass().getResourceAsStream(
|
||||
"/ec2/describe_image_attribute_productCodes.xml");
|
||||
|
||||
Set<String> expected = ImmutableSet.of("774F4FF8");
|
||||
|
||||
Set<String> result = factory.create(injector.getInstance(ProductCodesHandler.class))
|
||||
.parse(is);
|
||||
|
||||
assertEquals(result, expected);
|
||||
}
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
<AllocateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2009-08-15/">
|
||||
<AllocateAddressResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
|
||||
<publicIp>67.202.55.255</publicIp>
|
||||
</AllocateAddressResponse>
|
|
@ -1,4 +1,4 @@
|
|||
<CreateKeyPairResponse xmlns="http://ec2.amazonaws.com/doc/2009-08-15/">
|
||||
<CreateKeyPairResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
|
||||
<keyName>gsg-keypair</keyName>
|
||||
<keyFingerprint>1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f</keyFingerprint>
|
||||
<keyMaterial>-----BEGIN RSA PRIVATE KEY-----
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<DescribeAddressesResponse xmlns="http://ec2.amazonaws.com/doc/2009-08-15/">
|
||||
<DescribeAddressesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
|
||||
<addressesSet>
|
||||
<item>
|
||||
<instanceId>i-f15ebb98</instanceId>
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<DescribeImageAttributeResponse
|
||||
xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
|
||||
<imageId>ami-61a54008</imageId>
|
||||
<blockDeviceMapping>
|
||||
<item>
|
||||
<deviceName>/dev/sda1</deviceName>
|
||||
<ebs>
|
||||
<snapshotId>snap-d01272b9</snapshotId>
|
||||
<volumeSize>30</volumeSize>
|
||||
<deleteOnTermination>true</deleteOnTermination>
|
||||
</ebs>
|
||||
</item>
|
||||
<item>
|
||||
<deviceName>xvdf</deviceName>
|
||||
<ebs>
|
||||
<snapshotId>snap-d31272ba</snapshotId>
|
||||
<volumeSize>250</volumeSize>
|
||||
<deleteOnTermination>false</deleteOnTermination>
|
||||
</ebs>
|
||||
</item>
|
||||
</blockDeviceMapping>
|
||||
</DescribeImageAttributeResponse>
|
|
@ -0,0 +1,11 @@
|
|||
<DescribeImageAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
|
||||
<imageId>ami-61a54008</imageId>
|
||||
<launchPermission>
|
||||
<item>
|
||||
<group>all</group>
|
||||
</item>
|
||||
<item>
|
||||
<userId>495219933132</userId>
|
||||
</item>
|
||||
</launchPermission>
|
||||
</DescribeImageAttributeResponse>
|
|
@ -0,0 +1,9 @@
|
|||
<DescribeImageAttributeResponse
|
||||
xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
|
||||
<imageId>ami-61a54008</imageId>
|
||||
<productCodes>
|
||||
<item>
|
||||
<productCode>774F4FF8</productCode>
|
||||
</item>
|
||||
</productCodes>
|
||||
</DescribeImageAttributeResponse>
|
|
@ -1,16 +1,22 @@
|
|||
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2009-08-15/">
|
||||
<imagesSet>
|
||||
<item>
|
||||
<imageId>ami-be3adfd7</imageId>
|
||||
<imageLocation>ec2-public-images/fedora-8-i386-base-v1.04.manifest.xml
|
||||
</imageLocation>
|
||||
<imageState>available</imageState>
|
||||
<imageOwnerId>206029621532</imageOwnerId>
|
||||
<isPublic>false</isPublic>
|
||||
<architecture>i386</architecture>
|
||||
<imageType>machine</imageType>
|
||||
<kernelId>aki-4438dd2d</kernelId>
|
||||
<ramdiskId>ari-4538dd2c</ramdiskId>
|
||||
</item>
|
||||
</imagesSet>
|
||||
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
|
||||
<imagesSet>
|
||||
<item>
|
||||
<imageId>ami-be3adfd7</imageId>
|
||||
<imageLocation>ec2-public-images/fedora-8-i386-base-v1.04.manifest.xml</imageLocation>
|
||||
<imageState>available</imageState>
|
||||
<imageOwnerId>206029621532</imageOwnerId>
|
||||
<isPublic>false</isPublic>
|
||||
<productCodes>
|
||||
<item>
|
||||
<productCode>9961934F</productCode>
|
||||
</item>
|
||||
</productCodes>
|
||||
<architecture>i386</architecture>
|
||||
<imageType>machine</imageType>
|
||||
<kernelId>aki-4438dd2d</kernelId>
|
||||
<ramdiskId>ari-4538dd2c</ramdiskId>
|
||||
<rootDeviceType>instance-store</rootDeviceType>
|
||||
<blockDeviceMapping />
|
||||
</item>
|
||||
</imagesSet>
|
||||
</DescribeImagesResponse>
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0"?>
|
||||
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
|
||||
<requestId>c952eb86-3a28-4987-8df5-dd08e3e8e502</requestId>
|
||||
<imagesSet>
|
||||
<item>
|
||||
<imageId>ami-246f8d4d</imageId>
|
||||
<imageLocation>706093390852/websrv_2009-12-10
|
||||
</imageLocation>
|
||||
<imageState>available</imageState>
|
||||
<imageOwnerId>706093390852</imageOwnerId>
|
||||
<isPublic>true</isPublic>
|
||||
<architecture>i386</architecture>
|
||||
<imageType>machine</imageType>
|
||||
<platform>windows</platform>
|
||||
<name>websrv_2009-12-10</name>
|
||||
<description>Web Server AMI</description>
|
||||
<rootDeviceType>ebs</rootDeviceType>
|
||||
<rootDeviceName>/dev/sda1</rootDeviceName>
|
||||
<blockDeviceMapping>
|
||||
<item>
|
||||
<deviceName>/dev/sda1</deviceName>
|
||||
<ebs>
|
||||
<snapshotId>snap-d01272b9</snapshotId>
|
||||
<volumeSize>30</volumeSize>
|
||||
<deleteOnTermination>true</deleteOnTermination>
|
||||
</ebs>
|
||||
</item>
|
||||
<item>
|
||||
<deviceName>xvdf</deviceName>
|
||||
<ebs>
|
||||
<snapshotId>snap-d31272ba</snapshotId>
|
||||
<volumeSize>250</volumeSize>
|
||||
<deleteOnTermination>false</deleteOnTermination>
|
||||
</ebs>
|
||||
</item>
|
||||
</blockDeviceMapping>
|
||||
</item>
|
||||
</imagesSet>
|
||||
</DescribeImagesResponse>
|
|
@ -0,0 +1,21 @@
|
|||
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
|
||||
<imagesSet>
|
||||
<item>
|
||||
<imageId>ami-02eb086b</imageId>
|
||||
<imageLocation>aws-solutions-amis/SqlSvrStd2003r2-x86_64-Win_SFWBasic5.1-v1.0.manifest.xml</imageLocation>
|
||||
<imageState>available</imageState>
|
||||
<imageOwnerId>771350841976</imageOwnerId>
|
||||
<isPublic>true</isPublic>
|
||||
<productCodes>
|
||||
<item>
|
||||
<productCode>5771E9A6</productCode>
|
||||
</item>
|
||||
</productCodes>
|
||||
<architecture>x86_64</architecture>
|
||||
<imageType>machine</imageType>
|
||||
<platform>windows</platform>
|
||||
<rootDeviceType>instance-store</rootDeviceType>
|
||||
<blockDeviceMapping/>
|
||||
</item>
|
||||
</imagesSet>
|
||||
</DescribeImagesResponse>
|
|
@ -1,4 +1,4 @@
|
|||
<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-08-15/">
|
||||
<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
|
||||
<reservationSet>
|
||||
<item>
|
||||
<reservationId>r-44a5402d</reservationId>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-08-15/">
|
||||
<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
|
||||
<requestId>ae75a8cc-b707-4a20-b130-61ad6f20de61</requestId>
|
||||
<reservationSet>
|
||||
<item>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<DescribeKeyPairsResponse xmlns="http://ec2.amazonaws.com/doc/2009-08-15/">
|
||||
<DescribeKeyPairsResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
|
||||
<keySet>
|
||||
<item>
|
||||
<keyName>gsg-keypair</keyName>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<DescribeSecurityGroupsResponse xmlns="http://ec2.amazonaws.com/doc/2009-08-15/">
|
||||
<DescribeSecurityGroupsResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
|
||||
<securityGroupInfo>
|
||||
<item>
|
||||
<ownerId>UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM</ownerId>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-08-15/">
|
||||
<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
|
||||
<reservationId>r-47a5402e</reservationId>
|
||||
<ownerId>AIDADH4IGTRXXKCD</ownerId>
|
||||
<groupSet>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-08-15/">
|
||||
<TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-11-30/">
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId>i-3ea74257</instanceId>
|
||||
|
|
Loading…
Reference in New Issue