本文整理汇总了Java中com.amazonaws.services.ec2.model.TagDescription类的典型用法代码示例。如果您正苦于以下问题:Java TagDescription类的具体用法?Java TagDescription怎么用?Java TagDescription使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TagDescription类属于com.amazonaws.services.ec2.model包,在下文中一共展示了TagDescription类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testResourceNaming
import com.amazonaws.services.ec2.model.TagDescription; //导入依赖的package包/类
@Test
public void testResourceNaming() throws Throwable {
boolean tagFound = false;
AmazonEC2AsyncClient client = TestUtils.getClient(this.privateKeyId,this.privateKey,this.region,false);
//create something to name
AWSNetworkClient svc = new AWSNetworkClient(client);
String vpcID = svc.createVPC("10.20.0.0/16");
AWSUtils.tagResourcesWithName(client, TEST_NAME, vpcID);
List<TagDescription> tags = AWSUtils.getResourceTags(vpcID,client);
for (TagDescription tagDesc:tags) {
if (tagDesc.getKey().equalsIgnoreCase(AWS_TAG_NAME)) {
assertTrue(tagDesc.getValue().equalsIgnoreCase(TEST_NAME));
tagFound = true;
break;
}
}
// ensure we found the tag
assertTrue(tagFound);
svc.deleteVPC(vpcID);
}
开发者ID:vmware,项目名称:photon-model,代码行数:23,代码来源:TestAWSUtils.java
示例2: ElapsedTimeAggregatorTest
import com.amazonaws.services.ec2.model.TagDescription; //导入依赖的package包/类
/**
* Default constructor
*/
public ElapsedTimeAggregatorTest() {
AmazonEC2 ec2Client = mock(AmazonEC2.class);
AmazonCloudWatch cloudWatchClient = mock(AmazonCloudWatch.class);
Region region = Region.getRegion(Regions.US_WEST_1);
when(ec2Client.describeTags(any(DescribeTagsRequest.class))).
thenReturn(new DescribeTagsResult());
instanceOnlyAggregator = new ElapsedTimeAggregator("TEST", region, "i-500f6ca6", null, ec2Client, cloudWatchClient);
when(ec2Client.describeTags(any(DescribeTagsRequest.class))).
thenReturn(new DescribeTagsResult().withTags(
new TagDescription().
withKey("aws:autoscaling:groupName").
withValue("TEST")
));
asgAggregator = new ElapsedTimeAggregator("TEST", region, "i-500f6ca6", null, ec2Client, cloudWatchClient);
}
开发者ID:web-online,项目名称:cloudwatch-tomcat-valve,代码行数:22,代码来源:ElapsedTimeAggregatorTest.java
示例3: runningInstances
import com.amazonaws.services.ec2.model.TagDescription; //导入依赖的package包/类
private List<Instance> runningInstances(String resourceId) {
Tag tag = new EC2TagHelper(env).resourceId(resourceId);
DescribeTagsRequest request = new DescribeTagsRequest()
.withFilters(new Filter("key").withValues(tag.getKey()),
new Filter("value").withValues(tag.getValue()),
new Filter("resource-type").withValues("instance"));
List<TagDescription> remoteTags = AWS.ec2.describeTags(request);
List<String> instanceIds = remoteTags.stream().map(TagDescription::getResourceId).collect(Collectors.toList());
if (instanceIds.isEmpty()) {
com.amazonaws.services.autoscaling.model.AutoScalingGroup asGroup = AWS.as.describeASGroup(env.name + "-" + this.resourceId);
if (asGroup == null) throw new Error("can not find any running instance or asGroup, id=" + this.resourceId);
instanceIds = asGroup.getInstances().stream()
.map(com.amazonaws.services.autoscaling.model.Instance::getInstanceId)
.collect(Collectors.toList());
}
logger.info("find instanceId, {} => {}", resourceId, instanceIds);
List<Instance> instances = AWS.ec2.describeInstances(instanceIds)
.stream().filter(instance -> "running".equals(instance.getState().getName())).collect(Collectors.toList());
if (instances.isEmpty()) throw new Error("can not find any running instance, id=" + resourceId);
return instances;
}
开发者ID:neowu,项目名称:cmn-project,代码行数:27,代码来源:SSHRunner.java
示例4: createInstance
import com.amazonaws.services.ec2.model.TagDescription; //导入依赖的package包/类
@Override
protected Map<String, String> createInstance() throws Exception {
LinkedHashMap<String, String> properties = new LinkedHashMap<>();
DescribeTagsResult tags = this.amazonEc2.describeTags(new DescribeTagsRequest().withFilters(
new Filter("resource-id", Collections.singletonList(this.idProvider.getCurrentInstanceId())),
new Filter("resource-type", Collections.singletonList("instance"))));
for (TagDescription tag : tags.getTags()) {
properties.put(tag.getKey(), tag.getValue());
}
return properties;
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:12,代码来源:AmazonEc2InstanceUserTagsFactoryBean.java
示例5: describerTagsTest
import com.amazonaws.services.ec2.model.TagDescription; //导入依赖的package包/类
/**
* Test delete Tags.
*/
@Test(timeout = TIMEOUT_LEVEL1)
public final void describerTagsTest() {
log.info("Describe Tags test");
createTagsTest();
List<TagDescription> tagsDesc = getTags();
Assert.assertNotNull("tag Desc should not be null", tagsDesc);
Collection<String> resources = new ArrayList<String>();
Collection<Tag> tags = new ArrayList<Tag>();
for(TagDescription tagDesc : tagsDesc)
{
Tag tag = new Tag();
tag.setKey(tagDesc.getKey());
tag.setValue(tagDesc.getValue());
tags.add(tag);
resources.add(tagDesc.getResourceId());
}
Assert.assertTrue("Tags should be created.", deleteTags(resources, tags));
}
开发者ID:treelogic-swe,项目名称:aws-mock,代码行数:27,代码来源:Ec2NetworkTest.java
示例6: getResourceTags
import com.amazonaws.services.ec2.model.TagDescription; //导入依赖的package包/类
public static List<TagDescription> getResourceTags(String resourceID,
AmazonEC2AsyncClient client) {
Filter resource = new Filter().withName(AWS_FILTER_RESOURCE_ID)
.withValues(resourceID);
DescribeTagsRequest req = new DescribeTagsRequest()
.withFilters(resource);
DescribeTagsResult result = client.describeTags(req);
return result.getTags();
}
开发者ID:vmware,项目名称:photon-model,代码行数:10,代码来源:AWSUtils.java
示例7: loadEnvTags
import com.amazonaws.services.ec2.model.TagDescription; //导入依赖的package包/类
private List<EnvTag> loadEnvTags(Environment env) {
Map<String, EnvTag> tags = Maps.newHashMap();
DescribeTagsRequest request = new DescribeTagsRequest()
.withFilters(new Filter("key").withValues(new EC2TagHelper(env).prefix() + ":*"));
List<TagDescription> remoteTags = AWS.ec2.describeTags(request);
for (TagDescription remoteTag : remoteTags) {
String remoteResourceId = remoteTag.getResourceId();
EnvTag tag = tags.computeIfAbsent(remoteResourceId, key -> new EnvTag(remoteTag));
tag.addField(remoteTag);
}
return new ArrayList<>(tags.values());
}
开发者ID:neowu,项目名称:cmn-project,代码行数:16,代码来源:RemoteResourceLoader.java
示例8: getObject_userTagDataAvailable_objectContainsAllAvailableKeys
import com.amazonaws.services.ec2.model.TagDescription; //导入依赖的package包/类
@Test
public void getObject_userTagDataAvailable_objectContainsAllAvailableKeys() throws Exception {
//Arrange
AmazonEC2 amazonEC2 = mock(AmazonEC2.class);
InstanceIdProvider instanceIdProvider = mock(InstanceIdProvider.class);
when(instanceIdProvider.getCurrentInstanceId()).thenReturn("1234567890");
DescribeTagsRequest describeTagsRequest = new DescribeTagsRequest().withFilters(
new Filter("resource-id", Collections.singletonList("1234567890")),
new Filter("resource-type", Collections.singletonList("instance")));
DescribeTagsResult describeTagsResult = new DescribeTagsResult().withTags(
new TagDescription().withKey("keyA").withResourceType(ResourceType.Instance).withValue("valueA"),
new TagDescription().withKey("keyB").withResourceType(ResourceType.Instance).withValue("valueB")
);
when(amazonEC2.describeTags(describeTagsRequest)).thenReturn(describeTagsResult);
AmazonEc2InstanceUserTagsFactoryBean amazonEc2InstanceUserTagsFactoryBean = new AmazonEc2InstanceUserTagsFactoryBean(amazonEC2, instanceIdProvider);
//Act
amazonEc2InstanceUserTagsFactoryBean.afterPropertiesSet();
Map<String, String> resultMap = amazonEc2InstanceUserTagsFactoryBean.getObject();
//Assert
assertEquals("valueA", resultMap.get("keyA"));
assertEquals("valueB", resultMap.get("keyB"));
assertFalse(resultMap.containsKey("keyC"));
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:31,代码来源:AmazonEc2InstanceUserTagsFactoryBeanTest.java
示例9: getTags
import com.amazonaws.services.ec2.model.TagDescription; //导入依赖的package包/类
/**
* Describe Tags.
* @return TagsDescription
*/
protected final List<TagDescription> getTags() {
DescribeTagsResult result = amazonEC2Client.describeTags();
List<TagDescription> tagsDesc = null;
if (result != null) {
tagsDesc = result.getTags();
}
return tagsDesc;
}
开发者ID:treelogic-swe,项目名称:aws-mock,代码行数:16,代码来源:BaseTest.java
示例10: getTags
import com.amazonaws.services.ec2.model.TagDescription; //导入依赖的package包/类
/**
* Gets a map of tags for an AWS EC2 instance
* @param instanceId the EC2 instance ID
* @return Map of AWS tags
*/
public Map<String, String> getTags(String instanceId) {
Filter filter = new Filter("resource-id", Arrays.asList(instanceId));
DescribeTagsResult result = amazonEC2Client.describeTags(new DescribeTagsRequest().withFilters(filter));
return result.getTags().stream().collect(Collectors.toMap(TagDescription::getKey, TagDescription::getValue));
}
开发者ID:shinesolutions,项目名称:aem-orchestrator,代码行数:11,代码来源:AwsHelperService.java
示例11: describeTags
import com.amazonaws.services.ec2.model.TagDescription; //导入依赖的package包/类
public List<TagDescription> describeTags(DescribeTagsRequest request) {
logger.info("describe tags, request={}", request);
DescribeTagsResult result = ec2.describeTags(request);
Asserts.isNull(result.getNextToken(), "tags pagination is not supported yet, token={}", result.getNextToken());
return result.getTags();
}
开发者ID:neowu,项目名称:cmn-project,代码行数:7,代码来源:EC2.java
示例12: EnvTag
import com.amazonaws.services.ec2.model.TagDescription; //导入依赖的package包/类
public EnvTag(TagDescription tag) {
String resourceType = tag.getResourceType();
resourceClass = Asserts.notNull(RESOURCE_TYPES.get(resourceType), "not supported resourceType, type={}", resourceType);
remoteResourceId = tag.getResourceId();
}
开发者ID:neowu,项目名称:cmn-project,代码行数:6,代码来源:EnvTag.java
示例13: addField
import com.amazonaws.services.ec2.model.TagDescription; //导入依赖的package包/类
public void addField(TagDescription remoteTag) {
String key = remoteTag.getKey();
int index = key.lastIndexOf(':');
String field = key.substring(index + 1);
fields.put(field, remoteTag.getValue());
}
开发者ID:neowu,项目名称:cmn-project,代码行数:7,代码来源:EnvTag.java
注:本文中的com.amazonaws.services.ec2.model.TagDescription类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论