Package org.jclouds.openstack.nova.v2_0.features

Examples of org.jclouds.openstack.nova.v2_0.features.ServerApi


    this.serverId = serverId;
  }

  @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


    this.metadata = metadata;
  }

  @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);
      }
View Full Code Here

  }

  private String assignFloatingIp(NovaApi api, Server server)
      throws Exception {
    LOG.debug("assigning a floating IP address to {} ...", server.getId());
    ServerApi serverApi = api.getServerApiForZone(getAccount().getRegion());
    // server must have a private IP address before a floating IP can be
    // assigned
    waitForPrivateIpAddress(serverApi, server);

    FloatingIPApi floatingIPApi = api.getFloatingIPExtensionForZone(
View Full Code Here

   @Override
   public void setup() {
      super.setup();
      zones = api.getConfiguredZones();
      for (String zone : zones) {
         ServerApi serverApi = api.getServerApiForZone(zone);
         for (Resource server : serverApi.list().concat()) {
            if (server.getName().equals(hostName))
               serverApi.delete(server.getId());
         }
      }
   }
View Full Code Here

      setIfTestSystemPropertyPresent(props, NovaProperties.AUTO_ALLOCATE_FLOATING_IPS);
      return props;
   }
  
   protected Server createServerInZone(String zoneId) {
      ServerApi serverApi = api.getServerApiForZone(zoneId);
      ServerCreated server = serverApi.create(hostName, imageIdForZone(zoneId), flavorRefForZone(zoneId));
      blockUntilServerInState(server.getId(), serverApi, Status.ACTIVE);
      return serverApi.get(server.getId());
   }
View Full Code Here

      for (String zoneId : api.getConfiguredZones()) {
         Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPExtensionForZone(zoneId);
         if (!apiOption.isPresent())
            continue;
         FloatingIPApi api = apiOption.get();
         ServerApi serverApi = this.api.getServerApiForZone(zoneId);
         Server server = createServerInZone(zoneId);
         FloatingIP floatingIP = api.create();
         assertNotNull(floatingIP);
         try {
            api.addToServer(floatingIP.getIp(), server.getId());
            assertEventually(new ServerHasFloatingIP(serverApi, server.getId(), floatingIP.getIp()));
         } finally {
            api.removeFromServer(floatingIP.getIp(), server.getId());
            serverApi.delete(server.getId());
         }
      }
   }
View Full Code Here

      }

      @Override
      protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) {
         String zone = arg0.get().toString();
         final ServerApi serverApi = api.getServerApiForZone(zone);
         return new Function<Object, IterableWithMarker<Resource>>() {

            @SuppressWarnings("unchecked")
            @Override
            public IterableWithMarker<Resource> apply(Object input) {
               PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
               return IterableWithMarker.class.cast(serverApi.list(paginationOptions));
            }

            @Override
            public String toString() {
               return "list()";
View Full Code Here

      }

      @Override
      protected Function<Object, IterableWithMarker<Server>> markerToNextForArg0(Optional<Object> arg0) {
         String zone = arg0.get().toString();
         final ServerApi serverApi = api.getServerApiForZone(zone);
         return new Function<Object, IterableWithMarker<Server>>() {

            @SuppressWarnings("unchecked")
            @Override
            public IterableWithMarker<Server> apply(Object input) {
               PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
               return IterableWithMarker.class.cast(serverApi.listInDetail(paginationOptions));
            }

            @Override
            public String toString() {
               return "listInDetail()";
View Full Code Here

      Template template = computeService.templateBuilder().smallest().build();
      NodeMetadata nodeMetadata = computeService.createNodesInGroup("jclouds-reverse-dns-test", 1, template).iterator().next();
      serverId = nodeMetadata.getId();
      serverURI = nodeMetadata.getUri();

      ServerApi serverApi = nova.getApi().getServerApiForZone(nodeMetadata.getLocation().getParent().getId());
      Server server = serverApi.get(nodeMetadata.getProviderId());
      serverIPv4 = server.getAccessIPv4();
      serverIPv6 = server.getAccessIPv6();
     
      System.out.println("serverURI = " + serverURI);
      System.out.println("serverIPv4 = " + serverIPv4);
View Full Code Here

TOP

Related Classes of org.jclouds.openstack.nova.v2_0.features.ServerApi

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.