Package org.jclouds.compute.domain

Examples of org.jclouds.compute.domain.NodeMetadataBuilder


      NodeMetadata node = parser.apply(guest);

      assertEquals(
            node.toString(),
            new NodeMetadataBuilder().id("54").providerId("54").name("i-3-54-VM").group("i-3-54")
                  .location(ZoneToLocationTest.one).status(Status.PENDING).hostname("i-3-54-VM")
                  .privateAddresses(ImmutableSet.of("10.1.1.18"))
                  .hardware(addHypervisor(ServiceOfferingToHardwareTest.one, "XenServer"))
                  .imageId(TemplateToImageTest.one.getId())
                  .operatingSystem(TemplateToImageTest.one.getOperatingSystem()).build().toString());
View Full Code Here


   }

   @Override
   public NodeMetadata apply(VirtualGuest from) {
      // convert the result object to a jclouds NodeMetadata
      NodeMetadataBuilder builder = new NodeMetadataBuilder();
      builder.ids(from.getId() + "");
      builder.name(from.getHostname());
      builder.hostname(from.getHostname());
      if (from.getDatacenter() != null)
         builder.location(from(locations.get()).firstMatch(
               LocationPredicates.idEquals(from.getDatacenter().getId() + "")).orNull());
      builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getHostname()));

      Image image = images.getImage(from);
      if (image != null) {
         builder.imageId(image.getId());
         builder.operatingSystem(image.getOperatingSystem());
      }

      builder.hardware(hardware.getHardware(from));

      builder.status(serverStateToNodeStatus.get(from.getPowerState().getKeyName()));

      // These are null for 'bad' guest orders in the HALTED state.
      if (from.getPrimaryIpAddress() != null)
         builder.publicAddresses(ImmutableSet.<String> of(from.getPrimaryIpAddress()));
      if (from.getPrimaryBackendIpAddress() != null)
         builder.privateAddresses(ImmutableSet.<String> of(from.getPrimaryBackendIpAddress()));
      return builder.build();
   }
View Full Code Here

      NodeMetadata node = parser.apply(guest);

      assertEquals(
            node,
            new NodeMetadataBuilder().ids("416788").name("node1000360500").hostname("node1000360500")
                  .location(expectedLocation).status(Status.PENDING)
                  .publicAddresses(ImmutableSet.of("173.192.29.186"))
                  .privateAddresses(ImmutableSet.of("10.37.102.194"))
                  .hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
                  .imageId(new GetImageForVirtualGuestMock().getImage(guest).getId())
View Full Code Here

      NodeMetadata node = parser.apply(guest);

      assertEquals(
            node,
            new NodeMetadataBuilder().ids("413348").name("foo-ef4").hostname("foo-ef4").group("foo")
                  .status(Status.PENDING).hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
                  .imageId(new GetImageForVirtualGuestMock().getImage(guest).getId())
                  .operatingSystem(new GetImageForVirtualGuestMock().getImage(guest).getOperatingSystem()).build());

   }
View Full Code Here

      NodeMetadata node = parser.apply(guest);

      assertEquals(
            node,
            new NodeMetadataBuilder().ids("416700").name("node1703810489").hostname("node1703810489")
                  .location(expectedLocation).status(Status.PENDING)
                  .publicAddresses(ImmutableSet.of("173.192.29.187"))
                  .privateAddresses(ImmutableSet.of("10.37.102.195"))
                  .hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
                  .imageId(new GetImageForVirtualGuestMock().getImage(guest).getId())
View Full Code Here

      NodeMetadata node = parser.apply(guest);

      assertEquals(
            node,
            new NodeMetadataBuilder().ids("416700").name("node1703810489").hostname("node1703810489")
                  .location(expectedLocation).status(Status.SUSPENDED)
                  .publicAddresses(ImmutableSet.of("173.192.29.187"))
                  .privateAddresses(ImmutableSet.of("10.37.102.195"))
                  .hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
                  .imageId(new GetImageForVirtualGuestMock().getImage(guest).getId())
View Full Code Here

      NodeMetadata node = parser.apply(guest);

      assertEquals(
            node,
            new NodeMetadataBuilder().ids("416700").name("node1703810489").hostname("node1703810489")
                  .location(expectedLocation).status(Status.RUNNING)
                  .publicAddresses(ImmutableSet.of("173.192.29.187"))
                  .privateAddresses(ImmutableSet.of("10.37.102.195"))
                  .hardware(new GetHardwareForVirtualGuestMock().getHardware(guest))
                  .imageId(new GetImageForVirtualGuestMock().getImage(guest).getId())
View Full Code Here

    ClusterControllerFactory factory = mock(ClusterControllerFactory.class);
    ClusterController controller = mock(ClusterController.class);
    when(factory.create((String) any())).thenReturn(controller);

    NodeMetadata node1 = new NodeMetadataBuilder().name("name1").ids("id1")
        .location(new LocationBuilder().scope(LocationScope.PROVIDER)
          .id("location-id1").description("location-desc1").build())
        .imageId("image-id").state(NodeState.RUNNING)
        .publicAddresses(Lists.newArrayList("127.0.0.1"))
        .privateAddresses(Lists.newArrayList("127.0.0.1")).build();

    NodeMetadata node2 = new NodeMetadataBuilder().name("name2").ids("id2")
        .location(new LocationBuilder().scope(LocationScope.PROVIDER)
          .id("location-id2").description("location-desc2").build())
        .imageId("image-id").state(NodeState.RUNNING)
        .publicAddresses(Lists.newArrayList("127.0.0.2"))
        .privateAddresses(Lists.newArrayList("127.0.0.2")).build();
View Full Code Here

   @Override
   public NodeMetadata apply(Container container) {
      String name = cleanUpName(container.getName());
      String group = nodeNamingConvention.extractGroup(name);
      NodeMetadataBuilder builder = new NodeMetadataBuilder();
      builder.ids(container.getId())
              .name(name)
              .group(group)
              .hostname(container.getContainerConfig().getHostname())
               // TODO Set up hardware
              .hardware(new HardwareBuilder()
                      .id("")
                      .ram(container.getContainerConfig().getMemory())
                      .processor(new Processor(container.getContainerConfig().getCpuShares(), container.getContainerConfig().getCpuShares()))
                      .build());
      builder.status(toPortableStatus.apply(container.getState()));
      builder.imageId(container.getImage());
      builder.loginPort(getLoginPort(container));
      builder.publicAddresses(getPublicIpAddresses());
      builder.privateAddresses(getPrivateIpAddresses(container));
      builder.location(Iterables.getOnlyElement(locations.get()));
      String imageId = container.getImage();
      builder.imageId(imageId);
      if (images.get().containsKey(imageId)) {
          Image image = images.get().get(imageId);
          builder.operatingSystem(image.getOperatingSystem());
      }

      return builder.build();
   }
View Full Code Here

      Location zone = locationIndex.get().get(machineInDatacenter.getDatacenter());
      checkState(zone != null, "location %s not in locationIndex: %s", machineInDatacenter.getDatacenter(),
            locationIndex.get());
      Machine from = machineInDatacenter.get();

      NodeMetadataBuilder builder = new NodeMetadataBuilder();
      builder.id(machineInDatacenter.slashEncode());
      builder.providerId(from.getId());
      builder.name(from.getName());
      builder.hostname(from.getId());
      builder.location(zone);
      addMetadataAndParseTagsFromCommaDelimitedValue(builder, filterKeys(from.getMetadata(), new Predicate<String>() {

         @Override
         public boolean apply(String input) {
            // TODO make this more efficient
            for (Metadata key : Metadata.values())
               if (key.key().equals(input))
                  return false;
            return true;
         }

      }));
      builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getName()));
      builder.imageId(DatacenterAndName.fromDatacenterAndName(machineInDatacenter.getDatacenter(), from.getDatasetURN())
            .slashEncode());
      builder.operatingSystem(findOperatingSystemForMachineOrNull(machineInDatacenter));
      builder.hardware(findHardwareForMachineOrNull(machineInDatacenter));
      builder.status(toPortableNodeStatus.get(from.getState()));
      builder.publicAddresses(filter(from.getIps(), not(InetAddresses2.IsPrivateIPAddress.INSTANCE)));
      builder.privateAddresses(filter(from.getIps(), InetAddresses2.IsPrivateIPAddress.INSTANCE));
      return builder.build();
   }
View Full Code Here

TOP

Related Classes of org.jclouds.compute.domain.NodeMetadataBuilder

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.