Package org.jclouds.ec2.domain

Examples of org.jclouds.ec2.domain.RunningInstance


      checkNotNull(id, "id");
      String[] parts = AWSUtils.parseHandle(id);
      String region = parts[0];
      String instanceId = parts[1];
     
      RunningInstance instance = getOnlyElement(Iterables.concat(client.getInstanceApi().get().describeInstancesInRegion(region, instanceId)));

      if (instance == null) {
         return ImmutableSet.of();
      }
     
      Set<String> groupNames = instance.getGroupNames();
      Set<? extends org.jclouds.ec2.domain.SecurityGroup> rawGroups =
         client.getSecurityGroupApi().get().describeSecurityGroupsInRegion(region, Iterables.toArray(groupNames, String.class));
     
      return ImmutableSet.copyOf(transform(filter(rawGroups, notNull()), groupConverter));
   }
View Full Code Here


  private Map<String, String> getPrivateIpToPublicIP(List<RunningInstance> riList) {
    Map<String, String> privateIPMap = new HashMap<String, String>();
    Iterator<RunningInstance> runningInstanceIter = riList.iterator();
    while (runningInstanceIter.hasNext()) {
      RunningInstance ri = runningInstanceIter.next();
      privateIPMap.put(ri.getPrivateDnsName(), ri.getDnsName());
    }
    return privateIPMap;
  }
View Full Code Here

      try {
         if (command.equals("create")) {

            KeyPair pair = createKeyPair(client, name);

            RunningInstance instance = createSecurityGroupKeyPairAndInstance(client, name);

            System.out.printf("instance %s ready%n", instance.getId());
            System.out.printf("ip address: %s%n", instance.getIpAddress());
            System.out.printf("dns name: %s%n", instance.getDnsName());
            System.out.printf("login identity:%n%s%n", pair.getKeyMaterial());

         } else if (command.equals("destroy")) {
            destroySecurityGroupKeyPairAndInstance(client, name);
         } else {
View Full Code Here

            throws TimeoutException {
      // create a new security group
      createSecurityGroupAndAuthorizePorts(client, name);

      // create a new instance
      RunningInstance instance = runInstance(client, name, name);

      // await for the instance to start
      return blockUntilInstanceRunning(client, instance);
   }
View Full Code Here

   }

   @Test
   public void testPrivateIpAddressIncorrectlyInPublicAddressFieldGoesToPrivateAddressCollection() {
      RunningInstance instance = RunningInstance.builder().instanceId("id").imageId("image").instanceType("m1.small")
               .instanceState(InstanceState.RUNNING).rawState("running").region("us-east-1").ipAddress("10.1.1.1").build();

      RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.<Hardware> of(), ImmutableSet
               .<Location> of(), ImmutableSet.<Image> of(), ImmutableMap.<String, Credentials> of());
View Full Code Here

               "us-east-1/image").providerId("id").build().toString());
   }

   @Test
   public void testPublicIpAddressIncorrectlyInPrivateAddressFieldGoesToPublicAddressCollection() {
      RunningInstance instance = RunningInstance.builder().instanceId("id").imageId("image").instanceType("m1.small")
               .instanceState(InstanceState.RUNNING).rawState("running").region("us-east-1").privateIpAddress("1.1.1.1").build();

      RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.<Hardware> of(), ImmutableSet
               .<Location> of(), ImmutableSet.<Image> of(), ImmutableMap.<String, Credentials> of());
View Full Code Here

      RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.<Hardware> of(), ImmutableSet
               .<Location> of(), ImmutableSet.<Image> of(), ImmutableMap.<String, Credentials> of(
               "node#us-east-1/i-0799056f", creds));

      RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");

      assertEquals(
            parser.apply(server).toString(),
            new NodeMetadataBuilder().status(Status.RUNNING).backendStatus("running").hostname("ip-10-243-42-70")
                  .publicAddresses(ImmutableSet.<String> of()).privateAddresses(ImmutableSet.of("10.243.42.70"))
View Full Code Here

   @Test
   public void testApplyWhereTagDoesntMatchAndImageHardwareAndLocationNotFound() throws UnknownHostException {
      RunningInstanceToNodeMetadata parser = createNodeParser(ImmutableSet.<Hardware> of(), ImmutableSet
               .<Location> of(), ImmutableSet.<Image> of(), ImmutableMap.<String, Credentials> of());

      RunningInstance server = firstInstanceFromResource("/describe_instances_running.xml");

      assertEquals(parser.apply(server).toString(),
            new NodeMetadataBuilder().hostname("ip-10-243-42-70").status(Status.RUNNING).backendStatus("running")
                  .publicAddresses(ImmutableSet.<String> of()).privateAddresses(ImmutableSet.of("10.243.42.70"))
                  .publicAddresses(ImmutableSet.of("174.129.81.68")).imageId("us-east-1/ami-82e4b5c7")
View Full Code Here

      }
   }

   @Test(enabled = false, dependsOnMethods = "testCreateRunningInstance")
   void testReboot() throws InterruptedException, ExecutionException, TimeoutException, IOException {
      RunningInstance instance = getInstance(instanceId);
      System.out.printf("%d: %s rebooting instance %n", System.currentTimeMillis(), instanceId);
      client.getInstanceServices().rebootInstancesInRegion(null, instanceId);
      Thread.sleep(1000);
      instance = getInstance(instanceId);
      blockUntilWeCanSshIntoInstance(instance);
      SshClient ssh = sshFactory.create(HostAndPort.fromParts(instance.getIpAddress(), 22),
            LoginCredentials.builder().user("root").privateKey(keyPair.getKeyMaterial()).build());
      try {
         ssh.connect();
         ExecResponse uptime = ssh.exec("uptime");
         assert uptime.getOutput().indexOf("0 min") != -1 : "reboot didn't work: " + uptime;
View Full Code Here

         assert first.getCredentials() != null : first;
         assert first.getCredentials().identity != null : first;

         startedId = Iterables.getOnlyElement(nodes).getProviderId();

         RunningInstance instance = getInstance(instanceClient, startedId);

         assertEquals(instance.getKeyName(), group);

         // make sure we made our dummy group and also let in the user's group
         assertEquals(Sets.newTreeSet(instance.getGroupNames()), ImmutableSortedSet.<String> of("jclouds#" + group + "#"
                  + instance.getRegion(), group));

         // make sure our dummy group has no rules
         SecurityGroup secgroup = Iterables.getOnlyElement(securityGroupClient.describeSecurityGroupsInRegion(null,
                  "jclouds#" + group + "#" + instance.getRegion()));
         assert secgroup.size() == 0 : secgroup;

         // try to run a script with the original keyPair
         runScriptWithCreds(group, first.getOperatingSystem(),
               LoginCredentials.builder().user(first.getCredentials().identity).privateKey(result.getKeyMaterial())
View Full Code Here

TOP

Related Classes of org.jclouds.ec2.domain.RunningInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.