org.jclouds.openstack.nova.v2_0.compute.strategy
Class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet

java.lang.Object
  extended by org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet
      extended by org.jclouds.openstack.nova.v2_0.compute.strategy.ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet
All Implemented Interfaces:
CreateNodesInGroupThenAddToSet

@Singleton
public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet
extends CreateNodesWithGroupEncodedIntoNameThenAddToSet

Author:
Adrian Cole

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet
CreateNodesWithGroupEncodedIntoNameThenAddToSet.AddNode
 
Field Summary
 
Fields inherited from class org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet
addNodeWithGroupStrategy, customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory, executor, listNodesStrategy, logger, namingConvention
 
Constructor Summary
protected ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet(CreateNodeWithGroupEncodedIntoName addNodeWithTagStrategy, ListNodesStrategy listNodesStrategy, GroupNamingConvention.Factory namingConvention, CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory, ExecutorService executor, AllocateAndAddFloatingIpToNode allocateAndAddFloatingIpToNode, com.google.common.cache.LoadingCache<ZoneAndName,SecurityGroupInZone> securityGroupCache, com.google.common.cache.LoadingCache<ZoneAndName,KeyPair> keyPairCache, NovaApi novaApi)
           
 
Method Summary
protected  Future<AtomicReference<NodeMetadata>> createNodeInGroupWithNameAndTemplate(String group, String name, Template template)
          This calls logic necessary to create a node and convert it from its provider-specific object to the jclouds NodeMetadata object.
 Map<?,Future<Void>> execute(String group, int count, Template template, Set<NodeMetadata> goodNodes, Map<NodeMetadata,Exception> badNodes, com.google.common.collect.Multimap<NodeMetadata,CustomizationResponse> customizationResponses)
          This implementation gets a list of acceptable node names to encode the group into, then it simultaneously runs the nodes and applies options to them.
 
Methods inherited from class org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet
getNextNames
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet

@Inject
protected ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet(CreateNodeWithGroupEncodedIntoName addNodeWithTagStrategy,
                                                                                         ListNodesStrategy listNodesStrategy,
                                                                                         GroupNamingConvention.Factory namingConvention,
                                                                                         CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory,
                                                                                         @Named(value="jclouds.user-threads")
                                                                                         ExecutorService executor,
                                                                                         AllocateAndAddFloatingIpToNode allocateAndAddFloatingIpToNode,
                                                                                         com.google.common.cache.LoadingCache<ZoneAndName,SecurityGroupInZone> securityGroupCache,
                                                                                         com.google.common.cache.LoadingCache<ZoneAndName,KeyPair> keyPairCache,
                                                                                         NovaApi novaApi)
Method Detail

execute

public Map<?,Future<Void>> execute(String group,
                                   int count,
                                   Template template,
                                   Set<NodeMetadata> goodNodes,
                                   Map<NodeMetadata,Exception> badNodes,
                                   com.google.common.collect.Multimap<NodeMetadata,CustomizationResponse> customizationResponses)
Description copied from class: CreateNodesWithGroupEncodedIntoNameThenAddToSet
This implementation gets a list of acceptable node names to encode the group into, then it simultaneously runs the nodes and applies options to them.

Specified by:
execute in interface CreateNodesInGroupThenAddToSet
Overrides:
execute in class CreateNodesWithGroupEncodedIntoNameThenAddToSet

createNodeInGroupWithNameAndTemplate

protected Future<AtomicReference<NodeMetadata>> createNodeInGroupWithNameAndTemplate(String group,
                                                                                     String name,
                                                                                     Template template)
Description copied from class: CreateNodesWithGroupEncodedIntoNameThenAddToSet
This calls logic necessary to create a node and convert it from its provider-specific object to the jclouds NodeMetadata object. This call directly precedes customization, such as executing scripts.

The outcome of this operation does not imply the node is running. If you want to insert logic after the node is created, yet before an attempt to customize the node, then append your behaviour to this method. ex. to attach an ip address post-creation
 @Override
 protected Future<AtomicReference<NodeMetadata>> createNodeInGroupWithNameAndTemplate(String group, String name,
          Template template) {
 
    Future<AtomicReference<NodeMetadata>> future = super.addNodeIntoGroupWithNameAndTemplate(group, name, template);
    return Futures.compose(future, new Function<AtomicReference<NodeMetadata>, AtomicReference<NodeMetadata>>() {
 
       @Override
       public AtomicReference<NodeMetadata> apply(AtomicReference<NodeMetadata> input) {
          NodeMetadata node = input.get();
          // allocate and attach an ip
          input.set(NodeMetadataBuilder.fromNodeMetadata(node).publicAddresses(ImmutableSet.of(ip.getIp())).build());
          return input;
       }
 
    }, executor);
 }
 

Overrides:
createNodeInGroupWithNameAndTemplate in class CreateNodesWithGroupEncodedIntoNameThenAddToSet
Parameters:
group - group the node belongs to
name - generated name of the node
template - user-specified template
Returns:
node that is created, yet not necessarily in NodeMetadata.Status.RUNNING


Copyright © 2009-2012 jclouds. All Rights Reserved.