You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by "Andrew Phillips (JIRA)" <ji...@apache.org> on 2014/04/15 20:56:28 UTC

[jira] [Updated] (JCLOUDS-467) nameNodes only taking first name with AWS

     [ https://issues.apache.org/jira/browse/JCLOUDS-467?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrew Phillips updated JCLOUDS-467:
------------------------------------

    Fix Version/s:     (was: 1.7.2)
                   1.7.3

> nameNodes only taking first name with AWS
> -----------------------------------------
>
>                 Key: JCLOUDS-467
>                 URL: https://issues.apache.org/jira/browse/JCLOUDS-467
>             Project: jclouds
>          Issue Type: Bug
>          Components: jclouds-compute
>            Reporter: Everett Toews
>            Assignee: Andrew Bayer
>             Fix For: 1.8.0, 1.7.3
>
>
> I'll put nameNodes into TemplateOptions but only the first gets used.
> {code}
> public class NameNodes {
>     public static final String MCW = "multi-cloud-workshop";
>     public static final String LOAD_BALANCER = MCW + "-lb";
>     public static final String DATABASE = MCW + "-db";
>     public static final String WEB_SERVER_01 = MCW + "-webserver-01";
>     public static final String WEB_SERVER_02 = MCW + "-webserver-02";
>     private final ComputeService computeService;
>     public static void main(String[] args) {
>         NameNodes nameNodes = null;
>         try {
>             nameNodes = new NameNodes();
>             nameNodes.createServers();
>         } catch (Throwable e) {
>             e.printStackTrace();
>         } finally {
>             if (nameNodes != null) {
>                 nameNodes.close();
>             }
>         }
>     }
>     public NameNodes() throws IOException {
>         Iterable<Module> modules = ImmutableSet.<Module>of(
>                 new SLF4JLoggingModule(),
>                 new SshjSshClientModule());
>         Properties overrides = new Properties();
>         overrides.setProperty(POLL_INITIAL_PERIOD, "30000");
>         overrides.setProperty(POLL_MAX_PERIOD, "30000");
>         ComputeServiceContext context = ContextBuilder.newBuilder("aws-ec2")
>                 .credentials("myAwsAccessKeyId", "myAwsSecretAccessKey")
>                 .modules(modules)
>                 .overrides(overrides)
>                 .buildView(ComputeServiceContext.class);
>         computeService = context.getComputeService();
>     }
>     private Map<String, NodeMetadata> createServers() throws RunNodesException, IOException {
>         Set<String> nodeNames = ImmutableSet.of(DATABASE, WEB_SERVER_01, WEB_SERVER_02, LOAD_BALANCER);
>         System.out.println(format("Creating servers %s", Joiner.on(", ").join(nodeNames)));
>         TemplateOptions options = computeService.templateOptions()
>                 .nodeNames(nodeNames)
>                 .inboundPorts(22);
>         Template template = computeService.templateBuilder()
>                 .imageNameMatches("ubuntu/images/ubuntu-precise-12.04-amd64-server-20131003")
>                 .locationId("us-west-2")
>                 .hardwareId("m1.small")
>                 .options(options)
>                 .build();
>         Set<? extends NodeMetadata> nodes = computeService.createNodesInGroup(MCW, 4, template);
>         Map<String, NodeMetadata> nameToNode = newHashMap();
>         System.out.println("Created servers:");
>         for (NodeMetadata node: nodes) {
>             String name = node.getName();
>             String publicIpAddress = getOnlyElement(node.getPublicAddresses());
>             String user = node.getCredentials().getUser();
>             System.out.println(format("  %-40s %s@%s", name, user, publicIpAddress));
>             nameToNode.put(name, node);
>         }
>         return nameToNode;
>     }
>     private void close() {
>         computeService.getContext().close();
>     }
> }
> {code}
> The output is
> {code}
> Creating servers multi-cloud-workshop-db, multi-cloud-workshop-webserver-01, multi-cloud-workshop-webserver-02, multi-cloud-workshop-lb
> Created servers:
>   multi-cloud-workshop-db                  ubuntu@54.184.78.205
>   multi-cloud-workshop-db                  ubuntu@54.203.107.107
>   multi-cloud-workshop-db                  ubuntu@54.202.100.94
>   multi-cloud-workshop-db                  ubuntu@54.184.52.175
> {code}
> Confirmed the names of the instances in the AWS console too.



--
This message was sent by Atlassian JIRA
(v6.2#6252)