From ea5b899def4b0c522a0cadc427568908e0cbe2a1 Mon Sep 17 00:00:00 2001 From: Ignasi Barrera Date: Mon, 2 Jul 2018 13:19:46 +0200 Subject: [PATCH] Added Virtual Network Gateway API --- .../azurecompute/arm/AzureComputeApi.java | 11 +- .../arm/AzureComputeProviderMetadata.java | 2 + .../compute/config/AzurePredicatesModule.java | 987 +++++++++--------- .../CreateResourcesThenCreateNodes.java | 2 +- .../arm/config/AzureComputeProperties.java | 2 +- .../azurecompute/arm/domain/AddressSpace.java | 39 + .../arm/domain/IpAllocationMethod.java | 28 + .../azurecompute/arm/domain/Subnet.java | 10 + .../arm/domain/VirtualNetwork.java | 21 +- .../arm/domain/vpn/BGPSettings.java | 37 + .../azurecompute/arm/domain/vpn/DHGroup.java | 28 + .../arm/domain/vpn/IPSecEncryption.java | 28 + .../arm/domain/vpn/IPSecIntegrity.java | 28 + .../arm/domain/vpn/IPSecPolicy.java | 77 ++ .../arm/domain/vpn/IkeEncryption.java | 28 + .../arm/domain/vpn/IkeIntegrity.java | 28 + .../domain/{ => vpn}/LocalNetworkGateway.java | 11 +- .../LocalNetworkGatewayProperties.java | 47 +- .../azurecompute/arm/domain/vpn/PFSGroup.java | 28 + .../azurecompute/arm/domain/vpn/SKU.java | 55 + .../domain/vpn/VPNClientConfiguration.java | 89 ++ .../vpn/VPNClientRevokedCertificate.java | 57 + .../domain/vpn/VPNClientRootCertificate.java | 57 + .../azurecompute/arm/domain/vpn/VPNType.java | 27 + .../arm/domain/vpn/VirtualNetworkGateway.java | 72 ++ .../vpn/VirtualNetworkGatewayProperties.java | 144 +++ .../domain/vpn/VirtualNetworkGatewayType.java | 28 + .../arm/features/LocalNetworkGatewayApi.java | 4 +- .../features/VirtualNetworkGatewayApi.java | 80 ++ .../LocalNetworkGatewayApiLiveTest.java | 8 +- .../LocalNetworkGatewayApiMockTest.java | 8 +- .../NetworkInterfaceCardApiLiveTest.java | 1 - .../features/VirtualNetworkApiLiveTest.java | 3 +- .../features/VirtualNetworkApiMockTest.java | 22 +- .../VirtualNetworkGatewayApiLiveTest.java | 132 +++ .../VirtualNetworkGatewayApiMockTest.java | 161 +++ .../internal/BaseAzureComputeApiLiveTest.java | 49 +- .../virtualnetworkgatewaycreate.json | 45 + .../resources/virtualnetworkgatewayget.json | 37 + .../resources/virtualnetworkgatewaylist.json | 49 + 40 files changed, 1989 insertions(+), 581 deletions(-) create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AddressSpace.java create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/IpAllocationMethod.java create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/BGPSettings.java create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/DHGroup.java create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecEncryption.java create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecIntegrity.java create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecPolicy.java create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IkeEncryption.java create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IkeIntegrity.java rename providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/{ => vpn}/LocalNetworkGateway.java (85%) rename providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/{ => vpn}/LocalNetworkGatewayProperties.java (61%) create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/PFSGroup.java create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/SKU.java create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientConfiguration.java create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientRevokedCertificate.java create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientRootCertificate.java create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNType.java create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGateway.java create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGatewayProperties.java create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGatewayType.java create mode 100644 providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApi.java create mode 100644 providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApiLiveTest.java create mode 100644 providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApiMockTest.java create mode 100644 providers/azurecompute-arm/src/test/resources/virtualnetworkgatewaycreate.json create mode 100644 providers/azurecompute-arm/src/test/resources/virtualnetworkgatewayget.json create mode 100644 providers/azurecompute-arm/src/test/resources/virtualnetworkgatewaylist.json diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeApi.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeApi.java index a4b62824ec..d14f7e1dde 100644 --- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeApi.java +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeApi.java @@ -46,6 +46,7 @@ import org.jclouds.azurecompute.arm.features.VaultApi; import org.jclouds.azurecompute.arm.features.VirtualMachineApi; import org.jclouds.azurecompute.arm.features.VirtualMachineScaleSetApi; import org.jclouds.azurecompute.arm.features.VirtualNetworkApi; +import org.jclouds.azurecompute.arm.features.VirtualNetworkGatewayApi; import org.jclouds.rest.annotations.Delegate; import com.google.common.base.Supplier; @@ -151,7 +152,7 @@ public interface AzureComputeApi extends Closeable { /** * The Azure Resource Manager API gets all the OS images in your subscription. * - * @see docs + * @see docs */ @Delegate OSImageApi getOSImageApi(@PathParam("location") String location); @@ -271,6 +272,14 @@ public interface AzureComputeApi extends Closeable { @Delegate LocalNetworkGatewayApi getLocalNetworkGatewayApi(@PathParam("resourcegroup") String resourcegroup); + /** + * Management features for Virtual Network Gateways. + * + * @see docs + */ + @Delegate + VirtualNetworkGatewayApi getVirtualNetworkGatewayApi(@PathParam("resourcegroup") String resourcegroup); + /** * Returns the information about the current service principal. */ diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java index 3038f8e368..b16557a877 100644 --- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java @@ -63,6 +63,7 @@ import org.jclouds.azurecompute.arm.features.VaultApi; import org.jclouds.azurecompute.arm.features.VirtualMachineApi; import org.jclouds.azurecompute.arm.features.VirtualMachineScaleSetApi; import org.jclouds.azurecompute.arm.features.VirtualNetworkApi; +import org.jclouds.azurecompute.arm.features.VirtualNetworkGatewayApi; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.internal.BaseProviderMetadata; @@ -132,6 +133,7 @@ public class AzureComputeProviderMetadata extends BaseProviderMetadata { properties.put(API_VERSION_PREFIX + GraphRBACApi.class.getSimpleName(), "1.6"); properties.put(API_VERSION_PREFIX + VaultApi.class.getSimpleName(), "2016-10-01"); properties.put(API_VERSION_PREFIX + LocalNetworkGatewayApi.class.getSimpleName(), "2018-02-01"); + properties.put(API_VERSION_PREFIX + VirtualNetworkGatewayApi.class.getSimpleName(), "2018-02-01"); return properties; } diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/config/AzurePredicatesModule.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/config/AzurePredicatesModule.java index d02909b2f2..6d7f8ac9b7 100644 --- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/config/AzurePredicatesModule.java +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/config/AzurePredicatesModule.java @@ -35,6 +35,7 @@ import static org.jclouds.util.Predicates2.retry; import java.net.URI; import java.util.List; +import java.util.concurrent.TimeUnit; import org.jclouds.azurecompute.arm.AzureComputeApi; import org.jclouds.azurecompute.arm.domain.Certificate.CertificateBundle; @@ -52,6 +53,7 @@ import org.jclouds.azurecompute.arm.domain.Secret.SecretBundle; import org.jclouds.azurecompute.arm.domain.Vault; import org.jclouds.azurecompute.arm.domain.VirtualMachineInstance; import org.jclouds.azurecompute.arm.domain.VirtualNetwork; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGateway; import org.jclouds.azurecompute.arm.functions.ParseJobStatus; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.reference.ComputeServiceConstants.PollPeriod; @@ -65,74 +67,84 @@ import com.google.inject.Provides; import com.google.inject.name.Named; public class AzurePredicatesModule extends AbstractModule { - protected void configure() { - } + protected void configure() { + } - @Provides - @Named(TIMEOUT_NODE_RUNNING) - protected VirtualMachineInStatePredicateFactory provideVirtualMachineRunningPredicate(final AzureComputeApi api, - final ComputeServiceConstants.Timeouts timeouts, final PollPeriod pollPeriod) { - return new VirtualMachineInStatePredicateFactory(api, VirtualMachineInstance.PowerState.RUNNING, timeouts.nodeRunning, - pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); - } + @Provides + @Named(TIMEOUT_NODE_RUNNING) + protected VirtualMachineInStatePredicateFactory provideVirtualMachineRunningPredicate(final AzureComputeApi api, + final ComputeServiceConstants.Timeouts timeouts, final PollPeriod pollPeriod) { + return new VirtualMachineInStatePredicateFactory(api, VirtualMachineInstance.PowerState.RUNNING, + timeouts.nodeRunning, pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); + } - @Provides - @Named(TIMEOUT_NODE_TERMINATED) - protected Predicate provideNodeTerminatedPredicate(final AzureComputeApi api, final ComputeServiceConstants.Timeouts timeouts, - final PollPeriod pollPeriod) { - return retry(new ActionDonePredicate(api), timeouts.nodeTerminated, pollPeriod.pollInitialPeriod, - pollPeriod.pollMaxPeriod); - } + @Provides + @Named(TIMEOUT_NODE_TERMINATED) + protected Predicate provideNodeTerminatedPredicate(final AzureComputeApi api, + final ComputeServiceConstants.Timeouts timeouts, final PollPeriod pollPeriod) { + return retry(new ActionDonePredicate(api), timeouts.nodeTerminated, pollPeriod.pollInitialPeriod, + pollPeriod.pollMaxPeriod); + } - @Provides - @Named(TIMEOUT_IMAGE_AVAILABLE) - protected Predicate provideImageCapturedPredicate(final AzureComputeApi api, final ComputeServiceConstants.Timeouts timeouts, - final PollPeriod pollPeriod) { - return retry(new ImageCapturedPredicate(api), timeouts.imageAvailable, pollPeriod.pollInitialPeriod, - pollPeriod.pollMaxPeriod); - } + @Provides + @Named(TIMEOUT_IMAGE_AVAILABLE) + protected Predicate provideImageCapturedPredicate(final AzureComputeApi api, + final ComputeServiceConstants.Timeouts timeouts, final PollPeriod pollPeriod) { + return retry(new ImageCapturedPredicate(api), timeouts.imageAvailable, pollPeriod.pollInitialPeriod, + pollPeriod.pollMaxPeriod); + } - @Provides - @Named(TIMEOUT_RESOURCE_DELETED) - protected Predicate provideResourceDeletedPredicate(final AzureComputeApi api, final ComputeServiceConstants.Timeouts timeouts, - final PollPeriod pollPeriod) { - return retry(new ActionDonePredicate(api), timeouts.nodeTerminated, pollPeriod.pollInitialPeriod, - pollPeriod.pollMaxPeriod); - } + @Provides + @Named(TIMEOUT_RESOURCE_DELETED) + protected Predicate provideResourceDeletedPredicate(final AzureComputeApi api, + final ComputeServiceConstants.Timeouts timeouts, final PollPeriod pollPeriod) { + return retry(new ActionDonePredicate(api), timeouts.nodeTerminated, pollPeriod.pollInitialPeriod, + pollPeriod.pollMaxPeriod); + } - @Provides - @Named(TIMEOUT_NODE_SUSPENDED) - protected VirtualMachineInStatePredicateFactory provideNodeSuspendedPredicate(final AzureComputeApi api, - final ComputeServiceConstants.Timeouts timeouts, final PollPeriod pollPeriod) { - return new VirtualMachineInStatePredicateFactory(api, VirtualMachineInstance.PowerState.STOPPED, timeouts.nodeTerminated, - pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); - } + @Provides + @Named(TIMEOUT_NODE_SUSPENDED) + protected VirtualMachineInStatePredicateFactory provideNodeSuspendedPredicate(final AzureComputeApi api, + final ComputeServiceConstants.Timeouts timeouts, final PollPeriod pollPeriod) { + return new VirtualMachineInStatePredicateFactory(api, VirtualMachineInstance.PowerState.STOPPED, + timeouts.nodeTerminated, pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); + } - @Provides - protected PublicIpAvailablePredicateFactory providePublicIpAvailablePredicate(final AzureComputeApi api, - Predicate> resourceAvailable) { - return new PublicIpAvailablePredicateFactory(api, resourceAvailable); - } + @Provides + protected PublicIpAvailablePredicateFactory providePublicIpAvailablePredicate(final AzureComputeApi api, + Predicate> resourceAvailable) { + return new PublicIpAvailablePredicateFactory(api, resourceAvailable); + } - @Provides - protected SecurityGroupAvailablePredicateFactory provideSecurityGroupAvailablePredicate(final AzureComputeApi api, - Predicate> resourceAvailable) { - return new SecurityGroupAvailablePredicateFactory(api, resourceAvailable); - } + @Provides + protected SecurityGroupAvailablePredicateFactory provideSecurityGroupAvailablePredicate(final AzureComputeApi api, + Predicate> resourceAvailable) { + return new SecurityGroupAvailablePredicateFactory(api, resourceAvailable); + } - @Provides - protected ImageAvailablePredicateFactory provideImageAvailablePredicate(final AzureComputeApi api, - Predicate> resourceAvailable, final ComputeServiceConstants.Timeouts timeouts, final PollPeriod pollPeriod) { - return new ImageAvailablePredicateFactory(api, retry(new ResourceInStatusPredicate("Succeeded"), - timeouts.imageAvailable, pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod)); - } + @Provides + protected ImageAvailablePredicateFactory provideImageAvailablePredicate(final AzureComputeApi api, + final ComputeServiceConstants.Timeouts timeouts, final PollPeriod pollPeriod) { + return new ImageAvailablePredicateFactory(api, retry(new ResourceInStatusPredicate("Succeeded"), + timeouts.imageAvailable, pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod)); + } - @Provides - protected Predicate> provideResourceAvailablePredicate(final AzureComputeApi api, - @Named(OPERATION_TIMEOUT) Integer operationTimeout, PollPeriod pollPeriod) { - return retry(new ResourceInStatusPredicate("Succeeded"), operationTimeout, pollPeriod.pollInitialPeriod, - pollPeriod.pollMaxPeriod); - } + @Provides + protected VirtualNetworkGatewayAvailablePredicateFactory provideVirtualNetworkGatewayAvailablePredicate( + final AzureComputeApi api, Predicate> resourceAvailable, + final ComputeServiceConstants.Timeouts timeouts, final PollPeriod pollPeriod) { + // The Azure Virtual Gateways can take up to 45 minutes to be provisioned. + // Don't poll too aggressively + return new VirtualNetworkGatewayAvailablePredicateFactory(api, retry(new ResourceInStatusPredicate("Succeeded"), + 45, 1, 2, TimeUnit.MINUTES)); + } + + @Provides + protected Predicate> provideResourceAvailablePredicate(final AzureComputeApi api, + @Named(OPERATION_TIMEOUT) Integer operationTimeout, PollPeriod pollPeriod) { + return retry(new ResourceInStatusPredicate("Succeeded"), operationTimeout, pollPeriod.pollInitialPeriod, + pollPeriod.pollMaxPeriod); + } @Provides protected NetworkAvailablePredicateFactory provideNetworkAvailablePredicate(final AzureComputeApi api, @@ -140,151 +152,151 @@ public class AzurePredicatesModule extends AbstractModule { return new NetworkAvailablePredicateFactory(api, resourceAvailable); } - @VisibleForTesting - static class ActionDonePredicate implements Predicate { + @VisibleForTesting + static class ActionDonePredicate implements Predicate { - private final AzureComputeApi api; + private final AzureComputeApi api; - public ActionDonePredicate(final AzureComputeApi api) { - this.api = checkNotNull(api, "api must not be null"); - } + public ActionDonePredicate(final AzureComputeApi api) { + this.api = checkNotNull(api, "api must not be null"); + } - @Override - public boolean apply(final URI uri) { - checkNotNull(uri, "uri cannot be null"); - return ParseJobStatus.JobStatus.DONE == api.getJobApi().jobStatus(uri) - || ParseJobStatus.JobStatus.NO_CONTENT == api.getJobApi().jobStatus(uri); - } - } + @Override + public boolean apply(final URI uri) { + checkNotNull(uri, "uri cannot be null"); + return ParseJobStatus.JobStatus.DONE == api.getJobApi().jobStatus(uri) + || ParseJobStatus.JobStatus.NO_CONTENT == api.getJobApi().jobStatus(uri); + } + } - @VisibleForTesting - static class ImageCapturedPredicate implements Predicate { + @VisibleForTesting + static class ImageCapturedPredicate implements Predicate { - private final AzureComputeApi api; + private final AzureComputeApi api; - public ImageCapturedPredicate(final AzureComputeApi api) { - this.api = checkNotNull(api, "api must not be null"); - } + public ImageCapturedPredicate(final AzureComputeApi api) { + this.api = checkNotNull(api, "api must not be null"); + } - @Override - public boolean apply(final URI uri) { - checkNotNull(uri, "uri cannot be null"); - if (api.getJobApi().jobStatus(uri) != ParseJobStatus.JobStatus.DONE) { - return false; + @Override + public boolean apply(final URI uri) { + checkNotNull(uri, "uri cannot be null"); + if (api.getJobApi().jobStatus(uri) != ParseJobStatus.JobStatus.DONE) { + return false; + } + List definitions = api.getJobApi().captureStatus(uri); + return definitions != null; + } + } + + public static class VirtualMachineInStatePredicateFactory { + + private final AzureComputeApi api; + private final VirtualMachineInstance.PowerState powerState; + private final long timeout; + private final long period; + private final long maxPeriod; + + VirtualMachineInStatePredicateFactory(final AzureComputeApi api, + final VirtualMachineInstance.PowerState powerState, final long timeout, final long period, + final long maxPeriod) { + this.api = checkNotNull(api, "api cannot be null"); + this.powerState = checkNotNull(powerState, "powerState cannot be null"); + this.timeout = timeout; + this.period = period; + this.maxPeriod = maxPeriod; + } + + public Predicate create(final String azureGroup) { + return retry(new Predicate() { + @Override + public boolean apply(final String name) { + checkNotNull(name, "name cannot be null"); + VirtualMachineInstance vmInstance = api.getVirtualMachineApi(azureGroup).getInstanceDetails(name); + if (vmInstance == null) { + return false; + } + return powerState == vmInstance.powerState(); } - List definitions = api.getJobApi().captureStatus(uri); - return definitions != null; - } - } + }, timeout, period, maxPeriod); + } + } - public static class VirtualMachineInStatePredicateFactory { + public static class ResourceInStatusPredicate implements Predicate> { + private final String expectedStatus; - private final AzureComputeApi api; - private final VirtualMachineInstance.PowerState powerState; - private final long timeout; - private final long period; - private final long maxPeriod; + ResourceInStatusPredicate(String expectedStatus) { + this.expectedStatus = checkNotNull(expectedStatus, "expectedStatus cannot be null"); + } - VirtualMachineInStatePredicateFactory(final AzureComputeApi api, final VirtualMachineInstance.PowerState powerState, final long timeout, - final long period, final long maxPeriod) { - this.api = checkNotNull(api, "api cannot be null"); - this.powerState = checkNotNull(powerState, "powerState cannot be null"); - this.timeout = timeout; - this.period = period; - this.maxPeriod = maxPeriod; - } + @Override + public boolean apply(Supplier provisionableSupplier) { + checkNotNull(provisionableSupplier, "provisionableSupplier supplier cannot be null"); + Provisionable provisionable = provisionableSupplier.get(); + return provisionable != null && provisionable.provisioningState().equalsIgnoreCase(expectedStatus); + } + } - public Predicate create(final String azureGroup) { - return retry(new Predicate() { - @Override - public boolean apply(final String name) { - checkNotNull(name, "name cannot be null"); - VirtualMachineInstance vmInstance = api.getVirtualMachineApi(azureGroup).getInstanceDetails(name); - if (vmInstance == null) { - return false; - } - return powerState == vmInstance.powerState(); - } - }, timeout, period, maxPeriod); - } - } + public static class PublicIpAvailablePredicateFactory { + private final AzureComputeApi api; + private final Predicate> resourceAvailable; - public static class ResourceInStatusPredicate implements Predicate> { - private final String expectedStatus; + PublicIpAvailablePredicateFactory(final AzureComputeApi api, Predicate> resourceAvailable) { + this.api = checkNotNull(api, "api cannot be null"); + this.resourceAvailable = resourceAvailable; + } - ResourceInStatusPredicate(String expectedStatus) { - this.expectedStatus = checkNotNull(expectedStatus, "expectedStatus cannot be null"); - } + public Predicate create(final String azureGroup) { + checkNotNull(azureGroup, "azureGroup cannot be null"); + return new Predicate() { + @Override + public boolean apply(final String name) { + checkNotNull(name, "name cannot be null"); + return resourceAvailable.apply(new Supplier() { + @Override + public Provisionable get() { + PublicIPAddress publicIp = api.getPublicIPAddressApi(azureGroup).get(name); + return publicIp == null ? null : publicIp.properties(); + } + }); + } + }; + } + } - @Override - public boolean apply(Supplier provisionableSupplier) { - checkNotNull(provisionableSupplier, "provisionableSupplier supplier cannot be null"); - Provisionable provisionable = provisionableSupplier.get(); - return provisionable != null && provisionable.provisioningState().equalsIgnoreCase(expectedStatus); - } - } + public static class SecurityGroupAvailablePredicateFactory { + private final AzureComputeApi api; + private final Predicate> resourceAvailable; - public static class PublicIpAvailablePredicateFactory { - private final AzureComputeApi api; - private final Predicate> resourceAvailable; + SecurityGroupAvailablePredicateFactory(final AzureComputeApi api, + Predicate> resourceAvailable) { + this.api = checkNotNull(api, "api cannot be null"); + this.resourceAvailable = resourceAvailable; + } - PublicIpAvailablePredicateFactory(final AzureComputeApi api, Predicate> resourceAvailable) { - this.api = checkNotNull(api, "api cannot be null"); - this.resourceAvailable = resourceAvailable; - } - - public Predicate create(final String azureGroup) { - checkNotNull(azureGroup, "azureGroup cannot be null"); - return new Predicate() { - @Override - public boolean apply(final String name) { - checkNotNull(name, "name cannot be null"); - return resourceAvailable.apply(new Supplier() { - @Override - public Provisionable get() { - PublicIPAddress publicIp = api.getPublicIPAddressApi(azureGroup).get(name); - return publicIp == null ? null : publicIp.properties(); - } - }); - } - }; - } - } - - public static class SecurityGroupAvailablePredicateFactory { - private final AzureComputeApi api; - private final Predicate> resourceAvailable; - - SecurityGroupAvailablePredicateFactory(final AzureComputeApi api, - Predicate> resourceAvailable) { - this.api = checkNotNull(api, "api cannot be null"); - this.resourceAvailable = resourceAvailable; - } - - public Predicate create(final String resourceGroup) { - checkNotNull(resourceGroup, "resourceGroup cannot be null"); - return new Predicate() { - @Override - public boolean apply(final String name) { - checkNotNull(name, "name cannot be null"); - return resourceAvailable.apply(new Supplier() { - @Override - public Provisionable get() { - NetworkSecurityGroup sg = api.getNetworkSecurityGroupApi(resourceGroup).get(name); - return sg == null ? null : sg.properties(); - } - }); - } - }; - } - } + public Predicate create(final String resourceGroup) { + checkNotNull(resourceGroup, "resourceGroup cannot be null"); + return new Predicate() { + @Override + public boolean apply(final String name) { + checkNotNull(name, "name cannot be null"); + return resourceAvailable.apply(new Supplier() { + @Override + public Provisionable get() { + NetworkSecurityGroup sg = api.getNetworkSecurityGroupApi(resourceGroup).get(name); + return sg == null ? null : sg.properties(); + } + }); + } + }; + } + } public static class NetworkAvailablePredicateFactory { private final AzureComputeApi api; private final Predicate> resourceAvailable; - NetworkAvailablePredicateFactory(final AzureComputeApi api, - Predicate> resourceAvailable) { + NetworkAvailablePredicateFactory(final AzureComputeApi api, Predicate> resourceAvailable) { this.api = checkNotNull(api, "api cannot be null"); this.resourceAvailable = resourceAvailable; } @@ -307,324 +319,363 @@ public class AzurePredicatesModule extends AbstractModule { } } + public static class ImageAvailablePredicateFactory { + private final AzureComputeApi api; + private final Predicate> resourceAvailable; - public static class ImageAvailablePredicateFactory { - private final AzureComputeApi api; - private final Predicate> resourceAvailable; + ImageAvailablePredicateFactory(final AzureComputeApi api, Predicate> resourceAvailable) { + this.api = checkNotNull(api, "api cannot be null"); + this.resourceAvailable = resourceAvailable; + } - ImageAvailablePredicateFactory(final AzureComputeApi api, - Predicate> resourceAvailable) { + public Predicate create(final String resourceGroup) { + checkNotNull(resourceGroup, "resourceGroup cannot be null"); + return new Predicate() { + @Override + public boolean apply(final String name) { + checkNotNull(name, "name cannot be null"); + return resourceAvailable.apply(new Supplier() { + @Override + public Provisionable get() { + Image img = api.getVirtualMachineImageApi(resourceGroup).get(name); + return img == null ? null : img.properties(); + } + }); + } + }; + } + } + + public static class VirtualNetworkGatewayAvailablePredicateFactory { + private final AzureComputeApi api; + private final Predicate> resourceAvailable; + + VirtualNetworkGatewayAvailablePredicateFactory(final AzureComputeApi api, + Predicate> resourceAvailable) { + this.api = checkNotNull(api, "api cannot be null"); + this.resourceAvailable = resourceAvailable; + } + + public Predicate create(final String resourceGroup) { + checkNotNull(resourceGroup, "resourceGroup cannot be null"); + return new Predicate() { + @Override + public boolean apply(final String name) { + checkNotNull(name, "name cannot be null"); + return resourceAvailable.apply(new Supplier() { + @Override + public Provisionable get() { + VirtualNetworkGateway vng = api.getVirtualNetworkGatewayApi(resourceGroup).get(name); + return vng == null ? null : vng.properties(); + } + }); + } + }; + } + } + + @Provides + @Named(VAULT_DELETE_STATUS) + protected VaultPredicates.DeletedVaultStatusPredicateFactory provideDeletedVaultStatusPredicateFactory( + final AzureComputeApi api, @Named(OPERATION_TIMEOUT) Integer operationTimeout, final PollPeriod pollPeriod) { + return new VaultPredicates.DeletedVaultStatusPredicateFactory(api, operationTimeout.longValue(), + pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); + } + + public static class VaultPredicates { + public static class DeletedVaultStatusPredicateFactory { + private final AzureComputeApi api; + private final long operationTimeout; + private final long initialPeriod; + private final long maxPeriod; + + DeletedVaultStatusPredicateFactory(final AzureComputeApi api, final long operationTimeout, + final long initialPeriod, final long maxPeriod) { this.api = checkNotNull(api, "api cannot be null"); - this.resourceAvailable = resourceAvailable; - } + this.operationTimeout = operationTimeout; + this.initialPeriod = initialPeriod; + this.maxPeriod = maxPeriod; + } - public Predicate create(final String resourceGroup) { + public Predicate create(final String resourceGroup, final boolean shouldBePresent) { checkNotNull(resourceGroup, "resourceGroup cannot be null"); - return new Predicate() { - @Override - public boolean apply(final String name) { - checkNotNull(name, "name cannot be null"); - return resourceAvailable.apply(new Supplier() { - @Override - public Provisionable get() { - Image img = api.getVirtualMachineImageApi(resourceGroup).get(name); - return img == null ? null : img.properties(); - } - }); - } - }; - } - } + return retry(new Predicate() { + @Override + public boolean apply(final String name) { + checkNotNull(name, "name cannot be null"); + List vaults = api.getVaultApi(resourceGroup).listDeletedVaults(); + return shouldBePresent == Iterables.any(vaults, new Predicate() { + @Override + public boolean apply(Vault.DeletedVault input) { + return input.name().equals(name); + } + }); + } + }, operationTimeout, initialPeriod, maxPeriod); + } + } + } - @Provides - @Named(VAULT_DELETE_STATUS) - protected VaultPredicates.DeletedVaultStatusPredicateFactory provideDeletedVaultStatusPredicateFactory(final AzureComputeApi api, - @Named(OPERATION_TIMEOUT) Integer operationTimeout, - final PollPeriod pollPeriod) { - return new VaultPredicates.DeletedVaultStatusPredicateFactory(api, operationTimeout.longValue(), pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); - } + @Provides + @Named(VAULT_KEY_DELETED_STATUS) + protected VaultKeyPredicates.DeletedKeyStatusPredicateFactory provideDeletedKeyStatusPredicateFactory( + final AzureComputeApi api, @Named(OPERATION_TIMEOUT) Integer operationTimeout, final PollPeriod pollPeriod) { + return new VaultKeyPredicates.DeletedKeyStatusPredicateFactory(api, operationTimeout.longValue(), + pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); + } - public static class VaultPredicates { - public static class DeletedVaultStatusPredicateFactory { - private final AzureComputeApi api; - private final long operationTimeout; - private final long initialPeriod; - private final long maxPeriod; + @Provides + @Named(VAULT_KEY_RECOVERABLE_STATUS) + protected VaultKeyPredicates.RecoverableKeyStatusPredicateFactory provideRecoverableKeyStatusPredicateFactory( + final AzureComputeApi api, @Named(OPERATION_TIMEOUT) Integer operationTimeout, final PollPeriod pollPeriod) { + return new VaultKeyPredicates.RecoverableKeyStatusPredicateFactory(api, operationTimeout.longValue(), + pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); + } - DeletedVaultStatusPredicateFactory(final AzureComputeApi api, final long operationTimeout, final long initialPeriod, final long maxPeriod) { - this.api = checkNotNull(api, "api cannot be null"); - this.operationTimeout = operationTimeout; - this.initialPeriod = initialPeriod; - this.maxPeriod = maxPeriod; - } + public static class VaultKeyPredicates { + public static class DeletedKeyStatusPredicateFactory { + private final AzureComputeApi api; + private final long operationTimeout; + private final long initialPeriod; + private final long maxPeriod; - public Predicate create(final String resourceGroup, final boolean shouldBePresent) { - checkNotNull(resourceGroup, "resourceGroup cannot be null"); - return retry(new Predicate() { - @Override - public boolean apply(final String name) { - checkNotNull(name, "name cannot be null"); - List vaults = api.getVaultApi(resourceGroup).listDeletedVaults(); - return shouldBePresent == Iterables.any(vaults, new Predicate() { - @Override public boolean apply(Vault.DeletedVault input) { - return input.name().equals(name); - } - }); - } - }, operationTimeout, initialPeriod, maxPeriod); - } - } - } + DeletedKeyStatusPredicateFactory(final AzureComputeApi api, final long operationTimeout, + final long initialPeriod, final long maxPeriod) { + this.api = checkNotNull(api, "api cannot be null"); + this.operationTimeout = operationTimeout; + this.initialPeriod = initialPeriod; + this.maxPeriod = maxPeriod; + } - @Provides - @Named(VAULT_KEY_DELETED_STATUS) - protected VaultKeyPredicates.DeletedKeyStatusPredicateFactory provideDeletedKeyStatusPredicateFactory(final AzureComputeApi api, - @Named(OPERATION_TIMEOUT) Integer operationTimeout, - final PollPeriod pollPeriod) { - return new VaultKeyPredicates.DeletedKeyStatusPredicateFactory(api, operationTimeout.longValue(), pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); - } + public Predicate create(final String resourceGroup, final URI vaultUri, final boolean shouldBePresent) { + checkNotNull(resourceGroup, "resourceGroup cannot be null"); + checkNotNull(vaultUri, "vaultUri cannot be null"); + return retry(new Predicate() { + @Override + public boolean apply(final String name) { + checkNotNull(name, "name cannot be null"); + DeletedKeyBundle key = api.getVaultApi(resourceGroup).getDeletedKey(vaultUri, name); + return shouldBePresent == (key != null); + } + }, operationTimeout, initialPeriod, maxPeriod); + } + } - @Provides - @Named(VAULT_KEY_RECOVERABLE_STATUS) - protected VaultKeyPredicates.RecoverableKeyStatusPredicateFactory provideRecoverableKeyStatusPredicateFactory(final AzureComputeApi api, - @Named(OPERATION_TIMEOUT) Integer operationTimeout, - final PollPeriod pollPeriod) { - return new VaultKeyPredicates.RecoverableKeyStatusPredicateFactory(api, operationTimeout.longValue(), pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); - } + public static class RecoverableKeyStatusPredicateFactory { + private final AzureComputeApi api; + private final long operationTimeout; + private final long initialPeriod; + private final long maxPeriod; - public static class VaultKeyPredicates { - public static class DeletedKeyStatusPredicateFactory { - private final AzureComputeApi api; - private final long operationTimeout; - private final long initialPeriod; - private final long maxPeriod; + RecoverableKeyStatusPredicateFactory(final AzureComputeApi api, final long operationTimeout, + final long initialPeriod, final long maxPeriod) { + this.api = checkNotNull(api, "api cannot be null"); + this.operationTimeout = operationTimeout; + this.initialPeriod = initialPeriod; + this.maxPeriod = maxPeriod; + } - DeletedKeyStatusPredicateFactory(final AzureComputeApi api, final long operationTimeout, final long initialPeriod, final long maxPeriod) { - this.api = checkNotNull(api, "api cannot be null"); - this.operationTimeout = operationTimeout; - this.initialPeriod = initialPeriod; - this.maxPeriod = maxPeriod; - } + public Predicate create(final String resourceGroup, final URI vaultUri, final boolean isRecovered) { + checkNotNull(resourceGroup, "resourceGroup cannot be null"); + checkNotNull(vaultUri, "vaultUri cannot be null"); + return retry(new Predicate() { + @Override + public boolean apply(final String name) { + checkNotNull(name, "name cannot be null"); + KeyBundle key = api.getVaultApi(resourceGroup).getKey(vaultUri, name); + return key != null ? (isRecovered ? true : key.attributes().recoveryLevel().contains("Recoverable")) + : false; + } + }, operationTimeout, initialPeriod, maxPeriod); + } + } + } - public Predicate create(final String resourceGroup, final URI vaultUri, final boolean shouldBePresent) { - checkNotNull(resourceGroup, "resourceGroup cannot be null"); - checkNotNull(vaultUri, "vaultUri cannot be null"); - return retry(new Predicate() { - @Override - public boolean apply(final String name) { - checkNotNull(name, "name cannot be null"); - DeletedKeyBundle key = api.getVaultApi(resourceGroup).getDeletedKey(vaultUri, name); - return shouldBePresent == (key != null); - } - }, operationTimeout, initialPeriod, maxPeriod); - } - } + @Provides + @Named(VAULT_SECRET_DELETE_STATUS) + protected VaultSecretPredicates.DeletedSecretStatusPredicateFactory provideDeletedSecretStatusPredicateFactory( + final AzureComputeApi api, @Named(OPERATION_TIMEOUT) Integer operationTimeout, final PollPeriod pollPeriod) { + return new VaultSecretPredicates.DeletedSecretStatusPredicateFactory(api, operationTimeout.longValue(), + pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); + } - public static class RecoverableKeyStatusPredicateFactory { - private final AzureComputeApi api; - private final long operationTimeout; - private final long initialPeriod; - private final long maxPeriod; + @Provides + @Named(VAULT_SECRET_RECOVERABLE_STATUS) + protected VaultSecretPredicates.RecoverableSecretStatusPredicateFactory provideRecoverableSecretStatusPredicateFactory( + final AzureComputeApi api, @Named(OPERATION_TIMEOUT) Integer operationTimeout, final PollPeriod pollPeriod) { + return new VaultSecretPredicates.RecoverableSecretStatusPredicateFactory(api, operationTimeout.longValue(), + pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); + } - RecoverableKeyStatusPredicateFactory(final AzureComputeApi api, final long operationTimeout, final long initialPeriod, final long maxPeriod) { - this.api = checkNotNull(api, "api cannot be null"); - this.operationTimeout = operationTimeout; - this.initialPeriod = initialPeriod; - this.maxPeriod = maxPeriod; - } + public static class VaultSecretPredicates { + public static class DeletedSecretStatusPredicateFactory { + private final AzureComputeApi api; + private final long operationTimeout; + private final long initialPeriod; + private final long maxPeriod; - public Predicate create(final String resourceGroup, final URI vaultUri, final boolean isRecovered) { - checkNotNull(resourceGroup, "resourceGroup cannot be null"); - checkNotNull(vaultUri, "vaultUri cannot be null"); - return retry(new Predicate() { - @Override - public boolean apply(final String name) { - checkNotNull(name, "name cannot be null"); - KeyBundle key = api.getVaultApi(resourceGroup).getKey(vaultUri, name); - return key != null ? (isRecovered ? true : key.attributes().recoveryLevel().contains("Recoverable")) : false; - } - }, operationTimeout, initialPeriod, maxPeriod); - } - } - } + DeletedSecretStatusPredicateFactory(final AzureComputeApi api, final long operationTimeout, + final long initialPeriod, final long maxPeriod) { + this.api = checkNotNull(api, "api cannot be null"); + this.operationTimeout = operationTimeout; + this.initialPeriod = initialPeriod; + this.maxPeriod = maxPeriod; + } - @Provides - @Named(VAULT_SECRET_DELETE_STATUS) - protected VaultSecretPredicates.DeletedSecretStatusPredicateFactory provideDeletedSecretStatusPredicateFactory(final AzureComputeApi api, - @Named(OPERATION_TIMEOUT) Integer operationTimeout, - final PollPeriod pollPeriod) { - return new VaultSecretPredicates.DeletedSecretStatusPredicateFactory(api, operationTimeout.longValue(), pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); - } + public Predicate create(final String resourceGroup, final URI vaultUri, final boolean shouldBePresent) { + checkNotNull(resourceGroup, "resourceGroup cannot be null"); + checkNotNull(vaultUri, "vaultUri cannot be null"); + return retry(new Predicate() { + @Override + public boolean apply(final String name) { + checkNotNull(name, "name cannot be null"); + DeletedSecretBundle secret = api.getVaultApi(resourceGroup).getDeletedSecret(vaultUri, name); + return shouldBePresent == (secret != null); + } + }, operationTimeout, initialPeriod, maxPeriod); + } + } - @Provides - @Named(VAULT_SECRET_RECOVERABLE_STATUS) - protected VaultSecretPredicates.RecoverableSecretStatusPredicateFactory provideRecoverableSecretStatusPredicateFactory(final AzureComputeApi api, - @Named(OPERATION_TIMEOUT) Integer operationTimeout, - final PollPeriod pollPeriod) { - return new VaultSecretPredicates.RecoverableSecretStatusPredicateFactory(api, operationTimeout.longValue(), pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); - } + public static class RecoverableSecretStatusPredicateFactory { + private final AzureComputeApi api; + private final long operationTimeout; + private final long initialPeriod; + private final long maxPeriod; - public static class VaultSecretPredicates { - public static class DeletedSecretStatusPredicateFactory { - private final AzureComputeApi api; - private final long operationTimeout; - private final long initialPeriod; - private final long maxPeriod; + RecoverableSecretStatusPredicateFactory(final AzureComputeApi api, final long operationTimeout, + final long initialPeriod, final long maxPeriod) { + this.api = checkNotNull(api, "api cannot be null"); + this.operationTimeout = operationTimeout; + this.initialPeriod = initialPeriod; + this.maxPeriod = maxPeriod; + } - DeletedSecretStatusPredicateFactory(final AzureComputeApi api, final long operationTimeout, final long initialPeriod, final long maxPeriod) { - this.api = checkNotNull(api, "api cannot be null"); - this.operationTimeout = operationTimeout; - this.initialPeriod = initialPeriod; - this.maxPeriod = maxPeriod; - } + public Predicate create(final String resourceGroup, final URI vaultUri, final boolean isRecovered) { + checkNotNull(resourceGroup, "resourceGroup cannot be null"); + checkNotNull(vaultUri, "vaultUri cannot be null"); + return retry(new Predicate() { + @Override + public boolean apply(final String name) { + checkNotNull(name, "name cannot be null"); + SecretBundle secret = api.getVaultApi(resourceGroup).getSecret(vaultUri, name, null); + return secret != null ? (isRecovered ? true : secret.attributes().recoveryLevel() + .contains("Recoverable")) : false; + } + }, operationTimeout, initialPeriod, maxPeriod); + } + } + } - public Predicate create(final String resourceGroup, final URI vaultUri, final boolean shouldBePresent) { - checkNotNull(resourceGroup, "resourceGroup cannot be null"); - checkNotNull(vaultUri, "vaultUri cannot be null"); - return retry(new Predicate() { - @Override - public boolean apply(final String name) { - checkNotNull(name, "name cannot be null"); - DeletedSecretBundle secret = api.getVaultApi(resourceGroup).getDeletedSecret(vaultUri, name); - return shouldBePresent == (secret != null); - } - }, operationTimeout, initialPeriod, maxPeriod); - } - } + @Provides + @Named(VAULT_CERTIFICATE_DELETE_STATUS) + protected VaultCertificatePredicates.DeletedCertificateStatusPredicateFactory provideDeletedCertificateStatusPredicateFactory( + final AzureComputeApi api, @Named(OPERATION_TIMEOUT) Integer operationTimeout, final PollPeriod pollPeriod) { + return new VaultCertificatePredicates.DeletedCertificateStatusPredicateFactory(api, operationTimeout.longValue(), + pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); + } - public static class RecoverableSecretStatusPredicateFactory { - private final AzureComputeApi api; - private final long operationTimeout; - private final long initialPeriod; - private final long maxPeriod; + @Provides + @Named(VAULT_CERTIFICATE_RECOVERABLE_STATUS) + protected VaultCertificatePredicates.RecoverableCertificateStatusPredicateFactory provideRecoverableCertificateStatusPredicateFactory( + final AzureComputeApi api, @Named(OPERATION_TIMEOUT) Integer operationTimeout, final PollPeriod pollPeriod) { + return new VaultCertificatePredicates.RecoverableCertificateStatusPredicateFactory(api, + operationTimeout.longValue(), pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); + } - RecoverableSecretStatusPredicateFactory(final AzureComputeApi api, final long operationTimeout, final long initialPeriod, final long maxPeriod) { - this.api = checkNotNull(api, "api cannot be null"); - this.operationTimeout = operationTimeout; - this.initialPeriod = initialPeriod; - this.maxPeriod = maxPeriod; - } + @Provides + @Named(VAULT_CERTIFICATE_OPERATION_STATUS) + protected VaultCertificatePredicates.CertificateOperationStatusPredicateFactory provideCertificateOperationStatusPredicateFactory( + final AzureComputeApi api, @Named(OPERATION_TIMEOUT) Integer operationTimeout, final PollPeriod pollPeriod) { + return new VaultCertificatePredicates.CertificateOperationStatusPredicateFactory(api, + operationTimeout.longValue(), pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); + } - public Predicate create(final String resourceGroup, final URI vaultUri, final boolean isRecovered) { - checkNotNull(resourceGroup, "resourceGroup cannot be null"); - checkNotNull(vaultUri, "vaultUri cannot be null"); - return retry(new Predicate() { - @Override - public boolean apply(final String name) { - checkNotNull(name, "name cannot be null"); - SecretBundle secret = api.getVaultApi(resourceGroup).getSecret(vaultUri, name, null); - return secret != null ? (isRecovered ? true : secret.attributes().recoveryLevel().contains("Recoverable")) : false; - } - }, operationTimeout, initialPeriod, maxPeriod); - } - } - } + public static class VaultCertificatePredicates { + public static class DeletedCertificateStatusPredicateFactory { + private final AzureComputeApi api; + private final long operationTimeout; + private final long initialPeriod; + private final long maxPeriod; - @Provides - @Named(VAULT_CERTIFICATE_DELETE_STATUS) - protected VaultCertificatePredicates.DeletedCertificateStatusPredicateFactory provideDeletedCertificateStatusPredicateFactory(final AzureComputeApi api, - @Named(OPERATION_TIMEOUT) Integer operationTimeout, - final PollPeriod pollPeriod) { - return new VaultCertificatePredicates.DeletedCertificateStatusPredicateFactory(api, operationTimeout.longValue(), pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); - } + DeletedCertificateStatusPredicateFactory(final AzureComputeApi api, final long operationTimeout, + final long initialPeriod, final long maxPeriod) { + this.api = checkNotNull(api, "api cannot be null"); + this.operationTimeout = operationTimeout; + this.initialPeriod = initialPeriod; + this.maxPeriod = maxPeriod; + } - @Provides - @Named(VAULT_CERTIFICATE_RECOVERABLE_STATUS) - protected VaultCertificatePredicates.RecoverableCertificateStatusPredicateFactory provideRecoverableCertificateStatusPredicateFactory(final AzureComputeApi api, - @Named(OPERATION_TIMEOUT) Integer operationTimeout, - final PollPeriod pollPeriod) { - return new VaultCertificatePredicates.RecoverableCertificateStatusPredicateFactory(api, operationTimeout.longValue(), pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); - } + public Predicate create(final String resourceGroup, final URI vaultUri, final boolean shouldBePresent) { + checkNotNull(resourceGroup, "resourceGroup cannot be null"); + checkNotNull(vaultUri, "vaultUri cannot be null"); + return retry(new Predicate() { + @Override + public boolean apply(final String name) { + checkNotNull(name, "name cannot be null"); + DeletedCertificateBundle cert = api.getVaultApi(resourceGroup).getDeletedCertificate(vaultUri, name); + return shouldBePresent == (cert != null); + } + }, operationTimeout, initialPeriod, maxPeriod); + } + } - @Provides - @Named(VAULT_CERTIFICATE_OPERATION_STATUS) - protected VaultCertificatePredicates.CertificateOperationStatusPredicateFactory provideCertificateOperationStatusPredicateFactory(final AzureComputeApi api, - @Named(OPERATION_TIMEOUT) Integer operationTimeout, - final PollPeriod pollPeriod) { - return new VaultCertificatePredicates.CertificateOperationStatusPredicateFactory(api, operationTimeout.longValue(), pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod); - } + public static class RecoverableCertificateStatusPredicateFactory { + private final AzureComputeApi api; + private final long operationTimeout; + private final long initialPeriod; + private final long maxPeriod; - public static class VaultCertificatePredicates { - public static class DeletedCertificateStatusPredicateFactory { - private final AzureComputeApi api; - private final long operationTimeout; - private final long initialPeriod; - private final long maxPeriod; + RecoverableCertificateStatusPredicateFactory(final AzureComputeApi api, final long operationTimeout, + final long initialPeriod, final long maxPeriod) { + this.api = checkNotNull(api, "api cannot be null"); + this.operationTimeout = operationTimeout; + this.initialPeriod = initialPeriod; + this.maxPeriod = maxPeriod; + } - DeletedCertificateStatusPredicateFactory(final AzureComputeApi api, final long operationTimeout, final long initialPeriod, final long maxPeriod) { - this.api = checkNotNull(api, "api cannot be null"); - this.operationTimeout = operationTimeout; - this.initialPeriod = initialPeriod; - this.maxPeriod = maxPeriod; - } + public Predicate create(final String resourceGroup, final URI vaultUri, final boolean isImport) { + checkNotNull(resourceGroup, "resourceGroup cannot be null"); + checkNotNull(vaultUri, "vaultUri cannot be null"); + return retry(new Predicate() { + @Override + public boolean apply(final String name) { + checkNotNull(name, "name cannot be null"); + CertificateBundle cert = api.getVaultApi(resourceGroup).getCertificate(vaultUri, name, null); + return cert != null ? (isImport ? true : cert.attributes().recoveryLevel().contains("Recoverable")) + : false; - public Predicate create(final String resourceGroup, final URI vaultUri, final boolean shouldBePresent) { - checkNotNull(resourceGroup, "resourceGroup cannot be null"); - checkNotNull(vaultUri, "vaultUri cannot be null"); - return retry(new Predicate() { - @Override - public boolean apply(final String name) { - checkNotNull(name, "name cannot be null"); - DeletedCertificateBundle cert = api.getVaultApi(resourceGroup).getDeletedCertificate(vaultUri, name); - return shouldBePresent == (cert != null); - } - }, operationTimeout, initialPeriod, maxPeriod); - } - } + } + }, operationTimeout, initialPeriod, maxPeriod); + } + } - public static class RecoverableCertificateStatusPredicateFactory { - private final AzureComputeApi api; - private final long operationTimeout; - private final long initialPeriod; - private final long maxPeriod; + public static class CertificateOperationStatusPredicateFactory { + private final AzureComputeApi api; + private final long operationTimeout; + private final long initialPeriod; + private final long maxPeriod; - RecoverableCertificateStatusPredicateFactory(final AzureComputeApi api, final long operationTimeout, final long initialPeriod, final long maxPeriod) { - this.api = checkNotNull(api, "api cannot be null"); - this.operationTimeout = operationTimeout; - this.initialPeriod = initialPeriod; - this.maxPeriod = maxPeriod; - } + CertificateOperationStatusPredicateFactory(final AzureComputeApi api, final long operationTimeout, + final long initialPeriod, final long maxPeriod) { + this.api = checkNotNull(api, "api cannot be null"); + this.operationTimeout = operationTimeout; + this.initialPeriod = initialPeriod; + this.maxPeriod = maxPeriod; + } - public Predicate create(final String resourceGroup, final URI vaultUri, final boolean isImport) { - checkNotNull(resourceGroup, "resourceGroup cannot be null"); - checkNotNull(vaultUri, "vaultUri cannot be null"); - return retry(new Predicate() { - @Override - public boolean apply(final String name) { - checkNotNull(name, "name cannot be null"); - CertificateBundle cert = api.getVaultApi(resourceGroup).getCertificate(vaultUri, name, null); - return cert != null ? (isImport ? true : cert.attributes().recoveryLevel().contains("Recoverable")) : false; - - } - }, operationTimeout, initialPeriod, maxPeriod); - } - } - - public static class CertificateOperationStatusPredicateFactory { - private final AzureComputeApi api; - private final long operationTimeout; - private final long initialPeriod; - private final long maxPeriod; - - CertificateOperationStatusPredicateFactory(final AzureComputeApi api, final long operationTimeout, final long initialPeriod, final long maxPeriod) { - this.api = checkNotNull(api, "api cannot be null"); - this.operationTimeout = operationTimeout; - this.initialPeriod = initialPeriod; - this.maxPeriod = maxPeriod; - } - - public Predicate create(final String resourceGroup, final URI vaultUri, final boolean isCreate) { - checkNotNull(resourceGroup, "resourceGroup cannot be null"); - checkNotNull(vaultUri, "vaultUri cannot be null"); - return retry(new Predicate() { - @Override - public boolean apply(final String name) { - checkNotNull(name, "name cannot be null"); - CertificateOperation certOp = api.getVaultApi(resourceGroup).getCertificateOperation(vaultUri, name); - return isCreate ? ((certOp != null) ? !certOp.status().equals("inProgress") : false) : (certOp == null); - } - }, operationTimeout, initialPeriod, maxPeriod); - } - } - } + public Predicate create(final String resourceGroup, final URI vaultUri, final boolean isCreate) { + checkNotNull(resourceGroup, "resourceGroup cannot be null"); + checkNotNull(vaultUri, "vaultUri cannot be null"); + return retry(new Predicate() { + @Override + public boolean apply(final String name) { + checkNotNull(name, "name cannot be null"); + CertificateOperation certOp = api.getVaultApi(resourceGroup).getCertificateOperation(vaultUri, name); + return isCreate ? ((certOp != null) ? !certOp.status().equals("inProgress") : false) + : (certOp == null); + } + }, operationTimeout, initialPeriod, maxPeriod); + } + } + } } diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/strategy/CreateResourcesThenCreateNodes.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/strategy/CreateResourcesThenCreateNodes.java index 436dff0fc9..a2f2919f60 100644 --- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/strategy/CreateResourcesThenCreateNodes.java +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/compute/strategy/CreateResourcesThenCreateNodes.java @@ -41,13 +41,13 @@ import org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndNameAndIngres import org.jclouds.azurecompute.arm.compute.functions.TemplateToAvailabilitySet; import org.jclouds.azurecompute.arm.compute.options.AzureTemplateOptions; import org.jclouds.azurecompute.arm.compute.options.IpOptions; +import org.jclouds.azurecompute.arm.domain.AddressSpace; import org.jclouds.azurecompute.arm.domain.AvailabilitySet; import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroup; import org.jclouds.azurecompute.arm.domain.PublicIPAddress; import org.jclouds.azurecompute.arm.domain.ResourceGroup; import org.jclouds.azurecompute.arm.domain.Subnet; import org.jclouds.azurecompute.arm.domain.Subnet.SubnetProperties; -import org.jclouds.azurecompute.arm.domain.VirtualNetwork.AddressSpace; import org.jclouds.azurecompute.arm.domain.VirtualNetwork.VirtualNetworkProperties; import org.jclouds.compute.config.CustomizationResponse; import org.jclouds.compute.domain.NodeMetadata; diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeProperties.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeProperties.java index abe057ddab..80fa8f1923 100644 --- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeProperties.java +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/config/AzureComputeProperties.java @@ -23,7 +23,7 @@ package org.jclouds.azurecompute.arm.config; public class AzureComputeProperties { public static final String OPERATION_TIMEOUT = "jclouds.azurecompute.arm.operation.timeout"; - + public static final String IMAGE_PUBLISHERS = "jclouds.azurecompute.arm.publishers"; public static final String TIMEOUT_RESOURCE_DELETED = "jclouds.azurecompute.arm.timeout.resourcedeleted"; diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AddressSpace.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AddressSpace.java new file mode 100644 index 0000000000..1b7f434a7f --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AddressSpace.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain; + +import java.util.List; + +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableList; + +@AutoValue +public abstract class AddressSpace { + public abstract List addressPrefixes(); + + @SerializedNames({ "addressPrefixes" }) + public static AddressSpace create(List addressPrefixes) { + return new AutoValue_AddressSpace(addressPrefixes == null ? ImmutableList. of() + : ImmutableList.copyOf(addressPrefixes)); + } + + AddressSpace() { + + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/IpAllocationMethod.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/IpAllocationMethod.java new file mode 100644 index 0000000000..43911f91fa --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/IpAllocationMethod.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain; + +import org.jclouds.azurecompute.arm.util.GetEnumValue; + +public enum IpAllocationMethod { + + Static, Dynamic, Unrecognized; + + public static IpAllocationMethod fromValue(final String text) { + return (IpAllocationMethod) GetEnumValue.fromValueOrDefault(text, IpAllocationMethod.Unrecognized); + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Subnet.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Subnet.java index 80460b8f3f..ec57cbb1d2 100644 --- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Subnet.java +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Subnet.java @@ -31,6 +31,10 @@ import org.jclouds.json.SerializedNames; @AutoValue public abstract class Subnet { + // To create VPN endpoints, a "GatewaySubnet" is required. Azure identifies + // such networks by name, and they have to be named exactly "GatewaySubnet". + public static final String GATEWAY_SUBNET_NAME = "GatewaySubnet"; + private static final Pattern NETWORK_PATTERN = Pattern.compile("^.*/virtualNetworks/([^/]+)(/.*)?$"); @AutoValue @@ -131,6 +135,12 @@ public abstract class Subnet { public abstract Builder id(String id); public abstract Builder etag(String etag); public abstract Builder properties(SubnetProperties properties); + + // Gateway subnets are identified by name + public Builder setGatewaySubnet() { + return name(GATEWAY_SUBNET_NAME); + } + public abstract Subnet build(); } } diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/VirtualNetwork.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/VirtualNetwork.java index a0f5c3e118..6b01532943 100644 --- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/VirtualNetwork.java +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/VirtualNetwork.java @@ -18,30 +18,19 @@ package org.jclouds.azurecompute.arm.domain; import static com.google.common.collect.ImmutableList.copyOf; -import java.util.Map; import java.util.List; -import com.google.common.collect.ImmutableList; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableMap; +import java.util.Map; import org.jclouds.javax.annotation.Nullable; import org.jclouds.json.SerializedNames; +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; + @AutoValue public abstract class VirtualNetwork { - @AutoValue - public abstract static class AddressSpace { - - public abstract List addressPrefixes(); - - @SerializedNames({"addressPrefixes"}) - public static AddressSpace create(final List addressPrefixes) { - return new AutoValue_VirtualNetwork_AddressSpace(addressPrefixes == null ? ImmutableList.of() : ImmutableList.copyOf(addressPrefixes)); - } - } - @AutoValue public abstract static class VirtualNetworkProperties implements Provisionable { diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/BGPSettings.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/BGPSettings.java new file mode 100644 index 0000000000..740cf6298e --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/BGPSettings.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain.vpn; + +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +@AutoValue +public abstract class BGPSettings { + public abstract int asn(); + public abstract String bgpPeeringAddress(); + public abstract int peerWeight(); + + @SerializedNames({ "asn", "bgpPeeringAddress", "peerWeight" }) + public static BGPSettings create(int asn, String bgpPeeringAddress, int peerWeight) { + return new AutoValue_BGPSettings(asn, bgpPeeringAddress, peerWeight); + } + + BGPSettings() { + + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/DHGroup.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/DHGroup.java new file mode 100644 index 0000000000..66f7a7f985 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/DHGroup.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain.vpn; + +import org.jclouds.azurecompute.arm.util.GetEnumValue; + +public enum DHGroup { + + DHGroup1, DHGroup14, DHGroup2, DHGroup2048, DHGroup24, ECP256, ECP384, None, Unrecognized; + + public static DHGroup fromValue(final String text) { + return (DHGroup) GetEnumValue.fromValueOrDefault(text, DHGroup.Unrecognized); + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecEncryption.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecEncryption.java new file mode 100644 index 0000000000..a9405c531b --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecEncryption.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain.vpn; + +import org.jclouds.azurecompute.arm.util.GetEnumValue; + +public enum IPSecEncryption { + + AES128, AES192, AES256, DES, DES3, GCMAES128, GCMAES192, GCMAES256, None, Unrecognized; + + public static IPSecEncryption fromValue(final String text) { + return (IPSecEncryption) GetEnumValue.fromValueOrDefault(text, IPSecEncryption.Unrecognized); + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecIntegrity.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecIntegrity.java new file mode 100644 index 0000000000..02dc6ee02d --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecIntegrity.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain.vpn; + +import org.jclouds.azurecompute.arm.util.GetEnumValue; + +public enum IPSecIntegrity { + + GCMAES128, GCMAES192, GCMAES256, MD5, SHA1, SHA256, Unrecognized; + + public static IPSecIntegrity fromValue(final String text) { + return (IPSecIntegrity) GetEnumValue.fromValueOrDefault(text, IPSecIntegrity.Unrecognized); + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecPolicy.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecPolicy.java new file mode 100644 index 0000000000..d744fb04ef --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IPSecPolicy.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain.vpn; + +import org.jclouds.azurecompute.arm.domain.AddressSpace; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +@AutoValue +public abstract class IPSecPolicy { + @Nullable public abstract String radiusServerAddress(); + @Nullable public abstract String radiusServerSecret(); + @Nullable public abstract AddressSpace vpnClientAddressPool(); + @Nullable public abstract DHGroup dhGroup(); + @Nullable public abstract IkeEncryption ikeEncryption(); + @Nullable public abstract IkeIntegrity ikeIntegrity(); + @Nullable public abstract IPSecEncryption ipsecEncryption(); + @Nullable public abstract IPSecIntegrity ipsecIntegrity(); + @Nullable public abstract PFSGroup pfsGroup(); + @Nullable public abstract Integer saDataSizeKilobytes(); + @Nullable public abstract Integer saLifeTimeSeconds(); + + IPSecPolicy() { + + } + + @SerializedNames({ "radiusServerAddress", "radiusServerSecret", "vpnClientAddressPool", "dhGroup", "ikeEncryption", + "ikeIntegrity", "ipsecEncryption", "ipsecIntegrity", "pfsGroup", "saDataSizeKilobytes", "saLifeTimeSeconds" }) + public static IPSecPolicy create(String radiusServerAddress, String radiusServerSecret, + AddressSpace vpnClientAddressPool, DHGroup dhGroup, IkeEncryption ikeEncryption, IkeIntegrity ikeIntegrity, + IPSecEncryption ipsecEncryption, IPSecIntegrity ipsecIntegrity, PFSGroup pfsGroup, + Integer saDataSizeKilobytes, Integer saLifeTimeSeconds) { + return builder().radiusServerAddress(radiusServerAddress).radiusServerSecret(radiusServerSecret) + .vpnClientAddressPool(vpnClientAddressPool).dhGroup(dhGroup).ikeEncryption(ikeEncryption) + .ikeIntegrity(ikeIntegrity).ipsecEncryption(ipsecEncryption).ipsecIntegrity(ipsecIntegrity) + .pfsGroup(pfsGroup).saDataSizeKilobytes(saDataSizeKilobytes).saLifeTimeSeconds(saLifeTimeSeconds).build(); + } + + public static Builder builder() { + return new AutoValue_IPSecPolicy.Builder(); + } + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder radiusServerAddress(String radiusServerAddress); + public abstract Builder radiusServerSecret(String radiusServerSecret); + public abstract Builder vpnClientAddressPool(AddressSpace vpnClientAddressPool); + public abstract Builder dhGroup(DHGroup dhGroup); + public abstract Builder ikeEncryption(IkeEncryption ikeEncryption); + public abstract Builder ikeIntegrity(IkeIntegrity ikeIntegrity); + public abstract Builder ipsecEncryption(IPSecEncryption ipsecEncryption); + public abstract Builder ipsecIntegrity(IPSecIntegrity ipsecIntegrity); + public abstract Builder pfsGroup(PFSGroup pfsGroup); + public abstract Builder saDataSizeKilobytes(Integer saDataSizeKilobytes); + public abstract Builder saLifeTimeSeconds(Integer saLifeTimeSeconds); + + public abstract IPSecPolicy build(); + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IkeEncryption.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IkeEncryption.java new file mode 100644 index 0000000000..0ac8637401 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IkeEncryption.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain.vpn; + +import org.jclouds.azurecompute.arm.util.GetEnumValue; + +public enum IkeEncryption { + + AES128, AES192, AES256, DES, DES3, GCMAES128, GCMAES256, Unrecognized; + + public static IkeEncryption fromValue(final String text) { + return (IkeEncryption) GetEnumValue.fromValueOrDefault(text, IkeEncryption.Unrecognized); + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IkeIntegrity.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IkeIntegrity.java new file mode 100644 index 0000000000..1697347dba --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/IkeIntegrity.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain.vpn; + +import org.jclouds.azurecompute.arm.util.GetEnumValue; + +public enum IkeIntegrity { + + GCMAES128, GCMAES256, MD5, SHA1, SHA256, SHA384, Unrecognized; + + public static IkeIntegrity fromValue(final String text) { + return (IkeIntegrity) GetEnumValue.fromValueOrDefault(text, IkeIntegrity.Unrecognized); + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/LocalNetworkGateway.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/LocalNetworkGateway.java similarity index 85% rename from providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/LocalNetworkGateway.java rename to providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/LocalNetworkGateway.java index b8e95abb45..95d8fcd0b4 100644 --- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/LocalNetworkGateway.java +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/LocalNetworkGateway.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.azurecompute.arm.domain; +package org.jclouds.azurecompute.arm.domain.vpn; import java.util.Map; @@ -42,14 +42,13 @@ public abstract class LocalNetworkGateway { @SerializedNames({ "id", "name", "location", "type", "tags", "etag", "properties" }) public static LocalNetworkGateway create(String id, String name, String location, String type, Map tags, String etag, LocalNetworkGatewayProperties properties) { - return builder().id(id).name(name).location(location).type(type).tags(tags).etag(etag).properties(properties) - .build(); + return builder(name, location, properties).id(id).type(type).tags(tags).etag(etag).build(); } public abstract Builder toBuilder(); - public static Builder builder() { - return new AutoValue_LocalNetworkGateway.Builder(); + public static Builder builder(String name, String location, LocalNetworkGatewayProperties properties) { + return new AutoValue_LocalNetworkGateway.Builder().name(name).location(location).properties(properties); } @AutoValue.Builder @@ -62,13 +61,11 @@ public abstract class LocalNetworkGateway { public abstract Builder etag(String etag); public abstract Builder properties(LocalNetworkGatewayProperties properties); - abstract String location(); abstract Map tags(); abstract LocalNetworkGateway autoBuild(); public LocalNetworkGateway build() { tags(tags() != null ? ImmutableMap.copyOf(tags()) : null); - location(location().toLowerCase()); // Avoid issues in regions such as CanadaEast return autoBuild(); } } diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/LocalNetworkGatewayProperties.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/LocalNetworkGatewayProperties.java similarity index 61% rename from providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/LocalNetworkGatewayProperties.java rename to providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/LocalNetworkGatewayProperties.java index 56b773f525..031dcb9ef7 100644 --- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/LocalNetworkGatewayProperties.java +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/LocalNetworkGatewayProperties.java @@ -14,15 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.azurecompute.arm.domain; - -import java.util.List; +package org.jclouds.azurecompute.arm.domain.vpn; +import org.jclouds.azurecompute.arm.domain.AddressSpace; +import org.jclouds.azurecompute.arm.domain.Provisionable; import org.jclouds.javax.annotation.Nullable; import org.jclouds.json.SerializedNames; import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableList; @AutoValue public abstract class LocalNetworkGatewayProperties implements Provisionable { @@ -37,9 +36,8 @@ public abstract class LocalNetworkGatewayProperties implements Provisionable { "resourceGuid" }) public static LocalNetworkGatewayProperties create(BGPSettings bgpSettings, String gatewayIpAddress, AddressSpace localNetworkAddressSpace, String provisioningState, String resourceGuid) { - return builder().bgpSettings(bgpSettings).gatewayIpAddress(gatewayIpAddress) - .localNetworkAddressSpace(localNetworkAddressSpace).provisioningState(provisioningState) - .resourceGuid(resourceGuid).build(); + return builder(gatewayIpAddress).bgpSettings(bgpSettings).localNetworkAddressSpace(localNetworkAddressSpace) + .provisioningState(provisioningState).resourceGuid(resourceGuid).build(); } LocalNetworkGatewayProperties() { @@ -48,8 +46,8 @@ public abstract class LocalNetworkGatewayProperties implements Provisionable { public abstract LocalNetworkGatewayProperties.Builder toBuilder(); - public static LocalNetworkGatewayProperties.Builder builder() { - return new AutoValue_LocalNetworkGatewayProperties.Builder(); + public static LocalNetworkGatewayProperties.Builder builder(String gatewayIpAddress) { + return new AutoValue_LocalNetworkGatewayProperties.Builder().gatewayIpAddress(gatewayIpAddress); } @AutoValue.Builder @@ -62,35 +60,4 @@ public abstract class LocalNetworkGatewayProperties implements Provisionable { public abstract LocalNetworkGatewayProperties build(); } - - @AutoValue - public abstract static class BGPSettings { - public abstract int asn(); - public abstract String bgpPeeringAddress(); - public abstract int peerWeight(); - - @SerializedNames({ "asn", "bgpPeeringAddress", "peerWeight" }) - public static LocalNetworkGatewayProperties.BGPSettings create(int asn, String bgpPeeringAddress, int peerWeight) { - return new AutoValue_LocalNetworkGatewayProperties_BGPSettings(asn, bgpPeeringAddress, peerWeight); - } - - BGPSettings() { - - } - } - - @AutoValue - public abstract static class AddressSpace { - public abstract List addressPrefixes(); - - @SerializedNames({ "addressPrefixes" }) - public static LocalNetworkGatewayProperties.AddressSpace create(List addressPrefixes) { - return new AutoValue_LocalNetworkGatewayProperties_AddressSpace( - addressPrefixes == null ? ImmutableList. of() : ImmutableList.copyOf(addressPrefixes)); - } - - AddressSpace() { - - } - } } diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/PFSGroup.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/PFSGroup.java new file mode 100644 index 0000000000..5ff43ae298 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/PFSGroup.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain.vpn; + +import org.jclouds.azurecompute.arm.util.GetEnumValue; + +public enum PFSGroup { + + ECP256, ECP384, PFS1, PFS14, PFS2, PFS2048, PFS24, PFSMM, None, Unrecognized; + + public static PFSGroup fromValue(final String text) { + return (PFSGroup) GetEnumValue.fromValueOrDefault(text, PFSGroup.Unrecognized); + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/SKU.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/SKU.java new file mode 100644 index 0000000000..9ddf18a685 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/SKU.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain.vpn; + +import org.jclouds.azurecompute.arm.util.GetEnumValue; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +@AutoValue +public abstract class SKU { + + public static enum SKUName { + Basic, HighPerformance, Standard, UltraPerformance, VpnGw1, VpnGw2, VpnGw3, Unrecognized; + + public static SKUName fromValue(final String text) { + return (SKUName) GetEnumValue.fromValueOrDefault(text, SKUName.Unrecognized); + } + } + + public static enum SKUTier { + Basic, HighPerformance, Standard, UltraPerformance, VpnGw1, VpnGw2, VpnGw3, Unrecognized; + + public static SKUTier fromValue(final String text) { + return (SKUTier) GetEnumValue.fromValueOrDefault(text, SKUTier.Unrecognized); + } + } + + public abstract int capacity(); + public abstract SKUName name(); + public abstract SKUTier tier(); + + SKU() { + + } + + @SerializedNames({ "capacity", "name", "tier" }) + public static SKU create(int capacity, SKUName name, SKUTier tier) { + return new AutoValue_SKU(capacity, name, tier); + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientConfiguration.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientConfiguration.java new file mode 100644 index 0000000000..14871c0652 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientConfiguration.java @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain.vpn; + +import java.util.List; + +import org.jclouds.azurecompute.arm.domain.AddressSpace; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableList; + +@AutoValue +public abstract class VPNClientConfiguration { + @Nullable public abstract String radiusServerAddress(); + @Nullable public abstract String radiusServerSecret(); + @Nullable public abstract AddressSpace vpnClientAddressPool(); + public abstract List vpnClientIpsecPolicies(); + public abstract List vpnClientProtocols(); + public abstract List vpnClientRevokedCertificates(); + public abstract List vpnClientRootCertificates(); + + VPNClientConfiguration() { + + } + + @SerializedNames({ "radiusServerAddress", "radiusServerSecret", "vpnClientAddressPool", "vpnClientIpsecPolicies", + "vpnClientProtocols", "vpnClientRevokedCertificates", "vpnClientRootCertificates" }) + public static VPNClientConfiguration create(String radiusServerAddress, String radiusServerSecret, + AddressSpace vpnClientAddressPool, List vpnClientIpsecPolicies, List vpnClientProtocols, + List vpnClientRevokedCertificates, + List vpnClientRootCertificates) { + return builder().radiusServerAddress(radiusServerAddress).radiusServerSecret(radiusServerSecret) + .vpnClientAddressPool(vpnClientAddressPool).vpnClientIpsecPolicies(vpnClientIpsecPolicies) + .vpnClientProtocols(vpnClientProtocols).vpnClientRevokedCertificates(vpnClientRevokedCertificates) + .vpnClientRootCertificates(vpnClientRootCertificates).build(); + } + + public static Builder builder() { + return new AutoValue_VPNClientConfiguration.Builder(); + } + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder radiusServerAddress(String radiusServerAddress); + public abstract Builder radiusServerSecret(String radiusServerSecret); + public abstract Builder vpnClientAddressPool(AddressSpace vpnClientAddressPool); + public abstract Builder vpnClientIpsecPolicies(List vpnClientIpsecPolicies); + public abstract Builder vpnClientProtocols(List vpnClientProtocols); + public abstract Builder vpnClientRevokedCertificates(List vpnClientRevokedCertificates); + public abstract Builder vpnClientRootCertificates(List vpnClientRootCertificates); + + abstract List vpnClientIpsecPolicies(); + abstract List vpnClientProtocols(); + abstract List vpnClientRevokedCertificates(); + abstract List vpnClientRootCertificates(); + abstract VPNClientConfiguration autoBuild(); + + public VPNClientConfiguration build() { + vpnClientIpsecPolicies(vpnClientIpsecPolicies() == null ? ImmutableList. of() : ImmutableList + .copyOf(vpnClientIpsecPolicies())); + vpnClientProtocols(vpnClientProtocols() == null ? ImmutableList. of() : ImmutableList + .copyOf(vpnClientProtocols())); + vpnClientRevokedCertificates(vpnClientRevokedCertificates() == null ? ImmutableList + . of() : ImmutableList.copyOf(vpnClientRevokedCertificates())); + vpnClientRootCertificates(vpnClientRootCertificates() == null ? ImmutableList. of() + : ImmutableList.copyOf(vpnClientRootCertificates())); + + return autoBuild(); + } + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientRevokedCertificate.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientRevokedCertificate.java new file mode 100644 index 0000000000..39232cc6df --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientRevokedCertificate.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain.vpn; + +import org.jclouds.azurecompute.arm.domain.Provisionable; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +@AutoValue +public abstract class VPNClientRevokedCertificate { + @Nullable public abstract String id(); + public abstract String name(); + @Nullable public abstract String etag(); + public abstract VPNClientRevokedCertificateProperties properties(); + + VPNClientRevokedCertificate() { + + } + + @SerializedNames({ "id", "name", "etag", "properties" }) + public static VPNClientRevokedCertificate create(String id, String name, String etag, + VPNClientRevokedCertificateProperties properties) { + return new AutoValue_VPNClientRevokedCertificate(id, name, etag, properties); + } + + @AutoValue + public abstract static class VPNClientRevokedCertificateProperties implements Provisionable { + public abstract String provisioningState(); + public abstract String thumbprint(); + + VPNClientRevokedCertificateProperties() { + + } + + @SerializedNames({ "provisioningState", "thumbprint" }) + public static VPNClientRevokedCertificateProperties create(String provisioningState, String thumbprint) { + return new AutoValue_VPNClientRevokedCertificate_VPNClientRevokedCertificateProperties(provisioningState, + thumbprint); + } + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientRootCertificate.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientRootCertificate.java new file mode 100644 index 0000000000..0271c324c7 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNClientRootCertificate.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain.vpn; + +import org.jclouds.azurecompute.arm.domain.Provisionable; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +@AutoValue +public abstract class VPNClientRootCertificate { + @Nullable public abstract String id(); + public abstract String name(); + @Nullable public abstract String etag(); + public abstract VPNClientRootCertificateProperties properties(); + + VPNClientRootCertificate() { + + } + + @SerializedNames({ "id", "name", "etag", "properties" }) + public static VPNClientRootCertificate create(String id, String name, String etag, + VPNClientRootCertificateProperties properties) { + return new AutoValue_VPNClientRootCertificate(id, name, etag, properties); + } + + @AutoValue + public abstract static class VPNClientRootCertificateProperties implements Provisionable { + public abstract String provisioningState(); + public abstract String publicCertData(); + + VPNClientRootCertificateProperties() { + + } + + @SerializedNames({ "provisioningState", "publicCertData" }) + public static VPNClientRootCertificateProperties create(String provisioningState, String publicCertData) { + return new AutoValue_VPNClientRootCertificate_VPNClientRootCertificateProperties(provisioningState, + publicCertData); + } + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNType.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNType.java new file mode 100644 index 0000000000..d65cacfd7a --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VPNType.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain.vpn; + +import org.jclouds.azurecompute.arm.util.GetEnumValue; + +public enum VPNType { + PolicyBased, RouteBased, Unrecognized; + + public static VPNType fromValue(final String text) { + return (VPNType) GetEnumValue.fromValueOrDefault(text, VPNType.Unrecognized); + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGateway.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGateway.java new file mode 100644 index 0000000000..68f9579ff2 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGateway.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain.vpn; + +import java.util.Map; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableMap; + +@AutoValue +public abstract class VirtualNetworkGateway { + + @Nullable public abstract String id(); + public abstract String name(); + public abstract String location(); + @Nullable public abstract String type(); + @Nullable public abstract Map tags(); + @Nullable public abstract String etag(); + public abstract VirtualNetworkGatewayProperties properties(); + + VirtualNetworkGateway() { + + } + + @SerializedNames({ "id", "name", "location", "type", "tags", "etag", "properties" }) + public static VirtualNetworkGateway create(String id, String name, String location, String type, + Map tags, String etag, VirtualNetworkGatewayProperties properties) { + return builder(name, location, properties).id(id).type(type).tags(tags).etag(etag).build(); + } + + public abstract Builder toBuilder(); + + public static Builder builder(String name, String location, VirtualNetworkGatewayProperties properties) { + return new AutoValue_VirtualNetworkGateway.Builder().name(name).location(location).properties(properties); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder id(String id); + public abstract Builder name(String name); + public abstract Builder location(String location); + public abstract Builder type(String type); + public abstract Builder tags(Map tags); + public abstract Builder etag(String etag); + public abstract Builder properties(VirtualNetworkGatewayProperties properties); + + abstract Map tags(); + abstract VirtualNetworkGateway autoBuild(); + + public VirtualNetworkGateway build() { + tags(tags() != null ? ImmutableMap.copyOf(tags()) : null); + return autoBuild(); + } + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGatewayProperties.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGatewayProperties.java new file mode 100644 index 0000000000..1d30f5f6ae --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGatewayProperties.java @@ -0,0 +1,144 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain.vpn; + +import java.util.List; + +import org.jclouds.azurecompute.arm.domain.IdReference; +import org.jclouds.azurecompute.arm.domain.IpAllocationMethod; +import org.jclouds.azurecompute.arm.domain.Provisionable; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableList; + +@AutoValue +public abstract class VirtualNetworkGatewayProperties implements Provisionable { + + @Nullable public abstract Boolean activeActive(); + @Nullable public abstract BGPSettings bgpSettings(); + public abstract boolean enableBGP(); + @Nullable public abstract IdReference gatewayDefaultSite(); + public abstract VirtualNetworkGatewayType gatewayType(); + public abstract List ipConfigurations(); + @Nullable public abstract String provisioningState(); + @Nullable public abstract String resourceGuid(); + public abstract SKU sku(); + @Nullable public abstract VPNClientConfiguration vpnClientConfiguration(); + @Nullable public abstract VPNType vpnType(); + + VirtualNetworkGatewayProperties() { + + } + + @SerializedNames({ "activeActive", "bgpSettings", "enableBgp", "gatewayDefaultSite", "gatewayType", + "ipConfigurations", "provisioningState", "resourceGuid", "sku", "vpnClientConfiguration", "vpnType" }) + public static VirtualNetworkGatewayProperties create(Boolean activeActive, BGPSettings bgpSettings, + boolean enableBGP, IdReference gatewayDefaultSite, VirtualNetworkGatewayType gatewayType, + List ipConfigurations, String provisioningState, String resourceGuid, SKU sku, + VPNClientConfiguration vpnClientConfiguration, VPNType vpnType) { + return builder(enableBGP, gatewayType, sku).activeActive(activeActive).bgpSettings(bgpSettings) + .gatewayDefaultSite(gatewayDefaultSite).ipConfigurations(ipConfigurations) + .provisioningState(provisioningState).resourceGuid(resourceGuid) + .vpnClientConfiguration(vpnClientConfiguration).vpnType(vpnType).build(); + } + + public static Builder builder(boolean enableBGP, VirtualNetworkGatewayType virtualNetworkGatewayType, SKU sku) { + return new AutoValue_VirtualNetworkGatewayProperties.Builder().enableBGP(enableBGP) + .gatewayType(virtualNetworkGatewayType).sku(sku); + } + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder activeActive( Boolean activeActive); + public abstract Builder bgpSettings(BGPSettings bgpSettings); + public abstract Builder enableBGP(boolean enableBG); + public abstract Builder gatewayDefaultSite(IdReference gatewayDefaultSite); + public abstract Builder gatewayType(VirtualNetworkGatewayType gatewayType); + public abstract Builder ipConfigurations(List ipConfigurations); + public abstract Builder provisioningState(String provisioningState); + public abstract Builder resourceGuid(String resourceGuid); + public abstract Builder sku(SKU sku); + public abstract Builder vpnClientConfiguration(VPNClientConfiguration vpnClientConfiguration); + public abstract Builder vpnType(VPNType vpnType); + + abstract List ipConfigurations(); + abstract VirtualNetworkGatewayProperties autoBuild(); + + public VirtualNetworkGatewayProperties build() { + ipConfigurations(ipConfigurations() == null ? ImmutableList. of() : ImmutableList + .copyOf(ipConfigurations())); + return autoBuild(); + } + } + + @AutoValue + public abstract static class IpConfiguration { + @Nullable public abstract String id(); + public abstract String name(); + @Nullable public abstract String etag(); + public abstract IpConfigurationProperties properties(); + + IpConfiguration() { + + } + + @SerializedNames({ "id", "name", "etag", "properties" }) + public static IpConfiguration create(String id, String name, String etag, IpConfigurationProperties properties) { + return new AutoValue_VirtualNetworkGatewayProperties_IpConfiguration(id, name, etag, properties); + } + + @AutoValue + public abstract static class IpConfigurationProperties implements Provisionable { + public abstract IpAllocationMethod privateIPAllocationMethod(); + @Nullable public abstract String provisioningState(); + @Nullable public abstract IdReference publicIPAddress(); + @Nullable public abstract IdReference subnet(); + + @SerializedNames({ "privateIPAllocationMethod", "provisioningState", "publicIPAddress", "subnet" }) + public static IpConfigurationProperties create(IpAllocationMethod privateIPAllocationMethod, + String provisioningState, IdReference publicIPAddress, IdReference subnet) { + return builder(privateIPAllocationMethod).provisioningState(provisioningState) + .publicIPAddress(publicIPAddress).subnet(subnet).build(); + } + + IpConfigurationProperties() { + + } + + public static Builder builder(IpAllocationMethod privateIPAllocationMethod) { + return new AutoValue_VirtualNetworkGatewayProperties_IpConfiguration_IpConfigurationProperties.Builder() + .privateIPAllocationMethod(privateIPAllocationMethod); + } + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder privateIPAllocationMethod(IpAllocationMethod privateIPAllocationMethod); + public abstract Builder provisioningState(String provisioningState); + public abstract Builder publicIPAddress(IdReference publicIPAddress); + public abstract Builder subnet(IdReference subnet); + + public abstract IpConfigurationProperties build(); + } + } + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGatewayType.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGatewayType.java new file mode 100644 index 0000000000..46ec025a40 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/vpn/VirtualNetworkGatewayType.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain.vpn; + +import org.jclouds.azurecompute.arm.util.GetEnumValue; + +public enum VirtualNetworkGatewayType { + ExpressRoute, Vpn, Unrecognized; + + public static VirtualNetworkGatewayType fromValue(final String text) { + return (VirtualNetworkGatewayType) GetEnumValue.fromValueOrDefault(text, + VirtualNetworkGatewayType.Unrecognized); + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApi.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApi.java index a868e40230..4d8af399ee 100644 --- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApi.java +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApi.java @@ -32,8 +32,8 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azurecompute.arm.domain.LocalNetworkGateway; -import org.jclouds.azurecompute.arm.domain.LocalNetworkGatewayProperties; +import org.jclouds.azurecompute.arm.domain.vpn.LocalNetworkGateway; +import org.jclouds.azurecompute.arm.domain.vpn.LocalNetworkGatewayProperties; import org.jclouds.azurecompute.arm.filters.ApiVersionFilter; import org.jclouds.azurecompute.arm.functions.URIParser; import org.jclouds.javax.annotation.Nullable; diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApi.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApi.java new file mode 100644 index 0000000000..0fb62c35ce --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApi.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.features; + +import java.io.Closeable; +import java.net.URI; +import java.util.List; +import java.util.Map; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGateway; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayProperties; +import org.jclouds.azurecompute.arm.filters.ApiVersionFilter; +import org.jclouds.azurecompute.arm.functions.URIParser; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.oauth.v2.filters.OAuthFilter; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.binders.BindToJsonPayload; + +@Path("/resourcegroups/{resourcegroup}/providers/Microsoft.Network/virtualNetworkGateways") +@RequestFilters({ OAuthFilter.class, ApiVersionFilter.class }) +@Consumes(MediaType.APPLICATION_JSON) +public interface VirtualNetworkGatewayApi extends Closeable { + + @Named("virtualnetworkgateway:list") + @GET + @SelectJson("value") + @Fallback(EmptyListOnNotFoundOr404.class) + List list(); + + @Named("virtualnetworkgateway:get") + @Path("/{name}") + @GET + @Fallback(NullOnNotFoundOr404.class) + VirtualNetworkGateway get(@PathParam("name") String name); + + @Named("virtualnetworkgateway:createOrUpdate") + @MapBinder(BindToJsonPayload.class) + @Path("/{name}") + @PUT + VirtualNetworkGateway createOrUpdate(@PathParam("name") String name, @PayloadParam("location") String location, + @Nullable @PayloadParam("tags") Map tags, + @PayloadParam("properties") VirtualNetworkGatewayProperties properties); + + @Named("virtualnetworkgateway:delete") + @Path("/{name}") + @DELETE + @ResponseParser(URIParser.class) + @Fallback(NullOnNotFoundOr404.class) + URI delete(@PathParam("name") String name); +} diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApiLiveTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApiLiveTest.java index 301df03741..bdf26eeec1 100644 --- a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApiLiveTest.java +++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApiLiveTest.java @@ -23,10 +23,10 @@ import static org.testng.Assert.assertTrue; import java.net.URI; -import org.jclouds.azurecompute.arm.domain.LocalNetworkGateway; -import org.jclouds.azurecompute.arm.domain.LocalNetworkGatewayProperties; -import org.jclouds.azurecompute.arm.domain.LocalNetworkGatewayProperties.AddressSpace; +import org.jclouds.azurecompute.arm.domain.AddressSpace; import org.jclouds.azurecompute.arm.domain.Provisionable; +import org.jclouds.azurecompute.arm.domain.vpn.LocalNetworkGateway; +import org.jclouds.azurecompute.arm.domain.vpn.LocalNetworkGatewayProperties; import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -52,7 +52,7 @@ public class LocalNetworkGatewayApiLiveTest extends BaseAzureComputeApiLiveTest @Test public void createLocalNetworkGateway() { AddressSpace localAddresses = AddressSpace.create(ImmutableList.of("192.168.0.0/24")); - LocalNetworkGatewayProperties props = LocalNetworkGatewayProperties.builder().gatewayIpAddress("1.2.3.4") + LocalNetworkGatewayProperties props = LocalNetworkGatewayProperties.builder("1.2.3.4") .localNetworkAddressSpace(localAddresses).build(); LocalNetworkGateway gw = api().createOrUpdate(name, LOCATION, null, props); diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApiMockTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApiMockTest.java index 840c872401..e7efa71654 100644 --- a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApiMockTest.java +++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/LocalNetworkGatewayApiMockTest.java @@ -25,9 +25,9 @@ import static org.testng.Assert.assertTrue; import java.net.URI; import java.util.List; -import org.jclouds.azurecompute.arm.domain.LocalNetworkGateway; -import org.jclouds.azurecompute.arm.domain.LocalNetworkGatewayProperties; -import org.jclouds.azurecompute.arm.domain.LocalNetworkGatewayProperties.AddressSpace; +import org.jclouds.azurecompute.arm.domain.AddressSpace; +import org.jclouds.azurecompute.arm.domain.vpn.LocalNetworkGateway; +import org.jclouds.azurecompute.arm.domain.vpn.LocalNetworkGatewayProperties; import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest; import org.testng.annotations.Test; @@ -46,7 +46,7 @@ public class LocalNetworkGatewayApiMockTest extends BaseAzureComputeApiMockTest LocalNetworkGatewayApi gwapi = api.getLocalNetworkGatewayApi(resourcegroup); AddressSpace localAddresses = AddressSpace.create(ImmutableList.of("192.168.0.0/24")); - LocalNetworkGatewayProperties props = LocalNetworkGatewayProperties.builder().gatewayIpAddress("1.2.3.4") + LocalNetworkGatewayProperties props = LocalNetworkGatewayProperties.builder("1.2.3.4") .localNetworkAddressSpace(localAddresses).build(); LocalNetworkGateway gw = gwapi.createOrUpdate(name, "westeurope", null, props); diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiLiveTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiLiveTest.java index d7caab0da9..0d1e6ca17e 100644 --- a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiLiveTest.java +++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkInterfaceCardApiLiveTest.java @@ -49,7 +49,6 @@ public class NetworkInterfaceCardApiLiveTest extends BaseAzureComputeApiLiveTest public void setup() { super.setup(); createTestResourceGroup(); - assertNotNull(api.getResourceGroupApi().create(resourceGroupName, LOCATION, ImmutableMap.of())); String virtualNetworkName = String.format("vn-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); nicName = String.format("nic-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); String subnetName = String.format("s-%s-%s", this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name")); diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiLiveTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiLiveTest.java index c0271d3961..5a89b07bed 100644 --- a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiLiveTest.java +++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiLiveTest.java @@ -24,6 +24,7 @@ import static org.testng.Assert.assertTrue; import java.util.Arrays; import java.util.List; +import org.jclouds.azurecompute.arm.domain.AddressSpace; import org.jclouds.azurecompute.arm.domain.VirtualNetwork; import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest; import org.testng.annotations.BeforeClass; @@ -53,7 +54,7 @@ public class VirtualNetworkApiLiveTest extends BaseAzureComputeApiLiveTest { final VirtualNetwork.VirtualNetworkProperties virtualNetworkProperties = VirtualNetwork.VirtualNetworkProperties.builder().addressSpace( - VirtualNetwork.AddressSpace.create(Arrays.asList(DEFAULT_VIRTUALNETWORK_ADDRESS_PREFIX))).build(); + AddressSpace.create(Arrays.asList(DEFAULT_VIRTUALNETWORK_ADDRESS_PREFIX))).build(); VirtualNetwork vn = api().createOrUpdate(virtualNetworkName, LOCATION, null, virtualNetworkProperties); diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiMockTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiMockTest.java index 8ba0406088..2cf3a41023 100644 --- a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiMockTest.java +++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiMockTest.java @@ -16,21 +16,19 @@ */ package org.jclouds.azurecompute.arm.features; -import org.jclouds.azurecompute.arm.domain.VirtualNetwork; - -import org.testng.annotations.Test; - -import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest; +import static com.google.common.collect.Iterables.isEmpty; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; import java.util.Arrays; import java.util.List; -import static com.google.common.collect.Iterables.isEmpty; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.assertNull; +import org.jclouds.azurecompute.arm.domain.AddressSpace; +import org.jclouds.azurecompute.arm.domain.VirtualNetwork; +import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest; +import org.testng.annotations.Test; @Test(groups = "unit", testName = "VirtualNetworkApiMockTest", singleThreaded = true) public class VirtualNetworkApiMockTest extends BaseAzureComputeApiMockTest { @@ -98,7 +96,7 @@ public class VirtualNetworkApiMockTest extends BaseAzureComputeApiMockTest { final VirtualNetwork.VirtualNetworkProperties virtualNetworkProperties = VirtualNetwork.VirtualNetworkProperties.create(null, null, - VirtualNetwork.AddressSpace.create(Arrays.asList("10.2.0.0/16")), null); + AddressSpace.create(Arrays.asList("10.2.0.0/16")), null); vnApi.createOrUpdate(virtualNetwork, location, null, virtualNetworkProperties); diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApiLiveTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApiLiveTest.java new file mode 100644 index 0000000000..4faaf2dfd5 --- /dev/null +++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApiLiveTest.java @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.features; + +import static com.google.common.collect.Iterables.any; +import static java.util.Collections.singletonList; +import static org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayType.Vpn; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import java.net.URI; +import java.util.Collections; + +import org.jclouds.azurecompute.arm.domain.IdReference; +import org.jclouds.azurecompute.arm.domain.IpAllocationMethod; +import org.jclouds.azurecompute.arm.domain.PublicIPAddress; +import org.jclouds.azurecompute.arm.domain.PublicIPAddressProperties; +import org.jclouds.azurecompute.arm.domain.Subnet; +import org.jclouds.azurecompute.arm.domain.VirtualNetwork; +import org.jclouds.azurecompute.arm.domain.vpn.SKU; +import org.jclouds.azurecompute.arm.domain.vpn.SKU.SKUName; +import org.jclouds.azurecompute.arm.domain.vpn.SKU.SKUTier; +import org.jclouds.azurecompute.arm.domain.vpn.VPNType; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGateway; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayProperties; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayProperties.IpConfiguration; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayProperties.IpConfiguration.IpConfigurationProperties; +import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableMap; + +@Test(groups = "live", testName = "VirtualNetworkGatewayApiLiveTest", singleThreaded = true) +public class VirtualNetworkGatewayApiLiveTest extends BaseAzureComputeApiLiveTest { + + private String name; + private String subnetId; + private PublicIPAddress publicIp; + private Predicate virtualNetworkGatewayAvailable; + + @BeforeClass + @Override + public void setup() { + super.setup(); + createTestResourceGroup(); + name = "jclouds-" + RAND; + virtualNetworkGatewayAvailable = virtualNetworkGatewayStatus.create(resourceGroupName); + + VirtualNetwork vnet = createDefaultVirtualNetwork(resourceGroupName, name + "-net", "10.2.0.0/16", LOCATION); + Subnet subnet = createDefaultSubnet(resourceGroupName, Subnet.GATEWAY_SUBNET_NAME, vnet.name(), "10.2.0.0/23"); + subnetId = subnet.id(); + + PublicIPAddressProperties props = PublicIPAddressProperties.builder() + .publicIPAllocationMethod(IpAllocationMethod.Dynamic.name()).idleTimeoutInMinutes(4).build(); + publicIp = api.getPublicIPAddressApi(resourceGroupName).createOrUpdate(name + "-publicip", LOCATION, + Collections. emptyMap(), props); + } + + @Test + public void createVirtualNetworkGateway() { + IpConfigurationProperties ipprops = IpConfigurationProperties.builder(IpAllocationMethod.Dynamic) + .subnet(IdReference.create(subnetId)).publicIPAddress(IdReference.create(publicIp.id())).build(); + IpConfiguration ipconf = IpConfiguration.create(null, name + "-ipconf", null, ipprops); + + VirtualNetworkGatewayProperties props = VirtualNetworkGatewayProperties + .builder(false, Vpn, SKU.create(1, SKUName.Basic, SKUTier.Basic)).vpnType(VPNType.PolicyBased) + .ipConfigurations(singletonList(ipconf)).build(); + + VirtualNetworkGateway gw = api().createOrUpdate(name, LOCATION, null, props); + + assertNotNull(gw); + assertEquals(gw.name(), name); + assertNotNull(gw.properties()); + } + + @Test(dependsOnMethods = "createVirtualNetworkGateway") + public void getVirtualNetworkGateway() { + assertNotNull(api().get(name)); + } + + @Test(dependsOnMethods = "createVirtualNetworkGateway") + public void listVirtualNetworkGateways() { + assertTrue(any(api().list(), new Predicate() { + @Override + public boolean apply(VirtualNetworkGateway input) { + return name.equals(input.name()); + } + })); + } + + @Test(dependsOnMethods = "createVirtualNetworkGateway") + public void updateVirtualNetworkGateway() { + // Make sure the resource is fully provisioned before modifying it + assertTrue(virtualNetworkGatewayAvailable.apply(name)); + + VirtualNetworkGateway gw = api().get(name); + gw = api().createOrUpdate(name, LOCATION, ImmutableMap.of("foo", "bar"), gw.properties()); + + assertNotNull(gw); + assertTrue(gw.tags().containsKey("foo")); + assertEquals(gw.tags().get("foo"), "bar"); + } + + @Test(dependsOnMethods = { "getVirtualNetworkGateway", "listVirtualNetworkGateways", "updateVirtualNetworkGateway" }, alwaysRun = true) + public void deleteVirtualNetworkGateway() { + // Make sure the resource is fully provisioned before deleting it + assertTrue(virtualNetworkGatewayAvailable.apply(name)); + URI uri = api().delete(name); + assertResourceDeleted(uri); + } + + private VirtualNetworkGatewayApi api() { + return api.getVirtualNetworkGatewayApi(resourceGroupName); + } +} diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApiMockTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApiMockTest.java new file mode 100644 index 0000000000..1c8096fe9b --- /dev/null +++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkGatewayApiMockTest.java @@ -0,0 +1,161 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.features; + +import static com.google.common.collect.Iterables.isEmpty; +import static java.util.Collections.singletonList; +import static org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayType.Vpn; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + +import java.net.URI; +import java.util.List; + +import org.jclouds.azurecompute.arm.domain.IdReference; +import org.jclouds.azurecompute.arm.domain.IpAllocationMethod; +import org.jclouds.azurecompute.arm.domain.vpn.SKU; +import org.jclouds.azurecompute.arm.domain.vpn.SKU.SKUName; +import org.jclouds.azurecompute.arm.domain.vpn.SKU.SKUTier; +import org.jclouds.azurecompute.arm.domain.vpn.VPNType; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGateway; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayProperties; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayProperties.IpConfiguration; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayProperties.IpConfiguration.IpConfigurationProperties; +import org.jclouds.azurecompute.arm.domain.vpn.VirtualNetworkGatewayType; +import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "VirtualNetworkGatewayApiMockTest", singleThreaded = true) +public class VirtualNetworkGatewayApiMockTest extends BaseAzureComputeApiMockTest { + + private final String subscriptionid = "SUBSCRIPTIONID"; + private final String resourcegroup = "myresourcegroup"; + private final String name = "myvirtualgw"; + private final String apiVersion = "api-version=2018-02-01"; + + private static final String SUBNET_ID = "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/virtualNetworks/myvirtualgw-net/subnets/GatewaySubnet"; + private static final String PUBLIC_IP = "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/publicIPAddresses/myvirtualgw-publicip"; + + public void createOrUpdateVirtualNetworkGateway() throws InterruptedException { + server.enqueue(jsonResponse("/virtualnetworkgatewaycreate.json").setResponseCode(200)); + VirtualNetworkGatewayApi gwapi = api.getVirtualNetworkGatewayApi(resourcegroup); + + IpConfigurationProperties ipprops = IpConfigurationProperties.builder(IpAllocationMethod.Dynamic) + .subnet(IdReference.create(SUBNET_ID)).publicIPAddress(IdReference.create(PUBLIC_IP)).build(); + IpConfiguration ipconf = IpConfiguration.create(null, name + "-ipconf", null, ipprops); + + VirtualNetworkGatewayProperties props = VirtualNetworkGatewayProperties + .builder(false, Vpn, SKU.create(1, SKUName.Basic, SKUTier.Basic)).vpnType(VPNType.PolicyBased) + .ipConfigurations(singletonList(ipconf)).build(); + + VirtualNetworkGateway gw = gwapi.createOrUpdate(name, "westeurope", null, props); + + String path = String.format( + "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/virtualNetworkGateways/%s?%s", + subscriptionid, resourcegroup, name, apiVersion); + String json = "{\"location\":\"westeurope\",\"properties\":{\"enableBgp\":false,\"gatewayType\":\"Vpn\",\"ipConfigurations\":[{\"name\":\"myvirtualgw-ipconf\",\"properties\":{\"privateIPAllocationMethod\":\"Dynamic\",\"publicIPAddress\":{\"id\":\"/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/publicIPAddresses/myvirtualgw-publicip\"},\"subnet\":{\"id\":\"/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/virtualNetworks/myvirtualgw-net/subnets/GatewaySubnet\"}}}],\"sku\":{\"capacity\":1,\"name\":\"Basic\",\"tier\":\"Basic\"},\"vpnType\":\"PolicyBased\"}}"; + assertSent(server, "PUT", path, json); + + assertEquals(gw.name(), name); + assertNotNull(gw.properties()); + assertEquals(gw.properties().gatewayType(), VirtualNetworkGatewayType.Vpn); + } + + public void getVirtualNetworkGateway() throws InterruptedException { + server.enqueue(jsonResponse("/virtualnetworkgatewayget.json").setResponseCode(200)); + VirtualNetworkGatewayApi gwapi = api.getVirtualNetworkGatewayApi(resourcegroup); + + VirtualNetworkGateway gw = gwapi.get(name); + + String path = String.format( + "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/virtualNetworkGateways/%s?%s", + subscriptionid, resourcegroup, name, apiVersion); + assertSent(server, "GET", path); + + assertEquals(gw.name(), name); + } + + public void getVirtualNetworkGatewayReturns404() throws InterruptedException { + server.enqueue(response404()); + VirtualNetworkGatewayApi gwapi = api.getVirtualNetworkGatewayApi(resourcegroup); + + VirtualNetworkGateway gw = gwapi.get(name); + + String path = String.format( + "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/virtualNetworkGateways/%s?%s", + subscriptionid, resourcegroup, name, apiVersion); + assertSent(server, "GET", path); + + assertNull(gw); + } + + public void listVirtualNetworkGateways() throws InterruptedException { + server.enqueue(jsonResponse("/virtualnetworkgatewaylist.json").setResponseCode(200)); + VirtualNetworkGatewayApi gwapi = api.getVirtualNetworkGatewayApi(resourcegroup); + + List gws = gwapi.list(); + + String path = String.format( + "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/virtualNetworkGateways?%s", + subscriptionid, resourcegroup, apiVersion); + assertSent(server, "GET", path); + + assertTrue(gws.size() > 0); + } + + public void listVirtualNetworkGatewaysReturns404() throws InterruptedException { + server.enqueue(response404()); + VirtualNetworkGatewayApi gwapi = api.getVirtualNetworkGatewayApi(resourcegroup); + + List gws = gwapi.list(); + + String path = String.format( + "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/virtualNetworkGateways?%s", + subscriptionid, resourcegroup, apiVersion); + assertSent(server, "GET", path); + + assertTrue(isEmpty(gws)); + } + + public void deleteVirtualNetworkGateway() throws InterruptedException { + server.enqueue(response202WithHeader()); + VirtualNetworkGatewayApi gwapi = api.getVirtualNetworkGatewayApi(resourcegroup); + + URI uri = gwapi.delete(name); + assertNotNull(uri); + + String path = String.format( + "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/virtualNetworkGateways/%s?%s", + subscriptionid, resourcegroup, name, apiVersion); + assertSent(server, "DELETE", path); + } + + public void deleteVirtualNetworkGatewayDoesNotExist() throws InterruptedException { + server.enqueue(response204()); + VirtualNetworkGatewayApi gwapi = api.getVirtualNetworkGatewayApi(resourcegroup); + + URI uri = gwapi.delete(name); + assertNull(uri); + + String path = String.format( + "/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/virtualNetworkGateways/%s?%s", + subscriptionid, resourcegroup, name, apiVersion); + assertSent(server, "DELETE", path); + } +} diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java index 78d5425c2a..58338345be 100644 --- a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java +++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiLiveTest.java @@ -17,19 +17,19 @@ package org.jclouds.azurecompute.arm.internal; import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TIMEOUT_RESOURCE_DELETED; +import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_CERTIFICATE_DELETE_STATUS; +import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_CERTIFICATE_OPERATION_STATUS; +import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_CERTIFICATE_RECOVERABLE_STATUS; +import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_DELETE_STATUS; +import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_KEY_DELETED_STATUS; +import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_KEY_RECOVERABLE_STATUS; +import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_SECRET_DELETE_STATUS; +import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_SECRET_RECOVERABLE_STATUS; import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_IMAGE_AVAILABLE; import static org.jclouds.util.Predicates2.retry; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TIMEOUT_RESOURCE_DELETED; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_DELETE_STATUS; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_SECRET_DELETE_STATUS; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_SECRET_RECOVERABLE_STATUS; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_KEY_DELETED_STATUS; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_KEY_RECOVERABLE_STATUS; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_CERTIFICATE_DELETE_STATUS; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_CERTIFICATE_RECOVERABLE_STATUS; -import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.VAULT_CERTIFICATE_OPERATION_STATUS; import java.io.IOException; import java.net.URI; @@ -38,21 +38,20 @@ import java.util.List; import java.util.Properties; import java.util.Random; -import com.google.common.base.Charsets; -import com.google.common.base.Throwables; -import com.google.common.io.Resources; import org.jclouds.apis.BaseApiLiveTest; import org.jclouds.azurecompute.arm.AzureComputeApi; -import org.jclouds.azurecompute.arm.config.Tenant; -import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultPredicates.DeletedVaultStatusPredicateFactory; -import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultKeyPredicates.DeletedKeyStatusPredicateFactory; -import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultKeyPredicates.RecoverableKeyStatusPredicateFactory; -import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultSecretPredicates.DeletedSecretStatusPredicateFactory; -import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultSecretPredicates.RecoverableSecretStatusPredicateFactory; +import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.PublicIpAvailablePredicateFactory; import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultCertificatePredicates.CertificateOperationStatusPredicateFactory; import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultCertificatePredicates.DeletedCertificateStatusPredicateFactory; import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultCertificatePredicates.RecoverableCertificateStatusPredicateFactory; -import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.PublicIpAvailablePredicateFactory; +import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultKeyPredicates.DeletedKeyStatusPredicateFactory; +import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultKeyPredicates.RecoverableKeyStatusPredicateFactory; +import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultPredicates.DeletedVaultStatusPredicateFactory; +import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultSecretPredicates.DeletedSecretStatusPredicateFactory; +import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VaultSecretPredicates.RecoverableSecretStatusPredicateFactory; +import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VirtualNetworkGatewayAvailablePredicateFactory; +import org.jclouds.azurecompute.arm.config.Tenant; +import org.jclouds.azurecompute.arm.domain.AddressSpace; import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroup; import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroupProperties; import org.jclouds.azurecompute.arm.domain.NetworkSecurityRule; @@ -64,15 +63,18 @@ import org.jclouds.azurecompute.arm.domain.VirtualNetwork; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; +import com.google.common.base.Charsets; import com.google.common.base.Predicate; import com.google.common.base.Supplier; +import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; -import com.google.inject.name.Names; +import com.google.common.io.Resources; import com.google.inject.Injector; -import com.google.inject.Module; import com.google.inject.Key; +import com.google.inject.Module; import com.google.inject.TypeLiteral; +import com.google.inject.name.Names; public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest { @@ -84,6 +86,7 @@ public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest imageAvailablePredicate; protected Predicate resourceDeleted; protected PublicIpAvailablePredicateFactory publicIpAvailable; + protected VirtualNetworkGatewayAvailablePredicateFactory virtualNetworkGatewayStatus; protected Predicate> resourceAvailable; protected DeletedVaultStatusPredicateFactory deletedVaultStatus; protected DeletedKeyStatusPredicateFactory deletedKeyStatus; @@ -94,7 +97,6 @@ public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest>() { }, Names.named(TIMEOUT_RESOURCE_DELETED))); publicIpAvailable = injector.getInstance(PublicIpAvailablePredicateFactory.class); + virtualNetworkGatewayStatus = injector.getInstance(VirtualNetworkGatewayAvailablePredicateFactory.class); resourceAvailable = injector.getInstance(Key.get(new TypeLiteral>>() { })); deletedVaultStatus = injector.getInstance(Key.get(DeletedVaultStatusPredicateFactory.class, Names.named(VAULT_DELETE_STATUS))); @@ -172,7 +175,7 @@ public class BaseAzureComputeApiLiveTest extends BaseApiLiveTest() { @Override diff --git a/providers/azurecompute-arm/src/test/resources/virtualnetworkgatewaycreate.json b/providers/azurecompute-arm/src/test/resources/virtualnetworkgatewaycreate.json new file mode 100644 index 0000000000..6775283498 --- /dev/null +++ b/providers/azurecompute-arm/src/test/resources/virtualnetworkgatewaycreate.json @@ -0,0 +1,45 @@ +{ + "name": "myvirtualgw", + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/virtualNetworkGateways/myvirtualgw", + "etag": "W/\"7d15735c-35b4-4e22-a281-d7d54c6fdecf\"", + "type": "Microsoft.Network/virtualNetworkGateways", + "location": "westeurope", + "properties": { + "provisioningState": "Updating", + "resourceGuid": "36998db6-e664-4683-ad8d-9afb2e23b1d8", + "ipConfigurations": [ + { + "name": "myvirtualgw-ipconf", + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/virtualNetworkGateways/myvirtualgw/ipConfigurations/myvirtualgw-ipconf", + "etag": "W/\"7d15735c-35b4-4e22-a281-d7d54c6fdecf\"", + "properties": { + "provisioningState": "Updating", + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/publicIPAddresses/myvirtualgw-publicip" + }, + "subnet": { + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/virtualNetworks/myvirtualgw-net/subnets/GatewaySubnet" + } + } + } + ], + "sku": { + "name": "Basic", + "tier": "Basic", + "capacity": 2 + }, + "gatewayType": "Vpn", + "vpnType": "PolicyBased", + "enableBgp": false, + "activeActive": false, + "vpnClientConfiguration": { + "vpnClientProtocols": [ + "SSTP" + ], + "vpnClientRootCertificates": [], + "vpnClientRevokedCertificates": [], + "vpnClientIpsecPolicies": [] + } + } +} \ No newline at end of file diff --git a/providers/azurecompute-arm/src/test/resources/virtualnetworkgatewayget.json b/providers/azurecompute-arm/src/test/resources/virtualnetworkgatewayget.json new file mode 100644 index 0000000000..9dcfb4765a --- /dev/null +++ b/providers/azurecompute-arm/src/test/resources/virtualnetworkgatewayget.json @@ -0,0 +1,37 @@ +{ + "name": "myvirtualgw", + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/virtualNetworkGateways/myvirtualgw", + "etag": "W/\"7d15735c-35b4-4e22-a281-d7d54c6fdecf\"", + "type": "Microsoft.Network/virtualNetworkGateways", + "location": "westeurope", + "properties": { + "provisioningState": "Updating", + "resourceGuid": "36998db6-e664-4683-ad8d-9afb2e23b1d8", + "ipConfigurations": [ + { + "name": "myvirtualgw-ipconf", + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/virtualNetworkGateways/myvirtualgw/ipConfigurations/myvirtualgw-ipconf", + "etag": "W/\"7d15735c-35b4-4e22-a281-d7d54c6fdecf\"", + "properties": { + "provisioningState": "Updating", + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/publicIPAddresses/myvirtualgw-publicip" + }, + "subnet": { + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/virtualNetworks/myvirtualgw-net/subnets/GatewaySubnet" + } + } + } + ], + "sku": { + "name": "Basic", + "tier": "Basic", + "capacity": 2 + }, + "gatewayType": "Vpn", + "vpnType": "PolicyBased", + "enableBgp": false, + "activeActive": false + } +} \ No newline at end of file diff --git a/providers/azurecompute-arm/src/test/resources/virtualnetworkgatewaylist.json b/providers/azurecompute-arm/src/test/resources/virtualnetworkgatewaylist.json new file mode 100644 index 0000000000..b3218b95c8 --- /dev/null +++ b/providers/azurecompute-arm/src/test/resources/virtualnetworkgatewaylist.json @@ -0,0 +1,49 @@ +{ + "value": [ + { + "name": "myvirtualgw", + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/virtualNetworkGateways/myvirtualgw", + "etag": "W/\"7d15735c-35b4-4e22-a281-d7d54c6fdecf\"", + "type": "Microsoft.Network/virtualNetworkGateways", + "location": "westeurope", + "properties": { + "provisioningState": "Updating", + "resourceGuid": "36998db6-e664-4683-ad8d-9afb2e23b1d8", + "ipConfigurations": [ + { + "name": "myvirtualgw-ipconf", + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/virtualNetworkGateways/myvirtualgw/ipConfigurations/myvirtualgw-ipconf", + "etag": "W/\"7d15735c-35b4-4e22-a281-d7d54c6fdecf\"", + "properties": { + "provisioningState": "Updating", + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/publicIPAddresses/myvirtualgw-publicip" + }, + "subnet": { + "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/rg-virtualnetworkgatewayapilivetest-nacx/providers/Microsoft.Network/virtualNetworks/myvirtualgw-net/subnets/GatewaySubnet" + } + } + } + ], + "sku": { + "name": "Basic", + "tier": "Basic", + "capacity": 2 + }, + "gatewayType": "Vpn", + "vpnType": "PolicyBased", + "enableBgp": false, + "activeActive": false, + "vpnClientConfiguration": { + "vpnClientProtocols": [ + "SSTP" + ], + "vpnClientRootCertificates": [], + "vpnClientRevokedCertificates": [], + "vpnClientIpsecPolicies": [] + } + } + } + ] +} \ No newline at end of file