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


Java CreateTagsRequest.setTags方法代码示例

本文整理汇总了Java中com.amazonaws.services.ec2.model.CreateTagsRequest.setTags方法的典型用法代码示例。如果您正苦于以下问题:Java CreateTagsRequest.setTags方法的具体用法?Java CreateTagsRequest.setTags怎么用?Java CreateTagsRequest.setTags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.ec2.model.CreateTagsRequest的用法示例。


在下文中一共展示了CreateTagsRequest.setTags方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: attachSnapshotTags

import com.amazonaws.services.ec2.model.CreateTagsRequest; //导入方法依赖的package包/类
void attachSnapshotTags(AmazonEC2Async client, String sourceSnapshotId, String snapshotId) {

		DescribeSnapshotsResult result = client
				.describeSnapshots(new DescribeSnapshotsRequest().withSnapshotIds(sourceSnapshotId));
		List<Snapshot> snapshots = result.getSnapshots();
		if (snapshots.size() != 1) {
			throw new RuntimeException("snapshot can not found. sourceSnapshotId[" + snapshotId + "]");
		}
		List<Tag> sourceSnapshotTags = snapshots.get(0).getTags();

		List<Tag> tags = new ArrayList<Tag>();
		tags.addAll(sourceSnapshotTags);
		tags.add(new Tag("SourceSnapshotId", sourceSnapshotId));
		tags.add(new Tag("BackupType", "copy-snapshot")); // overwrite

		CreateTagsRequest snapshotTagsRequest = new CreateTagsRequest().withResources(snapshotId);
		snapshotTagsRequest.setTags(tags);
		client.createTags(snapshotTagsRequest);
	}
 
开发者ID:uzresk,项目名称:aws-auto-operations-using-lambda,代码行数:20,代码来源:EBSCopySnapshotFunction.java

示例2: attachSnapshotTags

import com.amazonaws.services.ec2.model.CreateTagsRequest; //导入方法依赖的package包/类
void attachSnapshotTags(AmazonEC2Async client, String volumeId, String snapshotId) {

		List<Tag> tags = new ArrayList<Tag>();
		tags.add(new Tag("VolumeId", volumeId));
		tags.add(new Tag("BackupType", "snapshot"));

		CreateTagsRequest snapshotTagsRequest = new CreateTagsRequest().withResources(snapshotId);
		snapshotTagsRequest.setTags(tags);
		client.createTags(snapshotTagsRequest);
	}
 
开发者ID:uzresk,项目名称:aws-auto-operations-using-lambda,代码行数:11,代码来源:EBSSnapshotFunction.java

示例3: createImageTags

import com.amazonaws.services.ec2.model.CreateTagsRequest; //导入方法依赖的package包/类
void createImageTags(AmazonEC2Async client, ImageCreateRequest imageCreateRequest, Context context) {

		try {
			// LambdaLogger logger = context.getLogger();
			String instanceId = imageCreateRequest.getInstanceId();
			String imageId = imageCreateRequest.getImageId();

			List<Tag> tags = new ArrayList<Tag>();
			tags.add(new Tag("InstanceId", instanceId));
			tags.add(new Tag("BackupType", "image"));
			String requestDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmm"));
			tags.add(new Tag("RequestDate", requestDate));

			// Tag to AMI
			CreateTagsRequest createTagsRequest = new CreateTagsRequest().withResources(imageId);
			createTagsRequest.setTags(tags);
			Future<CreateTagsResult> amiTagsResult = client.createTagsAsync(createTagsRequest);
			while (!amiTagsResult.isDone()) {
				Thread.sleep(100);
			}

			// Tag to EBS Snapshot
			tags.add(new Tag("ImageId", imageId)); // snapshotにはimageIdを付けておく。

			List<String> snapshotIds = getSnapshotIdsFromImageId(client, imageCreateRequest, context);
			CreateTagsRequest snapshotTagsRequest = new CreateTagsRequest().withResources(snapshotIds);

			snapshotTagsRequest.setTags(tags);
			Future<CreateTagsResult> snapshotTagsResult = client.createTagsAsync(snapshotTagsRequest);
			while (!snapshotTagsResult.isDone()) {
				Thread.sleep(100);
			}
		} catch (Exception e) {
			context.getLogger().log("[ERROR][ImageStateCheckAndParge] message[" + e.getMessage() + "] stackTrace["
					+ getStackTrace(e) + "] [" + imageCreateRequest + "]");
		}

	}
 
开发者ID:uzresk,项目名称:aws-auto-operations-using-lambda,代码行数:39,代码来源:ImageStateCheckAndPargeFunction.java

示例4: setName

import com.amazonaws.services.ec2.model.CreateTagsRequest; //导入方法依赖的package包/类
public void setName(String name) {
	com.amazonaws.services.ec2.AmazonEC2 client = AmazonEC2.connect();

	CreateTagsRequest req = new CreateTagsRequest();
	List<String> instanceIds = new ArrayList<String>();
	instanceIds.add(id);
	req.withResources(instanceIds);

	List<Tag> tags = new ArrayList<Tag>();
	tags.add(new Tag("Name", name));
	req.setTags(tags);

	client.createTags(req);
}
 
开发者ID:rickdesantis,项目名称:cloud-runner,代码行数:15,代码来源:Instance.java

示例5: tagResources

import com.amazonaws.services.ec2.model.CreateTagsRequest; //导入方法依赖的package包/类
public void tagResources(List<String> resources, List<Tag> tags) {
	CreateTagsRequest createTagsRequest = new CreateTagsRequest();
	createTagsRequest.setResources(resources);
	createTagsRequest.setTags(tags);
	try {
		ec2.createTags(createTagsRequest);
	} catch (AmazonServiceException e) {
		System.out.println("Error terminating instances");
		System.out.println("Caught Exception: " + e.getMessage());
		System.out.println("Reponse Status Code: " + e.getStatusCode());
		System.out.println("Error Code: " + e.getErrorCode());
		System.out.println("Request ID: " + e.getRequestId());
	}
}
 
开发者ID:cs553-cloud-computing,项目名称:amazon-cloudengine,代码行数:15,代码来源:EC2.java

示例6: addTag

import com.amazonaws.services.ec2.model.CreateTagsRequest; //导入方法依赖的package包/类
private void addTag(AmazonEC2Client amazonEC2Client, CloudInstance cloudInstance, Instance instance) {
    String tagName = awsClient.getCbName(cloudInstance.getTemplate().getGroupName(), cloudInstance.getTemplate().getPrivateId());
    Tag t = new Tag();
    t.setKey(TAG_NAME);
    t.setValue(tagName);
    CreateTagsRequest ctr = new CreateTagsRequest();
    ctr.setTags(Collections.singletonList(t));
    ctr.withResources(instance.getInstanceId());
    amazonEC2Client.createTags(ctr);
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:11,代码来源:AwsMetadataCollector.java

示例7: createTags

import com.amazonaws.services.ec2.model.CreateTagsRequest; //导入方法依赖的package包/类
/**
 * Create Tags.
 *
 * @param availabilityZone the availability zone
 * @param iops the iops
 * @param size the size
 * @param snapshotId the snapshot id
 * @param volumeType the volume type
 * @return Volume
 */
protected final boolean createTags(final Collection<String> resources, final Collection<Tag> tags) {
    CreateTagsRequest req = new CreateTagsRequest();
    req.setResources(resources);
    req.setTags(tags);
    
    CreateTagsResult result = amazonEC2Client.createTags(req);
    if (result != null) {
        return true;
    }

    return false;
}
 
开发者ID:treelogic-swe,项目名称:aws-mock,代码行数:23,代码来源:BaseTest.java

示例8: tagCreate

import com.amazonaws.services.ec2.model.CreateTagsRequest; //导入方法依赖的package包/类
public void tagCreate(final String resourceId, final String key,
		final String value) {

	final CreateTagsRequest request = new CreateTagsRequest();

	final Collection<String> resourceList = new ArrayList<String>(1);
	resourceList.add(resourceId);

	final Collection<Tag> tagList = new ArrayList<Tag>(1);
	tagList.add(new Tag(key, value));

	request.setResources(resourceList);
	request.setTags(tagList);

	logger.info("tag create request=" + request);

	amazonClient.createTags(request);

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


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