Package org.jclouds.openstack.nova.v2_0.domain

Examples of org.jclouds.openstack.nova.v2_0.domain.Server$ConcreteBuilder


   }

   @Override
   public ServerInZone getNode(String id) {
      ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
      Server server = novaApi.getServerApiForZone(zoneAndId.getZone()).get(zoneAndId.getId());
      return server == null ? null : new ServerInZone(server, zoneAndId.getZone());
   }
View Full Code Here


  }

  @Override
  public Boolean doRequest(NovaApi api) {
    try {
      Server server = new GetServerRequest(getAccount(), this.serverId)
          .call();
      return server != null;
    } catch (IllegalArgumentException e) {
      // GetServerRequest throws an IllegalArgumentException if the server
      // doesn't exist.
View Full Code Here

  }

  @Override
  public Server doRequest(NovaApi api) throws IllegalArgumentException {
    ServerApi serverApi = api.getServerApiForZone(getAccount().getRegion());
    Server server = serverApi.get(this.serverId);
    if (server == null) {
      throw new IllegalArgumentException(String.format(
          "failed to retrieve meta data for "
              + "server '%s' in region %s", this.serverId,
          getAccount().getRegion()));
View Full Code Here

  }

  @Override
  public Void doRequest(NovaApi api) {
    ServerApi serverApi = api.getServerApiForZone(getAccount().getRegion());
    Server server = serverApi.get(this.server.getId());
    if (server == null) {
      throw new ScalingGroupException(format(
          "failed to update meta data on server '%s': "
              + "server not found", this.server.getName()));
    }
    // set tags
    Map<String, String> tags = new HashMap<>(server.getMetadata());
    tags.putAll(this.metadata);
    serverApi.setMetadata(server.getId(), tags);
    return null;
  }
View Full Code Here

  @Override
  public Void doRequest(NovaApi api) {
    // look for victim server in all regions
    ServerApi serverApi = api.getServerApiForZone(getAccount().getRegion());
    Server victimServer = serverApi.get(this.victimId);
    if (victimServer != null) {
      releaseFloatingIps(api, getAccount().getRegion(), victimServer);
      boolean wasDeleted = serverApi.delete(this.victimId);
      if (!wasDeleted) {
        throw new ScalingGroupException(
            "failed to delete victim server " + this.victimId);
      }

      try {
        awaitTermination(victimServer.getId());
      } catch (Exception e) {
        throw new ScalingGroupException(String.format(
            "timed out waiting for server %s to be terminated",
            e.getMessage()), e);
      }
View Full Code Here

    try {
      for (int i = 0; i < count; i++) {
        // tag new server with scaling group membership
        Map<String, String> tags = ImmutableMap.of(
            Constants.SCALING_GROUP_TAG, getScalingGroupName());
        Server newServer = this.client.launchServer(uniqueServerName(),
            scaleUpConfig, tags);
        startedMachines.add(ServerToMachine.convert(newServer));

        if (config().isAssignFloatingIp()) {
          String serverId = newServer.getId();
          this.client.assignFloatingIp(serverId);
          // update meta data to include the public IP
          startedMachines.set(i, ServerToMachine.convert(this.client
              .getServer(serverId)));
        }
View Full Code Here

    return request.call();
  }

  @Override
  public String assignFloatingIp(String serverId) {
    Server server = getServer(serverId);
    return new AssignFloatingIpRequest(config(), server).call();
  }
View Full Code Here

   /**
    * Will block until the requested server is in the correct state, if Extended Server Status extension is loaded
    * this will continue to block while any task is in progress.
    */
   protected void blockUntilServerInState(String serverId, ServerApi api, Status status) {
      Server currentDetails = null;
      for (currentDetails = api.get(serverId); currentDetails.getStatus() != status
               || ((currentDetails.getExtendedStatus().isPresent() && currentDetails.getExtendedStatus().get()
                        .getTaskState() != null)); currentDetails = api.get(serverId)) {
         System.out.printf("blocking on status %s%n%s%n", status, currentDetails);
         try {
            Thread.sleep(5 * 1000);
         } catch (InterruptedException e) {
View Full Code Here

    @Test(description = "GET /v${apiVersion}/{tenantId}/servers/{id}", dependsOnMethods = { "testListServersInDetail" })
    public void testGetServerById() throws Exception {
       for (String zoneId : zones) {
          ServerApi serverApi = api.getServerApiForZone(zoneId);
          for (Resource server : serverApi.list().concat()) {
             Server details = serverApi.get(server.getId());
             assertEquals(details.getId(), server.getId());
             assertEquals(details.getName(), server.getName());
             assertEquals(details.getLinks(), server.getLinks());
             checkServer(details);
          }
       }
    }
View Full Code Here

        String serverId = null;
        for (String zoneId : zones) {
            ServerApi serverApi = api.getServerApiForZone(zoneId);
            try {
                serverId = createServer(zoneId, "nova", Server.Status.ACTIVE).getId();
                Server server = serverApi.get(serverId);
                assertEquals(server.getStatus(), Server.Status.ACTIVE);
            } finally {
                serverApi.delete(serverId);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.nova.v2_0.domain.Server$ConcreteBuilder

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.