当前位置: 首页>>代码示例>>Java>>正文


Java CreateImageRequest类代码示例

本文整理汇总了Java中com.amazonaws.services.ec2.model.CreateImageRequest的典型用法代码示例。如果您正苦于以下问题:Java CreateImageRequest类的具体用法?Java CreateImageRequest怎么用?Java CreateImageRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CreateImageRequest类属于com.amazonaws.services.ec2.model包,在下文中一共展示了CreateImageRequest类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAMI

import com.amazonaws.services.ec2.model.CreateImageRequest; //导入依赖的package包/类
private String createAMI(Context context, String instanceId) throws Exception {
    AWS.ec2.stopInstances(Lists.newArrayList(instanceId));

    logger.info("create AMI, instanceId={}, imageName={}", instanceId, resource.name());
    CreateImageResult result = AWS.ec2.ec2.createImage(new CreateImageRequest(instanceId, resource.name()));
    String imageId = result.getImageId();

    AWS.ec2.createTags(new CreateTagsRequest()
        .withResources(imageId)
        .withTags(tagHelper.env(),
            tagHelper.resourceId(resource.id),
            tagHelper.version(resource.nextVersion()),
            tagHelper.name(resource.id + ":" + resource.nextVersion())));

    String key = "ami/" + resource.id;
    context.output(key, String.format("imageId=%s", imageId));
    logger.info("result imageId => {}", imageId);
    return imageId;
}
 
开发者ID:neowu,项目名称:cmn-project,代码行数:20,代码来源:BakeAMITask.java

示例2: createAMI

import com.amazonaws.services.ec2.model.CreateImageRequest; //导入依赖的package包/类
/**
 * Build an AMI of a running EC2Instance. Creates a snap which is
 * disassociated and tracked via a the description.
 * 
 * @param sourceInstance
 *            the EC2 instance to create an AMI from
 * @param description
 *            to shove in the console so you know what your looking at
 * @return id of the ami
 * @throws TimeoutException
 *             if the ami isn't available in time.
 * 
 * @see #deleteStorageArtifacts(String)
 */
public String createAMI(String sourceInstance, String description)
		throws TimeoutException {
	CreateImageResult imageResult = ec2Client
			.createImage(new CreateImageRequest()
					.withInstanceId(sourceInstance)
					.withDescription(description)
					.withName(
							sourceInstance + "-"
									+ System.currentTimeMillis())
					.withNoReboot(true));

	String amiId = imageResult.getImageId();
	if (!waitForImage(amiId)) {
		throw new TimeoutException(
				"Timed out waiting for amazon to create AMI " + amiId);
	}
	log.info("Created new AMI with ID: " + amiId);
	return amiId;
}
 
开发者ID:krujos,项目名称:data-lifecycle-service-broker,代码行数:34,代码来源:AWSHelper.java

示例3: createAMI

import com.amazonaws.services.ec2.model.CreateImageRequest; //导入依赖的package包/类
String createAMI(ImageCreateRequest request, Context context) {

		LambdaLogger logger = context.getLogger();

		AmazonEC2Async client = createEC2Client();

		String imageId = null;
		try {
			Future<CreateImageResult> result = client
					.createImageAsync(new CreateImageRequest(request.getInstanceId(), request.getAmiName())
							.withNoReboot(request.isNoReboot()));
			while (!result.isDone()) {
				Thread.sleep(1000);
			}
			imageId = result.get().getImageId();

			logger.log("AMI Create Request End. instanceId[" + request.getInstanceId() + "] noReboot["
					+ request.isNoReboot() + "] imageId[" + imageId + "]");
		} catch (Exception e) {
			throw new RuntimeException("An unexpected error at the time of AMI creation has occurred", e);
		} finally {
			client.shutdown();
		}
		return imageId;
	}
 
开发者ID:uzresk,项目名称:aws-auto-operations-using-lambda,代码行数:26,代码来源:ImageCreateFunction.java

示例4: createImage

import com.amazonaws.services.ec2.model.CreateImageRequest; //导入依赖的package包/类
@Override
public Image createImage(CreateImageRequest request,
        ResultCapture<CreateImageResult> extractor) {

    ActionResult result = resource.performAction("CreateImage", request,
            extractor);

    if (result == null) return null;
    return new ImageImpl(result.getResource());
}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:11,代码来源:InstanceImpl.java

示例5: createImage

import com.amazonaws.services.ec2.model.CreateImageRequest; //导入依赖的package包/类
@Override
public CreateImageResult createImage(CreateImageRequest createImageRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AmazonEC2Mock.java

示例6: imageCreate

import com.amazonaws.services.ec2.model.CreateImageRequest; //导入依赖的package包/类
/**
 * stop instance and take image snapshot
 */
public Image imageCreate(final String instanceId, final String name,
		final String description) throws Exception {

	logger.info("ensure instance state : instanceId=" + instanceId);

	final InstanceStateName state = stateFrom(instanceId);

	final boolean wasRunning;

	switch (state) {
	case Pending:
		waitForIstanceState(instanceId, InstanceStateName.Running);
	case Running:
		wasRunning = true;
		break;
	case Stopping:
		waitForIstanceState(instanceId, InstanceStateName.Stopped);
	case Stopped:
		wasRunning = false;
		break;
	default:
		throw new Exception("image create : invalid instance state="
				+ state);
	}

	if (wasRunning) {
		instanceStop(instanceId);
	}

	final CreateImageRequest request = new CreateImageRequest();

	request.setInstanceId(instanceId);
	request.setName(name);
	request.setDescription(description);

	final CreateImageResult result = amazonClient.createImage(request);

	final String imageId = result.getImageId();

	logger.info("ensure image state: imageId=" + imageId);

	final Image image = waitForImageCreate(imageId);

	if (wasRunning) {
		instanceStart(instanceId);
	}

	return image;

}
 
开发者ID:jwrapper,项目名称:jwrapper-maven-plugin,代码行数:54,代码来源:CarrotElasticCompute.java

示例7: createImage

import com.amazonaws.services.ec2.model.CreateImageRequest; //导入依赖的package包/类
/**
 * Performs the <code>CreateImage</code> action.
 *
 * <p>
 * The following request parameters will be populated from the data of this
 * <code>Instance</code> resource, and any conflicting parameter value set
 * in the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>InstanceId</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @return The <code>Image</code> resource object associated with the result
 *         of this action.
 * @see CreateImageRequest
 */
com.amazonaws.resources.ec2.Image createImage(CreateImageRequest request);
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:22,代码来源:Instance.java


注:本文中的com.amazonaws.services.ec2.model.CreateImageRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。