當前位置: 首頁>>代碼示例>>Java>>正文


Java Tag.getKey方法代碼示例

本文整理匯總了Java中com.amazonaws.services.ec2.model.Tag.getKey方法的典型用法代碼示例。如果您正苦於以下問題:Java Tag.getKey方法的具體用法?Java Tag.getKey怎麽用?Java Tag.getKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.amazonaws.services.ec2.model.Tag的用法示例。


在下文中一共展示了Tag.getKey方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: convertInstanceToServer

import com.amazonaws.services.ec2.model.Tag; //導入方法依賴的package包/類
private List<Server> convertInstanceToServer(List<Instance> instances) {
    List<Server> servers = new ArrayList<>();
    for (Instance instance : instances) {
        Server server = new Server(instance.getInstanceId());
        for (Tag tag : instance.getTags()) {
            if (tag != null && tag.getKey() != null
                    && tag.getKey().equals("Name")) {
                server.setName(tag.getValue());
            }
        }
        server.setStatus(instance.getState().getName());
        server.setType(instance.getInstanceType());
        server.setPublicIP(Arrays.asList(instance.getPublicIpAddress()));
        server.setPrivateIP(Arrays.asList(instance.getPrivateIpAddress()));
        servers.add(server);
    }
    return servers;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:19,代碼來源:EC2Processor.java

示例2: 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

示例3: 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

示例4: 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

示例5: 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.getKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。