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


Java TemplateBuilder.locationId方法代码示例

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


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

示例1: getTemplateInRegion1

import org.jclouds.compute.domain.TemplateBuilder; //导入方法依赖的package包/类
public Template getTemplateInRegion1(Map<String, String> tags) {
    TemplateBuilder templateBuilder = computeService.templateBuilder();
    templateBuilder.locationId(AWS_REGION_1);
    templateBuilder.smallest();
    templateBuilder.options(userMetadata(tags));
    return templateBuilder.build();
}
 
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:8,代码来源:LiveComputeServiceUtil.java

示例2: getTemplateInRegion2

import org.jclouds.compute.domain.TemplateBuilder; //导入方法依赖的package包/类
public Template getTemplateInRegion2(Map<String, String> tags) {
    TemplateBuilder templateBuilder = computeService.templateBuilder();
    templateBuilder.locationId(AWS_REGION_2);
    templateBuilder.smallest();
    templateBuilder.options(userMetadata(tags));
    return templateBuilder.build();
}
 
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:8,代码来源:LiveComputeServiceUtil.java

示例3: createNode

import org.jclouds.compute.domain.TemplateBuilder; //导入方法依赖的package包/类
/**
 * Create a node with the specified group.
 */
protected void createNode(Exchange exchange) throws CamelException {
    String group = getGroup(exchange);
    String imageId = getImageId(exchange);
    String locationId = getLocationId(exchange);
    String hardwareId = getHardwareId(exchange);

    if (ObjectHelper.isEmpty(group)) {
        throw new CamelExchangeException("Group must be specific in the URI or as exchange property for the destroy node operation.", exchange);
    }
    TemplateBuilder builder = computeService.templateBuilder();
    builder.any();

    if (ObjectHelper.isNotEmpty(locationId)) {
        builder.locationId(locationId);
    }
    if (ObjectHelper.isNotEmpty(imageId)) {
        builder.imageId(imageId);
    }
    if (ObjectHelper.isNotEmpty(hardwareId)) {
        builder.hardwareId(hardwareId);
    }

    try {
        Set<? extends NodeMetadata> nodeMetadatas = computeService.createNodesInGroup(group, 1, builder.build());
        exchange.getOut().setBody(nodeMetadatas);
        exchange.getOut().setHeaders(exchange.getIn().getHeaders());
    } catch (RunNodesException e) {
        throw new CamelExchangeException("Error creating jclouds node.", exchange, e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:34,代码来源:JcloudsComputeProducer.java

示例4: OpenstackNode

import org.jclouds.compute.domain.TemplateBuilder; //导入方法依赖的package包/类
public OpenstackNode(OpenstackCloudProvider osCloudProvider, String name, Map<String, String> configOverrides) {
    super(osCloudProvider, name, configOverrides);

    NovaTemplateOptions templateOptions = buildTemplateOptions(objectProperties);

    final TemplateBuilder templateBuilder = computeService.templateBuilder();

    final String instanceType = objectProperties.getProperty(Config.Node.Openstack.INSTANCE_TYPE);
    if (!Strings.isNullOrEmpty(instanceType)) {
        String hwId = null;
        Set<? extends Hardware> hws = computeService.listHardwareProfiles();
        for (Hardware hw : hws) {
            String hwName = hw.getName();
            if (instanceType.equals(hw.getId()) || instanceType.equals(hwName)
                    || (hwName != null && hwName.endsWith("/" + instanceType))) {
                hwId = hw.getId();
                break;
            }
        }
        if (hwId == null) {
            throw new IllegalArgumentException("Hardware configuration '" + instanceType + "' was not found.");
        }
        templateBuilder.hardwareId(hwId);
    }
    String region = objectProperties.getProperty(Config.Node.Openstack.REGION);
    if (Strings.isNullOrEmpty(region)) {
        LOGGER.debug("Region for node '{}' was not configured, trying to assign automatically", name);
        Set<? extends Location> locations = computeService.listAssignableLocations();
        if (locations.size() == 1) {
            region = locations.iterator().next().getId();
            LOGGER.debug("Automatically assigned region '{}' to node '{}'", region, name);
        } else {
            LOGGER.warn("Failed to automatically assign region to node '{}', use {} (too many regions found: {})",
                    name, Config.Node.Openstack.REGION, locations);
            throw new IllegalArgumentException("Region was not configured for node " + name);
        }
    }
    templateBuilder.locationId(region);

    ResolvedImage resolvedImage = ResolvedImage.fromNameAndId(
            objectProperties.getProperty(Config.Node.Openstack.IMAGE),
            objectProperties.getProperty(Config.Node.Openstack.IMAGE_ID),
            region, computeService
    );
    this.imageName = resolvedImage.humanReadableName;

    if (!templateOptions.getFloatingIpPoolNames().isPresent()) {
        LOGGER.debug("Floating IP pool for node '{}' was not configured, trying to assign automatically", name);
        final Optional<FloatingIPPoolApi> floatingIPPoolApi = osCloudProvider.getNovaApi().getFloatingIPPoolApi(region);
        if (floatingIPPoolApi.isPresent()) {
            final ImmutableList<String> pools = floatingIPPoolApi.get().list().transform(FloatingIPPool::getName).toList();
            LOGGER.debug("Automatically assigned floating IP pools to node '{}': {}", name, pools);
            templateOptions.floatingIpPoolNames(pools);
        } else {
            LOGGER.error("FloatingIPPoolApi missing, floating IP pool stays unconfigured, use {}",
                    Config.Node.Openstack.FLOATING_IP_POOLS);
        }
    }

    final Template template = templateBuilder.imageId(resolvedImage.fullId).options(templateOptions).build();

    LOGGER.debug("Creating {} node from template: {}",
            cloudProvider.getCloudProviderType().getHumanReadableName(), template);
    try {
        this.initialNodeMetadata = createNode(template);
        String publicAddress = Iterables.getFirst(initialNodeMetadata.getPublicAddresses(), null);
        LOGGER.info("Started {} node '{}' from image {}, its public IP address is {}",
                cloudProvider.getCloudProviderType().getHumanReadableName(), name, imageName, publicAddress);
    } catch (RunNodesException e) {
        throw new RuntimeException("Unable to create " + cloudProvider.getCloudProviderType().getHumanReadableName()
                + " node from template " + template, e);
    }
}
 
开发者ID:wildfly-extras,项目名称:sunstone,代码行数:74,代码来源:OpenstackNode.java

示例5: buildTemplate

import org.jclouds.compute.domain.TemplateBuilder; //导入方法依赖的package包/类
@Override
protected Template buildTemplate(TemplateBuilder templateBuilder) {
   return super.buildTemplate(templateBuilder.locationId("NA9"));
}
 
开发者ID:cloudsoft,项目名称:amp-dimensiondata,代码行数:5,代码来源:DimensionDataCloudControllerComputeServiceLiveTest.java


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