@Test public void testServerToNodeMetadata() { Server server = Server.builder() .dataCenter(DataCenter.builder() .id("mock") .version(10) .location(org.jclouds.profitbricks.domain.Location.DE_FRA) .build()) .id("qwertyui-qwer-qwer-qwer-qwertyyuiiop") .name("mock-facebook-node") .cores(4) .ram(4096) .hasInternetAccess(true) .state(ProvisioningState.AVAILABLE) .status(Server.Status.RUNNING) .osType(OsType.LINUX) .availabilityZone(AvailabilityZone.AUTO) .isCpuHotPlug(true) .isRamHotPlug(true) .isNicHotPlug(true) .isNicHotUnPlug(true) .isDiscVirtioHotPlug(true) .isDiscVirtioHotUnPlug(true) .storages(ImmutableList.<Storage>of( Storage.builder() .bootDevice(true) .busType(Storage.BusType.VIRTIO) .deviceNumber(1) .size(40f) .id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh") .name("facebook-storage") .build() ) ) .nics(ImmutableList.<Nic>of( Nic.builder() .id("qwqwqwqw-wewe-erer-rtrt-tytytytytyty") .lanId(1) .dataCenterId("12345678-abcd-efgh-ijkl-987654321000") .internetAccess(true) .serverId("qwertyui-qwer-qwer-qwer-qwertyyuiiop") .macAddress("02:01:09:cd:f0:b0") .ips( ImmutableList.<String>of("173.252.120.6")) .build() ) ) .build(); NodeMetadata expected = fnNodeMetadata.apply(server); assertNotNull(expected); NodeMetadata actual = new NodeMetadataBuilder() .group("mock") .ids(server.id()) .name(server.name()) .backendStatus("AVAILABLE") .status(NodeMetadata.Status.RUNNING) .hardware(new HardwareBuilder() .ids("cpu=4,ram=4096,disk=40") .name("cpu=4,ram=4096,disk=40") .ram(server.ram()) .processor(new Processor(server.cores(), 1d)) .hypervisor("kvm") .volume(new VolumeBuilder() .bootDevice(true) .size(40f) .id("qswdefrg-qaws-qaws-defe-rgrgdsvcxbrh") .durable(true) .type(Volume.Type.LOCAL) .build()) .build()) .operatingSystem(new OperatingSystem.Builder() .description(OsFamily.LINUX.value()) .family(OsFamily.LINUX) .build()) .location(new LocationBuilder() .id("de/fra") .description("de/fra") .scope(LocationScope.ZONE) .parent(new LocationBuilder() .id("de") .description("de") .scope(LocationScope.REGION) .build()) .build()) .publicAddresses(ImmutableList.<String>of("173.252.120.6")) .build(); assertEquals(actual, expected); }
@Inject ServerToNodeMetadata(Function<Storage, Volume> fnVolume, @Memoized Supplier<Set<? extends Location>> locations, ProfitBricksApi api, GroupNamingConvention.Factory groupNamingConvention) { this.fnVolume = fnVolume; this.locations = locations; this.api = api; this.groupNamingConvention = groupNamingConvention.createWithoutPrefix(); this.fnCollectIps = new Function<List<Nic>, List<String>>() { @Override public List<String> apply(List<Nic> in) { List<String> ips = Lists.newArrayListWithExpectedSize(in.size()); for (Nic nic : in) ips.addAll(nic.ips()); return ips; } }; }
ServerToNodeMetadata implements Function<Server, NodeMetadata> { @Inject ServerToNodeMetadata(Function<Storage, Volume> fnVolume, @Memoized Supplier<Set<? extends Location>> locations, ProfitBricksApi api, GroupNamingConvention.Factory groupNamingConvention) { this.fnVolume = fnVolume; this.locations = locations; this.api = api; this.groupNamingConvention = groupNamingConvention.createWithoutPrefix(); this.fnCollectIps = new Function<List<Nic>, List<String>>() { @Override public List<String> apply(List<Nic> in) { List<String> ips = Lists.newArrayListWithExpectedSize(in.size()); for (Nic nic : in) ips.addAll(nic.ips()); return ips; } }; } }
ServerToNodeMetadata implements Function<Server, NodeMetadata> { @Inject ServerToNodeMetadata(Function<Storage, Volume> fnVolume, @Memoized Supplier<Set<? extends Location>> locations, ProfitBricksApi api, GroupNamingConvention.Factory groupNamingConvention) { this.fnVolume = fnVolume; this.locations = locations; this.api = api; this.groupNamingConvention = groupNamingConvention.createWithoutPrefix(); this.fnCollectIps = new Function<List<Nic>, List<String>>() { @Override public List<String> apply(List<Nic> in) { List<String> ips = Lists.newArrayListWithExpectedSize(in.size()); for (Nic nic : in) ips.addAll(nic.ips()); return ips; } }; } @Inject  ServerToNodeMetadata(Function<Storage, Volume> fnVolume,
           @Memoized Supplier<Set<? extends Location>> locations,
           ProfitBricksApi api,
           GroupNamingConvention.Factory groupNamingConvention); }
ServerToNodeMetadata implements Function<Server, NodeMetadata> { @Inject ServerToNodeMetadata(Function<Storage, Volume> fnVolume, @Memoized Supplier<Set<? extends Location>> locations, ProfitBricksApi api, GroupNamingConvention.Factory groupNamingConvention) { this.fnVolume = fnVolume; this.locations = locations; this.api = api; this.groupNamingConvention = groupNamingConvention.createWithoutPrefix(); this.fnCollectIps = new Function<List<Nic>, List<String>>() { @Override public List<String> apply(List<Nic> in) { List<String> ips = Lists.newArrayListWithExpectedSize(in.size()); for (Nic nic : in) ips.addAll(nic.ips()); return ips; } }; } @Inject  ServerToNodeMetadata(Function<Storage, Volume> fnVolume,
           @Memoized Supplier<Set<? extends Location>> locations,
           ProfitBricksApi api,
           GroupNamingConvention.Factory groupNamingConvention); @Override NodeMetadata apply(final Server server); }
ServerToNodeMetadata implements Function<Server, NodeMetadata> { @Inject ServerToNodeMetadata(Function<Storage, Volume> fnVolume, @Memoized Supplier<Set<? extends Location>> locations, ProfitBricksApi api, GroupNamingConvention.Factory groupNamingConvention) { this.fnVolume = fnVolume; this.locations = locations; this.api = api; this.groupNamingConvention = groupNamingConvention.createWithoutPrefix(); this.fnCollectIps = new Function<List<Nic>, List<String>>() { @Override public List<String> apply(List<Nic> in) { List<String> ips = Lists.newArrayListWithExpectedSize(in.size()); for (Nic nic : in) ips.addAll(nic.ips()); return ips; } }; } @Inject  ServerToNodeMetadata(Function<Storage, Volume> fnVolume,
           @Memoized Supplier<Set<? extends Location>> locations,
           ProfitBricksApi api,
           GroupNamingConvention.Factory groupNamingConvention); @Override NodeMetadata apply(final Server server);  }