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

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


   @Singleton
   public static class ServerAdapter implements JsonDeserializer<Server> {
      @Override
      public Server deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context)
            throws JsonParseException {
         Server serverBase = apply((ServerInternal) context.deserialize(jsonElement, ServerInternal.class));
         Server.Builder<?> result = Server.builder().fromServer(serverBase);
         ServerExtendedStatus extendedStatus = context.deserialize(jsonElement, ServerExtendedStatus.class);
         if (!Objects.equal(extendedStatus, ServerExtendedStatus.builder().build())) {
            result.extendedStatus(extendedStatus);
         }
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

   }

   @Override
   public ImageTemplate buildImageTemplateFromNode(String name, final String id) {
      ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
      Server server = novaApi.getServerApiForZone(zoneAndId.getZone()).get(zoneAndId.getId());
      if (server == null)
         throw new NoSuchElementException("Cannot find server with id: " + zoneAndId);
      CloneImageTemplate template = new ImageTemplateBuilder.CloneImageTemplateBuilder().nodeId(id).name(name).build();
      return template;
   }
View Full Code Here

      String imageId = template.getImage().getProviderId();
      String flavorId = template.getHardware().getProviderId();

      logger.debug(">> creating new server zone(%s) name(%s) image(%s) flavor(%s) options(%s)", zoneId, name, imageId, flavorId, options);
      ServerCreated lightweightServer = novaApi.getServerApiForZone(zoneId).create(name, imageId, flavorId, options);
      Server server = novaApi.getServerApiForZone(zoneId).get(lightweightServer.getId());

      logger.trace("<< server(%s)", server.getId());

      ServerInZone serverInZone = new ServerInZone(server, zoneId);
      if (!privateKey.isPresent() && lightweightServer.getAdminPass().isPresent())
         credentialsBuilder.password(lightweightServer.getAdminPass().get());
      return new NodeAndInitialCredentials<ServerInZone>(serverInZone, serverInZone.slashEncode(), credentialsBuilder
View Full Code Here

   }

   @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 NodeMetadata apply(ServerInZone serverInZone) {
      Location zone = locationIndex.get().get(serverInZone.getZone());
      checkState(zone != null, "location %s not in locationIndex: %s", serverInZone.getZone(), locationIndex.get());
      Server from = serverInZone.getServer();

      NodeMetadataBuilder builder = new NodeMetadataBuilder();
      builder.id(serverInZone.slashEncode());
      builder.providerId(from.getId());
      builder.name(from.getName());
      builder.hostname(from.getName());
      builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId())
            .description(from.getHostId()).parent(zone).build() : zone);
      addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata());
      builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName()));
      builder.imageId(ZoneAndId.fromZoneAndId(serverInZone.getZone(), from.getImage().getId()).slashEncode());
      builder.operatingSystem(findOperatingSystemForServerOrNull(serverInZone));
      builder.hardware(findHardwareForServerOrNull(serverInZone));
      builder.status(toPortableNodeStatus.get(from.getStatus()));
      builder.publicAddresses(filter(
            transform(filter(from.getAddresses().values(), Predicates.not(isPrivateAddress)),
                  AddressToStringTransformationFunction.INSTANCE), isInet4Address));
      builder.privateAddresses(filter(
            transform(filter(from.getAddresses().values(), isPrivateAddress), AddressToStringTransformationFunction.INSTANCE), isInet4Address));
     
      for (Link link: from.getLinks()) {
         if (link.getRelation().equals(Link.Relation.SELF)) {
            builder.uri(link.getHref());
         }
      }
     
View Full Code Here

    */
   public static void main(String[] args) throws IOException {
      ServerMetadata serverMetadata = new ServerMetadata(args[0], args[1]);

      try {
         Server server = serverMetadata.getServer();
         serverMetadata.setMetadata(server);
         serverMetadata.updateMetadata(server);
         serverMetadata.deleteMetadata(server);
         serverMetadata.getMetadata(server);
      }
View Full Code Here

    */
   public static void main(String[] args) throws IOException {
      ListVolumeAttachments listVolumeAttachments = new ListVolumeAttachments(args[0], args[1]);

      try {
         Server server = listVolumeAttachments.getServer();
         listVolumeAttachments.listVolumeAttachments(server);
      }
      catch (Exception e) {
         e.printStackTrace();
      }
View Full Code Here

       */
      @Override
      public boolean apply(String serverId) {
         checkNotNull(serverId, "server must be defined");

         Server server = serverApi.get(serverId);

         if (server == null) {
            throw new IllegalStateException(String.format("Server %s not found.", serverId));
         }

         return status.equals(server.getStatus());
      }
View Full Code Here

       */
      @Override
      public boolean apply(String serverId) {
         checkNotNull(serverId, "server must be defined");

         Server server = serverApi.get(serverId);

         if (server == null) {
            throw new IllegalStateException(String.format("Server %s not found.", serverId));
         }

         return status.equals(server.getStatus());
      }
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.