@Override public Server deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException { Server serverBase; // Servers can be created without an image so test if an image object is returned if (jsonElement.getAsJsonObject().get("image").isJsonObject()) { serverBase = apply((ServerInternal) context.deserialize(jsonElement, ServerInternal.class)); } else { serverBase = apply((ServerInternalWithoutImage) context.deserialize(jsonElement, ServerInternalWithoutImage.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); } ServerExtendedAttributes extraAttributes = context.deserialize(jsonElement, ServerExtendedAttributes.class); if (!Objects.equal(extraAttributes, ServerExtendedAttributes.builder().build())) { result.extendedAttributes(extraAttributes); } return result.build(); }
@Override public Server deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException { Server serverBase; // Servers can be created without an image so test if an image object is returned if (jsonElement.getAsJsonObject().get("image").isJsonObject()) { serverBase = apply((ServerInternal) context.deserialize(jsonElement, ServerInternal.class)); } else { serverBase = apply((ServerInternalWithoutImage) context.deserialize(jsonElement, ServerInternalWithoutImage.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); } ServerExtendedAttributes extraAttributes = context.deserialize(jsonElement, ServerExtendedAttributes.class); if (!Objects.equal(extraAttributes, ServerExtendedAttributes.builder().build())) { result.extendedAttributes(extraAttributes); } return result.build(); }
@Override public Server deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException { Server serverBase; // Servers can be created without an image so test if an image object is returned if (jsonElement.getAsJsonObject().get("image").isJsonObject()) { serverBase = apply((ServerInternal) context.deserialize(jsonElement, ServerInternal.class)); } else { serverBase = apply((ServerInternalWithoutImage) context.deserialize(jsonElement, ServerInternalWithoutImage.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); } ServerExtendedAttributes extraAttributes = context.deserialize(jsonElement, ServerExtendedAttributes.class); if (!Objects.equal(extraAttributes, ServerExtendedAttributes.builder().build())) { result.extendedAttributes(extraAttributes); } return result.build(); }
Relation.BOOKMARK, URI.create("https://nova-api.openstack.org:9774/37/servers/1459"))) .addresses(ImmutableMultimap.of("internet", Address.createV4("8.21.28.47"))).build();
.links( Link.create(Relation.SELF, URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/59662")), Link.create(Relation.BOOKMARK, URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/59662"))).build();
.links( Link.create(Link.Relation.SELF, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/servers/71752")), Link.create(Link.Relation.BOOKMARK, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752"))).build();
Relation.BOOKMARK, URI.create("https://nova-api.openstack.org:9774/37/servers/1459"))) .addresses(ImmutableMultimap.of("internet", Address.createV4("8.21.28.47"))).build();
.links( Link.create(Link.Relation.SELF, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752")), Link.create(Link.Relation.BOOKMARK, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752"))).build();
@Test public void testNullAccessIPs() { Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd") .providerId("52415800-8b69-11e0-9b19-734f216543fd").location(region).build(); Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54") .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build()) .providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE) .location(region).build(); Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage); Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet .of(existingHardware); Server serverToConvert = new ParseServerTest().expected().toBuilder() .accessIPv4(null) .accessIPv6(null) .build(); ServerInRegion serverInRegionToConvert = new ServerInRegion(serverToConvert, "az-1.region-a.geo-1"); ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata( NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers .<Set<? extends Image>> ofInstance(images), Suppliers .<Set<? extends Hardware>> ofInstance(hardwares), namingConvention); NodeMetadata convertedNodeMetadata = converter.apply(serverInRegionToConvert); assertNotNull(convertedNodeMetadata.getPrivateAddresses()); assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16")); assertNotNull(convertedNodeMetadata.getPublicAddresses()); // note jclouds doesn't yet support ipv6 b/c not tested yet assertEquals(convertedNodeMetadata.getPublicAddresses(), ImmutableSet.of("67.23.10.132", "67.23.10.131")); }
@Test public void testAlternateAccessIPs() { Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd") .providerId("52415800-8b69-11e0-9b19-734f216543fd").location(region).build(); Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54") .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build()) .providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE) .location(region).build(); Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage); Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet .of(existingHardware); Server serverToConvert = new ParseServerTest().expected().toBuilder() .accessIPv4("76.32.1.231") .accessIPv6("::babe:76.32.1.231") .build(); ServerInRegion serverInRegionToConvert = new ServerInRegion(serverToConvert, "az-1.region-a.geo-1"); ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata( NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers .<Set<? extends Image>> ofInstance(images), Suppliers .<Set<? extends Hardware>> ofInstance(hardwares), namingConvention); NodeMetadata convertedNodeMetadata = converter.apply(serverInRegionToConvert); assertNotNull(convertedNodeMetadata.getPrivateAddresses()); assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16")); assertNotNull(convertedNodeMetadata.getPublicAddresses()); // note jclouds doesn't yet support ipv6 b/c not tested yet assertEquals(convertedNodeMetadata.getPublicAddresses(), ImmutableSet.of("67.23.10.132", "67.23.10.131", "76.32.1.231")); }
@Test public void testDuplicateAccessIPs() { Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd") .providerId("52415800-8b69-11e0-9b19-734f216543fd").location(region).build(); Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54") .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build()) .providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE) .location(region).build(); Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage); Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet .of(existingHardware); Server serverToConvert = new ParseServerTest().expected().toBuilder() .accessIPv4("67.23.10.132") .accessIPv6("::babe:67.23.10.132") .build(); ServerInRegion serverInRegionToConvert = new ServerInRegion(serverToConvert, "az-1.region-a.geo-1"); ServerInRegionToNodeMetadata converter = new ServerInRegionToNodeMetadata( NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers .<Set<? extends Image>> ofInstance(images), Suppliers .<Set<? extends Hardware>> ofInstance(hardwares), namingConvention); NodeMetadata convertedNodeMetadata = converter.apply(serverInRegionToConvert); assertNotNull(convertedNodeMetadata.getPrivateAddresses()); assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16")); assertNotNull(convertedNodeMetadata.getPublicAddresses()); // note jclouds doesn't yet support ipv6 b/c not tested yet assertEquals(convertedNodeMetadata.getPublicAddresses(), ImmutableSet.of("67.23.10.132", "67.23.10.131")); }
@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); } ServerExtendedAttributes extraAttributes = context.deserialize(jsonElement, ServerExtendedAttributes.class); if (!Objects.equal(extraAttributes, ServerExtendedAttributes.builder().build())) { result.extendedAttributes(extraAttributes); } return result.build(); }
public Server apply(Server in) { return in.toBuilder().build(); }
public Server apply(ServerInternal in) { return in.toBuilder().build(); }
public Server apply(Server in) { return in.toBuilder().build(); }
@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); } ServerExtendedAttributes extraAttributes = context.deserialize(jsonElement, ServerExtendedAttributes.class); if (!Objects.equal(extraAttributes, ServerExtendedAttributes.builder().build())) { result.extendedAttributes(extraAttributes); } return result.build(); }
public Server apply(Server in) { return in.toBuilder().build(); }
public Server apply(ServerInternal in) { return in.toBuilder().build(); }
public Server apply(ServerInternal in) { return in.toBuilder().build(); }
@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); } ServerExtendedAttributes extraAttributes = context.deserialize(jsonElement, ServerExtendedAttributes.class); if (!Objects.equal(extraAttributes, ServerExtendedAttributes.builder().build())) { result.extendedAttributes(extraAttributes); } return result.build(); }