public T fromZone(Zone in) { return this .id(in.getId()) .description(in.getDescription()) .displayText(in.getDisplayText()) .DNS(in.getDNS()) .domain(in.getDomain()) .domainId(in.getDomainId()) .guestCIDRAddress(in.getGuestCIDRAddress()) .internalDNS(in.getInternalDNS()) .name(in.getName()) .networkType(in.getNetworkType()) .VLAN(in.getVLAN()) .securityGroupsEnabled(in.isSecurityGroupsEnabled()) .allocationState(in.getAllocationState()) .dhcpProvider(in.getDhcpProvider()) .zoneToken(in.getZoneToken()); } }
for (Zone zone : response) { Zone newDetails = Iterables.getOnlyElement(client.getZoneClient().listZones( ListZonesOptions.Builder.id(zone.getId()))); assertEquals(zone, newDetails); assertEquals(zone, client.getZoneClient().getZone(zone.getId())); assert zone.getId() != null : zone; assert zone.getName() != null : zone; assert zone.getNetworkType() != null && zone.getNetworkType() != NetworkType.UNRECOGNIZED : zone; switch (zone.getNetworkType()) { case ADVANCED: assert zone.getVLAN() == null : zone; assert zone.getDNS().size() >= 0 : zone; assert zone.getInternalDNS().size() >= 0 : zone; assert zone.getDomain() == null : zone; assert zone.getDomainId() == null : zone; assert zone.getGuestCIDRAddress() == null : zone; break;
@Override public int compareTo(Zone o) { return id.compareTo(o.getId()); } }
@Test public void testCreateUpdateDeleteZone() { skipIfNotGlobalAdmin(); Zone zone = null; String zoneName = prefix + "-zone"; try { zone = globalAdminClient.getZoneClient().createZone(zoneName, NetworkType.BASIC, "8.8.8.8", "10.10.10.10"); assertNotNull(zone); assertEquals(zone, globalAdminClient.getZoneClient().getZone(zone.getId())); assertEquals(zone.getNetworkType(), NetworkType.BASIC); assertEquals(zone.getDNS(), ImmutableList.of("8.8.8.8")); assertEquals(zone.getInternalDNS(), ImmutableList.of("10.10.10.10")); Zone updated = globalAdminClient.getZoneClient().updateZone(zone.getId(), name(zoneName + "-2").externalDns(ImmutableList.of("8.8.4.4"))); assertEquals(updated.getId(), zone.getId()); assertEquals(updated.getDNS(), ImmutableList.of("8.8.4.4")); } finally { if (zone != null) { globalAdminClient.getZoneClient().deleteZone(zone.getId()); } } }
@Override public boolean apply(Zone input) { return input.isSecurityGroupsEnabled(); }
@Override public boolean apply(Zone input) { return input.getName().equals(zoneName); } });
checkState(optionsConverters.containsKey(zone.getNetworkType()), "no options converter configured for network type %s", zone.getNetworkType()); DeployVirtualMachineOptions options = displayName(name).name(name); if (templateOptions.getAccount() != null) { OptionsConverter optionsConverter = optionsConverters.get(zone.getNetworkType()); options = optionsConverter.apply(templateOptions, networks, zoneId, options); String securityGroupName = namingConvention.create().sharedNameForGroup(group); SecurityGroup sg = securityGroupCache.getUnchecked(ZoneSecurityGroupNamePortsCidrs.builder() .zone(zone.getId()) .name(securityGroupName) .ports(ImmutableSet.copyOf(inboundPorts))
@Override public boolean apply(Zone zone) { return NetworkType.ADVANCED.equals(checkNotNull(zone, "zone").getNetworkType()); }
public Zone findAvailableZone(String domainId) { Set<Zone> zones = client.getZoneClient().listZones(ListZonesOptions.Builder.available(true)); for (Zone zone : zones) { if (zone.getDomainId() == null || zone.getDomainId().equals(domainId)) { LOG.debug("Found available zone in {} for domain {}: {}", new Object[] {loc, domainId, zone}); return zone; } } LOG.debug("No available zone for domain {}; zones: {}", domainId, zones); return null; }
for (Zone zone : response) { Zone newDetails = Iterables.getOnlyElement(client.getZoneApi().listZones( ListZonesOptions.Builder.id(zone.getId()))); assertEquals(zone, newDetails); assertEquals(zone, client.getZoneApi().getZone(zone.getId())); assert zone.getId() != null : zone; assert zone.getName() != null : zone; assert zone.getNetworkType() != null && zone.getNetworkType() != NetworkType.UNRECOGNIZED : zone; switch (zone.getNetworkType()) { case ADVANCED: assert zone.getVLAN() == null : zone; assert zone.getDNS().size() > 0 : zone; assert zone.getInternalDNS().size() > 0 : zone; assert zone.getDomain() == null : zone; assert zone.getDomainId() == null : zone; assert zone.getGuestCIDRAddress() == null : zone; break;
@Override public int compareTo(Zone o) { return id.compareTo(o.getId()); } }
@Test public void testCreateUpdateDeleteZone() { skipIfNotGlobalAdmin(); Zone zone = null; String zoneName = prefix + "-zone"; try { zone = globalAdminClient.getZoneApi().createZone(zoneName, NetworkType.BASIC, "8.8.8.8", "10.10.10.10"); assertNotNull(zone); assertEquals(zone, globalAdminClient.getZoneApi().getZone(zone.getId())); assertEquals(zone.getNetworkType(), NetworkType.BASIC); assertEquals(zone.getDNS(), ImmutableList.of("8.8.8.8")); assertEquals(zone.getInternalDNS(), ImmutableList.of("10.10.10.10")); Zone updated = globalAdminClient.getZoneApi().updateZone(zone.getId(), name(zoneName + "-2").externalDns(ImmutableList.of("8.8.4.4"))); assertEquals(updated.getId(), zone.getId()); assertEquals(updated.getDNS(), ImmutableList.of("8.8.4.4")); } finally { if (zone != null) { globalAdminClient.getZoneApi().deleteZone(zone.getId()); } } }
@Override public boolean apply(Zone input) { return input.isSecurityGroupsEnabled(); }
@Override public boolean apply(Zone zone) { return NetworkType.ADVANCED.equals(checkNotNull(zone, "zone").getNetworkType()); }
public T fromZone(Zone in) { return this .id(in.getId()) .description(in.getDescription()) .displayText(in.getDisplayText()) .DNS(in.getDNS()) .domain(in.getDomain()) .domainId(in.getDomainId()) .guestCIDRAddress(in.getGuestCIDRAddress()) .internalDNS(in.getInternalDNS()) .name(in.getName()) .networkType(in.getNetworkType()) .VLAN(in.getVLAN()) .securityGroupsEnabled(in.isSecurityGroupsEnabled()) .allocationState(in.getAllocationState()) .dhcpProvider(in.getDhcpProvider()) .zoneToken(in.getZoneToken()); } }
@Override public int compareTo(Zone o) { return id.compareTo(o.getId()); } }