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


Java Tag.getValue方法代码示例

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


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

示例1: findInstanceByName

import com.amazonaws.services.ec2.model.Tag; //导入方法依赖的package包/类
/**
 * Search Ec2 Instance by Name tag.
 * 
 * @param ec2
 * @param targetName
 *            Search Keyword for Name tag
 * @return Instance with Name tag equals targetName. If it does't found,
 *         then return null.
 */
public static Instance findInstanceByName(AmazonEC2 ec2, String targetName) {
	DescribeInstancesResult instanceResult = ec2.describeInstances();
	List<Reservation> reservations = instanceResult.getReservations();
	for (Reservation reservation : reservations) {
		List<Instance> instances = reservation.getInstances();
		for (Instance instance : instances) {
			List<Tag> tagList = instance.getTags();
			String name = "";
			for (Tag tag : tagList) {
				String tagKey = tag.getKey();
				String tagValue = tag.getValue();
				if (tagKey.contains("Name")) {
					name = tagValue;
					if (targetName.equals(name)) {
						return instance;
					}
					break;
				}
			}
		}
	}
	return null;
}
 
开发者ID:betahikaru,项目名称:ec2-util,代码行数:33,代码来源:AwsEc2Client.java

示例2: getVolumeIdFromTag

import com.amazonaws.services.ec2.model.Tag; //导入方法依赖的package包/类
String getVolumeIdFromTag(AmazonEC2Async client, String snapshotId) {
	List<Tag> snapshotTag = client.describeSnapshots(new DescribeSnapshotsRequest().withSnapshotIds(snapshotId))
			.getSnapshots().get(0).getTags();
	String volumeId = null;
	for (Tag tag : snapshotTag) {
		if ("VolumeId".equals(tag.getKey())) {
			volumeId = tag.getValue();
		}
	}
	if (volumeId == null) {
		throw new RuntimeException("volumeId can not found snapshot. snapshotId[" + snapshotId + "]");
	}
	return volumeId;

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

示例3: getTagValue

import com.amazonaws.services.ec2.model.Tag; //导入方法依赖的package包/类
/**
 * Get the Tag value corresponding to the provided key.
 */
public static String getTagValue(List<Tag> tags, String key) {
    for (Tag tag : tags) {
        if (tag.getKey().equals(key)) {
            return tag.getValue();
        }
    }
    return null;
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:12,代码来源:AWSEnumerationUtils.java

示例4: getTagValue

import com.amazonaws.services.ec2.model.Tag; //导入方法依赖的package包/类
public static String getTagValue( Instance instance, String tagKey ) {
	String tagValue = "";
	for ( Tag tag : instance.getTags() ) {
		if ( tag.getKey().equals( tagKey ) ) {
			tagValue = tag.getValue();
			break;
		}
	}
	return tagValue;
}
 
开发者ID:CodeArcsInc,项目名称:candlestack,代码行数:11,代码来源:EC2Util.java

示例5: getVirtualInstanceId

import com.amazonaws.services.ec2.model.Tag; //导入方法依赖的package包/类
/**
 * Determines the virtual instance ID from the specified list of tags.
 *
 * @param tags the tags
 * @param type the type of tagged object
 * @return the virtual instance ID
 * @throws IllegalStateException if the tags do not contain the virtual instance ID
 */
private String getVirtualInstanceId(List<Tag> tags, String type) {
  String idTagName = ec2TagHelper.getClouderaDirectorIdTagName();
  for (Tag tag : tags) {
    if (tag.getKey().equals(idTagName)) {
      return tag.getValue();
    }
  }

  throw new IllegalStateException(String.format("Any %s managed by " +
      "Cloudera Director should have a %s tag.", type, idTagName));
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:20,代码来源:EC2Provider.java

示例6: getEnvironmentFromInstance

import com.amazonaws.services.ec2.model.Tag; //导入方法依赖的package包/类
private ServerEnvironment getEnvironmentFromInstance(Instance instance) {
    ServerEnvironment env = new ServerEnvironment(instance.getInstanceId(), instance.getInstanceType());

    List<EnvironmentTag> tags = new ArrayList<EnvironmentTag>();
    for (Tag tag : instance.getTags()) {
        EnvironmentTag envTag = new EnvironmentTag(tag.getKey(), tag.getValue());
        tags.add(envTag);
        if (tag.getKey().equalsIgnoreCase(DEFAULT_INSTANCE_NAME_TAG)) {
            env.setEnvironmentTag(tag.getValue());
            if (tag.getValue().contains(PROD_VALUE)) {
                env.setType(ENVIRONMENT_TYPES.PRODUCTION);
            } else if (tag.getValue().contains(STAGING_VALUE)) {
                env.setType(ENVIRONMENT_TYPES.STAGING);
            } else if (tag.getValue().contains(JENKINS_VALUE)) {
                env.setType(ENVIRONMENT_TYPES.JENKINS);
            }
        }
        if (tag.getKey().equalsIgnoreCase(VERSION_TAG)) {
            env.setVersion(tag.getValue());
        }
    }
    env.setState(instance.getState());
    env.setLaunchTime(instance.getLaunchTime());
    env.setPublicIpAddress(instance.getPublicIpAddress());
    env.setTags(tags);
    return env;
}
 
开发者ID:codecentric,项目名称:jenkins-deployment-dashboard-plugin,代码行数:28,代码来源:EC2Connector.java

示例7: getTag

import com.amazonaws.services.ec2.model.Tag; //导入方法依赖的package包/类
/**
 * Retrieves a particular meta data tag value from an {@link Instance} or
 * return <code>null</code> if no such tag key is set on the instance.
 *
 * @param instance
 * @param tagKey
 * @return The value set for the key or <code>null</code> if not found.
 */
private static String getTag(Instance instance, String tagKey) {
    List<Tag> tags = instance.getTags();
    for (Tag tag : tags) {
        if (tag.getKey().equals(tagKey)) {
            return tag.getValue();
        }
    }
    return null;
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:18,代码来源:TestEc2PoolDriverOperation.java

示例8: getNameOfInstance

import com.amazonaws.services.ec2.model.Tag; //导入方法依赖的package包/类
private String getNameOfInstance(Instance x) {
    for (Tag tag : x.getTags()) {
        if("Name".equals(tag.getKey())) {
            return tag.getValue();
        }
    }

    return null;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-aws,代码行数:10,代码来源:InstanceLookupTable.java

示例9: getTag

import com.amazonaws.services.ec2.model.Tag; //导入方法依赖的package包/类
private String getTag(Instance instance) {
    for (Tag tag : instance.getTags()) {
        if (TAG_NAME.equals(tag.getKey())) {
            String value = tag.getValue();
            LOGGER.info("Instance: {} was already tagged: {}", instance.getInstanceId(), value);
            return value;
        }
    }
    return null;
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:11,代码来源:AwsMetadataCollector.java

示例10: checkForOrphanedSpotInstanceRequests

import com.amazonaws.services.ec2.model.Tag; //导入方法依赖的package包/类
/**
 * Identifies reusable Spot instance requests orphaned by a previous call.
 *
 * @return the reusable Spot instance requests orphaned by a previous call
 */
@VisibleForTesting
protected Set<String> checkForOrphanedSpotInstanceRequests() {

  Set<String> orphanedSpotInstanceRequests = Sets.newHashSet();

  LOG.info(">> Checking for orphaned Spot instance requests");
  String idTagName = ec2TagHelper.getClouderaDirectorIdTagName();
  DescribeSpotInstanceRequestsRequest describeSpotInstanceRequestsRequest =
      new DescribeSpotInstanceRequestsRequest().withFilters(
          new Filter()
              .withName("tag:" + idTagName)
              .withValues(virtualInstanceIds));
  DescribeSpotInstanceRequestsResult describeSpotInstanceRequestsResult =
      client.describeSpotInstanceRequests(describeSpotInstanceRequestsRequest);
  for (SpotInstanceRequest existingSpotInstanceRequest :
      describeSpotInstanceRequestsResult.getSpotInstanceRequests()) {
    String spotInstanceRequestId = existingSpotInstanceRequest.getSpotInstanceRequestId();
    String virtualInstanceId = null;
    for (Tag tag : existingSpotInstanceRequest.getTags()) {
      if (idTagName.equals(tag.getKey())) {
        virtualInstanceId = tag.getValue();
      }
    }
    if (virtualInstanceId == null) {
      LOG.warn(">> Orphaned Spot instance request {} has no virtual instance id",
          spotInstanceRequestId);
    } else {
      SpotAllocationRecord spotAllocationRecord = getSpotAllocationRecord(virtualInstanceId);
      SpotInstanceState spotInstanceState =
          SpotInstanceState.fromValue(existingSpotInstanceRequest.getState());
      switch (spotInstanceState) {
        case Active:
          spotAllocationRecord.spotInstanceRequestId = spotInstanceRequestId;
          String ec2InstanceId = existingSpotInstanceRequest.getInstanceId();
          LOG.info(">> Reusing fulfilled orphaned Spot instance request {} / {} / {}",
              spotInstanceRequestId, virtualInstanceId, ec2InstanceId);
          if (spotAllocationRecord.ec2InstanceId == null) {
            spotAllocationRecord.ec2InstanceId = ec2InstanceId;
          }
          break;
        case Cancelled:
        case Closed:
        case Failed:
          break;
        default:
          if (existingSpotInstanceRequest.getValidUntil().getTime() > System.currentTimeMillis()) {
            LOG.info(">> Reusing pending orphaned Spot instance request {} / {}",
                spotInstanceRequestId, virtualInstanceId);
            spotAllocationRecord.spotInstanceRequestId = spotInstanceRequestId;
          }
          break;
      }
    }
  }

  return orphanedSpotInstanceRequests;
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:63,代码来源:EC2Provider.java

示例11: EC2Tag

import com.amazonaws.services.ec2.model.Tag; //导入方法依赖的package包/类
public EC2Tag(Tag t) {
    name = t.getKey();
    value = t.getValue();
}
 
开发者ID:hudson3-plugins,项目名称:ec2-plugin,代码行数:5,代码来源:EC2Tag.java

示例12: TagDTO

import com.amazonaws.services.ec2.model.Tag; //导入方法依赖的package包/类
public TagDTO(Tag tag) {
    this.key = tag.getKey();
    this.value = tag.getValue();
}
 
开发者ID:kylesm,项目名称:vpcviewer,代码行数:5,代码来源:TagDTO.java


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