Package org.jclouds.gogrid.domain

Examples of org.jclouds.gogrid.domain.Server


      for (int i = 0; i < 500; i++)
         builder.append('a');

      String description = builder.toString();

      Server createdServer = api.getServerServices().addServer(nameOfServer,
               "GSI-f8979644-e646-4711-ad58-d98a5fa3612c", ram, availableIp.getIp(),
               new AddServerOptions().withDescription(description));
      assertNotNull(createdServer);
      assert serverLatestJobCompleted.apply(createdServer);
View Full Code Here


      Set<Ip> availableIps = api.getIpServices().getUnassignedPublicIpList();
      Ip availableIp = Iterables.getLast(availableIps);

      String ram = Iterables.get(api.getServerServices().getRamSizes(), 0).getName();

      Server createdServer = api.getServerServices().addServer(nameOfServer,
               "GSI-f8979644-e646-4711-ad58-d98a5fa3612c", ram, availableIp.getIp());
      assertNotNull(createdServer);
      assert serverLatestJobCompleted.apply(createdServer);

      // get server by name
View Full Code Here

      Set<Ip> availableIps = api.getIpServices().getUnassignedPublicIpList();

      String ram = Iterables.get(api.getServerServices().getRamSizes(), 0).getName();

      Server createdServer = api.getServerServices().addServer(nameOfServer,
               "GSI-f8979644-e646-4711-ad58-d98a5fa3612c", ram, Iterables.getLast(availableIps).getIp());

      assert serverLatestJobCompleted.apply(createdServer);

      // restart the server
View Full Code Here

      serversToDeleteAfterTheTests.add(nameOfServer);

      Set<Ip> availableIps = api.getIpServices().getUnassignedIpList();
      Ip availableIp = Iterables.getLast(availableIps);

      Server createdServer = api.getServerServices().addServer(nameOfServer,
               "GSI-f8979644-e646-4711-ad58-d98a5fa3612c", "1", availableIp.getIp());
      assertNotNull(createdServer);
      assert serverLatestJobCompleted.apply(createdServer);

      // get server by name
      Set<Server> response = api.getServerServices().getServersByName(nameOfServer);
      assert (response.size() == 1);
      createdServer = Iterables.getOnlyElement(response);

      Map<String, Credentials> credsMap = api.getServerServices().getServerCredentialsList();
      LoginCredentials instanceCredentials = LoginCredentials.fromCredentials(credsMap.get(createdServer.getName()));
      assertNotNull(instanceCredentials);

      HostAndPort socket = HostAndPort.fromParts(createdServer.getIp().getIp(), 22);
      SocketOpen socketOpen = Guice.createInjector().getInstance(SocketOpen.class);
      Predicate<HostAndPort> socketTester = retry(socketOpen, 180, 5, SECONDS);
      socketTester.apply(socket);

      // check that the get credentials call is the same as this
      assertEquals(api.getServerServices().getServerCredentials(createdServer.getId()), instanceCredentials);

      try {
         assertEquals(api.getServerServices().getServerCredentials(Long.MAX_VALUE), null);
      } catch (AssertionError e) {
         e.printStackTrace();
View Full Code Here

   }

   @Override
   public NodeAndInitialCredentials<Server> createNodeWithGroupEncodedIntoName(String group, String name,
            Template template) {
      Server addedServer = null;
      boolean notStarted = true;
      int numOfRetries = 20;
      GetIpListOptions unassignedIps = new GetIpListOptions().onlyUnassigned().inDatacenter(
               template.getLocation().getId()).onlyWithType(IpType.PUBLIC);
      // lock-free consumption of a shared resource: IP address pool
      while (notStarted) { // TODO: replace with Predicate-based thread
         // collision avoidance for simplicity
         Set<Ip> availableIps = client.getIpServices().getIpList(unassignedIps);
         if (availableIps.isEmpty())
            throw new RuntimeException("No IPs available on this identity.");
         int ipIndex = new SecureRandom().nextInt(availableIps.size());
         Ip availableIp = Iterables.get(availableIps, ipIndex);
         try {
            addedServer = addServer(name, template, availableIp);
            notStarted = false;
         } catch (Exception e) {
            if (--numOfRetries == 0)
               Throwables.propagate(e);
            notStarted = true;
         }
      }
      if (template.getOptions().shouldBlockUntilRunning()) {
         serverLatestJobCompleted.apply(addedServer);
         client.getServerServices().power(addedServer.getName(), PowerCommand.START);
         serverLatestJobCompletedShort.apply(addedServer);
         addedServer = Iterables.getOnlyElement(client.getServerServices().getServersByName(addedServer.getName()));
      }
      LoginCredentials credentials = LoginCredentials.fromCredentials(client.getServerServices()
               .getServerCredentialsList().get(addedServer.getName()));
      return new NodeAndInitialCredentials<Server>(addedServer, addedServer.getId() + "", credentials);
   }
View Full Code Here

               .getServerCredentialsList().get(addedServer.getName()));
      return new NodeAndInitialCredentials<Server>(addedServer, addedServer.getId() + "", credentials);
   }

   private Server addServer(String name, Template template, Ip availableIp) {
      Server addedServer = client.getServerServices().addServer(name,
               checkNotNull(template.getImage().getProviderId()), sizeToRam.apply(template.getHardware()),
               availableIp.getIp());
      return addedServer;
   }
View Full Code Here

   }

   @Override
   public void rebootNode(String id) {
      executeCommandOnServer(PowerCommand.RESTART, id);
      Server server = Iterables.getOnlyElement(client.getServerServices().getServersById(Long.valueOf(id)));
      client.getServerServices().power(server.getName(), PowerCommand.START);
      serverLatestJobCompletedShort.apply(server);
   }
View Full Code Here

      client.getServerServices().power(server.getName(), PowerCommand.START);
      serverLatestJobCompletedShort.apply(server);
   }

   private boolean executeCommandOnServer(PowerCommand command, String id) {
      Server server = Iterables.getOnlyElement(client.getServerServices().getServersById(Long.valueOf(id)));
      client.getServerServices().power(server.getName(), command);
      return serverLatestJobCompleted.apply(server);
   }
View Full Code Here

      String ram = get(api.getServerServices().getRamSizes(), 1).getName();
      try {
         NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1));

         Server updatedServer = api.getServerServices().editServerRam(Long.valueOf(node.getId()), ram);
         assertNotNull(updatedServer);
         assert serverLatestJobCompleted.apply(updatedServer);

         assertEquals(getLast(api.getServerServices().getServersById(Long.valueOf(node.getId()))).getRam().getName(),
               ram);
View Full Code Here

   }

   @Override
   public NodeAndInitialCredentials<Server> createNodeWithGroupEncodedIntoName(String group, String name,
            Template template) {
      Server addedServer = null;
      boolean notStarted = true;
      int numOfRetries = 20;
      GetIpListOptions unassignedIps = new GetIpListOptions().onlyUnassigned().inDatacenter(
               template.getLocation().getId()).onlyWithType(IpType.PUBLIC);
      // lock-free consumption of a shared resource: IP address pool
      while (notStarted) { // TODO: replace with Predicate-based thread
         // collision avoidance for simplicity
         Set<Ip> availableIps = client.getIpServices().getIpList(unassignedIps);
         if (availableIps.isEmpty())
            throw new RuntimeException("No IPs available on this identity.");
         int ipIndex = new SecureRandom().nextInt(availableIps.size());
         Ip availableIp = Iterables.get(availableIps, ipIndex);
         try {
            addedServer = addServer(name, template, availableIp);
            notStarted = false;
         } catch (Exception e) {
            if (--numOfRetries == 0)
               Throwables.propagate(e);
            notStarted = true;
         }
      }
      if (template.getOptions().shouldBlockUntilRunning()) {
         serverLatestJobCompleted.apply(addedServer);
         client.getServerServices().power(addedServer.getName(), PowerCommand.START);
         serverLatestJobCompletedShort.apply(addedServer);
         addedServer = Iterables.getOnlyElement(client.getServerServices().getServersByName(addedServer.getName()));
      }
      LoginCredentials credentials = LoginCredentials.fromCredentials(client.getServerServices()
               .getServerCredentialsList().get(addedServer.getName()));
      return new NodeAndInitialCredentials<Server>(addedServer, addedServer.getId() + "", credentials);
   }
View Full Code Here

TOP

Related Classes of org.jclouds.gogrid.domain.Server

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.