Пример #1
0
  @Test
  public void testApplyWhereImageFoundAndHardwareNotFound()
      throws UnknownHostException, NoSuchMethodException, ClassNotFoundException,
          URISyntaxException {
    Map<ServerStatus, Status> serverStateToNodeStatus =
        NovaComputeServiceContextModule.serverToNodeStatus;
    org.jclouds.compute.domain.Image jcImage = NovaImageToImageTest.convertImage();
    Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of(jcImage);
    Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of();
    Server server = ParseServerFromJsonResponseTest.parseServer();

    ServerToNodeMetadata parser =
        new ServerToNodeMetadata(
            serverStateToNodeStatus,
            Suppliers.<Set<? extends Image>>ofInstance(images),
            Suppliers.ofInstance(provider),
            Suppliers.<Set<? extends Hardware>>ofInstance(hardwares),
            namingConvention);

    NodeMetadata metadata = parser.apply(server);

    NodeMetadata constructedMetadata =
        newNodeMetadataBuilder()
            .imageId("2")
            .operatingSystem(
                new OperatingSystem.Builder()
                    .family(OsFamily.CENTOS)
                    .description("CentOS 5.2")
                    .version("5.2")
                    .is64Bit(true)
                    .build())
            .build();

    assertEquals(metadata, constructedMetadata);
  }
Пример #2
0
  @Test
  public void testApplyWhereImageAndHardwareFound()
      throws UnknownHostException, NoSuchMethodException, ClassNotFoundException,
          URISyntaxException {
    Map<ServerStatus, Status> serverStateToNodeStatus =
        NovaComputeServiceContextModule.serverToNodeStatus;
    Set<org.jclouds.compute.domain.Image> images =
        ImmutableSet.of(NovaImageToImageTest.convertImage());
    Set<org.jclouds.compute.domain.Hardware> hardwares =
        ImmutableSet.of(FlavorToHardwareTest.convertFlavor());
    Server server = ParseServerFromJsonResponseTest.parseServer();

    ServerToNodeMetadata parser =
        new ServerToNodeMetadata(
            serverStateToNodeStatus,
            Suppliers.<Set<? extends Image>>ofInstance(images),
            Suppliers.ofInstance(provider),
            Suppliers.<Set<? extends Hardware>>ofInstance(hardwares),
            namingConvention);

    NodeMetadata metadata = parser.apply(server);

    NodeMetadata constructedMetadata =
        newNodeMetadataBuilder()
            .imageId("2")
            .group("sample")
            .operatingSystem(
                new OperatingSystem.Builder()
                    .family(OsFamily.CENTOS)
                    .description("CentOS 5.2")
                    .version("5.2")
                    .is64Bit(true)
                    .build())
            .hardware(
                new HardwareBuilder()
                    .ids("1")
                    .name("256 MB Server")
                    .processors(ImmutableList.of(new Processor(1.0, 1.0)))
                    .ram(256)
                    .volumes(
                        ImmutableList.of(
                            new VolumeBuilder()
                                .type(Volume.Type.LOCAL)
                                .size(10.0f)
                                .durable(true)
                                .bootDevice(true)
                                .build()))
                    .uri(new URI("http://servers.api.openstack.org/1234/flavors/1"))
                    .build())
            .build();

    assertEquals(metadata, constructedMetadata);
  }
Пример #3
0
  @Test
  public void testApplyWhereImageAndHardwareNotFound()
      throws UnknownHostException, NoSuchMethodException, ClassNotFoundException,
          URISyntaxException {
    Map<ServerStatus, Status> serverStateToNodeStatus =
        NovaComputeServiceContextModule.serverToNodeStatus;
    Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of();
    Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of();
    Server server = ParseServerFromJsonResponseTest.parseServer();

    ServerToNodeMetadata parser =
        new ServerToNodeMetadata(
            serverStateToNodeStatus,
            Suppliers.<Set<? extends Image>>ofInstance(images),
            Suppliers.ofInstance(provider),
            Suppliers.<Set<? extends Hardware>>ofInstance(hardwares),
            namingConvention);

    NodeMetadata metadata = parser.apply(server);

    NodeMetadata constructedMetadata = newNodeMetadataBuilder().build();

    assertEquals(metadata, constructedMetadata);
  }