public Zone findZoneMatchingName(String name) { if (zones == null) zones = getZoneClient().listZones(); for (Zone z : zones) if (name.equals(z.getName())) return z; return null; }
@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()); } } }
@AfterGroups(groups = "live") @Override protected void tearDownContext() { if (pod != null) { globalAdminClient.getPodClient().deletePod(pod.getId()); pod = null; } if (zone != null) { globalAdminClient.getZoneApi().deleteZone(zone.getId()); zone = null; } super.tearDownContext(); } }
@Test public void testCreatePod() { skipIfNotGlobalAdmin(); zone = globalAdminClient.getZoneApi().createZone(prefix + "-zone-for-pod", NetworkType.BASIC, "8.8.8.8", "10.10.10.10"); pod = globalAdminClient.getPodClient().createPod(prefix + "-pod", zone.getId(), "172.20.0.1", "172.20.0.250", "172.20.0.254", "255.255.255.0", CreatePodOptions.Builder.allocationState(AllocationState.ENABLED)); assertNotNull(pod); assertEquals(pod.getName(), prefix + "-pod"); assertEquals(pod.getZoneId(), zone.getId()); assertEquals(pod.getZoneName(), prefix + "-zone-for-pod"); assertEquals(pod.getStartIp(), "172.20.0.1"); assertEquals(pod.getEndIp(), "172.20.0.250"); assertEquals(pod.getGateway(), "172.20.0.254"); assertEquals(pod.getNetmask(), "255.255.255.0"); assertEquals(pod.getAllocationState(), AllocationState.ENABLED); }
.build()); assertEquals(client.updateZone("6", name("test-zone").externalDns(ImmutableList.of("8.8.8.8"))), Zone.builder() .id("6") assertNull(client.updateZone("6", name("test-zone").externalDns(ImmutableList.of("8.8.8.8"))));
public void testDeleteZone() { GlobalZoneApi client = requestSendsResponse( HttpRequest.builder() .method("GET") .endpoint("http://localhost:8080/client/api") .addQueryParam("response", "json") .addQueryParam("command", "deleteZone") .addQueryParam("id", "6") .addQueryParam("apiKey", "identity") .addQueryParam("signature", "TfkzSIK8kzGJnIYo3DofECyuOII=") .addHeader("Accept", "application/json") .build(), HttpResponse.builder() .statusCode(200) .payload(payloadFromResource("/deletezoneresponse.json")) .build()); client.deleteZone("6"); }
public void testCreateZoneWhenResponseIs2xxAnd404() { GlobalZoneApi client = requestSendsResponse(createZone, HttpResponse.builder() .statusCode(200) .payload(payloadFromResource("/createzoneresponse.json")) .build()); assertEquals(client.createZone("test-zone", NetworkType.BASIC, "8.8.8.8", "10.10.10.10"), Zone.builder() .id("6") .name("test-zone") .DNS(ImmutableList.of("8.8.8.8")) .internalDNS(ImmutableList.of("10.10.10.10")) .networkType(NetworkType.BASIC) .securityGroupsEnabled(true) .allocationState(AllocationState.ENABLED) .zoneToken("7b6e27df-30a6-3024-9d8b-7971a3127f64") .dhcpProvider("DhcpServer").build()); client = requestSendsResponse(createZone, HttpResponse.builder().statusCode(404).build()); assertNull(client.createZone("test-zone", NetworkType.BASIC, "8.8.8.8", "10.10.10.10")); }
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; }
public Zone findZoneMatchingRegex(String regex) { if (zones == null) zones = getZoneClient().listZones(); for (Zone z : zones) if (z.getName() != null && z.getName().matches(regex)) return z; return null; }