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


Java TemplateBuilder类代码示例

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


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

示例1: DimensionDataCloudControllerComputeService

import org.jclouds.compute.domain.TemplateBuilder; //导入依赖的package包/类
@Inject
protected DimensionDataCloudControllerComputeService(ComputeServiceContext context, Map<String, Credentials> credentialStore,
                                                     @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
                                                     @Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
                                                     GetImageStrategy getImageStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy,
                                                     CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy,
                                                     DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy startNodeStrategy,
                                                     SuspendNodeStrategy stopNodeStrategy, Provider<TemplateBuilder> templateBuilderProvider,
                                                     @Named("DEFAULT") Provider<TemplateOptions> templateOptionsProvider,
                                                     @Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
                                                     @Named(TIMEOUT_NODE_TERMINATED) Predicate<AtomicReference<NodeMetadata>> nodeTerminated,
                                                     @Named(TIMEOUT_NODE_SUSPENDED) Predicate<AtomicReference<NodeMetadata>> nodeSuspended,
                                                     InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory,
                                                     RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess,
                                                     PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
                                                     @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
                                                     CleanupServer cleanupServer,
                                                     Optional<ImageExtension> imageExtension,
                                                     Optional<SecurityGroupExtension> securityGroupExtension) {
   super(context, credentialStore, images, sizes, locations, listNodesStrategy, getImageStrategy,
            getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy,
            startNodeStrategy, stopNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning,
            nodeTerminated, nodeSuspended, initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory,
            persistNodeCredentials, timeouts, userExecutor, imageExtension, securityGroupExtension);
   this.cleanupServer = checkNotNull(cleanupServer, "cleanupServer");
}
 
开发者ID:cloudsoft,项目名称:amp-dimensiondata,代码行数:27,代码来源:DimensionDataCloudControllerComputeService.java

示例2: ECSComputeService

import org.jclouds.compute.domain.TemplateBuilder; //导入依赖的package包/类
@Inject
protected ECSComputeService(
      ComputeServiceContext context,
      ECSComputeServiceAdapter client,
      Map<String, Credentials> credentialStore,
      @Memoized Supplier<Set<? extends Image>> images,
      Supplier<Set<? extends Hardware>> hardwareProfiles,
      @Memoized Supplier<Set<? extends Location>> locations,
      ListNodesStrategy listNodesStrategy,
      GetImageStrategy getImageStrategy,
      GetNodeMetadataStrategy getNodeMetadataStrategy,
      CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy,
      RebootNodeStrategy rebootNodeStrategy,
      DestroyNodeStrategy destroyNodeStrategy,
      ResumeNodeStrategy resumeNodeStrategy,
      SuspendNodeStrategy suspendNodeStrategy,
      @Named("ECS") Provider<TemplateBuilder> templateBuilderProvider,
      @Named("ECS") Provider<TemplateOptions> templateOptionsProvider,
      @Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
      @Named(TIMEOUT_NODE_TERMINATED) Predicate<AtomicReference<NodeMetadata>> nodeTerminated,
      @Named(TIMEOUT_NODE_SUSPENDED) Predicate<AtomicReference<NodeMetadata>> nodeSuspended,
      Factory initScriptRunnerFactory,
      InitAdminAccess initAdminAccess,
      org.jclouds.compute.callables.RunScriptOnNode.Factory runScriptOnNodeFactory,
      PersistNodeCredentials persistNodeCredentials,
      Timeouts timeouts,
      @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
      Optional<ImageExtension> imageExtension,
      Optional<SecurityGroupExtension> securityGroupExtension) {
   super(context, credentialStore, images, hardwareProfiles, locations, listNodesStrategy, getImageStrategy,
         getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy, resumeNodeStrategy,
         suspendNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning, nodeTerminated, nodeSuspended,
         initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory, persistNodeCredentials, timeouts, userExecutor,
         imageExtension, securityGroupExtension);
   this.client = client;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:37,代码来源:ECSComputeService.java

示例3: guiceProvideTemplateBuilder

import org.jclouds.compute.domain.TemplateBuilder; //导入依赖的package包/类
@Provides
@Named("ECS")
protected final TemplateBuilder guiceProvideTemplateBuilder(TemplateBuilder template) {
   return template.imageId("cn-shanghai:aliyun1501_64_20G_aliaegis_20150325.vhd")
         .hardwareId("ecs.t1.small")
         .locationId("cn-hangzhou");
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:8,代码来源:ECSComputeServiceContextModule.java

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

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

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

示例7: testVSphereContext

import org.jclouds.compute.domain.TemplateBuilder; //导入依赖的package包/类
public void testVSphereContext() throws RunNodesException {
      ImmutableSet modules = ImmutableSet.of(new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor()), new SshjSshClientModule());
      ComputeServiceContext context = ContextBuilder.newBuilder("vsphere")
//                .credentials("root", "master1234")
//                .endpoint("https://10.56.161.100/sdk")
              .credentials("root", "vmware")
              .endpoint("https://10.45.7.70/sdk")
              .modules(modules)
              .buildView(ComputeServiceContext.class);

      TemplateBuilder b = context.getComputeService().templateBuilder();
      TemplateOptions o = context.getComputeService().templateOptions();
      ((VSphereTemplateOptions) o).isoFileName("ISO/UCSInstall_UCOS_3.1.0.0-9914.iso");
      ((VSphereTemplateOptions) o).flpFileName("ISO/image.flp");
      ((VSphereTemplateOptions) o).postConfiguration(false);
      o.tags(ImmutableSet.of("from UnitTest"))
              .nodeNames(ImmutableSet.of("first-vm12"))
              .networks("VLAN537");
//        b.imageId("Cisco Centos 6.5").smallest();
//        b.imageId("Cisco Centos 6.5.0").smallest().options(o);
      //b.imageId("Cisco Centos 6.5").locationId("default").smallest().options(o);
      b.imageId("conductor-mgt").locationId("default").minRam(6000).options(o);

      // Set images = context.getComputeService().listNodesByIds(ImmutableSet.of("junit-test-9b7"));
      Set<? extends NodeMetadata> nodes = context.getComputeService().createNodesInGroup("junit-test", 1, b.build());

      System.out.print("");
   }
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:29,代码来源:ContextBuilderTest.java

示例8: testPhenixVsphere

import org.jclouds.compute.domain.TemplateBuilder; //导入依赖的package包/类
public void testPhenixVsphere() throws Exception {
      ImmutableSet modules = ImmutableSet.of(new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor()), new SshjSshClientModule());
      Properties p = new Properties();
      p.put("jclouds.vsphere.vm.password", "Nat0d12");
      ComputeServiceContext context = ContextBuilder.newBuilder("vsphere")
              .credentials("root", "vmware")
              .endpoint("https://10.63.120.120/sdk")
//              .credentials("[email protected]", "c1-Scope")
//              .endpoint("https://vcte-vcenter.cisco.com/sdk")
              .modules(modules)
              .overrides(p)
              .buildView(ComputeServiceContext.class);

      TemplateBuilder b = context.getComputeService().templateBuilder();
      TemplateOptions o = context.getComputeService().templateOptions();
      ((VSphereTemplateOptions) o).postConfiguration(true);
      ((VSphereTemplateOptions) o).distributedVirtualSwitch(true);
      ((VSphereTemplateOptions) o).vmFolder("campnou");
      ((VSphereTemplateOptions) o).datacenterName("PHOENIX");

      o.tags(ImmutableSet.of("from UnitTest"))
              .nodeNames(ImmutableSet.of("first-vm12"))
              .networks("BVLAN_293");
//        b.imageId("Cisco Centos 6.5").smallest();
//        b.imageId("Cisco Centos 6.5.0").smallest().options(o);
      //b.imageId("Cisco Centos 6.5").locationId("default").smallest().options(o);
      b.imageId("SCOPE-TMP-DB").locationId("PHOENIX").minRam(10000).options(o);

      // Set images = context.getComputeService().listNodesByIds(ImmutableSet.of("junit-test-9b7"));
      Set<? extends NodeMetadata> nodes = context.getComputeService().createNodesInGroup("junit-test", 1, b.build());

//      ServiceInstance serviceInstance = new ServiceInstance(new URL("https://10.63.120.120/sdk"), "root", "vmware", true);
//
//      ManagedEntity entity = new InventoryNavigator(serviceInstance.getRootFolder()).searchManagedEntity("DistributedVirtualPortgroup", "VLAN_283");
//      ManagedEntity entity1 = new InventoryNavigator(serviceInstance.getRootFolder()).searchManagedEntity("Folder", "GADWALL");

      System.out.print("");
   }
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:39,代码来源:ContextBuilderTest.java

示例9: apply

import org.jclouds.compute.domain.TemplateBuilder; //导入依赖的package包/类
@Override
public final VirtualMachine apply(final VirtualMachineTemplate virtualMachineTemplate) {

  final VirtualMachineTemplate virtualMachineTemplateToUse =
      modifyVirtualMachineTemplate(virtualMachineTemplate);

  final TemplateBuilder templateBuilder = jCloudsComputeClient.templateBuilder();

  templateBuilder.hardwareId(virtualMachineTemplateToUse.hardwareFlavorId())
      .imageId(virtualMachineTemplateToUse.imageId())
      .locationId(virtualMachineTemplateToUse.locationId());

  final org.jclouds.compute.options.TemplateOptions jcloudsTemplateOptions;

  if (virtualMachineTemplate.templateOptions().isPresent()) {
    //convert the template options
    jcloudsTemplateOptions =
        templateOptionsConverter.apply(virtualMachineTemplateToUse.templateOptions().get());

  } else {
    //create a template options object for setting the name
    jcloudsTemplateOptions = this.newTemplateOptions();
    templateBuilder.options(jcloudsTemplateOptions);
  }

  //set the name
  jcloudsTemplateOptions.nodeNames(Collections
      .singleton(namingStrategy.generateUniqueNameBasedOnName(virtualMachineTemplate.name())));

  //call extension point
  templateBuilder
      .options(modifyTemplateOptions(virtualMachineTemplate, jcloudsTemplateOptions));

  final Template template = templateBuilder.build();

  return this.computeMetadataVirtualMachineConverter
      .apply(this.jCloudsComputeClient.createNode(template));
}
 
开发者ID:cloudiator,项目名称:sword,代码行数:39,代码来源:JCloudsCreateVirtualMachineStrategy.java

示例10: AWSEC2TemplateBuilderImpl

import org.jclouds.compute.domain.TemplateBuilder; //导入依赖的package包/类
@Inject
protected AWSEC2TemplateBuilderImpl(@Memoized Supplier<Set<? extends Location>> locations,
      ImageCacheSupplier images, @Memoized Supplier<Set<? extends Hardware>> sizes,
      Supplier<Location> defaultLocation, @Named("DEFAULT") Provider<TemplateOptions> optionsProvider,
      @Named("DEFAULT") Provider<TemplateBuilder> defaultTemplateProvider, GetImageStrategy getImageStrategy,
      Supplier<LoadingCache<RegionAndName, ? extends Image>> imageMap) {
   super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider, getImageStrategy, imageMap);
}
 
开发者ID:apache,项目名称:stratos,代码行数:9,代码来源:AWSEC2TemplateBuilderImpl.java

示例11: configure

import org.jclouds.compute.domain.TemplateBuilder; //导入依赖的package包/类
@Override
protected void configure() {
   bind(TemplateBuilder.class).to(EC2TemplateBuilderImpl.class);
   bind(TemplateOptions.class).to(AWSEC2TemplateOptions.class);
   bind(ComputeService.class).to(AWSEC2ComputeService.class);
   bind(new TypeLiteral<CacheLoader<RunningInstance, Optional<LoginCredentials>>>() {
   }).to(CredentialsForInstance.class);
   bind(new TypeLiteral<CacheLoader<RegionAndName, String>>() {
   }).annotatedWith(Names.named("SECURITY")).to(AWSEC2CreateSecurityGroupIfNeeded.class);
   bind(new TypeLiteral<CacheLoader<RegionAndName, String>>() {
   }).annotatedWith(Names.named("ELASTICIP")).to(LoadPublicIpForInstanceOrNull.class);
   bind(new TypeLiteral<Function<String, String>>() {
   }).annotatedWith(Names.named("SECGROUP_NAME_TO_ID")).to(EC2SecurityGroupIdFromName.class);
   bind(new TypeLiteral<Function<PasswordDataAndPrivateKey, LoginCredentials>>() {
   }).to(WindowsLoginCredentialsFromEncryptedData.class);
   bind(new TypeLiteral<Function<RunningInstance, LoginCredentials>>() {
   }).to(PasswordCredentialsFromWindowsInstance.class);
   bind(new TypeLiteral<Function<RegionAndName, KeyPair>>() {
   }).to(CreateUniqueKeyPair.class);
   bind(new TypeLiteral<Function<RegionNameAndPublicKeyMaterial, KeyPair>>() {
   }).to(ImportOrReturnExistingKeypair.class);
   bind(new TypeLiteral<CacheLoader<RegionAndName, Image>>() {
   }).to(RegionAndIdToImage.class);
   install(new FactoryModuleBuilder().build(CallForImages.Factory.class));
   bind(new TypeLiteral<Function<org.jclouds.ec2.domain.Image, Image>>() {
   }).to(EC2ImageParser.class);
   bind(new TypeLiteral<Function<org.jclouds.ec2.domain.SecurityGroup, SecurityGroup>>() {
   }).to(AWSEC2SecurityGroupToSecurityGroup.class);
   bind(new TypeLiteral<ImageExtension>() {
   }).to(EC2ImageExtension.class);
   bind(new TypeLiteral<SecurityGroupExtension>() {
   }).to(AWSEC2SecurityGroupExtension.class);
}
 
开发者ID:apache,项目名称:stratos,代码行数:34,代码来源:AWSEC2ComputeServiceDependenciesModule.java

示例12: AWSEC2ComputeService

import org.jclouds.compute.domain.TemplateBuilder; //导入依赖的package包/类
@Inject
protected AWSEC2ComputeService(ComputeServiceContext context, Map<String, Credentials> credentialStore,
      @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
      @Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
      GetImageStrategy getImageStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy,
      CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy,
      DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy startNodeStrategy,
      SuspendNodeStrategy stopNodeStrategy, Provider<TemplateBuilder> templateBuilderProvider,
      @Named("DEFAULT") Provider<TemplateOptions> templateOptionsProvider,
      @Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
      @Named(TIMEOUT_NODE_TERMINATED) Predicate<AtomicReference<NodeMetadata>> nodeTerminated,
      @Named(TIMEOUT_NODE_SUSPENDED) Predicate<AtomicReference<NodeMetadata>> nodeSuspended,
      InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory,
      RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess,
      PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
      @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, AWSEC2Api client,
      ConcurrentMap<RegionAndName, KeyPair> credentialsMap,
      @Named("SECURITY") LoadingCache<RegionAndName, String> securityGroupMap,
      @Named("PLACEMENT") LoadingCache<RegionAndName, String> placementGroupMap,
      @Named("DELETED") Predicate<PlacementGroup> placementGroupDeleted, Optional<ImageExtension> imageExtension,
      GroupNamingConvention.Factory namingConvention,
      @Named(PROPERTY_EC2_GENERATE_INSTANCE_NAMES) boolean generateInstanceNames,
      Optional<SecurityGroupExtension> securityGroupExtension) {
   super(context, credentialStore, images, sizes, locations, listNodesStrategy, getImageStrategy,
         getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy,
         startNodeStrategy, stopNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning,
         nodeTerminated, nodeSuspended, initScriptRunnerFactory, runScriptOnNodeFactory, initAdminAccess,
         persistNodeCredentials, timeouts, userExecutor, client, credentialsMap, securityGroupMap, imageExtension,
         namingConvention, generateInstanceNames, securityGroupExtension);
   this.client = client;
   this.placementGroupMap = placementGroupMap;
   this.placementGroupDeleted = placementGroupDeleted;
}
 
开发者ID:apache,项目名称:stratos,代码行数:34,代码来源:AWSEC2ComputeService.java

示例13: EC2Node

import org.jclouds.compute.domain.TemplateBuilder; //导入依赖的package包/类
public EC2Node(EC2CloudProvider ec2CloudProvider, String name, Map<String, String> configOverrides) {
    super(ec2CloudProvider, name, configOverrides);

    EC2TemplateOptions templateOptions = buildTemplateOptions(objectProperties);
    final TemplateBuilder templateBuilder = computeService.templateBuilder();

    final String region = getRegion();
    final String instanceType = getInstanceType();

    if (Strings.isNullOrEmpty(region)) {
        throw new IllegalArgumentException("No region was provided for node " + name);
    }
    if (Strings.isNullOrEmpty(instanceType)) {
        throw new IllegalArgumentException("No instance type was provided for node " + name);
    }

    ResolvedImage resolvedImage = ResolvedImage.fromNameAndId(
            objectProperties.getProperty(Config.Node.EC2.IMAGE),
            objectProperties.getProperty(Config.Node.EC2.IMAGE_ID),
            region,
            computeService
    );

    this.imageName = resolvedImage.humanReadableName;

    final Template template = templateBuilder
            .hardwareId(instanceType)
            .locationId(region)
            .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,代码行数:45,代码来源:EC2Node.java

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

示例15: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。