mirror of https://github.com/apache/jclouds.git
Promote Azure ARM from jclouds-labs
This commit is contained in:
commit
cc969052a7
|
@ -0,0 +1,101 @@
|
||||||
|
jclouds Labs - Azure Compute ARM Provider
|
||||||
|
============
|
||||||
|
|
||||||
|
Build status for azurecomputearm module:
|
||||||
|
[![Build Status](https://jclouds.ci.cloudbees.com/buildStatus/icon?job=jclouds-labs/org.apache.jclouds.labs$azurecompute-arm)](https://jclouds.ci.cloudbees.com/job/jclouds-labs/org.apache.jclouds.labs$azurecompute-arm/)
|
||||||
|
|
||||||
|
## Setting Up Test Credentials
|
||||||
|
|
||||||
|
### Create a Service Principal
|
||||||
|
|
||||||
|
Install and configure Azure CLI following these [steps](http://azure.microsoft.com/en-us/documentation/articles/xplat-cli/).
|
||||||
|
|
||||||
|
Using the Azure CLI, run the following commands to create a service principal
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Enter your Microsoft account credentials when prompted
|
||||||
|
az login
|
||||||
|
|
||||||
|
# Set current subscription to create a service principal
|
||||||
|
az account set --subscription <Subscription-id>
|
||||||
|
|
||||||
|
# Create an AD application with your information.
|
||||||
|
az ad app create --display-name <name> --password <password> --homepage <home-page> --identifier-uris <identifier-uris>
|
||||||
|
|
||||||
|
# For example: az ad app create --display-name "jcloudsarm" --password abcd --homepage "https://jcloudsarm" --identifier-uris "https://jcloudsarm"
|
||||||
|
|
||||||
|
# Output will include a value for `Application Id`, which will be used for the live tests
|
||||||
|
|
||||||
|
# Create a Service Principal
|
||||||
|
az ad sp create --id <Application-id>
|
||||||
|
|
||||||
|
# Output will include a value for `Object Id`, to be used in the next step
|
||||||
|
```
|
||||||
|
|
||||||
|
Run the following commands to assign roles to the service principal
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Assign roles for this service principal
|
||||||
|
az role assignment create --role Contributor --assignee <ObjectId>
|
||||||
|
```
|
||||||
|
|
||||||
|
Look up the the tenant Id
|
||||||
|
|
||||||
|
```bash
|
||||||
|
az account show
|
||||||
|
|
||||||
|
# output will be a JSON which will include the `Tenant id`
|
||||||
|
```
|
||||||
|
|
||||||
|
Verify service principal
|
||||||
|
|
||||||
|
```bash
|
||||||
|
az login -u <Application-id> -p <password> --service-principal --tenant <Tenant-id>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run Live Tests
|
||||||
|
|
||||||
|
Use the following to run one live test:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mvn -Dtest=<name of the live test> \
|
||||||
|
-Dtest.azurecompute-arm.identity="<Application-id>" \
|
||||||
|
-Dtest.azurecompute-arm.credential="<password>" \
|
||||||
|
-Dtest.azurecompute-arm.endpoint="https://management.azure.com/subscriptions/<Subscription-id>" \
|
||||||
|
-Dtest.oauth.endpoint="https://login.microsoftonline.com/<Tenant-id>/oauth2/token"
|
||||||
|
integration-test -Plive
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Use the following to run all the live tests:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
|
||||||
|
mvn clean verify -Plive \
|
||||||
|
-Dtest.azurecompute-arm.identity="<Application-id>"" \
|
||||||
|
-Dtest.azurecompute-arm.credential="<password>"" \
|
||||||
|
-Dtest.azurecompute-arm.endpoint="https://management.azure.com/subscriptions/<Subscription-id>"" \
|
||||||
|
-Dtest.oauth.endpoint=https://login.microsoftonline.com/<Tenant-id>/oauth2/token
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## How to use it
|
||||||
|
|
||||||
|
Azure Compute ARM provider works exactly as any other jclouds provider.
|
||||||
|
Notice that as Azure supports dozens of locations, operations like listImages can be really time-consuming.
|
||||||
|
To limit the scope of such operations there are some additional properties you may want to use:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
jclouds.azurecompute.arm.publishers
|
||||||
|
```
|
||||||
|
which is by default `Canonical,RedHat`
|
||||||
|
|
||||||
|
and
|
||||||
|
```bash
|
||||||
|
jclouds.regions
|
||||||
|
```
|
||||||
|
which is by default `null`. If you want to target only the `north europe` region, you can use
|
||||||
|
|
||||||
|
```bash
|
||||||
|
jclouds.regions="northeurope"
|
||||||
|
```
|
|
@ -0,0 +1,165 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
-->
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.jclouds.labs</groupId>
|
||||||
|
<artifactId>jclouds-labs</artifactId>
|
||||||
|
<version>2.1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>azurecompute-arm</artifactId>
|
||||||
|
<name>jclouds Azure Compute ARM API</name>
|
||||||
|
<description>jclouds components to access an implementation of Azure's ARM Compute Service</description>
|
||||||
|
<packaging>bundle</packaging>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<test.jclouds.oauth.resource>https://management.azure.com/</test.jclouds.oauth.resource>
|
||||||
|
<test.oauth.endpoint>https://login.microsoftonline.com/FIXME_tenant-id/oauth2/token</test.oauth.endpoint>
|
||||||
|
<test.azurecompute-arm.endpoint>https://management.azure.com/subscriptions/FIXME_subscription-id</test.azurecompute-arm.endpoint>
|
||||||
|
<test.azurecompute-arm.api-version></test.azurecompute-arm.api-version>
|
||||||
|
<test.azurecompute-arm.build-version />
|
||||||
|
<test.azurecompute-arm.identity>app id</test.azurecompute-arm.identity>
|
||||||
|
<test.azurecompute-arm.credential>app password</test.azurecompute-arm.credential>
|
||||||
|
<jclouds.osgi.export>org.jclouds.azurecompute.arm*;version="${project.version}"</jclouds.osgi.export>
|
||||||
|
<jclouds.osgi.import>org.jclouds*;version="${project.version}",*</jclouds.osgi.import>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-compute</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.auto.service</groupId>
|
||||||
|
<artifactId>auto-service</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.auto.value</groupId>
|
||||||
|
<artifactId>auto-value</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.jclouds.api</groupId>
|
||||||
|
<artifactId>oauth</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.jclouds.driver</groupId>
|
||||||
|
<artifactId>jclouds-okhttp</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.jclouds.api</groupId>
|
||||||
|
<artifactId>oauth</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-compute</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.jclouds</groupId>
|
||||||
|
<artifactId>jclouds-core</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.jclouds.driver</groupId>
|
||||||
|
<artifactId>jclouds-slf4j</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.jclouds.driver</groupId>
|
||||||
|
<artifactId>jclouds-sshj</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-classic</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okhttp</groupId>
|
||||||
|
<artifactId>mockwebserver</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
<exclusions>
|
||||||
|
<!-- Already provided by jclouds-sshj -->
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.bouncycastle</groupId>
|
||||||
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>live</id>
|
||||||
|
<build>
|
||||||
|
<defaultGoal>clean verify</defaultGoal>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>integration</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<threadCount>1</threadCount>
|
||||||
|
<systemPropertyVariables>
|
||||||
|
<test.azurecompute-arm.endpoint>${test.azurecompute-arm.endpoint}</test.azurecompute-arm.endpoint>
|
||||||
|
<test.azurecompute-arm.api-version>${test.azurecompute-arm.api-version}</test.azurecompute-arm.api-version>
|
||||||
|
<test.azurecompute-arm.build-version>${test.azurecompute-arm.build-version}</test.azurecompute-arm.build-version>
|
||||||
|
<test.azurecompute-arm.identity>${test.azurecompute-arm.identity}</test.azurecompute-arm.identity>
|
||||||
|
<test.azurecompute-arm.credential>${test.azurecompute-arm.credential}</test.azurecompute-arm.credential>
|
||||||
|
<test.jclouds.oauth.resource>${test.jclouds.oauth.resource}</test.jclouds.oauth.resource>
|
||||||
|
<test.oauth.endpoint>${test.oauth.endpoint}</test.oauth.endpoint>
|
||||||
|
</systemPropertyVariables>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,270 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.domain.ServicePrincipal;
|
||||||
|
import org.jclouds.azurecompute.arm.features.AvailabilitySetApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.DeploymentApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.DiskApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.GraphRBACApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.ImageApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.JobApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.LoadBalancerApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.LocationApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.MetricDefinitionsApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.MetricsApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.NetworkInterfaceCardApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.NetworkSecurityGroupApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.NetworkSecurityRuleApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.OSImageApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.PublicIPAddressApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.ResourceGroupApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.ResourceProviderApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.StorageAccountApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.SubnetApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.VMSizeApi;
|
||||||
|
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.rest.annotations.Delegate;
|
||||||
|
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Azure Resource Manager API is a REST API for managing your services and deployments.
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn790568.aspx" >doc</a>
|
||||||
|
*/
|
||||||
|
public interface AzureComputeApi extends Closeable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Azure Resource Manager API includes operations for managing resource groups in your subscription.
|
||||||
|
*
|
||||||
|
* @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn790546.aspx">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
ResourceGroupApi getResourceGroupApi();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides access to the Job tracking API.
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
JobApi getJobApi();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This Azure Resource Manager API provides all of the locations that are available for resource providers
|
||||||
|
*
|
||||||
|
* @see <a href="https://msdn.microsoft.com/en-US/library/azure/dn790540.aspx">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
LocationApi getLocationApi();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Azure Resource Manager API includes operations for managing the storage accounts in your subscription.
|
||||||
|
*
|
||||||
|
* @see <https://msdn.microsoft.com/en-us/library/mt163683.aspx">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
StorageAccountApi getStorageAccountApi(@PathParam("resourceGroup") String resourceGroup);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Subnet API includes operations for managing the subnets in your virtual network.
|
||||||
|
*
|
||||||
|
* @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt163621.aspx">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
SubnetApi getSubnetApi(@PathParam("resourcegroup") String resourcegroup,
|
||||||
|
@PathParam("virtualnetwork") String virtualnetwork);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Virtual Network API includes operations for managing the virtual networks in your subscription.
|
||||||
|
*
|
||||||
|
* @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt163661.aspx">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
VirtualNetworkApi getVirtualNetworkApi(@PathParam("resourcegroup") String resourcegroup);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Network Interface Card API includes operations for managing the NICs in your subscription.
|
||||||
|
*
|
||||||
|
* @see <a href="https://msdn.microsoft.com/en-us/library/mt163668.aspx">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
NetworkInterfaceCardApi getNetworkInterfaceCardApi(@PathParam("resourcegroup") String resourcegroup);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Public IP Address API includes operations for managing public ID Addresses for NICs in your subscription.
|
||||||
|
*
|
||||||
|
* @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt163638.aspx">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
PublicIPAddressApi getPublicIPAddressApi(@PathParam("resourcegroup") String resourcegroup);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Virtual Machine API includes operations for managing the virtual machines in your subscription.
|
||||||
|
*
|
||||||
|
* @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt163630.aspx">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
VirtualMachineApi getVirtualMachineApi(@PathParam("resourceGroup") String resourceGroup);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Virtual Machine Scale Set API includes operations for managing the virtual machines in your subscription.
|
||||||
|
*
|
||||||
|
* @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt163630.aspx">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
VirtualMachineScaleSetApi getVirtualMachineScaleSetApi(@PathParam("resourceGroup") String resourceGroup);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This Azure Resource Manager API lists all available virtual machine sizes for a subscription in a given region
|
||||||
|
*
|
||||||
|
* @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt269440.aspx">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
VMSizeApi getVMSizeApi(@PathParam("location") String location);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Azure Resource Manager API gets all the OS images in your subscription.
|
||||||
|
*
|
||||||
|
* @see <a href="http://msdn.microsoft.com/en-us/library/jj157175">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
OSImageApi getOSImageApi(@PathParam("location") String location);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Deployment API allows for the management of Azure Resource Manager resources through the use of templates.
|
||||||
|
*
|
||||||
|
* @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn790549.aspx">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
DeploymentApi getDeploymentApi(@PathParam("resourcegroup") String resourceGroup);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The NetworkSecurityGroup API includes operations for managing network security groups within your subscription.
|
||||||
|
*
|
||||||
|
* @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt163615.aspx">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
NetworkSecurityGroupApi getNetworkSecurityGroupApi(@PathParam("resourcegroup") String resourcegroup);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The NetworkSecurityRule API includes operations for managing network security rules within a network security group.
|
||||||
|
*
|
||||||
|
* @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt163580.aspx">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
NetworkSecurityRuleApi getNetworkSecurityRuleApi(@PathParam("resourcegroup") String resourcegroup,
|
||||||
|
@PathParam("networksecuritygroup") String networksecuritygroup);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The LoadBalancer API includes operations for managing load balancers
|
||||||
|
* within your subscription.
|
||||||
|
*
|
||||||
|
* @see <a href=
|
||||||
|
* "https://msdn.microsoft.com/en-us/library/azure/mt163574.aspx">docs
|
||||||
|
* </a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
LoadBalancerApi getLoadBalancerApi(@PathParam("resourcegroup") String resourcegroup);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The AvailabilitySet API includes operations for managing availability sets
|
||||||
|
* within your subscription.
|
||||||
|
*
|
||||||
|
* @see <a href=
|
||||||
|
* "https://docs.microsoft.com/en-us/rest/api/compute/availabilitysets">docs
|
||||||
|
* </a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
AvailabilitySetApi getAvailabilitySetApi(@PathParam("resourcegroup") String resourcegroup);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Azure Resource Provider API provides information about a resource provider and its supported resource types.
|
||||||
|
*
|
||||||
|
* @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn790534.aspx">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
ResourceProviderApi getResourceProviderApi();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ManagedDataDisk API includes operations for managing data disks within your subscription.
|
||||||
|
*
|
||||||
|
* @see <a href="https://docs.microsoft.com/en-us/rest/api/manageddisks/disks/disks-rest-api">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
DiskApi getDiskApi(@PathParam("resourcegroup") String resourcegroup);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The virtual machine image API includes operations for managing data disks within your subscription.
|
||||||
|
*
|
||||||
|
* @see <a href="https://docs.microsoft.com/en-us/rest/api/manageddisks/images/images-rest-api">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
ImageApi getVirtualMachineImageApi(@PathParam("resourcegroup") String resourcegroup);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The metrics API includes operations to get insights into entities within your
|
||||||
|
* subscription.
|
||||||
|
*
|
||||||
|
* @see <a href="https://docs.microsoft.com/en-us/rest/api/monitor/metrics">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
MetricsApi getMetricsApi(@PathParam("resourceid") String resourceid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The metric definitions API includes operations to get insights available for entities within your
|
||||||
|
* subscription.
|
||||||
|
*
|
||||||
|
* @see <a href="https://docs.microsoft.com/en-us/rest/api/monitor/metricdefinitions">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
MetricDefinitionsApi getMetricsDefinitionsApi(@PathParam("resourceid") String resourceid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Azure Active Directory Graph API provides programmatic access to Azure
|
||||||
|
* AD through REST API endpoints.
|
||||||
|
*
|
||||||
|
* @see <a href="https://docs.microsoft.com/en-us/rest/api/graphrbac/">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
GraphRBACApi getGraphRBACApi();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Managing your key vaults as well as the keys, secrets, and certificates within your key vaults can be
|
||||||
|
* accomplished through a REST interface.
|
||||||
|
*
|
||||||
|
* @see <a href="https://docs.microsoft.com/en-us/rest/api/keyvault/">docs</a>
|
||||||
|
*/
|
||||||
|
@Delegate
|
||||||
|
VaultApi getVaultApi(@PathParam("resourcegroup") String resourcegroup);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the information about the current service principal.
|
||||||
|
*/
|
||||||
|
@Provides
|
||||||
|
Supplier<ServicePrincipal> getServicePrincipal();
|
||||||
|
}
|
|
@ -0,0 +1,165 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import static org.jclouds.Constants.PROPERTY_MAX_RATE_LIMIT_WAIT;
|
||||||
|
import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.API_VERSION_PREFIX;
|
||||||
|
import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.DEFAULT_SUBNET_ADDRESS_PREFIX;
|
||||||
|
import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.DEFAULT_VNET_ADDRESS_SPACE_PREFIX;
|
||||||
|
import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.IMAGE_PUBLISHERS;
|
||||||
|
import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.OPERATION_TIMEOUT;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.IMAGE_AUTHENTICATE_SUDO;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.IMAGE_LOGIN_USER;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.POLL_INITIAL_PERIOD;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.POLL_MAX_PERIOD;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.RESOURCENAME_DELIMITER;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.RESOURCENAME_PREFIX;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED;
|
||||||
|
import static org.jclouds.oauth.v2.config.CredentialType.CLIENT_CREDENTIALS_SECRET;
|
||||||
|
import static org.jclouds.oauth.v2.config.OAuthProperties.CREDENTIAL_TYPE;
|
||||||
|
import static org.jclouds.oauth.v2.config.OAuthProperties.RESOURCE;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Region;
|
||||||
|
import org.jclouds.azurecompute.arm.features.AvailabilitySetApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.DeploymentApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.DiskApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.GraphRBACApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.ImageApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.LoadBalancerApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.LocationApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.MetricDefinitionsApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.MetricsApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.NetworkInterfaceCardApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.NetworkSecurityGroupApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.NetworkSecurityRuleApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.OSImageApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.PublicIPAddressApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.ResourceGroupApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.ResourceProviderApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.StorageAccountApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.SubnetApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.VMSizeApi;
|
||||||
|
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.providers.ProviderMetadata;
|
||||||
|
import org.jclouds.providers.internal.BaseProviderMetadata;
|
||||||
|
|
||||||
|
import com.google.auto.service.AutoService;
|
||||||
|
|
||||||
|
@AutoService(ProviderMetadata.class)
|
||||||
|
public class AzureComputeProviderMetadata extends BaseProviderMetadata {
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return builder().fromProviderMetadata(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AzureComputeProviderMetadata() {
|
||||||
|
super(builder());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Properties defaultProperties() {
|
||||||
|
final Properties properties = AzureManagementApiMetadata.defaultProperties();
|
||||||
|
properties.put(POLL_INITIAL_PERIOD, 1000);
|
||||||
|
properties.put(POLL_MAX_PERIOD, 15000);
|
||||||
|
properties.put(OPERATION_TIMEOUT, 46000000);
|
||||||
|
properties.put(TIMEOUT_NODE_TERMINATED, 60 * 10 * 1000);
|
||||||
|
// Default max wait in rate limit: 5m30s
|
||||||
|
properties.put(PROPERTY_MAX_RATE_LIMIT_WAIT, 330000);
|
||||||
|
properties.put(RESOURCE, "https://management.azure.com/");
|
||||||
|
properties.put(CREDENTIAL_TYPE, CLIENT_CREDENTIALS_SECRET.toString());
|
||||||
|
// Set a default Oauth endpoint for Azure, fill in the tenantId based on the value supplied
|
||||||
|
properties.put("oauth.endpoint", "https://login.microsoft.com/${azurecompute-arm.tenantId}/oauth2/token");
|
||||||
|
properties.put(DEFAULT_VNET_ADDRESS_SPACE_PREFIX, "10.0.0.0/16");
|
||||||
|
properties.put(DEFAULT_SUBNET_ADDRESS_PREFIX, "10.0.0.0/24");
|
||||||
|
properties.put(RESOURCENAME_PREFIX, "jclouds");
|
||||||
|
properties.put(RESOURCENAME_DELIMITER, "-");
|
||||||
|
properties.put(IMAGE_PUBLISHERS, "Canonical,RedHat");
|
||||||
|
// Default credentials for all images, Azure doesn't accept root, admin; generate the password on the fly
|
||||||
|
properties.put(IMAGE_LOGIN_USER, "jclouds");
|
||||||
|
// Azure allows for passwordless sudo only when using a public key to login to the machine
|
||||||
|
properties.put(IMAGE_AUTHENTICATE_SUDO, "true");
|
||||||
|
properties.put(TEMPLATE, "imageNameMatches=UbuntuServer,osVersionMatches=1[456]\\.[01][04](\\.[0-9])?-LTS");
|
||||||
|
// Api versions used in each API
|
||||||
|
properties.put(API_VERSION_PREFIX + DeploymentApi.class.getSimpleName(), "2016-02-01");
|
||||||
|
properties.put(API_VERSION_PREFIX + LocationApi.class.getSimpleName(), "2015-11-01");
|
||||||
|
properties.put(API_VERSION_PREFIX + NetworkInterfaceCardApi.class.getSimpleName(), "2017-03-01");
|
||||||
|
properties.put(API_VERSION_PREFIX + NetworkSecurityGroupApi.class.getSimpleName(), "2016-03-30");
|
||||||
|
properties.put(API_VERSION_PREFIX + NetworkSecurityRuleApi.class.getSimpleName(), "2016-03-30");
|
||||||
|
properties.put(API_VERSION_PREFIX + OSImageApi.class.getSimpleName(), "2015-06-15");
|
||||||
|
properties.put(API_VERSION_PREFIX + PublicIPAddressApi.class.getSimpleName(), "2015-06-15");
|
||||||
|
properties.put(API_VERSION_PREFIX + ResourceGroupApi.class.getSimpleName(), "2015-01-01");
|
||||||
|
properties.put(API_VERSION_PREFIX + ResourceProviderApi.class.getSimpleName(), "2015-01-01");
|
||||||
|
properties.put(API_VERSION_PREFIX + StorageAccountApi.class.getSimpleName(), "2015-06-15");
|
||||||
|
properties.put(API_VERSION_PREFIX + SubnetApi.class.getSimpleName(), "2017-03-01");
|
||||||
|
properties.put(API_VERSION_PREFIX + VirtualNetworkApi.class.getSimpleName(), "2015-06-15");
|
||||||
|
properties.put(API_VERSION_PREFIX + VMSizeApi.class.getSimpleName(), "2015-06-15");
|
||||||
|
properties.put(API_VERSION_PREFIX + VirtualMachineApi.class.getSimpleName(), "2016-04-30-preview");
|
||||||
|
properties.put(API_VERSION_PREFIX + LoadBalancerApi.class.getSimpleName(), "2016-03-30");
|
||||||
|
properties.put(API_VERSION_PREFIX + AvailabilitySetApi.class.getSimpleName(), "2016-04-30-preview");
|
||||||
|
properties.put(API_VERSION_PREFIX + DiskApi.class.getSimpleName(), "2017-03-30");
|
||||||
|
properties.put(API_VERSION_PREFIX + ImageApi.class.getSimpleName(), "2016-04-30-preview");
|
||||||
|
properties.put(API_VERSION_PREFIX + MetricDefinitionsApi.class.getSimpleName(), "2017-05-01-preview");
|
||||||
|
properties.put(API_VERSION_PREFIX + MetricsApi.class.getSimpleName(), "2016-09-01");
|
||||||
|
properties.put(API_VERSION_PREFIX + VirtualMachineScaleSetApi.class.getSimpleName(), "2017-03-30");
|
||||||
|
properties.put(API_VERSION_PREFIX + GraphRBACApi.class.getSimpleName(), "1.6");
|
||||||
|
properties.put(API_VERSION_PREFIX + VaultApi.class.getSimpleName(), "2016-10-01");
|
||||||
|
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AzureComputeProviderMetadata(final Builder builder) {
|
||||||
|
super(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends BaseProviderMetadata.Builder {
|
||||||
|
|
||||||
|
protected Builder() {
|
||||||
|
super();
|
||||||
|
id("azurecompute-arm")
|
||||||
|
.name("Azure Resource Management")
|
||||||
|
.apiMetadata(new AzureManagementApiMetadata())
|
||||||
|
.endpoint("https://management.azure.com/subscriptions/${azurecompute-arm.subscriptionId}")
|
||||||
|
.homepage(URI.create("https://www.windowsazure.com/"))
|
||||||
|
.console(URI.create("https://windows.azure.com/default.aspx"))
|
||||||
|
.linkedServices("azureblob")
|
||||||
|
.iso3166Codes(Region.iso3166Codes())
|
||||||
|
.defaultProperties(AzureComputeProviderMetadata.defaultProperties());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AzureComputeProviderMetadata build() {
|
||||||
|
return new AzureComputeProviderMetadata(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder fromProviderMetadata(final ProviderMetadata providerMetadata) {
|
||||||
|
super.fromProviderMetadata(providerMetadata);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,99 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import static org.jclouds.reflect.Reflection2.typeToken;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.jclouds.apis.ApiMetadata;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.config.AzureComputeServiceContextModule;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule;
|
||||||
|
import org.jclouds.azurecompute.arm.config.AzureComputeHttpApiModule;
|
||||||
|
import org.jclouds.azurecompute.arm.config.AzureComputeParserModule;
|
||||||
|
import org.jclouds.azurecompute.arm.config.AzureComputeRateLimitModule;
|
||||||
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
|
import org.jclouds.http.okhttp.config.OkHttpCommandExecutorServiceModule;
|
||||||
|
import org.jclouds.oauth.v2.config.OAuthModule;
|
||||||
|
import org.jclouds.rest.internal.BaseHttpApiMetadata;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of {@link ApiMetadata} for Microsoft Azure Resource Manager REST API
|
||||||
|
*/
|
||||||
|
public class AzureManagementApiMetadata extends BaseHttpApiMetadata<AzureComputeApi> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder toBuilder() {
|
||||||
|
return new Builder().fromApiMetadata(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AzureManagementApiMetadata() {
|
||||||
|
this(builder());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AzureManagementApiMetadata(final Builder builder) {
|
||||||
|
super(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Properties defaultProperties() {
|
||||||
|
final Properties properties = BaseHttpApiMetadata.defaultProperties();
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder extends BaseHttpApiMetadata.Builder<AzureComputeApi, Builder> {
|
||||||
|
|
||||||
|
protected Builder() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
id("azurecompute-arm")
|
||||||
|
.name("Microsoft Azure Resource Manager REST API")
|
||||||
|
.identityName("Azure Service Principal Application Id")
|
||||||
|
.credentialName("Azure Service Principal Application Password")
|
||||||
|
.endpointName("Resource Manager Endpoint ending in your Subscription Id")
|
||||||
|
.documentation(URI.create("https://msdn.microsoft.com/en-us/library/azure/dn790568.aspx"))
|
||||||
|
.defaultProperties(AzureManagementApiMetadata.defaultProperties())
|
||||||
|
.view(typeToken(ComputeServiceContext.class))
|
||||||
|
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
||||||
|
.add(OAuthModule.class)
|
||||||
|
.add(OkHttpCommandExecutorServiceModule.class)
|
||||||
|
.add(AzureComputeParserModule.class)
|
||||||
|
.add(AzureComputeHttpApiModule.class)
|
||||||
|
.add(AzureComputeServiceContextModule.class)
|
||||||
|
.add(AzurePredicatesModule.class)
|
||||||
|
.add(AzureComputeRateLimitModule.class)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AzureManagementApiMetadata build() {
|
||||||
|
return new AzureManagementApiMetadata(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Builder self() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,128 @@
|
||||||
|
/*
|
||||||
|
* 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.compute;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Provider;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.Constants;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndName;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.strategy.CleanupResources;
|
||||||
|
import org.jclouds.collect.Memoized;
|
||||||
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
|
import org.jclouds.compute.callables.RunScriptOnNode;
|
||||||
|
import org.jclouds.compute.domain.Hardware;
|
||||||
|
import org.jclouds.compute.domain.Image;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.compute.domain.TemplateBuilder;
|
||||||
|
import org.jclouds.compute.extensions.ImageExtension;
|
||||||
|
import org.jclouds.compute.extensions.SecurityGroupExtension;
|
||||||
|
import org.jclouds.compute.internal.BaseComputeService;
|
||||||
|
import org.jclouds.compute.internal.PersistNodeCredentials;
|
||||||
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
|
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
|
||||||
|
import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet;
|
||||||
|
import org.jclouds.compute.strategy.DestroyNodeStrategy;
|
||||||
|
import org.jclouds.compute.strategy.GetImageStrategy;
|
||||||
|
import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
|
||||||
|
import org.jclouds.compute.strategy.InitializeRunScriptOnNodeOrPlaceInBadMap;
|
||||||
|
import org.jclouds.compute.strategy.ListNodesStrategy;
|
||||||
|
import org.jclouds.compute.strategy.RebootNodeStrategy;
|
||||||
|
import org.jclouds.compute.strategy.ResumeNodeStrategy;
|
||||||
|
import org.jclouds.compute.strategy.SuspendNodeStrategy;
|
||||||
|
import org.jclouds.domain.Credentials;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.scriptbuilder.functions.InitAdminAccess;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||||
|
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public class AzureComputeService extends BaseComputeService {
|
||||||
|
private final CleanupResources cleanupResources;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
protected AzureComputeService(ComputeServiceContext context, Map<String, Credentials> credentialStore,
|
||||||
|
@Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
|
||||||
|
@Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
|
||||||
|
GetImageStrategy getImageStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy,
|
||||||
|
CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy,
|
||||||
|
DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy startNodeStrategy,
|
||||||
|
SuspendNodeStrategy stopNodeStrategy, Provider<TemplateBuilder> templateBuilderProvider,
|
||||||
|
@Named("DEFAULT") Provider<TemplateOptions> templateOptionsProvider,
|
||||||
|
@Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
|
||||||
|
@Named(TIMEOUT_NODE_TERMINATED) Predicate<AtomicReference<NodeMetadata>> nodeTerminated,
|
||||||
|
@Named(TIMEOUT_NODE_SUSPENDED) Predicate<AtomicReference<NodeMetadata>> nodeSuspended,
|
||||||
|
InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory,
|
||||||
|
RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess,
|
||||||
|
PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
|
||||||
|
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
|
||||||
|
CleanupResources cleanupResources, Optional<ImageExtension> imageExtension,
|
||||||
|
Optional<SecurityGroupExtension> securityGroupExtension) {
|
||||||
|
super(context, credentialStore, images, sizes, locations, listNodesStrategy, getImageStrategy,
|
||||||
|
getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy,
|
||||||
|
startNodeStrategy, stopNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning,
|
||||||
|
nodeTerminated, nodeSuspended, initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory,
|
||||||
|
persistNodeCredentials, timeouts, userExecutor, imageExtension, securityGroupExtension);
|
||||||
|
this.cleanupResources = cleanupResources;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void cleanUpIncidentalResourcesOfDeadNodes(Set<? extends NodeMetadata> deadNodes) {
|
||||||
|
ImmutableMultimap.Builder<String, String> regionGroups = ImmutableMultimap.builder();
|
||||||
|
ImmutableSet.Builder<String> resourceGroups = ImmutableSet.builder();
|
||||||
|
|
||||||
|
for (NodeMetadata deadNode : deadNodes) {
|
||||||
|
String resourceGroupName = ResourceGroupAndName.fromSlashEncoded(deadNode.getId()).resourceGroup();
|
||||||
|
resourceGroups.add(resourceGroupName);
|
||||||
|
|
||||||
|
if (deadNode.getGroup() != null) {
|
||||||
|
regionGroups.put(resourceGroupName, deadNode.getGroup());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
cleanupResources.cleanupNode(deadNode.getId());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.warn(ex, "Error cleaning up resources for node %s", deadNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Entry<String, String> regionGroup : regionGroups.build().entries()) {
|
||||||
|
cleanupResources.cleanupSecurityGroupIfOrphaned(regionGroup.getKey(), regionGroup.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String resourceGroup : resourceGroups.build()) {
|
||||||
|
cleanupResources.deleteResourceGroupIfEmpty(resourceGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,545 @@
|
||||||
|
/*
|
||||||
|
* 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.compute;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static com.google.common.collect.ImmutableList.builder;
|
||||||
|
import static com.google.common.collect.ImmutableList.of;
|
||||||
|
import static com.google.common.collect.Iterables.filter;
|
||||||
|
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||||
|
import static com.google.common.collect.Iterables.transform;
|
||||||
|
import static com.google.common.collect.Lists.newArrayList;
|
||||||
|
import static org.jclouds.azurecompute.arm.compute.domain.LocationAndName.fromSlashEncoded;
|
||||||
|
import static org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndName.fromResourceGroupAndName;
|
||||||
|
import static org.jclouds.azurecompute.arm.compute.functions.VMImageToImage.getMarketplacePlanFromImageMetadata;
|
||||||
|
import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.IMAGE_PUBLISHERS;
|
||||||
|
import static org.jclouds.azurecompute.arm.domain.IdReference.extractName;
|
||||||
|
import static org.jclouds.azurecompute.arm.domain.IdReference.extractResourceGroup;
|
||||||
|
import static org.jclouds.azurecompute.arm.util.VMImages.isCustom;
|
||||||
|
import static org.jclouds.compute.util.ComputeServiceUtils.metadataAndTagsAsCommaDelimitedValue;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.AzureComputeApi;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.PublicIpAvailablePredicateFactory;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndName;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.functions.CustomImageToVMImage;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.options.AzureTemplateOptions;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.options.IpOptions;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.strategy.CleanupResources;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.AvailabilitySet;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.CreationData;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.DataDisk;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.HardwareProfile;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.IdReference;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.ImageReference;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.IpConfiguration;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.IpConfigurationProperties;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Location;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.ManagedDiskParameters;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCard;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCardProperties;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkProfile;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkProfile.NetworkInterface;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkProfile.NetworkInterface.NetworkInterfaceProperties;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.OSDisk;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.OSProfile;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Offer;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Plan;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Provisionable;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.PublicIPAddress;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.PublicIPAddressProperties;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.ResourceGroup;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.ResourceProviderMetaData;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.SKU;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.StorageAccountType;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.StorageProfile;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VMHardware;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VMImage;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VMSize;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Version;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VirtualMachine;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VirtualMachineProperties;
|
||||||
|
import org.jclouds.azurecompute.arm.features.NetworkInterfaceCardApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.OSImageApi;
|
||||||
|
import org.jclouds.compute.ComputeServiceAdapter;
|
||||||
|
import org.jclouds.compute.domain.Image;
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
import org.jclouds.compute.domain.Template;
|
||||||
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
|
import org.jclouds.location.Region;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.MoreObjects;
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Splitter;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.collect.FluentIterable;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the connection between the {@link AzureComputeApi} implementation and
|
||||||
|
* the jclouds {@link org.jclouds.compute.ComputeService}.
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class AzureComputeServiceAdapter implements ComputeServiceAdapter<VirtualMachine, VMHardware, VMImage, Location> {
|
||||||
|
|
||||||
|
public static final String GROUP_KEY = "jclouds_group";
|
||||||
|
public static final String AUTOGENERATED_IP_KEY = "jclouds-autogenerated";
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
private final CleanupResources cleanupResources;
|
||||||
|
private final AzureComputeApi api;
|
||||||
|
private final List<String> imagePublishers;
|
||||||
|
private final Supplier<Set<String>> regionIds;
|
||||||
|
private final PublicIpAvailablePredicateFactory publicIpAvailable;
|
||||||
|
private final CustomImageToVMImage customImagetoVmImage;
|
||||||
|
private final GroupNamingConvention namingConvention;
|
||||||
|
private Predicate<Supplier<Provisionable>> resourceAvailable;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
AzureComputeServiceAdapter(final AzureComputeApi api, @Named(IMAGE_PUBLISHERS) String imagePublishers,
|
||||||
|
CleanupResources cleanupResources, @Region Supplier<Set<String>> regionIds,
|
||||||
|
PublicIpAvailablePredicateFactory publicIpAvailable, CustomImageToVMImage customImagetoVmImage,
|
||||||
|
GroupNamingConvention.Factory namingConvention, Predicate<Supplier<Provisionable>> resourceAvailable) {
|
||||||
|
this.api = api;
|
||||||
|
this.imagePublishers = Splitter.on(',').trimResults().omitEmptyStrings().splitToList(imagePublishers);
|
||||||
|
this.cleanupResources = cleanupResources;
|
||||||
|
this.regionIds = regionIds;
|
||||||
|
this.publicIpAvailable = publicIpAvailable;
|
||||||
|
this.customImagetoVmImage = customImagetoVmImage;
|
||||||
|
this.namingConvention = namingConvention.create();
|
||||||
|
this.resourceAvailable = resourceAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NodeAndInitialCredentials<VirtualMachine> createNodeWithGroupEncodedIntoName(final String group, final String name, final Template template) {
|
||||||
|
String locationName = template.getLocation().getId();
|
||||||
|
Image image = template.getImage();
|
||||||
|
String hardwareId = fromSlashEncoded(template.getHardware().getId()).name();
|
||||||
|
AzureTemplateOptions templateOptions = template.getOptions().as(AzureTemplateOptions.class);
|
||||||
|
String resourceGroupName = templateOptions.getResourceGroup();
|
||||||
|
|
||||||
|
IdReference availabilitySet = getAvailabilitySetIdReference(templateOptions.getAvailabilitySet());
|
||||||
|
NetworkProfile networkProfile = createNetworkProfile(createNetworkInterfaceCards(name, locationName,
|
||||||
|
templateOptions));
|
||||||
|
StorageProfile storageProfile = createStorageProfile(image, templateOptions.getDataDisks());
|
||||||
|
HardwareProfile hardwareProfile = HardwareProfile.builder().vmSize(hardwareId).build();
|
||||||
|
OSProfile osProfile = createOsProfile(name, template);
|
||||||
|
|
||||||
|
VirtualMachineProperties virtualMachineProperties = VirtualMachineProperties.builder()
|
||||||
|
.availabilitySet(availabilitySet)
|
||||||
|
.hardwareProfile(hardwareProfile)
|
||||||
|
.storageProfile(storageProfile)
|
||||||
|
.osProfile(osProfile)
|
||||||
|
.networkProfile(networkProfile)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Store group apart from the name to be able to identify nodes with
|
||||||
|
// custom names in the configured group
|
||||||
|
templateOptions.getUserMetadata().put(GROUP_KEY, group);
|
||||||
|
Map<String, String> metadataAndTags = metadataAndTagsAsCommaDelimitedValue(templateOptions);
|
||||||
|
Plan plan = getMarketplacePlanFromImageMetadata(image);
|
||||||
|
|
||||||
|
VirtualMachine virtualMachine = api.getVirtualMachineApi(resourceGroupName).createOrUpdate(name, locationName,
|
||||||
|
virtualMachineProperties, metadataAndTags, plan);
|
||||||
|
|
||||||
|
// Safe to pass null credentials here, as jclouds will default populate
|
||||||
|
// the node with the default credentials from the image, or the ones in
|
||||||
|
// the options, if provided.
|
||||||
|
ResourceGroupAndName resourceGroupAndName = fromResourceGroupAndName(resourceGroupName, name);
|
||||||
|
return new NodeAndInitialCredentials<VirtualMachine>(virtualMachine, resourceGroupAndName.slashEncode(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<VMHardware> listHardwareProfiles() {
|
||||||
|
final List<VMHardware> hwProfiles = Lists.newArrayList();
|
||||||
|
for (Location location : listLocations()) {
|
||||||
|
Iterable<VMSize> vmSizes = api.getVMSizeApi(location.name()).list();
|
||||||
|
for (VMSize vmSize : vmSizes) {
|
||||||
|
VMHardware hwProfile = VMHardware
|
||||||
|
.create(vmSize.name(), vmSize.numberOfCores(), vmSize.osDiskSizeInMB(),
|
||||||
|
vmSize.resourceDiskSizeInMB(), vmSize.memoryInMB(), vmSize.maxDataDiskCount(), location.name());
|
||||||
|
hwProfiles.add(hwProfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hwProfiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<VMImage> getImagesFromPublisher(String publisherName, String location) {
|
||||||
|
List<VMImage> osImagesRef = Lists.newArrayList();
|
||||||
|
OSImageApi osImageApi = api.getOSImageApi(location);
|
||||||
|
Iterable<Offer> offerList = osImageApi.listOffers(publisherName);
|
||||||
|
|
||||||
|
for (Offer offer : offerList) {
|
||||||
|
Iterable<SKU> skuList = osImageApi.listSKUs(publisherName, offer.name());
|
||||||
|
|
||||||
|
for (SKU sku : skuList) {
|
||||||
|
Iterable<Version> versionList = osImageApi.listVersions(publisherName, offer.name(), sku.name());
|
||||||
|
for (Version version : versionList) {
|
||||||
|
Version versionDetails = osImageApi.getVersion(publisherName, offer.name(), sku.name(), version.name());
|
||||||
|
VMImage vmImage = VMImage.azureImage().publisher(publisherName).offer(offer.name()).sku(sku.name())
|
||||||
|
.version(versionDetails.name()).location(location).versionProperties(versionDetails.properties())
|
||||||
|
.build();
|
||||||
|
osImagesRef.add(vmImage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return osImagesRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<VMImage> listImagesByLocation(String location) {
|
||||||
|
final List<VMImage> osImages = Lists.newArrayList();
|
||||||
|
for (String publisher : imagePublishers) {
|
||||||
|
osImages.addAll(getImagesFromPublisher(publisher, location));
|
||||||
|
}
|
||||||
|
return osImages;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<VMImage> listCustomImagesByResourceGroup(String resourceGroup) {
|
||||||
|
List<org.jclouds.azurecompute.arm.domain.Image> customImgs = api.getVirtualMachineImageApi(resourceGroup).list();
|
||||||
|
return ImmutableList.copyOf(transform(
|
||||||
|
filter(customImgs, new Predicate<org.jclouds.azurecompute.arm.domain.Image>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(org.jclouds.azurecompute.arm.domain.Image input) {
|
||||||
|
return regionIds.get().contains(input.location());
|
||||||
|
}
|
||||||
|
}), customImagetoVmImage));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<VMImage> listImages() {
|
||||||
|
final ImmutableList.Builder<VMImage> osImages = ImmutableList.builder();
|
||||||
|
|
||||||
|
final List<String> availableLocationNames = newArrayList(transform(listLocations(),
|
||||||
|
new Function<Location, String>() {
|
||||||
|
@Override
|
||||||
|
public String apply(Location location) {
|
||||||
|
return location.name();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
for (String locationName : availableLocationNames) {
|
||||||
|
osImages.addAll(listImagesByLocation(locationName));
|
||||||
|
}
|
||||||
|
|
||||||
|
// We need to look for custom images in all resource groups
|
||||||
|
for (ResourceGroup resourceGroup : api.getResourceGroupApi().list()) {
|
||||||
|
osImages.addAll(listCustomImagesByResourceGroup(resourceGroup.name()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return osImages.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VMImage getImage(final String id) {
|
||||||
|
VMImage image = VMImage.decodeFieldsFromUniqueId(id);
|
||||||
|
|
||||||
|
if (image.custom()) {
|
||||||
|
org.jclouds.azurecompute.arm.domain.Image vmImage = api.getVirtualMachineImageApi(image.resourceGroup()).get(
|
||||||
|
image.name());
|
||||||
|
return vmImage == null ? null : customImagetoVmImage.apply(vmImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
String location = image.location();
|
||||||
|
String publisher = image.publisher();
|
||||||
|
String offer = image.offer();
|
||||||
|
String sku = image.sku();
|
||||||
|
|
||||||
|
OSImageApi osImageApi = api.getOSImageApi(location);
|
||||||
|
List<Version> versions = osImageApi.listVersions(publisher, offer, sku);
|
||||||
|
if (!versions.isEmpty()) {
|
||||||
|
Version version = osImageApi.getVersion(publisher, offer, sku, versions.get(0).name());
|
||||||
|
return VMImage.azureImage().publisher(publisher).offer(offer).sku(sku).version(version.name())
|
||||||
|
.location(location).versionProperties(version.properties()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<Location> listLocations() {
|
||||||
|
final Iterable<String> vmLocations = FluentIterable.from(api.getResourceProviderApi().get("Microsoft.Compute"))
|
||||||
|
.filter(new Predicate<ResourceProviderMetaData>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(ResourceProviderMetaData input) {
|
||||||
|
return input.resourceType().equals("virtualMachines");
|
||||||
|
}
|
||||||
|
}).transformAndConcat(new Function<ResourceProviderMetaData, Iterable<String>>() {
|
||||||
|
@Override
|
||||||
|
public Iterable<String> apply(ResourceProviderMetaData resourceProviderMetaData) {
|
||||||
|
return resourceProviderMetaData.locations();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
List<Location> locations = FluentIterable.from(api.getLocationApi().list()).filter(new Predicate<Location>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(Location location) {
|
||||||
|
return Iterables.contains(vmLocations, location.displayName());
|
||||||
|
}
|
||||||
|
}).filter(new Predicate<Location>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(Location location) {
|
||||||
|
return regionIds.get().isEmpty() ? true : regionIds.get().contains(location.name());
|
||||||
|
}
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
return locations;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VirtualMachine getNode(final String id) {
|
||||||
|
ResourceGroupAndName resourceGroupAndName = ResourceGroupAndName.fromSlashEncoded(id);
|
||||||
|
return api.getVirtualMachineApi(resourceGroupAndName.resourceGroup()).get(resourceGroupAndName.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroyNode(final String id) {
|
||||||
|
checkState(cleanupResources.cleanupNode(id), "server(%s) and its resources still there after deleting!?", id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void rebootNode(final String id) {
|
||||||
|
ResourceGroupAndName resourceGroupAndName = ResourceGroupAndName.fromSlashEncoded(id);
|
||||||
|
api.getVirtualMachineApi(resourceGroupAndName.resourceGroup()).restart(resourceGroupAndName.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resumeNode(final String id) {
|
||||||
|
ResourceGroupAndName resourceGroupAndName = ResourceGroupAndName.fromSlashEncoded(id);
|
||||||
|
api.getVirtualMachineApi(resourceGroupAndName.resourceGroup()).start(resourceGroupAndName.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void suspendNode(final String id) {
|
||||||
|
ResourceGroupAndName resourceGroupAndName = ResourceGroupAndName.fromSlashEncoded(id);
|
||||||
|
api.getVirtualMachineApi(resourceGroupAndName.resourceGroup()).stop(resourceGroupAndName.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<VirtualMachine> listNodes() {
|
||||||
|
ImmutableList.Builder<VirtualMachine> nodes = builder();
|
||||||
|
for (ResourceGroup resourceGroup : api.getResourceGroupApi().list()) {
|
||||||
|
List<VirtualMachine> vms = api.getVirtualMachineApi(resourceGroup.name()).list();
|
||||||
|
nodes.addAll(filter(vms, new Predicate<VirtualMachine>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(VirtualMachine input) {
|
||||||
|
return regionIds.get().contains(input.location());
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
return nodes.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<VirtualMachine> listNodesByIds(final Iterable<String> ids) {
|
||||||
|
return transform(ids, new Function<String, VirtualMachine>() {
|
||||||
|
@Override
|
||||||
|
public VirtualMachine apply(String input) {
|
||||||
|
return getNode(input);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private OSProfile createOsProfile(String computerName, Template template) {
|
||||||
|
String defaultLoginUser = template.getImage().getDefaultCredentials().getUser();
|
||||||
|
String adminUsername = MoreObjects.firstNonNull(template.getOptions().getLoginUser(), defaultLoginUser);
|
||||||
|
// Password already generated in CreateResourcesThenCreateNodes (if not set by user)
|
||||||
|
String adminPassword = template.getOptions().getLoginPassword();
|
||||||
|
OSProfile.Builder builder = OSProfile.builder().adminUsername(adminUsername).adminPassword(adminPassword)
|
||||||
|
.computerName(computerName);
|
||||||
|
|
||||||
|
if (!Strings.isNullOrEmpty(template.getOptions().getPublicKey())
|
||||||
|
&& OsFamily.WINDOWS != template.getImage().getOperatingSystem().getFamily()) {
|
||||||
|
OSProfile.LinuxConfiguration linuxConfiguration = OSProfile.LinuxConfiguration.create("true",
|
||||||
|
OSProfile.LinuxConfiguration.SSH.create(of(
|
||||||
|
OSProfile.LinuxConfiguration.SSH.SSHPublicKey.create(
|
||||||
|
String.format("/home/%s/.ssh/authorized_keys", adminUsername),
|
||||||
|
template.getOptions().getPublicKey()))));
|
||||||
|
builder.linuxConfiguration(linuxConfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
|
AzureTemplateOptions azureTemplateOptions = template.getOptions().as(AzureTemplateOptions.class);
|
||||||
|
|
||||||
|
if (azureTemplateOptions.getWindowsConfiguration() != null) {
|
||||||
|
builder.windowsConfiguration(azureTemplateOptions.getWindowsConfiguration());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (azureTemplateOptions.getSecrets() != null) {
|
||||||
|
builder.secrets(azureTemplateOptions.getSecrets());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Strings.isNullOrEmpty(azureTemplateOptions.getCustomData())) {
|
||||||
|
builder.customData(azureTemplateOptions.getCustomData());
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<NetworkInterfaceCard> createNetworkInterfaceCards(final String nodeName, final String location,
|
||||||
|
AzureTemplateOptions options) {
|
||||||
|
// Prefer a sorted list of NICs with the ones with public IPs first, to
|
||||||
|
// make sure the primary NIC is the public one
|
||||||
|
final String securityGroup = getOnlyElement(options.getGroups(), null);
|
||||||
|
return Lists.transform(publicIpsFirst(options.getIpOptions()), new Function<IpOptions, NetworkInterfaceCard>() {
|
||||||
|
@Override
|
||||||
|
public NetworkInterfaceCard apply(IpOptions input) {
|
||||||
|
return createNetworkInterfaceCard(input, nodeName, location, securityGroup);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private NetworkInterfaceCard createNetworkInterfaceCard(IpOptions ipConfig, String nodeName, String location,
|
||||||
|
String securityGroup) {
|
||||||
|
String resourceGroup = extractResourceGroup(ipConfig.subnet());
|
||||||
|
String subnetName = extractName(ipConfig.subnet());
|
||||||
|
|
||||||
|
IpConfigurationProperties.Builder ipProperties = IpConfigurationProperties.builder()
|
||||||
|
.subnet(IdReference.create(ipConfig.subnet()))
|
||||||
|
.privateIPAllocationMethod(ipConfig.address().isPresent() ? "Static" : "Dynamic")
|
||||||
|
.privateIPAddress(ipConfig.address().orNull());
|
||||||
|
|
||||||
|
configurePublicIP(ipConfig, ipProperties, resourceGroup, location, nodeName);
|
||||||
|
|
||||||
|
String ipName = namingConvention.uniqueNameForGroup(subnetName);
|
||||||
|
final String nicName = namingConvention.uniqueNameForGroup(subnetName);
|
||||||
|
|
||||||
|
IpConfiguration config = IpConfiguration.builder().name(ipName).properties(ipProperties.build()).build();
|
||||||
|
|
||||||
|
NetworkInterfaceCardProperties.Builder nicProperties = NetworkInterfaceCardProperties.builder().ipConfigurations(
|
||||||
|
ImmutableList.of(config));
|
||||||
|
|
||||||
|
if (securityGroup != null) {
|
||||||
|
nicProperties.networkSecurityGroup(IdReference.create(securityGroup));
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug(">> creating nic %s(%s) with security groups (%s)", nicName, config,
|
||||||
|
securityGroup != null ? securityGroup : "");
|
||||||
|
|
||||||
|
final NetworkInterfaceCardApi nicApi = api.getNetworkInterfaceCardApi(resourceGroup);
|
||||||
|
NetworkInterfaceCard nic = nicApi.createOrUpdate(nicName, location, nicProperties.build(),
|
||||||
|
ImmutableMap.of("jclouds", nodeName));
|
||||||
|
|
||||||
|
resourceAvailable.apply(new Supplier<Provisionable>() {
|
||||||
|
@Override
|
||||||
|
public Provisionable get() {
|
||||||
|
NetworkInterfaceCard updated = nicApi.get(nicName);
|
||||||
|
return updated == null ? null : updated.properties();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return nic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void configurePublicIP(IpOptions ipConfig, IpConfigurationProperties.Builder ipProperties,
|
||||||
|
String resourceGroup, String location, String nodeName) {
|
||||||
|
if (ipConfig.publicIpId() != null) {
|
||||||
|
logger.debug(">> configuring public ip: %s", extractName(ipConfig.publicIpId()));
|
||||||
|
PublicIPAddress publicIp = api.getPublicIPAddressApi(extractResourceGroup(ipConfig.publicIpId())).get(
|
||||||
|
extractName(ipConfig.publicIpId()));
|
||||||
|
ipProperties.publicIPAddress(IdReference.create(publicIp.id()));
|
||||||
|
} else if (ipConfig.allocateNewPublicIp()) {
|
||||||
|
PublicIPAddress publicIp = createPublicIp(resourceGroup, location, nodeName);
|
||||||
|
ipProperties.publicIPAddress(IdReference.create(publicIp.id()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the network profile and configure the first NIC as primary.
|
||||||
|
*/
|
||||||
|
private NetworkProfile createNetworkProfile(List<NetworkInterfaceCard> nics) {
|
||||||
|
List<NetworkInterface> nicAttachments = new ArrayList<NetworkInterface>(nics.size());
|
||||||
|
for (int i = 0; i < nics.size(); i++) {
|
||||||
|
nicAttachments.add(NetworkInterface.create(nics.get(i).id(), NetworkInterfaceProperties.create(i == 0)));
|
||||||
|
}
|
||||||
|
return NetworkProfile.create(nicAttachments);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<IpOptions> publicIpsFirst(List<IpOptions> ipOptions) {
|
||||||
|
List<IpOptions> sorted = new ArrayList<IpOptions>(ipOptions);
|
||||||
|
Collections.sort(sorted, new Comparator<IpOptions>() {
|
||||||
|
@Override
|
||||||
|
public int compare(IpOptions o1, IpOptions o2) {
|
||||||
|
return o1.allocateNewPublicIp() == o2.allocateNewPublicIp() ? 0 : o1.allocateNewPublicIp() ? -1 : 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return sorted;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PublicIPAddress createPublicIp(String resourceGroup, String location, String nodeName) {
|
||||||
|
String name = namingConvention.uniqueNameForGroup(nodeName);
|
||||||
|
|
||||||
|
PublicIPAddressProperties properties = PublicIPAddressProperties.builder()
|
||||||
|
.publicIPAllocationMethod("Static")
|
||||||
|
.idleTimeoutInMinutes(4)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
logger.debug(">> allocating new public ip address: %s", name);
|
||||||
|
|
||||||
|
PublicIPAddress ip = api.getPublicIPAddressApi(resourceGroup).createOrUpdate(name, location,
|
||||||
|
ImmutableMap.of("jclouds", nodeName, AUTOGENERATED_IP_KEY, "true"), properties);
|
||||||
|
|
||||||
|
checkState(publicIpAvailable.create(resourceGroup).apply(name),
|
||||||
|
"Public IP was not provisioned in the configured timeout");
|
||||||
|
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
private StorageProfile createStorageProfile(Image image, List<DataDisk> dataDisks) {
|
||||||
|
return StorageProfile.create(createImageReference(image), createOSDisk(image), dataDisks);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ImageReference createImageReference(Image image) {
|
||||||
|
return isCustom(image.getId()) ? ImageReference.builder().customImageId(image.getProviderId()).build() : ImageReference
|
||||||
|
.builder().publisher(image.getProviderId()).offer(image.getName()).sku(image.getVersion())
|
||||||
|
.version("latest").build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private OSDisk createOSDisk(Image image) {
|
||||||
|
OsFamily osFamily = image.getOperatingSystem().getFamily();
|
||||||
|
String osType = osFamily == OsFamily.WINDOWS ? "Windows" : "Linux";
|
||||||
|
return OSDisk.builder()
|
||||||
|
.osType(osType)
|
||||||
|
.caching(DataDisk.CachingTypes.READ_WRITE.toString())
|
||||||
|
.createOption(CreationData.CreateOptions.FROM_IMAGE.toString())
|
||||||
|
.managedDiskParameters(ManagedDiskParameters.create(null, StorageAccountType.STANDARD_LRS.toString()))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private IdReference getAvailabilitySetIdReference(AvailabilitySet availabilitySet) {
|
||||||
|
return availabilitySet != null ? IdReference.create(availabilitySet.id()) : null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,134 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.config;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.compute.AzureComputeService;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.AzureComputeServiceAdapter;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndNameAndIngressRules;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.extensions.AzureComputeImageExtension;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.extensions.AzureComputeSecurityGroupExtension;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.functions.LocationToLocation;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.functions.NetworkSecurityGroupToSecurityGroup;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.functions.NetworkSecurityRuleToIpPermission;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.functions.VMHardwareToHardware;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.functions.VMImageToImage;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.functions.VirtualMachineToNodeMetadata;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.loaders.CreateSecurityGroupIfNeeded;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.loaders.DefaultResourceGroup;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.options.AzureTemplateOptions;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.strategy.CreateResourcesThenCreateNodes;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Location;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroup;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityRule;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.ResourceGroup;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VMHardware;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VMImage;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VirtualMachine;
|
||||||
|
import org.jclouds.compute.ComputeService;
|
||||||
|
import org.jclouds.compute.ComputeServiceAdapter;
|
||||||
|
import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
|
||||||
|
import org.jclouds.compute.domain.Hardware;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.compute.domain.SecurityGroup;
|
||||||
|
import org.jclouds.compute.extensions.ImageExtension;
|
||||||
|
import org.jclouds.compute.extensions.SecurityGroupExtension;
|
||||||
|
import org.jclouds.compute.functions.NodeAndTemplateOptionsToStatement;
|
||||||
|
import org.jclouds.compute.functions.NodeAndTemplateOptionsToStatementWithoutPublicKey;
|
||||||
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
|
import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet;
|
||||||
|
import org.jclouds.net.domain.IpPermission;
|
||||||
|
import org.jclouds.util.PasswordGenerator;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
public class AzureComputeServiceContextModule extends
|
||||||
|
ComputeServiceAdapterContextModule<VirtualMachine, VMHardware, VMImage, Location> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
super.configure();
|
||||||
|
|
||||||
|
bind(new TypeLiteral<ComputeServiceAdapter<VirtualMachine, VMHardware, VMImage, Location>>() {
|
||||||
|
}).to(AzureComputeServiceAdapter.class);
|
||||||
|
|
||||||
|
bind(new TypeLiteral<Function<VMImage, org.jclouds.compute.domain.Image>>() {
|
||||||
|
}).to(VMImageToImage.class);
|
||||||
|
bind(new TypeLiteral<Function<VMHardware, Hardware>>() {
|
||||||
|
}).to(VMHardwareToHardware.class);
|
||||||
|
bind(new TypeLiteral<Function<VirtualMachine, NodeMetadata>>() {
|
||||||
|
}).to(VirtualMachineToNodeMetadata.class);
|
||||||
|
bind(new TypeLiteral<Function<Location, org.jclouds.domain.Location>>() {
|
||||||
|
}).to(LocationToLocation.class);
|
||||||
|
bind(new TypeLiteral<Function<NetworkSecurityGroup, SecurityGroup>>() {
|
||||||
|
}).to(NetworkSecurityGroupToSecurityGroup.class);
|
||||||
|
bind(new TypeLiteral<Function<NetworkSecurityRule, IpPermission>>() {
|
||||||
|
}).to(NetworkSecurityRuleToIpPermission.class);
|
||||||
|
bind(ComputeService.class).to(AzureComputeService.class);
|
||||||
|
|
||||||
|
install(new LocationsFromComputeServiceAdapterModule<VirtualMachine, VMHardware, VMImage, Location>() {
|
||||||
|
});
|
||||||
|
|
||||||
|
bind(TemplateOptions.class).to(AzureTemplateOptions.class);
|
||||||
|
bind(NodeAndTemplateOptionsToStatement.class).to(NodeAndTemplateOptionsToStatementWithoutPublicKey.class);
|
||||||
|
bind(CreateNodesInGroupThenAddToSet.class).to(CreateResourcesThenCreateNodes.class);
|
||||||
|
|
||||||
|
bind(new TypeLiteral<CacheLoader<ResourceGroupAndNameAndIngressRules, String>>() {
|
||||||
|
}).to(CreateSecurityGroupIfNeeded.class);
|
||||||
|
bind(new TypeLiteral<CacheLoader<String, ResourceGroup>>() {
|
||||||
|
}).to(DefaultResourceGroup.class);
|
||||||
|
|
||||||
|
bind(new TypeLiteral<ImageExtension>() {
|
||||||
|
}).to(AzureComputeImageExtension.class);
|
||||||
|
bind(new TypeLiteral<SecurityGroupExtension>() {
|
||||||
|
}).to(AzureComputeSecurityGroupExtension.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
protected PasswordGenerator.Config providePasswordGenerator() {
|
||||||
|
// Guest passwords must be between 6-72 characters long.
|
||||||
|
// Must contain an upper case character.
|
||||||
|
// Must contain a lower case character.
|
||||||
|
// Must contain a numeric digit.
|
||||||
|
// Must contain a special character. Control characters are not allowed.
|
||||||
|
return new PasswordGenerator()
|
||||||
|
.lower().min(2).max(10)
|
||||||
|
.upper().min(2).max(10)
|
||||||
|
.numbers().min(2).max(10)
|
||||||
|
.symbols().min(2).max(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
protected final LoadingCache<ResourceGroupAndNameAndIngressRules, String> securityGroupMap(
|
||||||
|
CacheLoader<ResourceGroupAndNameAndIngressRules, String> in) {
|
||||||
|
return CacheBuilder.newBuilder().build(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
protected final LoadingCache<String, ResourceGroup> defaultResourceGroup(CacheLoader<String, ResourceGroup> in) {
|
||||||
|
return CacheBuilder.newBuilder().build(in);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,602 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.config;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
import com.google.inject.name.Named;
|
||||||
|
|
||||||
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
|
import org.jclouds.compute.reference.ComputeServiceConstants.PollPeriod;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Image;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroup;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Provisionable;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.PublicIPAddress;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.ResourceDefinition;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Vault;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VirtualMachineInstance;
|
||||||
|
import org.jclouds.azurecompute.arm.functions.ParseJobStatus;
|
||||||
|
import org.jclouds.azurecompute.arm.AzureComputeApi;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Key.DeletedKeyBundle;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Key.KeyBundle;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Secret.DeletedSecretBundle;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Secret.SecretBundle;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Certificate.DeletedCertificateBundle;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Certificate.CertificateBundle;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Certificate.CertificateOperation;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.jclouds.util.Predicates2.retry;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_IMAGE_AVAILABLE;
|
||||||
|
import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TIMEOUT_RESOURCE_DELETED;
|
||||||
|
import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.OPERATION_TIMEOUT;
|
||||||
|
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.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 static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
public class AzurePredicatesModule extends AbstractModule {
|
||||||
|
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_TERMINATED)
|
||||||
|
protected Predicate<URI> 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<URI> 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<URI> 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
|
||||||
|
protected PublicIpAvailablePredicateFactory providePublicIpAvailablePredicate(final AzureComputeApi api,
|
||||||
|
Predicate<Supplier<Provisionable>> resourceAvailable) {
|
||||||
|
return new PublicIpAvailablePredicateFactory(api, resourceAvailable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
protected SecurityGroupAvailablePredicateFactory provideSecurityGroupAvailablePredicate(final AzureComputeApi api,
|
||||||
|
Predicate<Supplier<Provisionable>> resourceAvailable) {
|
||||||
|
return new SecurityGroupAvailablePredicateFactory(api, resourceAvailable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
protected ImageAvailablePredicateFactory provideImageAvailablePredicate(final AzureComputeApi api,
|
||||||
|
Predicate<Supplier<Provisionable>> resourceAvailable, final ComputeServiceConstants.Timeouts timeouts, final PollPeriod pollPeriod) {
|
||||||
|
return new ImageAvailablePredicateFactory(api, retry(new ResourceInStatusPredicate("Succeeded"),
|
||||||
|
timeouts.imageAvailable, pollPeriod.pollInitialPeriod, pollPeriod.pollMaxPeriod));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
protected Predicate<Supplier<Provisionable>> provideResourceAvailablePredicate(final AzureComputeApi api,
|
||||||
|
@Named(OPERATION_TIMEOUT) Integer operationTimeout, PollPeriod pollPeriod) {
|
||||||
|
return retry(new ResourceInStatusPredicate("Succeeded"), operationTimeout, pollPeriod.pollInitialPeriod,
|
||||||
|
pollPeriod.pollMaxPeriod);
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
static class ActionDonePredicate implements Predicate<URI> {
|
||||||
|
|
||||||
|
private final AzureComputeApi api;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
static class ImageCapturedPredicate implements Predicate<URI> {
|
||||||
|
|
||||||
|
private final AzureComputeApi api;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
List<ResourceDefinition> 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<String> create(final String azureGroup) {
|
||||||
|
return retry(new Predicate<String>() {
|
||||||
|
@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 ResourceInStatusPredicate implements Predicate<Supplier<Provisionable>> {
|
||||||
|
private final String expectedStatus;
|
||||||
|
|
||||||
|
ResourceInStatusPredicate(String expectedStatus) {
|
||||||
|
this.expectedStatus = checkNotNull(expectedStatus, "expectedStatus cannot be null");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Supplier<Provisionable> provisionableSupplier) {
|
||||||
|
checkNotNull(provisionableSupplier, "provisionableSupplier supplier cannot be null");
|
||||||
|
Provisionable provisionable = provisionableSupplier.get();
|
||||||
|
return provisionable != null && provisionable.provisioningState().equalsIgnoreCase(expectedStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class PublicIpAvailablePredicateFactory {
|
||||||
|
private final AzureComputeApi api;
|
||||||
|
private final Predicate<Supplier<Provisionable>> resourceAvailable;
|
||||||
|
|
||||||
|
PublicIpAvailablePredicateFactory(final AzureComputeApi api, Predicate<Supplier<Provisionable>> resourceAvailable) {
|
||||||
|
this.api = checkNotNull(api, "api cannot be null");
|
||||||
|
this.resourceAvailable = resourceAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Predicate<String> create(final String azureGroup) {
|
||||||
|
checkNotNull(azureGroup, "azureGroup cannot be null");
|
||||||
|
return new Predicate<String>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(final String name) {
|
||||||
|
checkNotNull(name, "name cannot be null");
|
||||||
|
return resourceAvailable.apply(new Supplier<Provisionable>() {
|
||||||
|
@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<Supplier<Provisionable>> resourceAvailable;
|
||||||
|
|
||||||
|
SecurityGroupAvailablePredicateFactory(final AzureComputeApi api,
|
||||||
|
Predicate<Supplier<Provisionable>> resourceAvailable) {
|
||||||
|
this.api = checkNotNull(api, "api cannot be null");
|
||||||
|
this.resourceAvailable = resourceAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Predicate<String> create(final String resourceGroup) {
|
||||||
|
checkNotNull(resourceGroup, "resourceGroup cannot be null");
|
||||||
|
return new Predicate<String>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(final String name) {
|
||||||
|
checkNotNull(name, "name cannot be null");
|
||||||
|
return resourceAvailable.apply(new Supplier<Provisionable>() {
|
||||||
|
@Override
|
||||||
|
public Provisionable get() {
|
||||||
|
NetworkSecurityGroup sg = api.getNetworkSecurityGroupApi(resourceGroup).get(name);
|
||||||
|
return sg == null ? null : sg.properties();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ImageAvailablePredicateFactory {
|
||||||
|
private final AzureComputeApi api;
|
||||||
|
private final Predicate<Supplier<Provisionable>> resourceAvailable;
|
||||||
|
|
||||||
|
ImageAvailablePredicateFactory(final AzureComputeApi api,
|
||||||
|
Predicate<Supplier<Provisionable>> resourceAvailable) {
|
||||||
|
this.api = checkNotNull(api, "api cannot be null");
|
||||||
|
this.resourceAvailable = resourceAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Predicate<String> create(final String resourceGroup) {
|
||||||
|
checkNotNull(resourceGroup, "resourceGroup cannot be null");
|
||||||
|
return new Predicate<String>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(final String name) {
|
||||||
|
checkNotNull(name, "name cannot be null");
|
||||||
|
return resourceAvailable.apply(new Supplier<Provisionable>() {
|
||||||
|
@Override
|
||||||
|
public Provisionable get() {
|
||||||
|
Image img = api.getVirtualMachineImageApi(resourceGroup).get(name);
|
||||||
|
return img == null ? null : img.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.operationTimeout = operationTimeout;
|
||||||
|
this.initialPeriod = initialPeriod;
|
||||||
|
this.maxPeriod = maxPeriod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Predicate<String> create(final String resourceGroup, final boolean shouldBePresent) {
|
||||||
|
checkNotNull(resourceGroup, "resourceGroup cannot be null");
|
||||||
|
return retry(new Predicate<String>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(final String name) {
|
||||||
|
checkNotNull(name, "name cannot be null");
|
||||||
|
boolean present = false;
|
||||||
|
List<Vault.DeletedVault> vaults = api.getVaultApi(resourceGroup).listDeletedVaults();
|
||||||
|
return shouldBePresent == Iterables.any(vaults, new Predicate<Vault.DeletedVault>() {
|
||||||
|
@Override public boolean apply(Vault.DeletedVault input) {
|
||||||
|
return input.name().equals(name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, operationTimeout, initialPeriod, 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 VaultKeyPredicates {
|
||||||
|
public static class DeletedKeyStatusPredicateFactory {
|
||||||
|
private final AzureComputeApi api;
|
||||||
|
private final long operationTimeout;
|
||||||
|
private final long initialPeriod;
|
||||||
|
private final long 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<String> 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<String>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(final String name) {
|
||||||
|
checkNotNull(name, "name cannot be null");
|
||||||
|
boolean present = false;
|
||||||
|
DeletedKeyBundle key = api.getVaultApi(resourceGroup).getDeletedKey(vaultUri, name);
|
||||||
|
return shouldBePresent == (key != null);
|
||||||
|
}
|
||||||
|
}, operationTimeout, initialPeriod, maxPeriod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RecoverableKeyStatusPredicateFactory {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Predicate<String> 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<String>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(final String name) {
|
||||||
|
checkNotNull(name, "name cannot be null");
|
||||||
|
boolean result = false;
|
||||||
|
KeyBundle key = api.getVaultApi(resourceGroup).getKey(vaultUri, name);
|
||||||
|
return key != null ? (isRecovered ? true : key.attributes().recoveryLevel().contains("Recoverable")) : false;
|
||||||
|
}
|
||||||
|
}, 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 VaultSecretPredicates {
|
||||||
|
public static class DeletedSecretStatusPredicateFactory {
|
||||||
|
private final AzureComputeApi api;
|
||||||
|
private final long operationTimeout;
|
||||||
|
private final long initialPeriod;
|
||||||
|
private final long 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<String> 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<String>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(final String name) {
|
||||||
|
boolean present = false;
|
||||||
|
checkNotNull(name, "name cannot be null");
|
||||||
|
DeletedSecretBundle secret = api.getVaultApi(resourceGroup).getDeletedSecret(vaultUri, name);
|
||||||
|
return shouldBePresent == (secret != null);
|
||||||
|
}
|
||||||
|
}, operationTimeout, initialPeriod, maxPeriod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RecoverableSecretStatusPredicateFactory {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Predicate<String> 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<String>() {
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 VaultCertificatePredicates {
|
||||||
|
public static class DeletedCertificateStatusPredicateFactory {
|
||||||
|
private final AzureComputeApi api;
|
||||||
|
private final long operationTimeout;
|
||||||
|
private final long initialPeriod;
|
||||||
|
private final long 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<String> 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<String>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(final String name) {
|
||||||
|
boolean present = false;
|
||||||
|
checkNotNull(name, "name cannot be null");
|
||||||
|
DeletedCertificateBundle cert = api.getVaultApi(resourceGroup).getDeletedCertificate(vaultUri, name);
|
||||||
|
return shouldBePresent == (cert != null);
|
||||||
|
}
|
||||||
|
}, operationTimeout, initialPeriod, maxPeriod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RecoverableCertificateStatusPredicateFactory {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Predicate<String> 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<String>() {
|
||||||
|
@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<String> 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<String>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(final String name) {
|
||||||
|
checkNotNull(name, "name cannot be null");
|
||||||
|
boolean result = false;
|
||||||
|
CertificateOperation certOp = api.getVaultApi(resourceGroup).getCertificateOperation(vaultUri, name);
|
||||||
|
return isCreate ? ((certOp != null) ? !certOp.status().equals("inProgress") : false) : (certOp == null);
|
||||||
|
}
|
||||||
|
}, operationTimeout, initialPeriod, maxPeriod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.base.Splitter;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class LocationAndName {
|
||||||
|
|
||||||
|
public abstract String location();
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
protected LocationAndName() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LocationAndName fromSlashEncoded(String id) {
|
||||||
|
Iterable<String> parts = Splitter.on('/').split(checkNotNull(id, "id"));
|
||||||
|
checkArgument(Iterables.size(parts) == 2, "id must be in format location/name");
|
||||||
|
return new AutoValue_LocationAndName(Iterables.get(parts, 0), Iterables.get(parts, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LocationAndName fromLocationAndName(String location, String name) {
|
||||||
|
return new AutoValue_LocationAndName(location, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String slashEncode() {
|
||||||
|
return location() + "/" + name();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.domain;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.base.Splitter;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class ResourceGroupAndName {
|
||||||
|
|
||||||
|
public abstract String resourceGroup();
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
protected ResourceGroupAndName() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResourceGroupAndName fromSlashEncoded(String id) {
|
||||||
|
Iterable<String> parts = Splitter.on('/').split(checkNotNull(id, "id"));
|
||||||
|
checkArgument(Iterables.size(parts) == 2, "id must be in format resourcegroup/name");
|
||||||
|
return new AutoValue_ResourceGroupAndName(Iterables.get(parts, 0), Iterables.get(parts, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResourceGroupAndName fromResourceGroupAndName(String resourceGroup, String name) {
|
||||||
|
return new AutoValue_ResourceGroupAndName(resourceGroup, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String slashEncode() {
|
||||||
|
return resourceGroup() + "/" + name();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.domain;
|
||||||
|
|
||||||
|
import static org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndName.fromResourceGroupAndName;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class ResourceGroupAndNameAndIngressRules {
|
||||||
|
|
||||||
|
abstract ResourceGroupAndName resourceGroupAndName(); // Intentionally hidden
|
||||||
|
|
||||||
|
public abstract String location();
|
||||||
|
|
||||||
|
@SuppressWarnings("mutable")
|
||||||
|
public abstract int[] inboundPorts();
|
||||||
|
|
||||||
|
ResourceGroupAndNameAndIngressRules() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResourceGroupAndNameAndIngressRules create(String resourceGroup, String location, String name,
|
||||||
|
int[] inboundPorts) {
|
||||||
|
return new AutoValue_ResourceGroupAndNameAndIngressRules(fromResourceGroupAndName(resourceGroup, name), location,
|
||||||
|
Arrays.copyOf(inboundPorts, inboundPorts.length));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String name() {
|
||||||
|
return resourceGroupAndName().name();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String resourceGroup() {
|
||||||
|
return resourceGroupAndName().resourceGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Intentionally delegate equals and hashcode to the fields in the parent
|
||||||
|
// class so that we can search only by region/id in a map
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(resourceGroup(), name());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj == this) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof ResourceGroupAndName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ResourceGroupAndName that = (ResourceGroupAndName) obj;
|
||||||
|
return Objects.equal(resourceGroup(), that.resourceGroup()) && Objects.equal(name(), that.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,134 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.extensions;
|
||||||
|
|
||||||
|
import static com.google.common.base.Functions.compose;
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndName.fromSlashEncoded;
|
||||||
|
import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TIMEOUT_RESOURCE_DELETED;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import org.jclouds.Constants;
|
||||||
|
import org.jclouds.azurecompute.arm.AzureComputeApi;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.ImageAvailablePredicateFactory;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.VirtualMachineInStatePredicateFactory;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndName;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.functions.CustomImageToVMImage;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.IdReference;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.ImageProperties;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VMImage;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VirtualMachine;
|
||||||
|
import org.jclouds.compute.domain.CloneImageTemplate;
|
||||||
|
import org.jclouds.compute.domain.Image;
|
||||||
|
import org.jclouds.compute.domain.ImageTemplate;
|
||||||
|
import org.jclouds.compute.domain.ImageTemplateBuilder;
|
||||||
|
import org.jclouds.compute.extensions.ImageExtension;
|
||||||
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.name.Named;
|
||||||
|
|
||||||
|
public class AzureComputeImageExtension implements ImageExtension {
|
||||||
|
public static final String CUSTOM_IMAGE_OFFER = "custom";
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
private final AzureComputeApi api;
|
||||||
|
private final ListeningExecutorService userExecutor;
|
||||||
|
private final ImageAvailablePredicateFactory imageAvailablePredicate;
|
||||||
|
private final VirtualMachineInStatePredicateFactory nodeSuspendedPredicate;
|
||||||
|
private final Function<VMImage, Image> vmImageToImage;
|
||||||
|
private final Predicate<URI> resourceDeleted;
|
||||||
|
private final CustomImageToVMImage customImagetoVmImage;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
AzureComputeImageExtension(AzureComputeApi api, ImageAvailablePredicateFactory imageAvailablePredicate,
|
||||||
|
@Named(TIMEOUT_NODE_SUSPENDED) VirtualMachineInStatePredicateFactory nodeSuspendedPredicate,
|
||||||
|
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
|
||||||
|
Function<VMImage, Image> vmImageToImage, @Named(TIMEOUT_RESOURCE_DELETED) Predicate<URI> resourceDeleted,
|
||||||
|
CustomImageToVMImage customImagetoVmImage) {
|
||||||
|
this.api = api;
|
||||||
|
this.imageAvailablePredicate = imageAvailablePredicate;
|
||||||
|
this.nodeSuspendedPredicate = nodeSuspendedPredicate;
|
||||||
|
this.userExecutor = userExecutor;
|
||||||
|
this.vmImageToImage = vmImageToImage;
|
||||||
|
this.resourceDeleted = resourceDeleted;
|
||||||
|
this.customImagetoVmImage = customImagetoVmImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ImageTemplate buildImageTemplateFromNode(String name, String id) {
|
||||||
|
return new ImageTemplateBuilder.CloneImageTemplateBuilder().nodeId(id).name(name.toLowerCase()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListenableFuture<Image> createImage(ImageTemplate template) {
|
||||||
|
final CloneImageTemplate cloneTemplate = (CloneImageTemplate) template;
|
||||||
|
final ResourceGroupAndName resourceGroupAndName = fromSlashEncoded(cloneTemplate.getSourceNodeId());
|
||||||
|
final String resourceGroupName = resourceGroupAndName.resourceGroup();
|
||||||
|
final String vmName = resourceGroupAndName.name();
|
||||||
|
|
||||||
|
final VirtualMachine vm = api.getVirtualMachineApi(resourceGroupName).get(vmName);
|
||||||
|
final IdReference vmIdRef = IdReference.create(vm.id());
|
||||||
|
|
||||||
|
logger.debug(">> stopping node %s...", cloneTemplate.getSourceNodeId());
|
||||||
|
api.getVirtualMachineApi(resourceGroupName).stop(vmName);
|
||||||
|
checkState(nodeSuspendedPredicate.create(resourceGroupName).apply(vmName),
|
||||||
|
"Node %s was not suspended within the configured time limit", cloneTemplate.getSourceNodeId());
|
||||||
|
|
||||||
|
return userExecutor.submit(new Callable<Image>() {
|
||||||
|
@Override
|
||||||
|
public Image call() throws Exception {
|
||||||
|
logger.debug(">> generalizing virtal machine %s...", vmName);
|
||||||
|
|
||||||
|
api.getVirtualMachineApi(resourceGroupName).generalize(vmName);
|
||||||
|
|
||||||
|
org.jclouds.azurecompute.arm.domain.Image imageFromVM = api.getVirtualMachineImageApi(resourceGroupName)
|
||||||
|
.createOrUpdate(cloneTemplate.getName(), vm.location(),
|
||||||
|
ImageProperties.builder().sourceVirtualMachine(vmIdRef).build());
|
||||||
|
|
||||||
|
checkState(imageAvailablePredicate.create(resourceGroupName).apply(imageFromVM.name()),
|
||||||
|
"Image for node %s was not created within the configured time limit", cloneTemplate.getName());
|
||||||
|
|
||||||
|
return compose(vmImageToImage, customImagetoVmImage).apply(imageFromVM);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteImage(String id) {
|
||||||
|
VMImage image = VMImage.decodeFieldsFromUniqueId(id);
|
||||||
|
checkArgument(image.custom(), "Only custom images can be deleted");
|
||||||
|
|
||||||
|
logger.debug(">> deleting image %s", id);
|
||||||
|
URI uri = api.getVirtualMachineImageApi(image.resourceGroup()).delete(image.name());
|
||||||
|
return resourceDeleted.apply(uri);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,345 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.extensions;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static com.google.common.base.Predicates.equalTo;
|
||||||
|
import static com.google.common.base.Predicates.notNull;
|
||||||
|
import static com.google.common.collect.Iterables.any;
|
||||||
|
import static com.google.common.collect.Iterables.filter;
|
||||||
|
import static com.google.common.collect.Iterables.transform;
|
||||||
|
import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TIMEOUT_RESOURCE_DELETED;
|
||||||
|
import static org.jclouds.azurecompute.arm.domain.IdReference.extractName;
|
||||||
|
import static org.jclouds.azurecompute.arm.domain.IdReference.extractResourceGroup;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.AzureComputeApi;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.SecurityGroupAvailablePredicateFactory;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndName;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCard;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkProfile.NetworkInterface;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroup;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroupProperties;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityRule;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Access;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Direction;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Protocol;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.ResourceGroup;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VirtualMachine;
|
||||||
|
import org.jclouds.azurecompute.arm.features.NetworkSecurityGroupApi;
|
||||||
|
import org.jclouds.azurecompute.arm.features.NetworkSecurityRuleApi;
|
||||||
|
import org.jclouds.compute.domain.SecurityGroup;
|
||||||
|
import org.jclouds.compute.domain.SecurityGroupBuilder;
|
||||||
|
import org.jclouds.compute.extensions.SecurityGroupExtension;
|
||||||
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.location.Region;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.net.domain.IpPermission;
|
||||||
|
import org.jclouds.net.domain.IpProtocol;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
import com.google.common.collect.Ordering;
|
||||||
|
|
||||||
|
public class AzureComputeSecurityGroupExtension implements SecurityGroupExtension {
|
||||||
|
@Resource
|
||||||
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
private final AzureComputeApi api;
|
||||||
|
private final Function<NetworkSecurityGroup, SecurityGroup> securityGroupConverter;
|
||||||
|
private final SecurityGroupAvailablePredicateFactory securityGroupAvailable;
|
||||||
|
private final Predicate<URI> resourceDeleted;
|
||||||
|
private final LoadingCache<String, ResourceGroup> defaultResourceGroup;
|
||||||
|
private final Supplier<Set<String>> regionIds;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
AzureComputeSecurityGroupExtension(AzureComputeApi api,
|
||||||
|
Function<NetworkSecurityGroup, SecurityGroup> groupConverter,
|
||||||
|
SecurityGroupAvailablePredicateFactory securityRuleAvailable,
|
||||||
|
@Named(TIMEOUT_RESOURCE_DELETED) Predicate<URI> resourceDeleted,
|
||||||
|
LoadingCache<String, ResourceGroup> defaultResourceGroup,
|
||||||
|
@Region Supplier<Set<String>> regionIds) {
|
||||||
|
this.api = api;
|
||||||
|
this.securityGroupConverter = groupConverter;
|
||||||
|
this.securityGroupAvailable = securityRuleAvailable;
|
||||||
|
this.resourceDeleted = resourceDeleted;
|
||||||
|
this.defaultResourceGroup = defaultResourceGroup;
|
||||||
|
this.regionIds = regionIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<SecurityGroup> listSecurityGroupsInLocation(Location location) {
|
||||||
|
return securityGroupsInLocations(ImmutableSet.of(location.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<SecurityGroup> listSecurityGroups() {
|
||||||
|
return securityGroupsInLocations(regionIds.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<SecurityGroup> securityGroupsInLocations(final Set<String> locations) {
|
||||||
|
List<SecurityGroup> securityGroups = new ArrayList<SecurityGroup>();
|
||||||
|
for (ResourceGroup rg : api.getResourceGroupApi().list()) {
|
||||||
|
securityGroups.addAll(securityGroupsInResourceGroup(rg.name()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ImmutableSet.copyOf(filter(securityGroups, new Predicate<SecurityGroup>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(SecurityGroup input) {
|
||||||
|
return locations.contains(input.getLocation().getId());
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<SecurityGroup> securityGroupsInResourceGroup(String resourceGroup) {
|
||||||
|
List<NetworkSecurityGroup> networkGroups = api.getNetworkSecurityGroupApi(resourceGroup).list();
|
||||||
|
return ImmutableSet.copyOf(transform(filter(networkGroups, notNull()), securityGroupConverter));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<SecurityGroup> listSecurityGroupsForNode(String nodeId) {
|
||||||
|
logger.debug(">> getting security groups for node %s...", nodeId);
|
||||||
|
|
||||||
|
final ResourceGroupAndName resourceGroupAndName = ResourceGroupAndName.fromSlashEncoded(nodeId);
|
||||||
|
|
||||||
|
VirtualMachine vm = api.getVirtualMachineApi(resourceGroupAndName.resourceGroup()).get(
|
||||||
|
resourceGroupAndName.name());
|
||||||
|
if (vm == null) {
|
||||||
|
throw new IllegalArgumentException("Node " + nodeId + " was not found");
|
||||||
|
}
|
||||||
|
List<NetworkInterface> networkInterfaces = vm.properties().networkProfile().networkInterfaces();
|
||||||
|
List<NetworkSecurityGroup> networkGroups = new ArrayList<NetworkSecurityGroup>();
|
||||||
|
|
||||||
|
for (NetworkInterface networkInterfaceCardIdReference : networkInterfaces) {
|
||||||
|
String nicName = extractName(networkInterfaceCardIdReference.id());
|
||||||
|
String nicResourceGroup = extractResourceGroup(networkInterfaceCardIdReference.id());
|
||||||
|
NetworkInterfaceCard card = api.getNetworkInterfaceCardApi(nicResourceGroup).get(nicName);
|
||||||
|
if (card != null && card.properties().networkSecurityGroup() != null) {
|
||||||
|
String secGroupName = card.properties().networkSecurityGroup().name();
|
||||||
|
String sgResourceGroup = card.properties().networkSecurityGroup().resourceGroup();
|
||||||
|
NetworkSecurityGroup group = api.getNetworkSecurityGroupApi(sgResourceGroup).get(secGroupName);
|
||||||
|
networkGroups.add(group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ImmutableSet.copyOf(transform(filter(networkGroups, notNull()), securityGroupConverter));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SecurityGroup getSecurityGroupById(String id) {
|
||||||
|
logger.debug(">> getting security group %s...", id);
|
||||||
|
final ResourceGroupAndName resourceGroupAndName = ResourceGroupAndName.fromSlashEncoded(id);
|
||||||
|
NetworkSecurityGroup securityGroup = api.getNetworkSecurityGroupApi(resourceGroupAndName.resourceGroup()).get(
|
||||||
|
resourceGroupAndName.name());
|
||||||
|
return securityGroup == null ? null : securityGroupConverter.apply(securityGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SecurityGroup createSecurityGroup(String name, Location location) {
|
||||||
|
ResourceGroup resourceGroup = defaultResourceGroup.getUnchecked(location.getId());
|
||||||
|
|
||||||
|
logger.debug(">> creating security group %s in %s...", name, location);
|
||||||
|
|
||||||
|
SecurityGroupBuilder builder = new SecurityGroupBuilder();
|
||||||
|
builder.name(name);
|
||||||
|
builder.location(location);
|
||||||
|
|
||||||
|
NetworkSecurityGroup sg = api.getNetworkSecurityGroupApi(resourceGroup.name()).createOrUpdate(name,
|
||||||
|
location.getId(), null, NetworkSecurityGroupProperties.builder().build());
|
||||||
|
|
||||||
|
checkState(securityGroupAvailable.create(resourceGroup.name()).apply(name),
|
||||||
|
"Security group was not created in the configured timeout");
|
||||||
|
|
||||||
|
return securityGroupConverter.apply(sg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removeSecurityGroup(String id) {
|
||||||
|
logger.debug(">> deleting security group %s...", id);
|
||||||
|
|
||||||
|
final ResourceGroupAndName resourceGroupAndName = ResourceGroupAndName.fromSlashEncoded(id);
|
||||||
|
URI uri = api.getNetworkSecurityGroupApi(resourceGroupAndName.resourceGroup())
|
||||||
|
.delete(resourceGroupAndName.name());
|
||||||
|
|
||||||
|
// https://docs.microsoft.com/en-us/rest/api/network/virtualnetwork/delete-a-network-security-group
|
||||||
|
if (uri != null) {
|
||||||
|
// 202-Accepted if resource exists and the request is accepted.
|
||||||
|
return resourceDeleted.apply(uri);
|
||||||
|
} else {
|
||||||
|
// 204-No Content if resource does not exist.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SecurityGroup addIpPermission(IpPermission ipPermission, SecurityGroup group) {
|
||||||
|
return addIpPermission(ipPermission.getIpProtocol(), ipPermission.getFromPort(), ipPermission.getToPort(),
|
||||||
|
ipPermission.getTenantIdGroupNamePairs(), ipPermission.getCidrBlocks(), ipPermission.getGroupIds(), group);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SecurityGroup removeIpPermission(IpPermission ipPermission, SecurityGroup group) {
|
||||||
|
return removeIpPermission(ipPermission.getIpProtocol(), ipPermission.getFromPort(), ipPermission.getToPort(),
|
||||||
|
ipPermission.getTenantIdGroupNamePairs(), ipPermission.getCidrBlocks(), ipPermission.getGroupIds(), group);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SecurityGroup addIpPermission(IpProtocol protocol, int startPort, int endPort,
|
||||||
|
Multimap<String, String> tenantIdGroupNamePairs, Iterable<String> ipRanges, Iterable<String> groupIds,
|
||||||
|
SecurityGroup group) {
|
||||||
|
String portRange = startPort + "-" + endPort;
|
||||||
|
String ruleName = "ingress-" + protocol.name().toLowerCase() + "-" + portRange;
|
||||||
|
|
||||||
|
logger.debug(">> adding ip permission [%s] to %s...", ruleName, group.getName());
|
||||||
|
|
||||||
|
// TODO: Support Azure network tags somehow?
|
||||||
|
|
||||||
|
final ResourceGroupAndName resourceGroupAndName = ResourceGroupAndName.fromSlashEncoded(group.getId());
|
||||||
|
|
||||||
|
NetworkSecurityGroupApi groupApi = api.getNetworkSecurityGroupApi(resourceGroupAndName.resourceGroup());
|
||||||
|
NetworkSecurityGroup networkSecurityGroup = groupApi.get(resourceGroupAndName.name());
|
||||||
|
|
||||||
|
if (networkSecurityGroup == null) {
|
||||||
|
throw new IllegalArgumentException("Security group " + group.getName() + " was not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkSecurityRuleApi ruleApi = api.getNetworkSecurityRuleApi(resourceGroupAndName.resourceGroup(), networkSecurityGroup.name());
|
||||||
|
int nextPriority = getRuleStartingPriority(networkSecurityGroup);
|
||||||
|
|
||||||
|
for (String ipRange : ipRanges) {
|
||||||
|
NetworkSecurityRuleProperties properties = NetworkSecurityRuleProperties.builder()
|
||||||
|
.protocol(Protocol.fromValue(protocol.name()))
|
||||||
|
.sourceAddressPrefix(ipRange)
|
||||||
|
.sourcePortRange("*")
|
||||||
|
.destinationAddressPrefix("*")
|
||||||
|
.destinationPortRange(portRange)
|
||||||
|
.direction(Direction.Inbound)
|
||||||
|
.access(Access.Allow)
|
||||||
|
.priority(nextPriority++)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
logger.debug(">> creating network security rule %s for %s...", ruleName, ipRange);
|
||||||
|
|
||||||
|
ruleApi.createOrUpdate(ruleName, properties);
|
||||||
|
|
||||||
|
checkState(
|
||||||
|
securityGroupAvailable.create(resourceGroupAndName.resourceGroup()).apply(networkSecurityGroup.name()),
|
||||||
|
"Security group was not updated in the configured timeout");
|
||||||
|
}
|
||||||
|
|
||||||
|
return getSecurityGroupById(group.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SecurityGroup removeIpPermission(final IpProtocol protocol, int startPort, int endPort,
|
||||||
|
Multimap<String, String> tenantIdGroupNamePairs, final Iterable<String> ipRanges, Iterable<String> groupIds,
|
||||||
|
SecurityGroup group) {
|
||||||
|
final String portRange = startPort + "-" + endPort;
|
||||||
|
String ruleName = "ingress-" + protocol.name().toLowerCase() + "-" + portRange;
|
||||||
|
|
||||||
|
logger.debug(">> deleting ip permissions matching [%s] from %s...", ruleName, group.getName());
|
||||||
|
|
||||||
|
final ResourceGroupAndName resourceGroupAndName = ResourceGroupAndName.fromSlashEncoded(group.getId());
|
||||||
|
|
||||||
|
NetworkSecurityGroupApi groupApi = api.getNetworkSecurityGroupApi(resourceGroupAndName.resourceGroup());
|
||||||
|
NetworkSecurityGroup networkSecurityGroup = groupApi.get(resourceGroupAndName.name());
|
||||||
|
|
||||||
|
if (networkSecurityGroup == null) {
|
||||||
|
throw new IllegalArgumentException("Security group " + group.getName() + " was not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkSecurityRuleApi ruleApi = api.getNetworkSecurityRuleApi(resourceGroupAndName.resourceGroup(),
|
||||||
|
networkSecurityGroup.name());
|
||||||
|
Iterable<NetworkSecurityRule> rules = filter(ruleApi.list(), new Predicate<NetworkSecurityRule>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(NetworkSecurityRule input) {
|
||||||
|
NetworkSecurityRuleProperties props = input.properties();
|
||||||
|
return Objects.equal(portRange, props.destinationPortRange())
|
||||||
|
&& Objects.equal(Protocol.fromValue(protocol.name()), props.protocol())
|
||||||
|
&& Objects.equal(Direction.Inbound, props.direction()) //
|
||||||
|
&& Objects.equal(Access.Allow, props.access())
|
||||||
|
&& any(ipRanges, equalTo(props.sourceAddressPrefix().replace("*", "0.0.0.0/0")));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (NetworkSecurityRule matchingRule : rules) {
|
||||||
|
logger.debug(">> deleting network security rule %s from %s...", matchingRule.name(), group.getName());
|
||||||
|
ruleApi.delete(matchingRule.name());
|
||||||
|
checkState(
|
||||||
|
securityGroupAvailable.create(resourceGroupAndName.resourceGroup()).apply(networkSecurityGroup.name()),
|
||||||
|
"Security group was not updated in the configured timeout");
|
||||||
|
}
|
||||||
|
|
||||||
|
return getSecurityGroupById(group.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsTenantIdGroupNamePairs() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsTenantIdGroupIdPairs() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsGroupIds() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsPortRangesForGroups() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsExclusionCidrBlocks() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getRuleStartingPriority(NetworkSecurityGroup securityGroup) {
|
||||||
|
List<NetworkSecurityRule> existingRules = securityGroup.properties().securityRules();
|
||||||
|
return existingRules.isEmpty() ? 100 : rulesByPriority().max(existingRules).properties().priority() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Ordering<NetworkSecurityRule> rulesByPriority() {
|
||||||
|
return new Ordering<NetworkSecurityRule>() {
|
||||||
|
@Override
|
||||||
|
public int compare(NetworkSecurityRule left, NetworkSecurityRule right) {
|
||||||
|
return left.properties().priority() - right.properties().priority();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.functions;
|
||||||
|
|
||||||
|
import static org.jclouds.azurecompute.arm.domain.IdReference.extractResourceGroup;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Image;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VMImage;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
public class CustomImageToVMImage implements Function<Image, VMImage> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VMImage apply(Image input) {
|
||||||
|
return VMImage.customImage().resourceGroup(extractResourceGroup(input.id())).customImageId(input.id()).location(input.location()).name(input.name())
|
||||||
|
.offer(input.properties().storageProfile().osDisk().osType()).build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.functions;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Location;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Region;
|
||||||
|
import org.jclouds.domain.LocationBuilder;
|
||||||
|
import org.jclouds.domain.LocationScope;
|
||||||
|
import org.jclouds.location.suppliers.all.JustProvider;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts an Location into a Location.
|
||||||
|
*/
|
||||||
|
@Singleton
|
||||||
|
public class LocationToLocation implements Function<Location, org.jclouds.domain.Location> {
|
||||||
|
|
||||||
|
private final JustProvider justProvider;
|
||||||
|
|
||||||
|
// allow us to lazy discover the provider of a resource
|
||||||
|
@Inject
|
||||||
|
LocationToLocation(JustProvider justProvider) {
|
||||||
|
this.justProvider = justProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public org.jclouds.domain.Location apply(final Location location) {
|
||||||
|
final LocationBuilder builder = new LocationBuilder();
|
||||||
|
builder.id(location.name());
|
||||||
|
builder.description(location.displayName());
|
||||||
|
builder.parent(getOnlyElement(justProvider.get()));
|
||||||
|
builder.scope(LocationScope.REGION);
|
||||||
|
final Region region = Region.byName(location.displayName());
|
||||||
|
if (region != null) {
|
||||||
|
builder.iso3166Codes(ImmutableSet.of(region.iso3166Code()));
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.functions;
|
||||||
|
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.RESOURCENAME_DELIMITER;
|
||||||
|
import static org.jclouds.compute.config.ComputeServiceProperties.RESOURCENAME_PREFIX;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the resource group for the current location.
|
||||||
|
*/
|
||||||
|
public class LocationToResourceGroupName implements Function<String, String> {
|
||||||
|
|
||||||
|
private final String prefix;
|
||||||
|
private final char delimiter;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
LocationToResourceGroupName(@Named(RESOURCENAME_PREFIX) String prefix, @Named(RESOURCENAME_DELIMITER) char delimiter) {
|
||||||
|
this.prefix = prefix;
|
||||||
|
this.delimiter = delimiter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String apply(String input) {
|
||||||
|
return String.format("%s%s%s", prefix, delimiter, input);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.functions;
|
||||||
|
|
||||||
|
import static com.google.common.collect.Iterables.filter;
|
||||||
|
import static com.google.common.collect.Iterables.transform;
|
||||||
|
import static org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndName.fromResourceGroupAndName;
|
||||||
|
import static org.jclouds.azurecompute.arm.compute.functions.NetworkSecurityRuleToIpPermission.InboundRule;
|
||||||
|
import static org.jclouds.azurecompute.arm.compute.functions.VirtualMachineToNodeMetadata.getLocation;
|
||||||
|
import static org.jclouds.azurecompute.arm.domain.IdReference.extractResourceGroup;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroup;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityRule;
|
||||||
|
import org.jclouds.collect.Memoized;
|
||||||
|
import org.jclouds.compute.domain.SecurityGroup;
|
||||||
|
import org.jclouds.compute.domain.SecurityGroupBuilder;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.net.domain.IpPermission;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public class NetworkSecurityGroupToSecurityGroup implements Function<NetworkSecurityGroup, SecurityGroup> {
|
||||||
|
private final Function<NetworkSecurityRule, IpPermission> ruleToPermission;
|
||||||
|
private final Supplier<Set<? extends Location>> locations;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
NetworkSecurityGroupToSecurityGroup(Function<NetworkSecurityRule, IpPermission> ruleToPermission,
|
||||||
|
@Memoized Supplier<Set<? extends Location>> locations) {
|
||||||
|
this.ruleToPermission = ruleToPermission;
|
||||||
|
this.locations = locations;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SecurityGroup apply(NetworkSecurityGroup input) {
|
||||||
|
SecurityGroupBuilder builder = new SecurityGroupBuilder();
|
||||||
|
|
||||||
|
builder.id(fromResourceGroupAndName(extractResourceGroup(input.id()), input.name()).slashEncode());
|
||||||
|
builder.providerId(input.id());
|
||||||
|
builder.name(input.name());
|
||||||
|
builder.location(getLocation(locations, input.location()));
|
||||||
|
|
||||||
|
if (input.properties().securityRules() != null) {
|
||||||
|
// We just support security groups that allow traffic to a set of
|
||||||
|
// targets. We don't support deny rules or origin based rules in the
|
||||||
|
// security group api.
|
||||||
|
builder.ipPermissions(transform(filter(input.properties().securityRules(), InboundRule), ruleToPermission));
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.functions;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityRule;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Access;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Direction;
|
||||||
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.net.domain.IpPermission;
|
||||||
|
import org.jclouds.net.domain.IpProtocol;
|
||||||
|
import org.jclouds.net.util.IpPermissions;
|
||||||
|
import org.jclouds.net.util.IpPermissions.PortSelection;
|
||||||
|
import org.jclouds.net.util.IpPermissions.ToSourceSelection;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public class NetworkSecurityRuleToIpPermission implements Function<NetworkSecurityRule, IpPermission> {
|
||||||
|
|
||||||
|
public static final Predicate<NetworkSecurityRule> InboundRule = new Predicate<NetworkSecurityRule>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(NetworkSecurityRule input) {
|
||||||
|
return Direction.Inbound.equals(input.properties().direction())
|
||||||
|
&& Access.Allow.equals(input.properties().access());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IpPermission apply(final NetworkSecurityRule rule) {
|
||||||
|
if (!InboundRule.apply(rule)) {
|
||||||
|
logger.warn(">> ignoring non-inbound network security rule %s...", rule.name());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
IpPermission permissions = IpPermissions.permit(IpProtocol.fromValue(rule.properties().protocol().name()));
|
||||||
|
|
||||||
|
String portRange = rule.properties().destinationPortRange();
|
||||||
|
if (!"*".equals(portRange)) {
|
||||||
|
String[] range = portRange.split("-"); // One single element if it is a single port
|
||||||
|
permissions = PortSelection.class.cast(permissions).fromPort(Integer.parseInt(range[0]))
|
||||||
|
.to(Integer.parseInt(range[range.length - 1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!"*".equals(rule.properties().sourceAddressPrefix())) {
|
||||||
|
permissions = ToSourceSelection.class.cast(permissions).originatingFromCidrBlock(
|
||||||
|
rule.properties().sourceAddressPrefix());
|
||||||
|
}
|
||||||
|
|
||||||
|
return permissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,94 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.functions;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.AzureComputeApi;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.options.AzureTemplateOptions;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.AvailabilitySet;
|
||||||
|
import org.jclouds.compute.domain.Template;
|
||||||
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public class TemplateToAvailabilitySet implements Function<Template, AvailabilitySet> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
private final AzureComputeApi api;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
TemplateToAvailabilitySet(AzureComputeApi api) {
|
||||||
|
this.api = api;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public AvailabilitySet apply(final Template input) {
|
||||||
|
checkArgument(input.getOptions() instanceof AzureTemplateOptions, "An AzureTemplateOptions object is required");
|
||||||
|
AzureTemplateOptions options = input.getOptions().as(AzureTemplateOptions.class);
|
||||||
|
|
||||||
|
AvailabilitySet availabilitySet = null;
|
||||||
|
String location = input.getLocation().getId();
|
||||||
|
String resourceGroup = options.getResourceGroup();
|
||||||
|
|
||||||
|
if (options.getAvailabilitySetName() != null) {
|
||||||
|
availabilitySet = api.getAvailabilitySetApi(resourceGroup).get(options.getAvailabilitySetName());
|
||||||
|
|
||||||
|
checkArgument(availabilitySet != null, "No availability set with name '%s' was found", options.getAvailabilitySetName());
|
||||||
|
checkArgument(location.equals(availabilitySet.location()), "The availability set %s does not belong to location %s",
|
||||||
|
options.getAvailabilitySetName(), location);
|
||||||
|
|
||||||
|
} else if (options.getAvailabilitySet() != null) {
|
||||||
|
availabilitySet = api.getAvailabilitySetApi(resourceGroup).get(options.getAvailabilitySet().name());
|
||||||
|
|
||||||
|
if (availabilitySet != null) {
|
||||||
|
checkArgument(location.equals(availabilitySet.location()), "The availability set %s does not belong to location %s",
|
||||||
|
options.getAvailabilitySet().name(), location);
|
||||||
|
} else {
|
||||||
|
Map<String, String> tags = new HashMap<String, String>();
|
||||||
|
if (options.getAvailabilitySet().tags() != null) {
|
||||||
|
tags.putAll(options.getAvailabilitySet().tags());
|
||||||
|
}
|
||||||
|
tags.put("jclouds", options.getAvailabilitySet().name());
|
||||||
|
|
||||||
|
logger.debug(">> creating availability set [%s]", options.getAvailabilitySet().name());
|
||||||
|
|
||||||
|
availabilitySet = api.getAvailabilitySetApi(resourceGroup).createOrUpdate(
|
||||||
|
options.getAvailabilitySet().name(), options.getAvailabilitySet().sku(), location, tags,
|
||||||
|
options.getAvailabilitySet().properties());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return availabilitySet;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.functions;
|
||||||
|
|
||||||
|
import static org.jclouds.azurecompute.arm.compute.domain.LocationAndName.fromLocationAndName;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VMHardware;
|
||||||
|
import org.jclouds.collect.Memoized;
|
||||||
|
import org.jclouds.compute.domain.Hardware;
|
||||||
|
import org.jclouds.compute.domain.HardwareBuilder;
|
||||||
|
import org.jclouds.compute.domain.Processor;
|
||||||
|
import org.jclouds.compute.domain.Volume;
|
||||||
|
import org.jclouds.compute.domain.VolumeBuilder;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.location.predicates.LocationPredicates;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.collect.FluentIterable;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
public class VMHardwareToHardware implements Function<VMHardware, Hardware> {
|
||||||
|
|
||||||
|
private final Supplier<Set<? extends Location>> locations;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
VMHardwareToHardware(@Memoized final Supplier<Set<? extends Location>> locations) {
|
||||||
|
this.locations = locations;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Hardware apply(VMHardware from) {
|
||||||
|
final HardwareBuilder builder = new HardwareBuilder()
|
||||||
|
.name(from.name())
|
||||||
|
.providerId(from.name())
|
||||||
|
.id(fromLocationAndName(from.location(), from.name()).slashEncode())
|
||||||
|
.processors(ImmutableList.of(new Processor(from.numberOfCores(), 2)))
|
||||||
|
.ram(from.memoryInMB())
|
||||||
|
.location(FluentIterable.from(locations.get())
|
||||||
|
.firstMatch(LocationPredicates.idEquals(from.location()))
|
||||||
|
.get());
|
||||||
|
|
||||||
|
// No id or providerId from Azure
|
||||||
|
if (from.resourceDiskSizeInMB() != null) {
|
||||||
|
builder.volume(new VolumeBuilder()
|
||||||
|
.size(Float.valueOf(from.resourceDiskSizeInMB()))
|
||||||
|
.type(Volume.Type.LOCAL)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
if (from.osDiskSizeInMB() != null) {
|
||||||
|
builder.volume(new VolumeBuilder()
|
||||||
|
.size(Float.valueOf(from.osDiskSizeInMB()))
|
||||||
|
.type(Volume.Type.LOCAL)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
ImmutableMap.Builder<String, String> metadata = ImmutableMap.builder();
|
||||||
|
metadata.put("maxDataDiskCount", String.valueOf(from.maxDataDiskCount()));
|
||||||
|
builder.userMetadata(metadata.build());
|
||||||
|
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,157 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.functions;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.google.common.collect.Iterables.tryFind;
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
|
import static org.jclouds.location.predicates.LocationPredicates.idEquals;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.compute.extensions.AzureComputeImageExtension;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Plan;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VMImage;
|
||||||
|
import org.jclouds.collect.Memoized;
|
||||||
|
import org.jclouds.compute.domain.Image;
|
||||||
|
import org.jclouds.compute.domain.ImageBuilder;
|
||||||
|
import org.jclouds.compute.domain.OperatingSystem;
|
||||||
|
import org.jclouds.compute.domain.OsFamily;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Optional;
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.collect.FluentIterable;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
public class VMImageToImage implements Function<VMImage, Image> {
|
||||||
|
|
||||||
|
private static final Map<String, OsFamily> OTHER_OS_MAP = ImmutableMap.<String, OsFamily> builder()
|
||||||
|
.put("openlogic", OsFamily.CENTOS)
|
||||||
|
.put("win", OsFamily.WINDOWS)
|
||||||
|
.put("sles", OsFamily.SUSE)
|
||||||
|
.put("oracle-linux", OsFamily.OEL)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
private final Supplier<Set<? extends org.jclouds.domain.Location>> locations;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
VMImageToImage(@Memoized Supplier<Set<? extends Location>> locations) {
|
||||||
|
this.locations = locations;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Image apply(final VMImage image) {
|
||||||
|
final ImageBuilder builder = new ImageBuilder();
|
||||||
|
addMarketplacePlanToMetadataIfPresent(builder, image);
|
||||||
|
|
||||||
|
Location location = FluentIterable.from(locations.get()).firstMatch(idEquals(image.location())).get();
|
||||||
|
|
||||||
|
if (image.custom()) {
|
||||||
|
builder
|
||||||
|
.id(image.encodeFieldsToUniqueIdCustom())
|
||||||
|
.providerId(image.customImageId())
|
||||||
|
.name(image.name())
|
||||||
|
.location(location)
|
||||||
|
.description(image.group())
|
||||||
|
.status(Image.Status.AVAILABLE)
|
||||||
|
.version("latest");
|
||||||
|
} else {
|
||||||
|
builder
|
||||||
|
.id(image.encodeFieldsToUniqueId())
|
||||||
|
.providerId(image.publisher())
|
||||||
|
.name(image.offer())
|
||||||
|
.location(location)
|
||||||
|
.description(image.sku())
|
||||||
|
.status(Image.Status.AVAILABLE)
|
||||||
|
.version(image.sku());
|
||||||
|
}
|
||||||
|
|
||||||
|
final OperatingSystem.Builder osBuilder = osFamily().apply(image);
|
||||||
|
builder.operatingSystem(osBuilder.build());
|
||||||
|
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addMarketplacePlanToMetadataIfPresent(ImageBuilder builder, VMImage image) {
|
||||||
|
if (image.versionProperties() != null && image.versionProperties().plan() != null) {
|
||||||
|
// Store the plan information in the metadata so the adapter can
|
||||||
|
// properly configure it when deploying images from the marketplace
|
||||||
|
Plan plan = image.versionProperties().plan();
|
||||||
|
builder.userMetadata(ImmutableMap.of("publisher", plan.publisher(), "name", plan.name(), "product",
|
||||||
|
plan.product()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static Plan getMarketplacePlanFromImageMetadata(Image image) {
|
||||||
|
Map<String, String> imageMetadata = image.getUserMetadata();
|
||||||
|
return imageMetadata.containsKey("product") ? Plan.create(imageMetadata.get("publisher"),
|
||||||
|
imageMetadata.get("name"), imageMetadata.get("product")) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Function<VMImage, OperatingSystem.Builder> osFamily() {
|
||||||
|
return new Function<VMImage, OperatingSystem.Builder>() {
|
||||||
|
@Override
|
||||||
|
public OperatingSystem.Builder apply(final VMImage image) {
|
||||||
|
final String label = checkNotNull(image.offer(), "offer").toLowerCase();
|
||||||
|
OsFamily family = findInStandardFamilies(label).or(findInOtherOSMap(label)).or(OsFamily.UNRECOGNIZED);
|
||||||
|
|
||||||
|
// Fallback to generic operating system type
|
||||||
|
if (OsFamily.UNRECOGNIZED == family && image.versionProperties() != null
|
||||||
|
&& image.versionProperties().osDiskImage() != null
|
||||||
|
&& image.versionProperties().osDiskImage().operatingSystem() != null) {
|
||||||
|
family = OsFamily.fromValue(image.versionProperties().osDiskImage().operatingSystem().toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
// only 64bit OS images are supported by Azure ARM
|
||||||
|
return OperatingSystem.builder().family(family).is64Bit(true)
|
||||||
|
.description(image.custom() ? AzureComputeImageExtension.CUSTOM_IMAGE_OFFER : image.sku())
|
||||||
|
.version(image.custom() ? "latest" : image.sku());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Optional<OsFamily> findInStandardFamilies(final String label) {
|
||||||
|
return tryFind(asList(OsFamily.values()), new Predicate<OsFamily>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(OsFamily input) {
|
||||||
|
return label.contains(input.value());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Optional<OsFamily> findInOtherOSMap(final String label) {
|
||||||
|
return tryFind(OTHER_OS_MAP.keySet(), new Predicate<String>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(String input) {
|
||||||
|
return label.contains(input);
|
||||||
|
}
|
||||||
|
}).transform(new Function<String, OsFamily>() {
|
||||||
|
@Override
|
||||||
|
public OsFamily apply(String input) {
|
||||||
|
return OTHER_OS_MAP.get(input);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,208 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.functions;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Strings.nullToEmpty;
|
||||||
|
import static com.google.common.collect.Iterables.find;
|
||||||
|
import static org.jclouds.azurecompute.arm.compute.AzureComputeServiceAdapter.GROUP_KEY;
|
||||||
|
import static org.jclouds.azurecompute.arm.compute.domain.LocationAndName.fromLocationAndName;
|
||||||
|
import static org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndName.fromResourceGroupAndName;
|
||||||
|
import static org.jclouds.azurecompute.arm.domain.IdReference.extractName;
|
||||||
|
import static org.jclouds.azurecompute.arm.domain.IdReference.extractResourceGroup;
|
||||||
|
import static org.jclouds.compute.util.ComputeServiceUtils.addMetadataAndParseTagsFromCommaDelimitedValue;
|
||||||
|
import static org.jclouds.location.predicates.LocationPredicates.idEquals;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.AzureComputeApi;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.domain.LocationAndName;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.functions.VirtualMachineToStatus.StatusAndBackendStatus;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.IdReference;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.IpConfiguration;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCard;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkProfile.NetworkInterface;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.PublicIPAddress;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.StorageProfile;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VirtualMachine;
|
||||||
|
import org.jclouds.collect.Memoized;
|
||||||
|
import org.jclouds.compute.domain.Hardware;
|
||||||
|
import org.jclouds.compute.domain.Image;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||||
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
|
import org.jclouds.compute.suppliers.ImageCacheSupplier;
|
||||||
|
import org.jclouds.domain.Credentials;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Optional;
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
public class VirtualMachineToNodeMetadata implements Function<VirtualMachine, NodeMetadata> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
private final AzureComputeApi api;
|
||||||
|
private final GroupNamingConvention nodeNamingConvention;
|
||||||
|
private final Supplier<Set<? extends Location>> locations;
|
||||||
|
private final Supplier<Map<String, ? extends Hardware>> hardwares;
|
||||||
|
private final ImageCacheSupplier imageCache;
|
||||||
|
private final VirtualMachineToStatus virtualMachineToStatus;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
VirtualMachineToNodeMetadata(AzureComputeApi api, GroupNamingConvention.Factory namingConvention,
|
||||||
|
Supplier<Map<String, ? extends Hardware>> hardwares, @Memoized Supplier<Set<? extends Location>> locations,
|
||||||
|
Map<String, Credentials> credentialStore, @Memoized Supplier<Set<? extends Image>> imageCache,
|
||||||
|
VirtualMachineToStatus virtualMachineToStatus) {
|
||||||
|
this.api = api;
|
||||||
|
this.nodeNamingConvention = namingConvention.createWithoutPrefix();
|
||||||
|
this.locations = locations;
|
||||||
|
this.hardwares = hardwares;
|
||||||
|
this.virtualMachineToStatus = virtualMachineToStatus;
|
||||||
|
checkArgument(imageCache instanceof ImageCacheSupplier,
|
||||||
|
"This provider needs an instance of the ImageCacheSupplier");
|
||||||
|
this.imageCache = (ImageCacheSupplier) imageCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NodeMetadata apply(VirtualMachine virtualMachine) {
|
||||||
|
NodeMetadataBuilder builder = new NodeMetadataBuilder();
|
||||||
|
builder.id(fromResourceGroupAndName(extractResourceGroup(virtualMachine.id()), virtualMachine.name())
|
||||||
|
.slashEncode());
|
||||||
|
builder.providerId(virtualMachine.id());
|
||||||
|
builder.name(virtualMachine.name());
|
||||||
|
builder.hostname(virtualMachine.name());
|
||||||
|
|
||||||
|
StatusAndBackendStatus status = virtualMachineToStatus.apply(virtualMachine);
|
||||||
|
builder.status(status.status());
|
||||||
|
builder.backendStatus(status.backendStatus());
|
||||||
|
|
||||||
|
builder.publicAddresses(getPublicIpAddresses(virtualMachine.properties().networkProfile().networkInterfaces()));
|
||||||
|
builder.privateAddresses(getPrivateIpAddresses(virtualMachine.properties().networkProfile().networkInterfaces()));
|
||||||
|
|
||||||
|
String groupFromMetadata = null;
|
||||||
|
if (virtualMachine.tags() != null) {
|
||||||
|
addMetadataAndParseTagsFromCommaDelimitedValue(builder, virtualMachine.tags());
|
||||||
|
groupFromMetadata = virtualMachine.tags().get(GROUP_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to read the group from the virtual machine tags, and parse the name
|
||||||
|
// if missing
|
||||||
|
builder.group(groupFromMetadata != null ? groupFromMetadata : nodeNamingConvention.extractGroup(virtualMachine
|
||||||
|
.name()));
|
||||||
|
|
||||||
|
String locationName = virtualMachine.location();
|
||||||
|
builder.location(getLocation(locations, locationName));
|
||||||
|
|
||||||
|
Optional<? extends Image> image = findImage(virtualMachine.properties().storageProfile(), locationName);
|
||||||
|
|
||||||
|
if (image.isPresent()) {
|
||||||
|
builder.imageId(image.get().getId());
|
||||||
|
builder.operatingSystem(image.get().getOperatingSystem());
|
||||||
|
} else {
|
||||||
|
logger.info(">> image with id %s for virtualmachine %s was not found. "
|
||||||
|
+ "This might be because the image that was used to create the virtualmachine has a new id.",
|
||||||
|
virtualMachine.id(), virtualMachine.id());
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.hardware(getHardware(fromLocationAndName(virtualMachine.location(), virtualMachine.properties()
|
||||||
|
.hardwareProfile().vmSize())));
|
||||||
|
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Iterable<String> getPrivateIpAddresses(List<NetworkInterface> networkInterfaces) {
|
||||||
|
List<String> privateIpAddresses = Lists.newArrayList();
|
||||||
|
for (NetworkInterface networkInterfaceCardIdReference : networkInterfaces) {
|
||||||
|
NetworkInterfaceCard networkInterfaceCard = getNetworkInterfaceCard(networkInterfaceCardIdReference);
|
||||||
|
if (networkInterfaceCard != null && networkInterfaceCard.properties() != null
|
||||||
|
&& networkInterfaceCard.properties().ipConfigurations() != null) {
|
||||||
|
for (IpConfiguration ipConfiguration : networkInterfaceCard.properties().ipConfigurations()) {
|
||||||
|
if (ipConfiguration.properties().privateIPAddress() != null) {
|
||||||
|
privateIpAddresses.add(ipConfiguration.properties().privateIPAddress());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return privateIpAddresses;
|
||||||
|
}
|
||||||
|
|
||||||
|
private NetworkInterfaceCard getNetworkInterfaceCard(NetworkInterface nic) {
|
||||||
|
return api.getNetworkInterfaceCardApi(extractResourceGroup(nic.id())).get(extractName(nic.id()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Iterable<String> getPublicIpAddresses(List<NetworkInterface> networkInterfaces) {
|
||||||
|
List<String> publicIpAddresses = Lists.newArrayList();
|
||||||
|
for (NetworkInterface networkInterfaceCardIdReference : networkInterfaces) {
|
||||||
|
NetworkInterfaceCard networkInterfaceCard = getNetworkInterfaceCard(networkInterfaceCardIdReference);
|
||||||
|
if (networkInterfaceCard != null && networkInterfaceCard.properties() != null
|
||||||
|
&& networkInterfaceCard.properties().ipConfigurations() != null) {
|
||||||
|
for (IpConfiguration ipConfiguration : networkInterfaceCard.properties().ipConfigurations()) {
|
||||||
|
if (ipConfiguration.properties().publicIPAddress() != null) {
|
||||||
|
IdReference publicIpId = ipConfiguration.properties().publicIPAddress();
|
||||||
|
PublicIPAddress publicIp = api.getPublicIPAddressApi(publicIpId.resourceGroup()).get(
|
||||||
|
publicIpId.name());
|
||||||
|
if (publicIp != null && publicIp.properties().ipAddress() != null) {
|
||||||
|
publicIpAddresses.add(publicIp.properties().ipAddress());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return publicIpAddresses;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static Location getLocation(Supplier<Set<? extends Location>> locations, final String locationName) {
|
||||||
|
return find(locations.get(), idEquals(nullToEmpty(locationName)), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Optional<? extends Image> findImage(final StorageProfile storageProfile, String locatioName) {
|
||||||
|
if (storageProfile.imageReference() != null) {
|
||||||
|
String imageId = storageProfile.imageReference().customImageId() != null ?
|
||||||
|
storageProfile.imageReference().encodeFieldsToUniqueIdCustom(locatioName) :
|
||||||
|
storageProfile.imageReference().encodeFieldsToUniqueId(locatioName);
|
||||||
|
return imageCache.get(imageId);
|
||||||
|
} else {
|
||||||
|
logger.warn("could not find image for storage profile %s", storageProfile);
|
||||||
|
return Optional.absent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Hardware getHardware(final LocationAndName hardwareId) {
|
||||||
|
final String slashEncoded = hardwareId.slashEncode();
|
||||||
|
return find(hardwares.get().values(), new Predicate<Hardware>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(Hardware input) {
|
||||||
|
return input.getId().equals(slashEncoded);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,116 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.functions;
|
||||||
|
|
||||||
|
import static com.google.common.collect.Iterables.transform;
|
||||||
|
import static org.jclouds.azurecompute.arm.domain.IdReference.extractResourceGroup;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.AzureComputeApi;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.functions.VirtualMachineToStatus.StatusAndBackendStatus;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Status;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VirtualMachine;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VirtualMachineInstance;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VirtualMachineInstance.PowerState;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VirtualMachineProperties;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VirtualMachineProperties.ProvisioningState;
|
||||||
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Functions;
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public class VirtualMachineToStatus implements Function<VirtualMachine, StatusAndBackendStatus> {
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class StatusAndBackendStatus {
|
||||||
|
public abstract NodeMetadata.Status status();
|
||||||
|
|
||||||
|
public abstract String backendStatus();
|
||||||
|
|
||||||
|
public static StatusAndBackendStatus create(NodeMetadata.Status status, String backendStatus) {
|
||||||
|
return new AutoValue_VirtualMachineToStatus_StatusAndBackendStatus(status, backendStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// When using the Deployment API to deploy an ARM template, the deployment
|
||||||
|
// goes through stages: Accepted -> Running -> Succeeded.
|
||||||
|
// Only when the deployment has SUCCEEDED is the resource deployed using the
|
||||||
|
// template actually ready.
|
||||||
|
// To get details about the resource(s) deployed via template, one needs to
|
||||||
|
// query the various resources after the deployment has SUCCEEDED.
|
||||||
|
private static final Function<VirtualMachineProperties.ProvisioningState, NodeMetadata.Status> PROVISIONINGSTATE_TO_NODESTATUS = Functions
|
||||||
|
.forMap(
|
||||||
|
ImmutableMap.<VirtualMachineProperties.ProvisioningState, NodeMetadata.Status> builder()
|
||||||
|
.put(VirtualMachineProperties.ProvisioningState.ACCEPTED, NodeMetadata.Status.PENDING)
|
||||||
|
.put(VirtualMachineProperties.ProvisioningState.READY, NodeMetadata.Status.PENDING)
|
||||||
|
.put(VirtualMachineProperties.ProvisioningState.CREATING, NodeMetadata.Status.PENDING)
|
||||||
|
.put(VirtualMachineProperties.ProvisioningState.RUNNING, NodeMetadata.Status.PENDING)
|
||||||
|
.put(VirtualMachineProperties.ProvisioningState.UPDATING, NodeMetadata.Status.PENDING)
|
||||||
|
.put(VirtualMachineProperties.ProvisioningState.DELETED, NodeMetadata.Status.TERMINATED)
|
||||||
|
.put(VirtualMachineProperties.ProvisioningState.CANCELED, NodeMetadata.Status.TERMINATED)
|
||||||
|
.put(VirtualMachineProperties.ProvisioningState.FAILED, NodeMetadata.Status.ERROR)
|
||||||
|
.put(VirtualMachineProperties.ProvisioningState.UNRECOGNIZED, NodeMetadata.Status.UNRECOGNIZED)
|
||||||
|
.build(), NodeMetadata.Status.UNRECOGNIZED);
|
||||||
|
|
||||||
|
private static final Function<PowerState, NodeMetadata.Status> POWERSTATE_TO_NODESTATUS = Functions.forMap(
|
||||||
|
ImmutableMap.<PowerState, NodeMetadata.Status> builder().put(PowerState.RUNNING, NodeMetadata.Status.RUNNING)
|
||||||
|
.put(PowerState.STOPPED, NodeMetadata.Status.SUSPENDED)
|
||||||
|
.put(PowerState.UNRECOGNIZED, NodeMetadata.Status.UNRECOGNIZED).build(),
|
||||||
|
NodeMetadata.Status.UNRECOGNIZED);
|
||||||
|
|
||||||
|
private final AzureComputeApi api;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
VirtualMachineToStatus(AzureComputeApi api) {
|
||||||
|
this.api = api;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StatusAndBackendStatus apply(VirtualMachine virtualMachine) {
|
||||||
|
String resourceGroup = extractResourceGroup(virtualMachine.id());
|
||||||
|
ProvisioningState provisioningState = virtualMachine.properties().provisioningState();
|
||||||
|
|
||||||
|
NodeMetadata.Status status = PROVISIONINGSTATE_TO_NODESTATUS.apply(provisioningState);
|
||||||
|
String backendStatus = provisioningState.name();
|
||||||
|
|
||||||
|
if (ProvisioningState.SUCCEEDED.equals(provisioningState)) {
|
||||||
|
// If the provisioning succeeded, we need to query the *real* status of
|
||||||
|
// the VM
|
||||||
|
VirtualMachineInstance instanceDetails = api.getVirtualMachineApi(resourceGroup).getInstanceDetails(
|
||||||
|
virtualMachine.name());
|
||||||
|
if (instanceDetails != null && instanceDetails.powerState() != null) {
|
||||||
|
status = POWERSTATE_TO_NODESTATUS.apply(instanceDetails.powerState());
|
||||||
|
backendStatus = Joiner.on(',').join(transform(instanceDetails.statuses(), new Function<Status, String>() {
|
||||||
|
@Override
|
||||||
|
public String apply(Status input) {
|
||||||
|
return input.code();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
status = NodeMetadata.Status.PENDING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return StatusAndBackendStatus.create(status, backendStatus);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,100 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.loaders;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static org.jclouds.compute.util.ComputeServiceUtils.getPortRangesFromList;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.AzureComputeApi;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.config.AzurePredicatesModule.SecurityGroupAvailablePredicateFactory;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndNameAndIngressRules;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroup;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroupProperties;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityRule;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Access;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Direction;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityRuleProperties.Protocol;
|
||||||
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
import com.google.common.cache.CacheLoader;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public class CreateSecurityGroupIfNeeded extends CacheLoader<ResourceGroupAndNameAndIngressRules, String> {
|
||||||
|
@Resource
|
||||||
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
private final AzureComputeApi api;
|
||||||
|
private final SecurityGroupAvailablePredicateFactory securityGroupAvailable;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
CreateSecurityGroupIfNeeded(AzureComputeApi api, SecurityGroupAvailablePredicateFactory securityRuleAvailable) {
|
||||||
|
this.api = api;
|
||||||
|
this.securityGroupAvailable = securityRuleAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String load(ResourceGroupAndNameAndIngressRules key) throws Exception {
|
||||||
|
return createSecurityGroup(key.location(), key.resourceGroup(), key.name(), key.inboundPorts());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createSecurityGroup(String location, String resourceGroup, String name, int[] inboundPorts) {
|
||||||
|
logger.debug(">> creating security group %s in %s...", name, location);
|
||||||
|
|
||||||
|
Map<Integer, Integer> portRanges = getPortRangesFromList(inboundPorts);
|
||||||
|
|
||||||
|
List<NetworkSecurityRule> rules = new ArrayList<NetworkSecurityRule>();
|
||||||
|
|
||||||
|
int startPriority = 100;
|
||||||
|
for (Map.Entry<Integer, Integer> portRange : portRanges.entrySet()) {
|
||||||
|
String range = portRange.getKey() + "-" + portRange.getValue();
|
||||||
|
String ruleName = "tcp-" + range;
|
||||||
|
|
||||||
|
NetworkSecurityRuleProperties properties = NetworkSecurityRuleProperties.builder().protocol(Protocol.Tcp) //
|
||||||
|
.sourceAddressPrefix("*") //
|
||||||
|
.sourcePortRange("*") //
|
||||||
|
.destinationAddressPrefix("*") //
|
||||||
|
.destinationPortRange(range) //
|
||||||
|
.direction(Direction.Inbound) //
|
||||||
|
.access(Access.Allow) //
|
||||||
|
.priority(startPriority++) //
|
||||||
|
.build();
|
||||||
|
|
||||||
|
rules.add(NetworkSecurityRule.create(ruleName, null, null, properties));
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkSecurityGroup securityGroup = api.getNetworkSecurityGroupApi(resourceGroup).createOrUpdate(name, location,
|
||||||
|
null, NetworkSecurityGroupProperties.builder().securityRules(rules).build());
|
||||||
|
|
||||||
|
checkState(securityGroupAvailable.create(resourceGroup).apply(name),
|
||||||
|
"Security group was not created in the configured timeout");
|
||||||
|
|
||||||
|
return securityGroup.id();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.loaders;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.AzureComputeApi;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.functions.LocationToResourceGroupName;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.ResourceGroup;
|
||||||
|
import org.jclouds.azurecompute.arm.features.ResourceGroupApi;
|
||||||
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
import com.google.common.cache.CacheLoader;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public class DefaultResourceGroup extends CacheLoader<String, ResourceGroup> {
|
||||||
|
@Resource
|
||||||
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
private final ResourceGroupApi api;
|
||||||
|
private final LocationToResourceGroupName locationToResourceGroupName;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
DefaultResourceGroup(AzureComputeApi api, LocationToResourceGroupName locationToResourceGroupName) {
|
||||||
|
this.api = api.getResourceGroupApi();
|
||||||
|
this.locationToResourceGroupName = locationToResourceGroupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceGroup load(String locationId) throws Exception {
|
||||||
|
String azureGroupName = locationToResourceGroupName.apply(locationId);
|
||||||
|
ResourceGroup resourceGroup = api.get(azureGroupName);
|
||||||
|
if (resourceGroup == null) {
|
||||||
|
logger.debug(">> creating resource group %s", azureGroupName);
|
||||||
|
final Map<String, String> tags = ImmutableMap.of("description", "jclouds default resource group");
|
||||||
|
resourceGroup = api.create(azureGroupName, locationId, tags);
|
||||||
|
}
|
||||||
|
return resourceGroup;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,324 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.options;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.domain.AvailabilitySet;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.DataDisk;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.OSProfile.WindowsConfiguration;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.Secrets;
|
||||||
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
|
|
||||||
|
import com.google.common.base.MoreObjects;
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Azure ARM custom options
|
||||||
|
*/
|
||||||
|
public class AzureTemplateOptions extends TemplateOptions implements Cloneable {
|
||||||
|
|
||||||
|
private AvailabilitySet availabilitySet;
|
||||||
|
private String availabilitySetName;
|
||||||
|
private List<DataDisk> dataDisks = ImmutableList.of();
|
||||||
|
private String resourceGroup;
|
||||||
|
private List<IpOptions> ipOptions = ImmutableList.of();
|
||||||
|
private WindowsConfiguration windowsConfiguration;
|
||||||
|
private List<Secrets> secrets = ImmutableList.of();
|
||||||
|
private String customData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the availability set where the nodes will be configured. If it does
|
||||||
|
* not exist jclouds will create a new one with the given configuration.
|
||||||
|
*/
|
||||||
|
public AzureTemplateOptions availabilitySet(AvailabilitySet availabilitySet) {
|
||||||
|
this.availabilitySet = availabilitySet;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the availability set where the nodes will be configured. The
|
||||||
|
* availability set must exist.
|
||||||
|
*/
|
||||||
|
public AzureTemplateOptions availabilitySet(String availabilitySetName) {
|
||||||
|
this.availabilitySetName = availabilitySetName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The resource group where the new resources will be created.
|
||||||
|
*/
|
||||||
|
public AzureTemplateOptions resourceGroup(String resourceGroup) {
|
||||||
|
this.resourceGroup = resourceGroup;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AzureTemplateOptions dataDisks(Iterable<DataDisk> dataDisks) {
|
||||||
|
for (DataDisk dataDisk : checkNotNull(dataDisks, "dataDisks"))
|
||||||
|
checkNotNull(dataDisk, "all dataDisks must be non-empty");
|
||||||
|
this.dataDisks = ImmutableList.copyOf(dataDisks);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AzureTemplateOptions dataDisks(DataDisk... dataDisks) {
|
||||||
|
return dataDisks(ImmutableList.copyOf(checkNotNull(dataDisks, "dataDisks")));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure the NICs that will be attached to the created nodes.
|
||||||
|
* <p>
|
||||||
|
* Note that the number of NICs that can be attached depends on the size of
|
||||||
|
* the virtual machine, and that the guest operating system needs to be
|
||||||
|
* prepared to set up all the configured interfaces.
|
||||||
|
* <p>
|
||||||
|
* Depending on the image being used, a cloud-init or bootstrap script might
|
||||||
|
* be needed to make the interface setup.
|
||||||
|
*/
|
||||||
|
public AzureTemplateOptions ipOptions(Iterable<IpOptions> ipOptions) {
|
||||||
|
for (IpOptions ipOption : checkNotNull(ipOptions, "ipOptions"))
|
||||||
|
checkNotNull(ipOption, "all ipOptions must be non-empty");
|
||||||
|
this.ipOptions = ImmutableList.copyOf(ipOptions);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see {@link AzureTemplateOptions#ipOptions(Iterable)
|
||||||
|
|
||||||
|
*/
|
||||||
|
public AzureTemplateOptions ipOptions(IpOptions... ipOptions) {
|
||||||
|
return ipOptions(ImmutableList.copyOf(checkNotNull(ipOptions, "ipOptions")));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Windows configuration parameters
|
||||||
|
*
|
||||||
|
* @see <a
|
||||||
|
* href="https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/virtualmachines-create-or-update#bk_windowsconfig5">docs</a>
|
||||||
|
*/
|
||||||
|
public AzureTemplateOptions windowsConfiguration(WindowsConfiguration windowsConfiguration) {
|
||||||
|
this.windowsConfiguration = windowsConfiguration;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import certificates in the Windows Certificate Store
|
||||||
|
*
|
||||||
|
* @see <a
|
||||||
|
* href="https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/virtualmachines-create-or-update#bk_srcvault">docs</a>
|
||||||
|
*/
|
||||||
|
public AzureTemplateOptions secrets(Iterable<? extends Secrets> secrets) {
|
||||||
|
for (Secrets secret : checkNotNull(secrets, "secrets"))
|
||||||
|
checkNotNull(secret, "secrets can not be empty");
|
||||||
|
this.secrets = ImmutableList.copyOf(secrets);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom data (for cloud-init) for the Azure ARM API
|
||||||
|
*/
|
||||||
|
public AzureTemplateOptions customData(String customData) {
|
||||||
|
this.customData = customData;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AvailabilitySet getAvailabilitySet() {
|
||||||
|
return availabilitySet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAvailabilitySetName() {
|
||||||
|
return availabilitySetName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DataDisk> getDataDisks() {
|
||||||
|
return dataDisks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getResourceGroup() {
|
||||||
|
return resourceGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<IpOptions> getIpOptions() {
|
||||||
|
return ipOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WindowsConfiguration getWindowsConfiguration() {
|
||||||
|
return windowsConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Secrets> getSecrets() {
|
||||||
|
return secrets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCustomData() {
|
||||||
|
return customData;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AzureTemplateOptions clone() {
|
||||||
|
AzureTemplateOptions options = new AzureTemplateOptions();
|
||||||
|
copyTo(options);
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void copyTo(TemplateOptions to) {
|
||||||
|
super.copyTo(to);
|
||||||
|
if (to instanceof AzureTemplateOptions) {
|
||||||
|
AzureTemplateOptions eTo = AzureTemplateOptions.class.cast(to);
|
||||||
|
eTo.availabilitySet(availabilitySet);
|
||||||
|
eTo.availabilitySet(availabilitySetName);
|
||||||
|
eTo.dataDisks(dataDisks);
|
||||||
|
eTo.resourceGroup(resourceGroup);
|
||||||
|
eTo.ipOptions(ipOptions);
|
||||||
|
eTo.windowsConfiguration(windowsConfiguration);
|
||||||
|
eTo.secrets(secrets);
|
||||||
|
eTo.customData(customData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o)
|
||||||
|
return true;
|
||||||
|
if (!(o instanceof AzureTemplateOptions))
|
||||||
|
return false;
|
||||||
|
if (!super.equals(o))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
AzureTemplateOptions that = (AzureTemplateOptions) o;
|
||||||
|
|
||||||
|
return Objects.equal(availabilitySetName, that.availabilitySetName)
|
||||||
|
&& Objects.equal(resourceGroup, that.resourceGroup) && Objects.equal(availabilitySet, that.availabilitySet)
|
||||||
|
&& Objects.equal(dataDisks, that.dataDisks) && Objects.equal(ipOptions, that.ipOptions)
|
||||||
|
&& Objects.equal(windowsConfiguration, that.windowsConfiguration) && Objects.equal(secrets, that.secrets)
|
||||||
|
&& Objects.equal(this.customData, that.customData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(super.hashCode(), availabilitySet, availabilitySetName, dataDisks, resourceGroup,
|
||||||
|
ipOptions, customData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MoreObjects.ToStringHelper string() {
|
||||||
|
MoreObjects.ToStringHelper toString = super.string();
|
||||||
|
if (availabilitySet != null)
|
||||||
|
toString.add("availabilitySet", availabilitySet);
|
||||||
|
if (availabilitySetName != null)
|
||||||
|
toString.add("availabilitySetName", availabilitySetName);
|
||||||
|
if (!dataDisks.isEmpty())
|
||||||
|
toString.add("dataDisks", dataDisks);
|
||||||
|
if (resourceGroup != null)
|
||||||
|
toString.add("resourceGroup", resourceGroup);
|
||||||
|
if (!ipOptions.isEmpty())
|
||||||
|
toString.add("ipOptions", ipOptions);
|
||||||
|
if (windowsConfiguration != null)
|
||||||
|
toString.add("windowsConfiguration", windowsConfiguration);
|
||||||
|
if (!secrets.isEmpty())
|
||||||
|
toString.add("secrets", secrets);
|
||||||
|
if (customData != null)
|
||||||
|
toString.add("customData", customData);
|
||||||
|
return toString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AzureTemplateOptions#availabilitySet(AvailabilitySet)
|
||||||
|
*/
|
||||||
|
public static AzureTemplateOptions availabilitySet(AvailabilitySet availabilitySet) {
|
||||||
|
AzureTemplateOptions options = new AzureTemplateOptions();
|
||||||
|
return options.availabilitySet(availabilitySet);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AzureTemplateOptions#availabilitySet(String)
|
||||||
|
*/
|
||||||
|
public static AzureTemplateOptions availabilitySet(String availabilitySetName) {
|
||||||
|
AzureTemplateOptions options = new AzureTemplateOptions();
|
||||||
|
return options.availabilitySet(availabilitySetName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AzureTemplateOptions#dataDisks(DataDisk...)
|
||||||
|
*/
|
||||||
|
public static AzureTemplateOptions dataDisks(DataDisk... dataDisks) {
|
||||||
|
AzureTemplateOptions options = new AzureTemplateOptions();
|
||||||
|
return options.dataDisks(dataDisks);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AzureTemplateOptions#dataDisks(Iterable)
|
||||||
|
*/
|
||||||
|
public static AzureTemplateOptions dataDisks(Iterable<DataDisk> dataDisks) {
|
||||||
|
AzureTemplateOptions options = new AzureTemplateOptions();
|
||||||
|
return options.dataDisks(dataDisks);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AzureTemplateOptions#resourceGroup(String)
|
||||||
|
*/
|
||||||
|
public static AzureTemplateOptions resourceGroup(String resourceGroup) {
|
||||||
|
AzureTemplateOptions options = new AzureTemplateOptions();
|
||||||
|
return options.resourceGroup(resourceGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AzureTemplateOptions#ipOptions(IpOptions...)
|
||||||
|
*/
|
||||||
|
public static AzureTemplateOptions ipOptions(IpOptions... ipOptions) {
|
||||||
|
AzureTemplateOptions options = new AzureTemplateOptions();
|
||||||
|
return options.ipOptions(ipOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AzureTemplateOptions#ipOptions(Iterable)
|
||||||
|
*/
|
||||||
|
public static AzureTemplateOptions ipOptions(Iterable<IpOptions> ipOptions) {
|
||||||
|
AzureTemplateOptions options = new AzureTemplateOptions();
|
||||||
|
return options.ipOptions(ipOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AzureTemplateOptions#windowsConfiguration(WindowsConfiguration)
|
||||||
|
*/
|
||||||
|
public static AzureTemplateOptions windowsConfiguration(WindowsConfiguration windowsConfiguration) {
|
||||||
|
AzureTemplateOptions options = new AzureTemplateOptions();
|
||||||
|
return options.windowsConfiguration(windowsConfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AzureTemplateOptions#secrets(List)
|
||||||
|
*/
|
||||||
|
public static AzureTemplateOptions secrets(Iterable<? extends Secrets> secrets) {
|
||||||
|
AzureTemplateOptions options = new AzureTemplateOptions();
|
||||||
|
return options.secrets(secrets);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see AzureTemplateOptions#customData
|
||||||
|
*/
|
||||||
|
public static AzureTemplateOptions customData(String customData) {
|
||||||
|
AzureTemplateOptions options = new AzureTemplateOptions();
|
||||||
|
return options.customData(customData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.options;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.base.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the ip addresses to be configured for the created nodes.
|
||||||
|
*/
|
||||||
|
@AutoValue
|
||||||
|
public abstract class IpOptions {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The subnet where the NIC will be attached.
|
||||||
|
*/
|
||||||
|
public abstract String subnet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The IP address to be configured, in case of static allocation, or absent
|
||||||
|
* for dynamic assignment.
|
||||||
|
*/
|
||||||
|
public abstract Optional<String> address();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag to indicate if a public ip address should be allocated and bound to
|
||||||
|
* this NIC.
|
||||||
|
*/
|
||||||
|
public abstract boolean allocateNewPublicIp();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID of the public IP to associate with the NIC.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String publicIpId();
|
||||||
|
|
||||||
|
IpOptions() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_IpOptions.Builder().address((String) null).allocateNewPublicIp(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder subnet(String subnet);
|
||||||
|
public abstract Builder allocateNewPublicIp(boolean allocatePublicIp);
|
||||||
|
public abstract Builder publicIpId(String publicIpId);
|
||||||
|
|
||||||
|
abstract Builder address(Optional<String> address);
|
||||||
|
public Builder address(String address) {
|
||||||
|
return address(Optional.fromNullable(address));
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract IpOptions build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,237 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.strategy;
|
||||||
|
|
||||||
|
import static com.google.common.base.Predicates.not;
|
||||||
|
import static com.google.common.base.Predicates.notNull;
|
||||||
|
import static com.google.common.collect.Iterables.filter;
|
||||||
|
import static com.google.common.collect.Iterables.transform;
|
||||||
|
import static com.google.common.collect.Maps.filterValues;
|
||||||
|
import static org.jclouds.azurecompute.arm.compute.AzureComputeServiceAdapter.AUTOGENERATED_IP_KEY;
|
||||||
|
import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TIMEOUT_RESOURCE_DELETED;
|
||||||
|
import static org.jclouds.azurecompute.arm.domain.IdReference.extractName;
|
||||||
|
import static org.jclouds.azurecompute.arm.domain.IdReference.extractResourceGroup;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.AzureComputeApi;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndName;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.AvailabilitySet;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.DataDisk;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.IdReference;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.IpConfiguration;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.ManagedDiskParameters;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCard;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkProfile.NetworkInterface;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.NetworkSecurityGroup;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.OSDisk;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.PublicIPAddress;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.VirtualMachine;
|
||||||
|
import org.jclouds.azurecompute.arm.features.NetworkSecurityGroupApi;
|
||||||
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
|
import com.google.common.base.Predicate;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public class CleanupResources {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
private final AzureComputeApi api;
|
||||||
|
private final Predicate<URI> resourceDeleted;
|
||||||
|
private final GroupNamingConvention.Factory namingConvention;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
CleanupResources(AzureComputeApi azureComputeApi, @Named(TIMEOUT_RESOURCE_DELETED) Predicate<URI> resourceDeleted,
|
||||||
|
GroupNamingConvention.Factory namingConvention) {
|
||||||
|
this.api = azureComputeApi;
|
||||||
|
this.resourceDeleted = resourceDeleted;
|
||||||
|
this.namingConvention = namingConvention;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean cleanupNode(final String id) {
|
||||||
|
ResourceGroupAndName resourceGroupAndName = ResourceGroupAndName.fromSlashEncoded(id);
|
||||||
|
String resourceGroupName = resourceGroupAndName.resourceGroup();
|
||||||
|
|
||||||
|
VirtualMachine virtualMachine = api.getVirtualMachineApi(resourceGroupName).get(resourceGroupAndName.name());
|
||||||
|
if (virtualMachine == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug(">> destroying %s ...", id);
|
||||||
|
boolean vmDeleted = deleteVirtualMachine(resourceGroupName, virtualMachine);
|
||||||
|
|
||||||
|
// We don't delete the network here, as it is global to the resource
|
||||||
|
// group. It will be deleted when the resource group is deleted
|
||||||
|
|
||||||
|
cleanupVirtualMachineNICs(virtualMachine);
|
||||||
|
cleanupManagedDisks(virtualMachine);
|
||||||
|
cleanupAvailabilitySetIfOrphaned(virtualMachine);
|
||||||
|
|
||||||
|
return vmDeleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean cleanupVirtualMachineNICs(VirtualMachine virtualMachine) {
|
||||||
|
boolean deleted = true;
|
||||||
|
for (NetworkInterface nicRef : virtualMachine.properties().networkProfile().networkInterfaces()) {
|
||||||
|
String nicResourceGroup = extractResourceGroup(nicRef.id());
|
||||||
|
String nicName = extractName(nicRef.id());
|
||||||
|
NetworkInterfaceCard nic = api.getNetworkInterfaceCardApi(nicResourceGroup).get(nicName);
|
||||||
|
|
||||||
|
Iterable<IdReference> publicIps = getPublicIps(nic);
|
||||||
|
|
||||||
|
logger.debug(">> destroying nic %s...", nicName);
|
||||||
|
URI nicDeletionURI = api.getNetworkInterfaceCardApi(nicResourceGroup).delete(nicName);
|
||||||
|
deleted &= nicDeletionURI == null || resourceDeleted.apply(nicDeletionURI);
|
||||||
|
|
||||||
|
for (IdReference publicIp : publicIps) {
|
||||||
|
String publicIpResourceGroup = publicIp.resourceGroup();
|
||||||
|
String publicIpName = publicIp.name();
|
||||||
|
|
||||||
|
PublicIPAddress ip = api.getPublicIPAddressApi(publicIpResourceGroup).get(publicIpName);
|
||||||
|
if (ip.tags() != null && Boolean.parseBoolean(ip.tags().get(AUTOGENERATED_IP_KEY))) {
|
||||||
|
logger.debug(">> deleting public ip %s...", publicIpName);
|
||||||
|
deleted &= api.getPublicIPAddressApi(publicIpResourceGroup).delete(publicIpName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean cleanupManagedDisks(VirtualMachine virtualMachine) {
|
||||||
|
Map<String, URI> deleteJobs = new HashMap<String, URI>();
|
||||||
|
|
||||||
|
OSDisk osDisk = virtualMachine.properties().storageProfile().osDisk();
|
||||||
|
deleteManagedDisk(osDisk.managedDiskParameters(), deleteJobs);
|
||||||
|
|
||||||
|
for (DataDisk dataDisk : virtualMachine.properties().storageProfile().dataDisks()) {
|
||||||
|
deleteManagedDisk(dataDisk.managedDiskParameters(), deleteJobs);
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> nonDeletedDisks = filterValues(deleteJobs, not(resourceDeleted)).keySet();
|
||||||
|
if (!nonDeletedDisks.isEmpty()) {
|
||||||
|
logger.warn(">> could not delete disks: %s", Joiner.on(',').join(nonDeletedDisks));
|
||||||
|
}
|
||||||
|
|
||||||
|
return nonDeletedDisks.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteManagedDisk(@Nullable ManagedDiskParameters managedDisk, Map<String, URI> deleteJobs) {
|
||||||
|
if (managedDisk != null) {
|
||||||
|
IdReference diskRef = IdReference.create(managedDisk.id());
|
||||||
|
logger.debug(">> deleting managed disk %s...", diskRef.name());
|
||||||
|
URI uri = api.getDiskApi(diskRef.resourceGroup()).delete(diskRef.name());
|
||||||
|
if (uri != null) {
|
||||||
|
deleteJobs.put(diskRef.name(), uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean cleanupSecurityGroupIfOrphaned(String resourceGroup, String group) {
|
||||||
|
String name = namingConvention.create().sharedNameForGroup(group);
|
||||||
|
NetworkSecurityGroupApi sgapi = api.getNetworkSecurityGroupApi(resourceGroup);
|
||||||
|
|
||||||
|
boolean deleted = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
NetworkSecurityGroup securityGroup = sgapi.get(name);
|
||||||
|
if (securityGroup != null) {
|
||||||
|
List<NetworkInterfaceCard> nics = securityGroup.properties().networkInterfaces();
|
||||||
|
if (nics == null || nics.isEmpty()) {
|
||||||
|
logger.debug(">> deleting orphaned security group %s from %s...", name, resourceGroup);
|
||||||
|
try {
|
||||||
|
deleted = resourceDeleted.apply(sgapi.delete(name));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.warn(ex, ">> error deleting orphaned security group %s from %s...", name, resourceGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.warn(ex, "Error deleting security groups for %s and group %s", resourceGroup, group);
|
||||||
|
}
|
||||||
|
|
||||||
|
return deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean cleanupAvailabilitySetIfOrphaned(VirtualMachine virtualMachine) {
|
||||||
|
boolean deleted = true;
|
||||||
|
IdReference availabilitySetRef = virtualMachine.properties().availabilitySet();
|
||||||
|
|
||||||
|
if (availabilitySetRef != null) {
|
||||||
|
String name = availabilitySetRef.name();
|
||||||
|
String resourceGroup = availabilitySetRef.resourceGroup();
|
||||||
|
AvailabilitySet availabilitySet = api.getAvailabilitySetApi(resourceGroup).get(name);
|
||||||
|
|
||||||
|
if (isOrphanedJcloudsAvailabilitySet(availabilitySet)) {
|
||||||
|
logger.debug(">> deleting orphaned availability set %s from %s...", name, resourceGroup);
|
||||||
|
URI uri = api.getAvailabilitySetApi(resourceGroup).delete(name);
|
||||||
|
deleted = uri == null || resourceDeleted.apply(uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean deleteResourceGroupIfEmpty(String group) {
|
||||||
|
boolean deleted = false;
|
||||||
|
if (api.getResourceGroupApi().resources(group).isEmpty()) {
|
||||||
|
logger.debug(">> the resource group %s is empty. Deleting...", group);
|
||||||
|
deleted = resourceDeleted.apply(api.getResourceGroupApi().delete(group));
|
||||||
|
}
|
||||||
|
return deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Iterable<IdReference> getPublicIps(NetworkInterfaceCard nic) {
|
||||||
|
return filter(transform(nic.properties().ipConfigurations(), new Function<IpConfiguration, IdReference>() {
|
||||||
|
@Override
|
||||||
|
public IdReference apply(IpConfiguration input) {
|
||||||
|
return input.properties().publicIPAddress();
|
||||||
|
}
|
||||||
|
}), notNull());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isOrphanedJcloudsAvailabilitySet(AvailabilitySet availabilitySet) {
|
||||||
|
// We check for the presence of the 'jclouds' tag to make sure we only
|
||||||
|
// delete availability sets that were automatically created by jclouds
|
||||||
|
return availabilitySet != null
|
||||||
|
&& availabilitySet.tags() != null
|
||||||
|
&& availabilitySet.tags().containsKey("jclouds")
|
||||||
|
&& (availabilitySet.properties().virtualMachines() == null || availabilitySet.properties()
|
||||||
|
.virtualMachines().isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean deleteVirtualMachine(String group, VirtualMachine virtualMachine) {
|
||||||
|
return resourceDeleted.apply(api.getVirtualMachineApi(group).delete(virtualMachine.name()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,258 @@
|
||||||
|
/*
|
||||||
|
* 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.compute.strategy;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.Constants;
|
||||||
|
import org.jclouds.azurecompute.arm.AzureComputeApi;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndName;
|
||||||
|
import org.jclouds.azurecompute.arm.compute.domain.ResourceGroupAndNameAndIngressRules;
|
||||||
|
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.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;
|
||||||
|
import org.jclouds.compute.domain.Template;
|
||||||
|
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||||
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
|
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||||
|
import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName;
|
||||||
|
import org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap;
|
||||||
|
import org.jclouds.compute.strategy.ListNodesStrategy;
|
||||||
|
import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet;
|
||||||
|
import org.jclouds.domain.Location;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.util.PasswordGenerator;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
import com.google.common.base.Optional;
|
||||||
|
import com.google.common.cache.LoadingCache;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||||
|
import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.DEFAULT_SUBNET_ADDRESS_PREFIX;
|
||||||
|
import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.DEFAULT_VNET_ADDRESS_SPACE_PREFIX;
|
||||||
|
import static org.jclouds.azurecompute.arm.domain.IdReference.extractName;
|
||||||
|
import static org.jclouds.azurecompute.arm.domain.IdReference.extractResourceGroup;
|
||||||
|
import static org.jclouds.azurecompute.arm.domain.Subnet.extractVirtualNetwork;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public class CreateResourcesThenCreateNodes extends CreateNodesWithGroupEncodedIntoNameThenAddToSet {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
@Named(ComputeServiceConstants.COMPUTE_LOGGER)
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
private final AzureComputeApi api;
|
||||||
|
private final LoadingCache<ResourceGroupAndNameAndIngressRules, String> securityGroupMap;
|
||||||
|
private final String defaultVnetAddressPrefix;
|
||||||
|
private final String defaultSubnetAddressPrefix;
|
||||||
|
private final TemplateToAvailabilitySet templateToAvailabilitySet;
|
||||||
|
private final PasswordGenerator.Config passwordGenerator;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
protected CreateResourcesThenCreateNodes(
|
||||||
|
CreateNodeWithGroupEncodedIntoName addNodeWithGroupStrategy,
|
||||||
|
ListNodesStrategy listNodesStrategy,
|
||||||
|
GroupNamingConvention.Factory namingConvention,
|
||||||
|
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
|
||||||
|
CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory,
|
||||||
|
AzureComputeApi api, @Named(DEFAULT_VNET_ADDRESS_SPACE_PREFIX) String defaultVnetAddressPrefix,
|
||||||
|
@Named(DEFAULT_SUBNET_ADDRESS_PREFIX) String defaultSubnetAddressPrefix,
|
||||||
|
LoadingCache<ResourceGroupAndNameAndIngressRules, String> securityGroupMap,
|
||||||
|
TemplateToAvailabilitySet templateToAvailabilitySet,
|
||||||
|
PasswordGenerator.Config passwordGenerator) {
|
||||||
|
super(addNodeWithGroupStrategy, listNodesStrategy, namingConvention, userExecutor,
|
||||||
|
customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory);
|
||||||
|
this.api = api;
|
||||||
|
this.securityGroupMap = securityGroupMap;
|
||||||
|
this.defaultVnetAddressPrefix = defaultVnetAddressPrefix;
|
||||||
|
this.defaultSubnetAddressPrefix = defaultSubnetAddressPrefix;
|
||||||
|
this.templateToAvailabilitySet = templateToAvailabilitySet;
|
||||||
|
this.passwordGenerator = passwordGenerator;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<?, ListenableFuture<Void>> execute(String group, int count, Template template,
|
||||||
|
Set<NodeMetadata> goodNodes, Map<NodeMetadata, Exception> badNodes,
|
||||||
|
Multimap<NodeMetadata, CustomizationResponse> customizationResponses) {
|
||||||
|
|
||||||
|
AzureTemplateOptions options = template.getOptions().as(AzureTemplateOptions.class);
|
||||||
|
|
||||||
|
// TODO Generate a private key instead. Also no need to use AUTHENTICATE_SUDO in this case.
|
||||||
|
generatePasswordIfNoneProvided(template);
|
||||||
|
|
||||||
|
// If there is a script to be run on the node and public key
|
||||||
|
// authentication has been configured, warn users if the private key
|
||||||
|
// is not present
|
||||||
|
if (hasRunScriptWithKeyAuthAndNoPrivateKey(template)) {
|
||||||
|
logger.warn(">> a runScript was configured but no SSH key has been provided. "
|
||||||
|
+ "Authentication will delegate to the ssh-agent");
|
||||||
|
}
|
||||||
|
|
||||||
|
String location = template.getLocation().getId();
|
||||||
|
|
||||||
|
createResourceGroupIfNeeded(group, location, options);
|
||||||
|
|
||||||
|
normalizeNetworkOptions(options);
|
||||||
|
createDefaultNetworkIfNeeded(group, location, options);
|
||||||
|
|
||||||
|
configureSecurityGroupForOptions(group, template.getLocation(), options);
|
||||||
|
configureAvailabilitySetForTemplate(template);
|
||||||
|
|
||||||
|
return super.execute(group, count, template, goodNodes, badNodes, customizationResponses);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Azure requires that we pass it the VM password. Need to generate one if not overridden by the user.
|
||||||
|
private void generatePasswordIfNoneProvided(Template template) {
|
||||||
|
TemplateOptions options = template.getOptions();
|
||||||
|
if (options.getLoginPassword() == null) {
|
||||||
|
Optional<String> passwordOptional = template.getImage().getDefaultCredentials().getOptionalPassword();
|
||||||
|
options.overrideLoginPassword(passwordOptional.or(passwordGenerator.generate()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected synchronized void createDefaultNetworkIfNeeded(String group, String location, AzureTemplateOptions options) {
|
||||||
|
if (options.getIpOptions().isEmpty()) {
|
||||||
|
String name = namingConvention.create().sharedNameForGroup(group);
|
||||||
|
|
||||||
|
Subnet subnet = Subnet.builder().name(name)
|
||||||
|
.properties(SubnetProperties.builder().addressPrefix(defaultSubnetAddressPrefix).build()).build();
|
||||||
|
|
||||||
|
VirtualNetworkProperties properties = VirtualNetworkProperties.builder()
|
||||||
|
.addressSpace(AddressSpace.create(Arrays.asList(defaultVnetAddressPrefix)))
|
||||||
|
.subnets(Arrays.asList(subnet)).build();
|
||||||
|
|
||||||
|
logger.debug(">> network options have not been configured. Creating network %s(%s) and subnet %s(%s)", name,
|
||||||
|
defaultVnetAddressPrefix, name, defaultSubnetAddressPrefix);
|
||||||
|
|
||||||
|
api.getVirtualNetworkApi(options.getResourceGroup()).createOrUpdate(name, location, null, properties);
|
||||||
|
Subnet createdSubnet = api.getSubnetApi(options.getResourceGroup(), name).get(name);
|
||||||
|
|
||||||
|
options.ipOptions(IpOptions.builder().subnet(createdSubnet.id()).allocateNewPublicIp(true).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean hasRunScriptWithKeyAuthAndNoPrivateKey(Template template) {
|
||||||
|
return template.getOptions().getRunScript() != null && template.getOptions().getPublicKey() != null
|
||||||
|
&& !template.getOptions().hasLoginPrivateKeyOption();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void configureSecurityGroupForOptions(String group, Location location, AzureTemplateOptions options) {
|
||||||
|
|
||||||
|
checkArgument(options.getGroups().size() <= 1,
|
||||||
|
"Only one security group can be configured for each network interface");
|
||||||
|
|
||||||
|
if (!options.getGroups().isEmpty()) {
|
||||||
|
ResourceGroupAndName securityGroupId = ResourceGroupAndName.fromSlashEncoded(getOnlyElement(options.getGroups()));
|
||||||
|
NetworkSecurityGroup securityGroup = api.getNetworkSecurityGroupApi(securityGroupId.resourceGroup()).get(
|
||||||
|
securityGroupId.name());
|
||||||
|
checkArgument(securityGroup != null, "Security group %s was not found", securityGroupId.slashEncode());
|
||||||
|
options.securityGroups(securityGroup.id());
|
||||||
|
} else if (options.getInboundPorts().length > 0) {
|
||||||
|
String name = namingConvention.create().sharedNameForGroup(group);
|
||||||
|
ResourceGroupAndNameAndIngressRules regionAndIdAndIngressRules = ResourceGroupAndNameAndIngressRules.create(
|
||||||
|
options.getResourceGroup(), location.getId(), name, options.getInboundPorts());
|
||||||
|
// this will create if not yet exists.
|
||||||
|
String securityGroupId = securityGroupMap.getUnchecked(regionAndIdAndIngressRules);
|
||||||
|
options.securityGroups(securityGroupId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void configureAvailabilitySetForTemplate(Template template) {
|
||||||
|
AvailabilitySet availabilitySet = templateToAvailabilitySet.apply(template);
|
||||||
|
if (availabilitySet != null) {
|
||||||
|
logger.debug(">> configuring nodes in availability set [%s]", availabilitySet.name());
|
||||||
|
template.getOptions().as(AzureTemplateOptions.class).availabilitySet(availabilitySet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createResourceGroupIfNeeded(String group, String location, AzureTemplateOptions options) {
|
||||||
|
if (options.getResourceGroup() == null) {
|
||||||
|
options.resourceGroup(group);
|
||||||
|
}
|
||||||
|
logger.debug(">> using resource group [%s]", options.getResourceGroup());
|
||||||
|
ResourceGroup rg = api.getResourceGroupApi().get(options.getResourceGroup());
|
||||||
|
if (rg == null) {
|
||||||
|
logger.debug(">> resource group [%s] does not exist. Creating!", options.getResourceGroup());
|
||||||
|
api.getResourceGroupApi().create(options.getResourceGroup(), location,
|
||||||
|
ImmutableMap.of("description", "jclouds default resource group"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void normalizeNetworkOptions(AzureTemplateOptions options) {
|
||||||
|
if (!options.getNetworks().isEmpty() && !options.getIpOptions().isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("The options.networks and options.ipOptions are exclusive");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!options.getNetworks().isEmpty()) {
|
||||||
|
// The portable interface allows to configure network IDs (subnet IDs),
|
||||||
|
// but we don't know the type of the IP configurations to be applied
|
||||||
|
// when attaching nodes to those networks. We'll assume private IPs
|
||||||
|
// with Dynamic allocation and new public ip address allocated.
|
||||||
|
ImmutableList.Builder<IpOptions> ipOptions = ImmutableList.builder();
|
||||||
|
for (String subnetId : options.getNetworks()) {
|
||||||
|
ipOptions.add(IpOptions.builder().subnet(subnetId).allocateNewPublicIp(true).build());
|
||||||
|
}
|
||||||
|
options.ipOptions(ipOptions.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!options.getIpOptions().isEmpty()) {
|
||||||
|
// Eagerly validate that all configured subnets exist.
|
||||||
|
for (IpOptions ipConfig : options.getIpOptions()) {
|
||||||
|
if (ipConfig.allocateNewPublicIp() && ipConfig.publicIpId() != null) {
|
||||||
|
throw new IllegalArgumentException("The allocateNewPublicIps and publicIpId are exclusive");
|
||||||
|
}
|
||||||
|
|
||||||
|
String resourceGroup = extractResourceGroup(ipConfig.subnet());
|
||||||
|
String networkName = extractVirtualNetwork(ipConfig.subnet());
|
||||||
|
String subnetName = extractName(ipConfig.subnet());
|
||||||
|
Subnet subnet = api.getSubnetApi(resourceGroup, networkName).get(subnetName);
|
||||||
|
checkState(subnet != null, "Configured subnet %s does not exist", ipConfig.subnet());
|
||||||
|
|
||||||
|
if (ipConfig.publicIpId() != null) {
|
||||||
|
PublicIPAddress publicIp = api.getPublicIPAddressApi(extractResourceGroup(ipConfig.publicIpId())).get(
|
||||||
|
extractName(ipConfig.publicIpId()));
|
||||||
|
checkState(publicIp != null, "Configured public ip %s does not exist", ipConfig.publicIpId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
/*
|
||||||
|
* 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.config;
|
||||||
|
|
||||||
|
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.AzureComputeApi;
|
||||||
|
import org.jclouds.azurecompute.arm.config.GraphRBAC.GraphRBACForTenant;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.ServicePrincipal;
|
||||||
|
import org.jclouds.azurecompute.arm.handlers.AzureComputeErrorHandler;
|
||||||
|
import org.jclouds.http.HttpErrorHandler;
|
||||||
|
import org.jclouds.http.annotation.ClientError;
|
||||||
|
import org.jclouds.http.annotation.Redirection;
|
||||||
|
import org.jclouds.http.annotation.ServerError;
|
||||||
|
import org.jclouds.location.suppliers.ImplicitLocationSupplier;
|
||||||
|
import org.jclouds.location.suppliers.implicit.FirstRegion;
|
||||||
|
import org.jclouds.oauth.v2.config.OAuthConfigFactory;
|
||||||
|
import org.jclouds.oauth.v2.config.OAuthScopes;
|
||||||
|
import org.jclouds.rest.AuthorizationException;
|
||||||
|
import org.jclouds.rest.ConfiguresHttpApi;
|
||||||
|
import org.jclouds.rest.config.HttpApiModule;
|
||||||
|
import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
|
||||||
|
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
import com.google.inject.Scopes;
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
import com.google.inject.name.Named;
|
||||||
|
|
||||||
|
@ConfiguresHttpApi
|
||||||
|
public class AzureComputeHttpApiModule extends HttpApiModule<AzureComputeApi> {
|
||||||
|
|
||||||
|
private static final Pattern OAUTH_TENANT_PATTERN = Pattern
|
||||||
|
.compile("https://login.microsoft(?:online)?.com/([^/]+)/oauth2/token");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void bindErrorHandlers() {
|
||||||
|
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(AzureComputeErrorHandler.class);
|
||||||
|
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(AzureComputeErrorHandler.class);
|
||||||
|
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(AzureComputeErrorHandler.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void installLocations() {
|
||||||
|
super.installLocations();
|
||||||
|
bind(ImplicitLocationSupplier.class).to(FirstRegion.class).in(Scopes.SINGLETON);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
super.configure();
|
||||||
|
bind(OAuthScopes.class).toInstance(OAuthScopes.NoScopes.create());
|
||||||
|
bind(OAuthConfigFactory.class).to(AzureOAuthConfigFactory.class).in(Scopes.SINGLETON);
|
||||||
|
bindServiceEndpoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void bindServiceEndpoints() {
|
||||||
|
bind(new TypeLiteral<Supplier<URI>>() {
|
||||||
|
}).annotatedWith(GraphRBAC.class).to(GraphRBACForTenant.class).in(Scopes.SINGLETON);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
@Tenant
|
||||||
|
protected final String provideTenant(@Named("oauth.endpoint") final String oauthEndpoint) {
|
||||||
|
Matcher m = OAUTH_TENANT_PATTERN.matcher(oauthEndpoint);
|
||||||
|
if (!m.matches()) {
|
||||||
|
throw new IllegalArgumentException("Could not parse tenantId from: " + oauthEndpoint);
|
||||||
|
}
|
||||||
|
return m.group(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
protected final Supplier<ServicePrincipal> provideServicePrincipal(final AzureComputeApi api,
|
||||||
|
AtomicReference<AuthorizationException> authException, @Named(PROPERTY_SESSION_INTERVAL) long seconds) {
|
||||||
|
// This supplier must be defensive against any auth exception.
|
||||||
|
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier.create(authException,
|
||||||
|
new Supplier<ServicePrincipal>() {
|
||||||
|
@Override
|
||||||
|
public ServicePrincipal get() {
|
||||||
|
return api.getGraphRBACApi().getCurrentServicePrincipal();
|
||||||
|
}
|
||||||
|
}, seconds, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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.config;
|
||||||
|
|
||||||
|
import org.jclouds.json.config.GsonModule;
|
||||||
|
|
||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
|
||||||
|
public class AzureComputeParserModule extends AbstractModule {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
bind(GsonModule.DateAdapter.class).to(GsonModule.Iso8601DateAdapter.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* 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.config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration properties and constants used in Azure Resource Manager
|
||||||
|
* connections.
|
||||||
|
*/
|
||||||
|
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";
|
||||||
|
|
||||||
|
public static final String DEFAULT_VNET_ADDRESS_SPACE_PREFIX = "jclouds.azurecompute.arm.vnet.addressprefix";
|
||||||
|
|
||||||
|
public static final String DEFAULT_SUBNET_ADDRESS_PREFIX = "jclouds.azurecompute.arm.subnet.addressprefix";
|
||||||
|
|
||||||
|
public static final String API_VERSION_PREFIX = "jclouds.azurecompute.arm.apiversion.";
|
||||||
|
|
||||||
|
// Predicate constants
|
||||||
|
public static final String VAULT_DELETE_STATUS = "jclouds.azurecompute.arm.vault.delete_status";
|
||||||
|
public static final String VAULT_KEY_DELETED_STATUS = "jclouds.azurecompute.arm.vault.key.delete_status";
|
||||||
|
public static final String VAULT_KEY_RECOVERABLE_STATUS = "jclouds.azurecompute.arm.vault.key.recoverable_status";
|
||||||
|
public static final String VAULT_SECRET_DELETE_STATUS = "jclouds.azurecompute.arm.vault.secret.delete_status";
|
||||||
|
public static final String VAULT_SECRET_RECOVERABLE_STATUS = "jclouds.azurecompute.arm.vault.secret.recoverable_status";
|
||||||
|
public static final String VAULT_CERTIFICATE_DELETE_STATUS = "jclouds.azurecompute.arm.vault.certificate.delete_status";
|
||||||
|
public static final String VAULT_CERTIFICATE_RECOVERABLE_STATUS = "jclouds.azurecompute.arm.vault.certificate.recoverable_status";
|
||||||
|
public static final String VAULT_CERTIFICATE_OPERATION_STATUS = "jclouds.azurecompute.arm.vault.certificate.operation_status";
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* 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.config;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.handlers.AzureRateLimitRetryHandler;
|
||||||
|
import org.jclouds.http.HttpRetryHandler;
|
||||||
|
import org.jclouds.http.annotation.ClientError;
|
||||||
|
|
||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
|
||||||
|
public class AzureComputeRateLimitModule extends AbstractModule {
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(AzureRateLimitRetryHandler.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* 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.config;
|
||||||
|
|
||||||
|
import static org.jclouds.oauth.v2.config.OAuthProperties.AUDIENCE;
|
||||||
|
import static org.jclouds.oauth.v2.config.OAuthProperties.RESOURCE;
|
||||||
|
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.oauth.v2.config.OAuthConfigFactory;
|
||||||
|
import org.jclouds.oauth.v2.config.OAuthScopes;
|
||||||
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.name.Named;
|
||||||
|
|
||||||
|
public class AzureOAuthConfigFactory implements OAuthConfigFactory {
|
||||||
|
private final OAuthScopes scopes;
|
||||||
|
|
||||||
|
@Named(AUDIENCE)
|
||||||
|
@Inject(optional = true)
|
||||||
|
private String audience;
|
||||||
|
|
||||||
|
@Named(RESOURCE)
|
||||||
|
@Inject(optional = true)
|
||||||
|
private String resource;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
AzureOAuthConfigFactory(OAuthScopes scopes) {
|
||||||
|
this.scopes = scopes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OAuthConfig forRequest(HttpRequest input) {
|
||||||
|
OAuthResource customResource = null;
|
||||||
|
if (input instanceof GeneratedHttpRequest) {
|
||||||
|
GeneratedHttpRequest request = (GeneratedHttpRequest) input;
|
||||||
|
customResource = request.getInvocation().getInvokable().getAnnotation(OAuthResource.class);
|
||||||
|
if (customResource == null) {
|
||||||
|
customResource = request.getInvocation().getInvokable().getDeclaringClass()
|
||||||
|
.getAnnotation(OAuthResource.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String oauthResource = customResource != null ? customResource.value() : resource;
|
||||||
|
return OAuthConfig.create(scopes.forRequest(input), audience, oauthResource);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* 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.config;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Qualifier;
|
||||||
|
|
||||||
|
import com.google.common.base.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the Graph RBAC API endpoint for the current tenant.
|
||||||
|
*/
|
||||||
|
@Retention(value = RetentionPolicy.RUNTIME)
|
||||||
|
@Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
|
||||||
|
@Qualifier
|
||||||
|
public @interface GraphRBAC {
|
||||||
|
|
||||||
|
String ENDPOINT = "https://graph.windows.net/";
|
||||||
|
|
||||||
|
static class GraphRBACForTenant implements Supplier<URI> {
|
||||||
|
private final String tenantId;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
GraphRBACForTenant(@Tenant String tenantId) {
|
||||||
|
this.tenantId = tenantId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public URI get() {
|
||||||
|
return URI.create(GraphRBAC.ENDPOINT + tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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.config;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import javax.inject.Qualifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures a custom OAuth resource for certain APIs and methods.
|
||||||
|
*/
|
||||||
|
@Retention(value = RetentionPolicy.RUNTIME)
|
||||||
|
@Target(value = { ElementType.TYPE, ElementType.METHOD })
|
||||||
|
@Qualifier
|
||||||
|
public @interface OAuthResource {
|
||||||
|
|
||||||
|
String value();
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* 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.config;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import javax.inject.Qualifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Qualifies an object that describes the current tenant.
|
||||||
|
*/
|
||||||
|
@Retention(value = RetentionPolicy.RUNTIME)
|
||||||
|
@Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
|
||||||
|
@Qualifier
|
||||||
|
public @interface Tenant {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class Availability {
|
||||||
|
|
||||||
|
public abstract String nameAvailable();
|
||||||
|
|
||||||
|
@SerializedNames({"nameAvailable"})
|
||||||
|
public static Availability create(final String nameAvailable) {
|
||||||
|
return new AutoValue_Availability(nameAvailable);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,223 @@
|
||||||
|
/*
|
||||||
|
* 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 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AvailabilitySet for subscription
|
||||||
|
*/
|
||||||
|
@AutoValue
|
||||||
|
public abstract class AvailabilitySet {
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class AvailabilitySetProperties {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A platform Update Domain Count
|
||||||
|
*/
|
||||||
|
public abstract int platformUpdateDomainCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A platform Fault Domain Count
|
||||||
|
*/
|
||||||
|
public abstract int platformFaultDomainCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of virtual machines in the availability set
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract List<IdReference> virtualMachines();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of statuses in the availability set
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract List<Status> statuses();
|
||||||
|
|
||||||
|
@SerializedNames({ "platformUpdateDomainCount", "platformFaultDomainCount", "virtualMachines", "statuses" })
|
||||||
|
public static AvailabilitySetProperties create(final int platformUpdateDomainCount,
|
||||||
|
final int platformFaultDomainCount, List<IdReference> virtualMachines, List<Status> statuses) {
|
||||||
|
return builder().platformUpdateDomainCount(platformUpdateDomainCount)
|
||||||
|
.platformFaultDomainCount(platformFaultDomainCount).virtualMachines(virtualMachines).statuses(statuses)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_AvailabilitySet_AvailabilitySetProperties.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder platformUpdateDomainCount(int platformUpdateDomainCount);
|
||||||
|
public abstract Builder platformFaultDomainCount(int platformFaultDomainCount);
|
||||||
|
public abstract Builder virtualMachines(List<IdReference> virtualMachines);
|
||||||
|
public abstract Builder statuses(List<Status> statuses);
|
||||||
|
|
||||||
|
abstract List<IdReference> virtualMachines();
|
||||||
|
abstract List<Status> statuses();
|
||||||
|
abstract AvailabilitySetProperties autoBuild();
|
||||||
|
|
||||||
|
public AvailabilitySetProperties build() {
|
||||||
|
virtualMachines(virtualMachines() != null ? ImmutableList.copyOf(virtualMachines()) : null);
|
||||||
|
statuses(statuses() != null ? ImmutableList.copyOf(statuses()) : null);
|
||||||
|
return autoBuild();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum AvailabilitySetType {
|
||||||
|
MANAGED("Aligned"),
|
||||||
|
CLASSIC("Classic");
|
||||||
|
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
AvailabilitySetType(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AvailabilitySetType fromString(String value) {
|
||||||
|
AvailabilitySetType[] items = AvailabilitySetType.values();
|
||||||
|
for (AvailabilitySetType item : items) {
|
||||||
|
if (item.toString().equalsIgnoreCase(value)) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Unexpected type: " + value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class SKU {
|
||||||
|
|
||||||
|
public abstract AvailabilitySetType type();
|
||||||
|
|
||||||
|
@SerializedNames({ "name" })
|
||||||
|
public static SKU create(final String type) {
|
||||||
|
return create(AvailabilitySetType.fromString(type));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SKU create(AvailabilitySetType type) {
|
||||||
|
return new AutoValue_AvailabilitySet_SKU(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The id of the availability set
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the availability set.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of the availability set.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String type();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The location of the availability set
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String location();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the type of the availability set
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract SKU sku();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the tags of the availability set
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract Map<String, String> tags();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the properties of the availability set
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract AvailabilitySetProperties properties();
|
||||||
|
|
||||||
|
@SerializedNames({ "id", "name", "type", "location", "sku", "tags", "properties" })
|
||||||
|
public static AvailabilitySet create(final String id, final String name, final String type, final String location,
|
||||||
|
SKU sku, final Map<String, String> tags, AvailabilitySetProperties properties) {
|
||||||
|
return builder().id(id).name(name).type(type).location(location).sku(sku).tags(tags).properties(properties)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
private static Builder builder() {
|
||||||
|
return new AutoValue_AvailabilitySet.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder managed() {
|
||||||
|
return builder().managed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Builder classic() {
|
||||||
|
return builder().classic();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder id(String id);
|
||||||
|
public abstract Builder name(String name);
|
||||||
|
public abstract Builder type(String type);
|
||||||
|
public abstract Builder location(String location);
|
||||||
|
public abstract Builder tags(Map<String, String> tags);
|
||||||
|
public abstract Builder properties(AvailabilitySetProperties properties);
|
||||||
|
|
||||||
|
abstract Builder sku(SKU sku);
|
||||||
|
public Builder managed() {
|
||||||
|
return sku(SKU.create(AvailabilitySetType.MANAGED));
|
||||||
|
}
|
||||||
|
public Builder classic() {
|
||||||
|
return sku(SKU.create(AvailabilitySetType.CLASSIC));
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract Map<String, String> tags();
|
||||||
|
abstract AvailabilitySet autoBuild();
|
||||||
|
|
||||||
|
public AvailabilitySet build() {
|
||||||
|
tags(tags() != null ? ImmutableMap.copyOf(tags()) : null);
|
||||||
|
return autoBuild();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* 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.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class BackendAddressPool {
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract BackendAddressPoolProperties properties();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String etag();
|
||||||
|
|
||||||
|
@SerializedNames({ "name", "id", "properties", "etag" })
|
||||||
|
public static BackendAddressPool create(final String name, final String id,
|
||||||
|
final BackendAddressPoolProperties properties, final String etag) {
|
||||||
|
return new AutoValue_BackendAddressPool(name, id, properties, etag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* 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.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class BackendAddressPoolProperties implements Provisionable {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String provisioningState();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<IdReference> backendIPConfigurations();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<IdReference> loadBalancingRules();
|
||||||
|
|
||||||
|
|
||||||
|
@SerializedNames({ "provisioningState", "backendIPConfigurations", "loadBalancingRules"})
|
||||||
|
public static BackendAddressPoolProperties create(final String provisioningState,
|
||||||
|
final List<IdReference> backendIPConfigurations, final List<IdReference> loadBalancingRules) {
|
||||||
|
return builder().provisioningState(provisioningState).backendIPConfigurations(backendIPConfigurations).loadBalancingRules(loadBalancingRules).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_BackendAddressPoolProperties.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
|
||||||
|
public abstract Builder provisioningState(String provisioningState);
|
||||||
|
|
||||||
|
public abstract Builder backendIPConfigurations(List<IdReference> backendIPConfigurations);
|
||||||
|
|
||||||
|
public abstract Builder loadBalancingRules(List<IdReference> loadBalancingRules);
|
||||||
|
|
||||||
|
abstract List<IdReference> backendIPConfigurations();
|
||||||
|
abstract List<IdReference> loadBalancingRules();
|
||||||
|
|
||||||
|
abstract BackendAddressPoolProperties autoBuild();
|
||||||
|
|
||||||
|
public BackendAddressPoolProperties build() {
|
||||||
|
backendIPConfigurations(backendIPConfigurations() != null ? ImmutableList.copyOf(backendIPConfigurations())
|
||||||
|
: null);
|
||||||
|
loadBalancingRules(loadBalancingRules() != null ? ImmutableList.copyOf(loadBalancingRules()) : null);
|
||||||
|
return autoBuild();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,638 @@
|
||||||
|
/*
|
||||||
|
* 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.Map;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class Certificate {
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class CertificateAttributes {
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer created();
|
||||||
|
|
||||||
|
public abstract boolean enabled();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer expiry();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer notBefore();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String recoveryLevel();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer updated();
|
||||||
|
|
||||||
|
@SerializedNames({"created", "enabled", "exp", "nbf", "recoveryLevel", "updated"})
|
||||||
|
public static CertificateAttributes create(final Integer created,
|
||||||
|
final boolean enabled,
|
||||||
|
final Integer expiry,
|
||||||
|
final Integer notBefore,
|
||||||
|
final String recoveryLevel,
|
||||||
|
final Integer updated) {
|
||||||
|
return new AutoValue_Certificate_CertificateAttributes(created, enabled, expiry, notBefore, recoveryLevel, updated);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class IssuerParameters {
|
||||||
|
@Nullable
|
||||||
|
public abstract String certType();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
@SerializedNames({"cty", "name"})
|
||||||
|
public static IssuerParameters create(final String certType,
|
||||||
|
final String name) {
|
||||||
|
return new AutoValue_Certificate_IssuerParameters(certType, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class KeyProperties {
|
||||||
|
@Nullable
|
||||||
|
public abstract Boolean exportable();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer keySize();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String keyType();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Boolean reuseKey();
|
||||||
|
|
||||||
|
@SerializedNames({"exportable", "key_size", "kty", "reuse_key"})
|
||||||
|
public static KeyProperties create(final boolean exportable,
|
||||||
|
final Integer keySize,
|
||||||
|
final String keyType,
|
||||||
|
final boolean reuseKey) {
|
||||||
|
return new AutoValue_Certificate_KeyProperties(exportable, keySize, keyType, reuseKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class LifetimeActionTrigger {
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer daysBeforeExpiry();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer lifetimePercentage();
|
||||||
|
|
||||||
|
@SerializedNames({"days_before_expiry", "lifetime_percentage"})
|
||||||
|
public static LifetimeActionTrigger create(final Integer daysBeforeExpiry,
|
||||||
|
final Integer lifetimePercentage) {
|
||||||
|
return new AutoValue_Certificate_LifetimeActionTrigger(daysBeforeExpiry, lifetimePercentage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class LifetimeActionAction {
|
||||||
|
public abstract String actionType();
|
||||||
|
|
||||||
|
@SerializedNames({"action_type"})
|
||||||
|
public static LifetimeActionAction create(final String actionType) {
|
||||||
|
return new AutoValue_Certificate_LifetimeActionAction(actionType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class LifetimeAction {
|
||||||
|
public abstract LifetimeActionAction action();
|
||||||
|
|
||||||
|
public abstract LifetimeActionTrigger trigger();
|
||||||
|
|
||||||
|
@SerializedNames({"action", "trigger"})
|
||||||
|
public static LifetimeAction create(final LifetimeActionAction action,
|
||||||
|
final LifetimeActionTrigger trigger) {
|
||||||
|
return new AutoValue_Certificate_LifetimeAction(action, trigger);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class SecretProperties {
|
||||||
|
public abstract String contentType();
|
||||||
|
|
||||||
|
@SerializedNames({"contentType"})
|
||||||
|
public static SecretProperties create(final String contentType) {
|
||||||
|
return new AutoValue_Certificate_SecretProperties(contentType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class SubjectAlternativeNames {
|
||||||
|
public abstract List<String> dnsNames();
|
||||||
|
|
||||||
|
public abstract List<String> emails();
|
||||||
|
|
||||||
|
public abstract List<String> upns();
|
||||||
|
|
||||||
|
@SerializedNames({"dns_names", "emails", "upns"})
|
||||||
|
public static SubjectAlternativeNames create(final List<String> dnsNames,
|
||||||
|
final List<String> emails,
|
||||||
|
final List<String> upns) {
|
||||||
|
return new AutoValue_Certificate_SubjectAlternativeNames(
|
||||||
|
dnsNames != null ? ImmutableList.copyOf(dnsNames) : ImmutableList.<String> of(),
|
||||||
|
emails != null ? ImmutableList.copyOf(emails) : ImmutableList.<String> of(),
|
||||||
|
upns != null ? ImmutableList.copyOf(upns) : ImmutableList.<String> of()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class X509CertificateProperties {
|
||||||
|
public abstract List<String> enhancedKeyUsage();
|
||||||
|
|
||||||
|
public abstract List<String> keyUsage();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract SubjectAlternativeNames subjectAltNames();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String subject();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer validityMonths();
|
||||||
|
|
||||||
|
@SerializedNames({"ekus", "key_usage", "sans", "subject", "validity_months"})
|
||||||
|
public static X509CertificateProperties create(final List<String> enhancedKeyUsage,
|
||||||
|
final List<String> keyUsage,
|
||||||
|
final SubjectAlternativeNames subjectAltNames,
|
||||||
|
final String subject,
|
||||||
|
final Integer validityMonths) {
|
||||||
|
return new AutoValue_Certificate_X509CertificateProperties(
|
||||||
|
enhancedKeyUsage != null ? ImmutableList.copyOf(enhancedKeyUsage) : ImmutableList.<String> of(),
|
||||||
|
keyUsage != null ? ImmutableList.copyOf(keyUsage) : ImmutableList.<String> of(),
|
||||||
|
subjectAltNames,
|
||||||
|
subject,
|
||||||
|
validityMonths
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class CertificatePolicy {
|
||||||
|
@Nullable
|
||||||
|
public abstract CertificateAttributes attributes();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract IssuerParameters issuer();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract KeyProperties keyProps();
|
||||||
|
|
||||||
|
public abstract List<LifetimeAction> lifetimeActions();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract SecretProperties secretProps();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract X509CertificateProperties x509props();
|
||||||
|
|
||||||
|
@SerializedNames({"attributes", "id", "issuer", "key_props", "lifetime_actions", "secret_props", "x509_props"})
|
||||||
|
public static CertificatePolicy create(final CertificateAttributes attributes,
|
||||||
|
final String id,
|
||||||
|
final IssuerParameters issuer,
|
||||||
|
final KeyProperties keyProps,
|
||||||
|
final List<LifetimeAction> lifetimeActions,
|
||||||
|
final SecretProperties secretProperties,
|
||||||
|
final X509CertificateProperties x509Props) {
|
||||||
|
return new AutoValue_Certificate_CertificatePolicy(
|
||||||
|
attributes,
|
||||||
|
id,
|
||||||
|
issuer,
|
||||||
|
keyProps,
|
||||||
|
lifetimeActions != null ? ImmutableList.copyOf(lifetimeActions) : ImmutableList.<LifetimeAction>of(),
|
||||||
|
secretProperties,
|
||||||
|
x509Props
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class CertificateError {
|
||||||
|
@Nullable
|
||||||
|
public abstract String code();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String message();
|
||||||
|
|
||||||
|
@SerializedNames({"code", "message"})
|
||||||
|
public static CertificateError create(final String code,
|
||||||
|
final String message) {
|
||||||
|
return new AutoValue_Certificate_CertificateError(code, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class CertificateOperation {
|
||||||
|
@Nullable
|
||||||
|
public abstract Boolean cancellationRequested();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String csr();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract CertificateError error();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract IssuerParameters issuer();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String requestId();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String status();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String statusDetails();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String target();
|
||||||
|
|
||||||
|
@SerializedNames({"cancellation_requested", "csr", "error", "id", "issuer", "request_id", "status", "status_details", "target"})
|
||||||
|
public static CertificateOperation create(final boolean cancellationRequested,
|
||||||
|
final String csr,
|
||||||
|
final CertificateError error,
|
||||||
|
final String id,
|
||||||
|
final IssuerParameters issuer,
|
||||||
|
final String requestId,
|
||||||
|
final String status,
|
||||||
|
final String statusDetails,
|
||||||
|
final String target) {
|
||||||
|
return new AutoValue_Certificate_CertificateOperation(
|
||||||
|
cancellationRequested,
|
||||||
|
csr,
|
||||||
|
error,
|
||||||
|
id,
|
||||||
|
issuer,
|
||||||
|
requestId,
|
||||||
|
status,
|
||||||
|
statusDetails,
|
||||||
|
target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class CertificateBundle {
|
||||||
|
@Nullable
|
||||||
|
public abstract CertificateAttributes attributes();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String certificate();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String contentType();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String keyId();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract CertificatePolicy policy();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String secretId();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Map<String, String> tags();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String thumbprint();
|
||||||
|
|
||||||
|
@SerializedNames({"attributes", "cer", "contentType", "id", "kid", "policy", "sid", "tags", "x5t"})
|
||||||
|
public static CertificateBundle create(final CertificateAttributes attributes,
|
||||||
|
final String certificate,
|
||||||
|
final String contentType,
|
||||||
|
final String id,
|
||||||
|
final String keyId,
|
||||||
|
final CertificatePolicy policy,
|
||||||
|
final String secretId,
|
||||||
|
final Map<String, String> tags,
|
||||||
|
final String thumbprint) {
|
||||||
|
return new AutoValue_Certificate_CertificateBundle(attributes,
|
||||||
|
certificate,
|
||||||
|
contentType,
|
||||||
|
id,
|
||||||
|
keyId,
|
||||||
|
policy,
|
||||||
|
secretId,
|
||||||
|
tags != null ? ImmutableMap.copyOf(tags) : null,
|
||||||
|
thumbprint
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class CertificateIssuer {
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
public abstract String provider();
|
||||||
|
|
||||||
|
@SerializedNames({"id", "provider"})
|
||||||
|
public static CertificateIssuer create(final String id,
|
||||||
|
final String provider) {
|
||||||
|
return new AutoValue_Certificate_CertificateIssuer(id, provider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class IssuerAttributes {
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer created();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Boolean enabled();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer updated();
|
||||||
|
|
||||||
|
@SerializedNames({"created", "enabled", "updated"})
|
||||||
|
public static IssuerAttributes create(final Integer created,
|
||||||
|
final Boolean enabled,
|
||||||
|
final Integer updated) {
|
||||||
|
return new AutoValue_Certificate_IssuerAttributes(created, enabled, updated);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class IssuerCredentials {
|
||||||
|
@Nullable
|
||||||
|
public abstract String accountId();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String password();
|
||||||
|
|
||||||
|
@SerializedNames({"account_id", "pwd"})
|
||||||
|
public static IssuerCredentials create(final String accountId,
|
||||||
|
final String password) {
|
||||||
|
return new AutoValue_Certificate_IssuerCredentials(accountId, password);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class OrganizationDetails {
|
||||||
|
public abstract List<AdministrationDetails> adminDetails();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@SerializedNames({"admin_details", "id"})
|
||||||
|
public static OrganizationDetails create(final List<AdministrationDetails> adminDetails,
|
||||||
|
final String id) {
|
||||||
|
return new AutoValue_Certificate_OrganizationDetails(
|
||||||
|
adminDetails != null ? ImmutableList.copyOf(adminDetails) : ImmutableList.<AdministrationDetails> of(),
|
||||||
|
id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class AdministrationDetails {
|
||||||
|
@Nullable
|
||||||
|
public abstract String email();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String firstName();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String lastName();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String phoneNumber();
|
||||||
|
|
||||||
|
@SerializedNames({"email", "first_name", "last_name", "phone"})
|
||||||
|
public static AdministrationDetails create(final String email,
|
||||||
|
final String firstName,
|
||||||
|
final String lastName,
|
||||||
|
final String phoneNumber) {
|
||||||
|
return new AutoValue_Certificate_AdministrationDetails(email, firstName, lastName, phoneNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class IssuerBundle {
|
||||||
|
@Nullable
|
||||||
|
public abstract IssuerAttributes attributes();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract IssuerCredentials credentials();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract OrganizationDetails organizationDetails();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String provider();
|
||||||
|
|
||||||
|
@SerializedNames({"attributes", "credentials", "id", "org_details", "provider"})
|
||||||
|
public static IssuerBundle create(final IssuerAttributes attributes,
|
||||||
|
final IssuerCredentials credentials,
|
||||||
|
final String id,
|
||||||
|
final OrganizationDetails orgDetails,
|
||||||
|
final String provider) {
|
||||||
|
return new AutoValue_Certificate_IssuerBundle(attributes, credentials, id, orgDetails, provider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class Contact {
|
||||||
|
@Nullable
|
||||||
|
public abstract String email();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String phone();
|
||||||
|
|
||||||
|
@SerializedNames({"email", "name", "phone"})
|
||||||
|
public static Contact create(final String email,
|
||||||
|
final String name,
|
||||||
|
final String phone) {
|
||||||
|
return new AutoValue_Certificate_Contact(email, name, phone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class Contacts {
|
||||||
|
public abstract List<Contact> contacts();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@SerializedNames({"contacts", "id"})
|
||||||
|
public static Contacts create(final List<Contact> contacts,
|
||||||
|
final String id) {
|
||||||
|
return new AutoValue_Certificate_Contacts(
|
||||||
|
contacts != null ? ImmutableList.copyOf(contacts) : ImmutableList.<Contact> of(),
|
||||||
|
id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class DeletedCertificateBundle {
|
||||||
|
@Nullable
|
||||||
|
public abstract CertificateAttributes attributes();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String bytes();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer deletedDate();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String keyId();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String recoveryId();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer scheduledPurgeDate();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String secredId();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Map<String, String> tags();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String thumbprint();
|
||||||
|
|
||||||
|
@SerializedNames({"attributes", "cer", "deletedDate", "id", "kid", "recoveryId", "scheduledPurgeDate", "sid", "tags", "x5t"})
|
||||||
|
public static DeletedCertificateBundle create(final CertificateAttributes attributes,
|
||||||
|
final String bytes,
|
||||||
|
final Integer deletedDate,
|
||||||
|
final String id,
|
||||||
|
final String keyId,
|
||||||
|
final String recoveryId,
|
||||||
|
final Integer scheduledPurgeDate,
|
||||||
|
final String secretId,
|
||||||
|
final Map<String, String> tags,
|
||||||
|
final String thumbprint) {
|
||||||
|
return new AutoValue_Certificate_DeletedCertificateBundle(
|
||||||
|
attributes,
|
||||||
|
bytes,
|
||||||
|
deletedDate,
|
||||||
|
id,
|
||||||
|
keyId,
|
||||||
|
recoveryId,
|
||||||
|
scheduledPurgeDate,
|
||||||
|
secretId,
|
||||||
|
tags != null ? ImmutableMap.copyOf(tags) : null,
|
||||||
|
thumbprint
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class DeletedCertificate {
|
||||||
|
@Nullable
|
||||||
|
public abstract CertificateAttributes attributes();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer deletedDate();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String recoveryId();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer scheduledPurgeDate();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Map<String, String> tags();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String thumbprint();
|
||||||
|
|
||||||
|
@SerializedNames({"attributes", "deletedDate", "id", "recoveryId", "scheduledPurgeDate", "tags", "x5t"})
|
||||||
|
public static DeletedCertificate create(final CertificateAttributes attributes,
|
||||||
|
final Integer deletedDate,
|
||||||
|
final String id,
|
||||||
|
final String recoveryId,
|
||||||
|
final Integer scheduledPurgeDate,
|
||||||
|
final Map<String, String> tags,
|
||||||
|
final String thumbprint) {
|
||||||
|
return new AutoValue_Certificate_DeletedCertificate(
|
||||||
|
attributes,
|
||||||
|
deletedDate,
|
||||||
|
id,
|
||||||
|
recoveryId,
|
||||||
|
scheduledPurgeDate,
|
||||||
|
tags != null ? ImmutableMap.copyOf(tags) : null,
|
||||||
|
thumbprint
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract CertificateAttributes attributes();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Map<String, String> tags();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String thumbprint();
|
||||||
|
|
||||||
|
@SerializedNames({"attributes", "id", "tags", "x5t"})
|
||||||
|
public static Certificate create(final CertificateAttributes attributes,
|
||||||
|
final String id,
|
||||||
|
final Map<String, String> tags,
|
||||||
|
final String thumbprint) {
|
||||||
|
return new AutoValue_Certificate(
|
||||||
|
attributes,
|
||||||
|
id,
|
||||||
|
tags != null ? ImmutableMap.copyOf(tags) : null,
|
||||||
|
thumbprint
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Certificate() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* 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 class ComputeNode {
|
||||||
|
public enum Status {
|
||||||
|
GOOD,
|
||||||
|
BAD,
|
||||||
|
UNRECOGNIZED;
|
||||||
|
|
||||||
|
public static Status fromValue(final String text) {
|
||||||
|
return (Status) GetEnumValue.fromValueOrDefault(text, Status.UNRECOGNIZED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.base.CaseFormat;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class CreationData {
|
||||||
|
|
||||||
|
|
||||||
|
public enum CreateOptions {
|
||||||
|
EMPTY,
|
||||||
|
FROM_IMAGE,
|
||||||
|
COPY,
|
||||||
|
IMPORT,
|
||||||
|
UNRECOGNIZED;
|
||||||
|
|
||||||
|
public static CreateOptions fromValue(final String text) {
|
||||||
|
return (CreateOptions) GetEnumValue.fromValueOrDefault(text, UNRECOGNIZED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract CreateOptions createOption();
|
||||||
|
|
||||||
|
@SerializedNames({ "createOption" })
|
||||||
|
public static CreationData create(CreateOptions createOption) {
|
||||||
|
return new AutoValue_CreationData(createOption);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,160 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.base.CaseFormat;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class DataDisk implements Provisionable {
|
||||||
|
|
||||||
|
public enum DiskCreateOptionTypes {
|
||||||
|
FROM_IMAGE,
|
||||||
|
EMPTY,
|
||||||
|
ATTACH,
|
||||||
|
UNRECOGNIZED;
|
||||||
|
|
||||||
|
public static DiskCreateOptionTypes fromValue(final String text) {
|
||||||
|
return (DiskCreateOptionTypes) GetEnumValue.fromValueOrDefault(text, UNRECOGNIZED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CachingTypes {
|
||||||
|
NONE,
|
||||||
|
READ_ONLY,
|
||||||
|
READ_WRITE,
|
||||||
|
UNRECOGNIZED;
|
||||||
|
|
||||||
|
public static CachingTypes fromValue(final String text) {
|
||||||
|
for (CachingTypes type : CachingTypes.values()) {
|
||||||
|
if (type.toString().equals(text)) {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return UNRECOGNIZED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the data disk
|
||||||
|
*/
|
||||||
|
@Nullable public abstract String name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The size of the data disk
|
||||||
|
*/
|
||||||
|
@Nullable public abstract String diskSizeGB();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The lun value of the data disk
|
||||||
|
*/
|
||||||
|
@Nullable public abstract Integer lun();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The vhd of the data disk
|
||||||
|
*/
|
||||||
|
@Nullable public abstract VHD vhd();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The source user image virtual hard disk. This virtual hard disk will be
|
||||||
|
* copied before using it to attach to the virtual machine. If SourceImage
|
||||||
|
* is provided, the destination virtual hard disk must not exist.
|
||||||
|
*/
|
||||||
|
@Nullable public abstract VHD image();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The create option of the data disk
|
||||||
|
*/
|
||||||
|
public abstract DiskCreateOptionTypes createOption();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The caching type. Possible values include: 'None', 'ReadOnly',
|
||||||
|
* 'ReadWrite'.
|
||||||
|
*/
|
||||||
|
@Nullable public abstract CachingTypes caching();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The managed disk parameters.
|
||||||
|
*/
|
||||||
|
@Nullable public abstract ManagedDiskParameters managedDiskParameters();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String provisioningState();
|
||||||
|
|
||||||
|
@SerializedNames({"name", "diskSizeGB", "lun", "vhd", "image", "createOption", "caching", "managedDisk", "provisioningState"})
|
||||||
|
public static DataDisk create(final String name, final String diskSizeGB, final Integer lun,
|
||||||
|
final VHD vhd, final VHD image, final String createOption, final String caching,
|
||||||
|
final ManagedDiskParameters managedDiskParamenters, final String provisioningState) {
|
||||||
|
final Builder builder = builder();
|
||||||
|
if (caching != null) {
|
||||||
|
builder.caching(CachingTypes.fromValue(caching));
|
||||||
|
}
|
||||||
|
return builder.name(name)
|
||||||
|
.diskSizeGB(diskSizeGB)
|
||||||
|
.lun(lun)
|
||||||
|
.vhd(vhd)
|
||||||
|
.image(image)
|
||||||
|
.createOption(DiskCreateOptionTypes.fromValue(createOption))
|
||||||
|
.managedDiskParameters(managedDiskParamenters)
|
||||||
|
.provisioningState(provisioningState)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_DataDisk.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
|
||||||
|
public abstract Builder name(String name);
|
||||||
|
|
||||||
|
public abstract Builder diskSizeGB(String diskSizeGB);
|
||||||
|
|
||||||
|
public abstract Builder createOption(DiskCreateOptionTypes createOption);
|
||||||
|
|
||||||
|
public abstract Builder lun(Integer lun);
|
||||||
|
|
||||||
|
public abstract Builder vhd(VHD vhd);
|
||||||
|
|
||||||
|
public abstract Builder image(VHD image);
|
||||||
|
|
||||||
|
public abstract Builder caching(CachingTypes caching);
|
||||||
|
|
||||||
|
public abstract Builder managedDiskParameters(ManagedDiskParameters managedDiskParameters);
|
||||||
|
|
||||||
|
public abstract Builder provisioningState(String provisioningState);
|
||||||
|
|
||||||
|
public abstract DataDisk build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,254 @@
|
||||||
|
/*
|
||||||
|
* 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 java.util.Map;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.util.GetEnumValue;
|
||||||
|
import org.jclouds.domain.JsonBall;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
import static com.google.common.collect.ImmutableList.copyOf;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class Deployment {
|
||||||
|
|
||||||
|
public enum ProvisioningState {
|
||||||
|
ACCEPTED,
|
||||||
|
READY,
|
||||||
|
CANCELED,
|
||||||
|
FAILED,
|
||||||
|
DELETED,
|
||||||
|
SUCCEEDED,
|
||||||
|
RUNNING,
|
||||||
|
UNRECOGNIZED;
|
||||||
|
|
||||||
|
public static ProvisioningState fromValue(final String text) {
|
||||||
|
return (ProvisioningState) GetEnumValue.fromValueOrDefault(text, ProvisioningState.UNRECOGNIZED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum DeploymentMode {
|
||||||
|
INCREMENTAL,
|
||||||
|
COMPLETE,
|
||||||
|
UNRECOGNIZED;
|
||||||
|
|
||||||
|
public static DeploymentMode fromValue(final String text) {
|
||||||
|
return (DeploymentMode) GetEnumValue.fromValueOrDefault(text, DeploymentMode.UNRECOGNIZED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class TypeValue {
|
||||||
|
public abstract String type();
|
||||||
|
|
||||||
|
public abstract String value();
|
||||||
|
|
||||||
|
@SerializedNames({"type", "value"})
|
||||||
|
public static TypeValue create(final String type, final String value) {
|
||||||
|
return new AutoValue_Deployment_TypeValue(type, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class ProviderResourceType {
|
||||||
|
@Nullable
|
||||||
|
public abstract String resourceType();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<String> locations();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<String> apiVersions();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Map<String, JsonBall> properties();
|
||||||
|
|
||||||
|
@SerializedNames({"resourceType", "locations", "apiVersions", "properties"})
|
||||||
|
public static ProviderResourceType create(final String resourceType,
|
||||||
|
final List<String> locations,
|
||||||
|
final List<String> apiVersions,
|
||||||
|
@Nullable final Map<String, JsonBall> properties) {
|
||||||
|
return new AutoValue_Deployment_ProviderResourceType(resourceType,
|
||||||
|
locations == null ? null : copyOf(locations),
|
||||||
|
apiVersions == null ? null : copyOf(apiVersions),
|
||||||
|
properties == null ? ImmutableMap.<String, JsonBall>builder().build() : ImmutableMap.copyOf(properties));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class Provider {
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String namespace();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String registrationState();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<ProviderResourceType> resourceTypes();
|
||||||
|
|
||||||
|
@SerializedNames({"id", "namespace", "registrationState", "resourceTypes"})
|
||||||
|
public static Provider create(final String id,
|
||||||
|
final String namespace,
|
||||||
|
final String registrationState,
|
||||||
|
final List<ProviderResourceType> resourceTypes) {
|
||||||
|
return new AutoValue_Deployment_Provider(id, namespace, registrationState, resourceTypes == null ? null : copyOf(resourceTypes));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class Dependency {
|
||||||
|
@Nullable
|
||||||
|
public abstract List<Dependency> dependencies();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<Dependency> dependsOn();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String resourceType();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String resourceName();
|
||||||
|
|
||||||
|
@SerializedNames({"dependencies", "dependsOn", "id", "resourceType", "resourceName"})
|
||||||
|
public static Dependency create(final List<Dependency> dependencies,
|
||||||
|
final List<Dependency> dependsOn,
|
||||||
|
final String id,
|
||||||
|
final String resourceType,
|
||||||
|
final String resourceName) {
|
||||||
|
return new AutoValue_Deployment_Dependency(dependencies == null ? null : copyOf(dependencies),
|
||||||
|
dependsOn == null ? null : copyOf(dependsOn), id, resourceType, resourceName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class ContentLink {
|
||||||
|
public abstract String uri();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String contentVersion();
|
||||||
|
|
||||||
|
@SerializedNames({"uri", "contentVersion"})
|
||||||
|
public static ContentLink create(final String uri, final String contentVersion) {
|
||||||
|
return new AutoValue_Deployment_ContentLink(uri, contentVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class DeploymentProperties implements Provisionable {
|
||||||
|
@Nullable
|
||||||
|
public abstract String provisioningState();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String correlationId();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String timestamp();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Map<String, JsonBall> outputs();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<Provider> providers();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<Dependency> dependencies();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Map<String, JsonBall> template();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract ContentLink templateLink();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Map<String, Value> parameters();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract ContentLink parametersLink();
|
||||||
|
|
||||||
|
public abstract String mode();
|
||||||
|
|
||||||
|
// The entries below seem to be dynamic/not documented in the specification
|
||||||
|
@Nullable
|
||||||
|
public abstract String duration();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<Map<String, String>> outputResources();
|
||||||
|
|
||||||
|
@SerializedNames({"provisioningState", "correlationId", "timestamp", "outputs", "providers", "dependencies", "template", "templateLink", "parameters", "parametersLink", "mode", "duration", "outputResources"})
|
||||||
|
public static DeploymentProperties create(final String provisioningState,
|
||||||
|
final String correlationId,
|
||||||
|
final String timestamp,
|
||||||
|
@Nullable final Map<String, JsonBall> outputs,
|
||||||
|
final List<Provider> providers,
|
||||||
|
final List<Dependency> dependencies,
|
||||||
|
final Map<String, JsonBall> template,
|
||||||
|
final ContentLink templateLink,
|
||||||
|
final Map<String, Value> parameters,
|
||||||
|
final ContentLink parametersLink,
|
||||||
|
final String mode,
|
||||||
|
final String duration,
|
||||||
|
final List<Map<String, String>> outputResources) {
|
||||||
|
return new AutoValue_Deployment_DeploymentProperties(provisioningState,
|
||||||
|
correlationId,
|
||||||
|
timestamp,
|
||||||
|
outputs == null ? ImmutableMap.<String, JsonBall>builder().build() : ImmutableMap.copyOf(outputs),
|
||||||
|
providers == null ? null : copyOf(providers),
|
||||||
|
dependencies == null ? null : copyOf(dependencies),
|
||||||
|
template == null ? ImmutableMap.<String, JsonBall>builder().build() : ImmutableMap.copyOf(template),
|
||||||
|
templateLink,
|
||||||
|
parameters == null ? ImmutableMap.<String, Value>builder().build() : ImmutableMap.copyOf(parameters),
|
||||||
|
parametersLink,
|
||||||
|
mode,
|
||||||
|
duration,
|
||||||
|
outputResources == null ? null : copyOf(outputResources));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ID associated with the template deployment.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name associated with the template deployment.
|
||||||
|
*/
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Properties of the deployment.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract DeploymentProperties properties();
|
||||||
|
|
||||||
|
@SerializedNames({"id", "name", "properties"})
|
||||||
|
public static Deployment create(final String id, final String name, final DeploymentProperties properties) {
|
||||||
|
return new AutoValue_Deployment(id, name, properties);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import org.jclouds.azurecompute.arm.domain.DeploymentTemplate.Parameters;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class DeploymentBody {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract DeploymentTemplate template();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String mode();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Parameters parameters();
|
||||||
|
|
||||||
|
@SerializedNames({"template", "mode", "parameters"})
|
||||||
|
public static DeploymentBody create(final DeploymentTemplate template,
|
||||||
|
final String mode,
|
||||||
|
final Parameters parameters) {
|
||||||
|
return new AutoValue_DeploymentBody(template, mode, parameters);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class DeploymentProperties {
|
||||||
|
|
||||||
|
public abstract DeploymentBody properties();
|
||||||
|
|
||||||
|
@SerializedNames({"properties"})
|
||||||
|
public static DeploymentProperties create(final DeploymentBody properties) {
|
||||||
|
return new AutoValue_DeploymentProperties(properties);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,125 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class DeploymentTemplate {
|
||||||
|
|
||||||
|
//Empty placeholders as we want to generate the empty JSON object
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class Parameters {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract KeyVaultReference publicKeyFromAzureKeyVault();
|
||||||
|
|
||||||
|
public static Parameters create(KeyVaultReference reference)
|
||||||
|
{
|
||||||
|
return new AutoValue_DeploymentTemplate_Parameters(reference);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class TemplateParameters {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract TemplateParameterType publicKeyFromAzureKeyVault();
|
||||||
|
|
||||||
|
public static TemplateParameters create(TemplateParameterType publicKeyFromAzureKeyVault)
|
||||||
|
{
|
||||||
|
return new AutoValue_DeploymentTemplate_TemplateParameters(publicKeyFromAzureKeyVault);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract String schema();
|
||||||
|
|
||||||
|
public abstract String contentVersion();
|
||||||
|
|
||||||
|
public abstract TemplateParameters parameters();
|
||||||
|
|
||||||
|
public abstract Map<String, String> variables();
|
||||||
|
|
||||||
|
public abstract List<ResourceDefinition> resources();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<?> outputs();
|
||||||
|
|
||||||
|
@SerializedNames({"$schema", "contentVersion", "parameters", "variables", "resources" , "outputs"})
|
||||||
|
public static DeploymentTemplate create(final String schema,
|
||||||
|
final String contentVersion,
|
||||||
|
final TemplateParameters parameters,
|
||||||
|
final Map<String, String> variables,
|
||||||
|
final List<ResourceDefinition> resources,
|
||||||
|
final List<?> outputs) {
|
||||||
|
|
||||||
|
DeploymentTemplate.Builder builder = DeploymentTemplate.builder()
|
||||||
|
.schema(schema)
|
||||||
|
.contentVersion(contentVersion)
|
||||||
|
.parameters(parameters);
|
||||||
|
|
||||||
|
if (variables != null)
|
||||||
|
builder.variables(variables);
|
||||||
|
|
||||||
|
if (resources != null)
|
||||||
|
builder.resources(resources);
|
||||||
|
|
||||||
|
builder.outputs(outputs == null ? null : ImmutableList.copyOf(outputs));
|
||||||
|
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_DeploymentTemplate.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder schema(String schema);
|
||||||
|
|
||||||
|
public abstract Builder contentVersion(String type);
|
||||||
|
|
||||||
|
public abstract Builder parameters(TemplateParameters parameters);
|
||||||
|
|
||||||
|
public abstract Builder variables(Map<String, String> variables);
|
||||||
|
|
||||||
|
public abstract Builder resources(List<ResourceDefinition> resources);
|
||||||
|
|
||||||
|
public abstract Builder outputs(List<?> outputs);
|
||||||
|
|
||||||
|
abstract Map<String, String> variables();
|
||||||
|
abstract List<ResourceDefinition> resources();
|
||||||
|
|
||||||
|
abstract DeploymentTemplate autoBuild();
|
||||||
|
|
||||||
|
public DeploymentTemplate build() {
|
||||||
|
variables(variables() != null ? ImmutableMap.copyOf(variables()) : null);
|
||||||
|
resources(resources() != null ? ImmutableList.copyOf(resources()) : null);
|
||||||
|
return autoBuild();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class DiagnosticsProfile {
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class BootDiagnostics{
|
||||||
|
|
||||||
|
public abstract boolean enabled();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String storageUri();
|
||||||
|
|
||||||
|
@SerializedNames({"enabled", "storageUri"})
|
||||||
|
public static BootDiagnostics create(final boolean enabled, final String storageUri) {
|
||||||
|
return builder()
|
||||||
|
.enabled(enabled)
|
||||||
|
.storageUri(storageUri)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_DiagnosticsProfile_BootDiagnostics.Builder();
|
||||||
|
}
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder enabled(boolean enabled);
|
||||||
|
public abstract Builder storageUri(String storageUri);
|
||||||
|
public abstract BootDiagnostics build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract BootDiagnostics bootDiagnostics();
|
||||||
|
|
||||||
|
@SerializedNames({"bootDiagnostics"})
|
||||||
|
public static DiagnosticsProfile create(final BootDiagnostics bootDiagnostics) {
|
||||||
|
return builder().bootDiagnostics(bootDiagnostics).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_DiagnosticsProfile.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder bootDiagnostics(BootDiagnostics bootDiagnostics);
|
||||||
|
public abstract DiagnosticsProfile build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,105 @@
|
||||||
|
/*
|
||||||
|
* 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.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 Disk {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The id of the disk
|
||||||
|
*/
|
||||||
|
@Nullable public abstract String id();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the disk
|
||||||
|
*/
|
||||||
|
@Nullable public abstract String name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The location of the disk
|
||||||
|
*/
|
||||||
|
public abstract String location();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of the disk
|
||||||
|
*/
|
||||||
|
@Nullable public abstract String type();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sku of the disk
|
||||||
|
*/
|
||||||
|
@Nullable public abstract SKU sku();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The managed disk parameters.
|
||||||
|
*/
|
||||||
|
public abstract DiskProperties properties();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the tags of the disk
|
||||||
|
*/
|
||||||
|
@Nullable public abstract Map<String, String> tags();
|
||||||
|
|
||||||
|
@SerializedNames({"id", "name", "location", "type", "sku", "properties", "tags"})
|
||||||
|
public static Disk create(final String id, final String name, final String location,
|
||||||
|
final String type, final SKU sku,
|
||||||
|
final DiskProperties properties, final Map<String, String> tags) {
|
||||||
|
return builder()
|
||||||
|
.id(id)
|
||||||
|
.name(name)
|
||||||
|
.location(location)
|
||||||
|
.type(type)
|
||||||
|
.sku(sku)
|
||||||
|
.properties(properties)
|
||||||
|
.tags(tags)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_Disk.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 sku(SKU sku);
|
||||||
|
public abstract Builder properties(DiskProperties properties);
|
||||||
|
public abstract Builder tags(Map<String, String> tags);
|
||||||
|
|
||||||
|
abstract Map<String, String> tags();
|
||||||
|
abstract Disk autoBuild();
|
||||||
|
|
||||||
|
public Disk build() {
|
||||||
|
tags(tags() != null ? ImmutableMap.copyOf(tags()) : null);
|
||||||
|
return autoBuild();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
* 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.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class DiskProperties implements Provisionable {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String provisioningState();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String timeCreated();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String diskState();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer diskSizeGB();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer lun();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract VHD vhd();
|
||||||
|
|
||||||
|
public abstract CreationData creationData();
|
||||||
|
|
||||||
|
@SerializedNames({"provisioningState", "timeCreated", "diskState", "diskSizeGB", "lun", "vhd", "creationData"})
|
||||||
|
public static DiskProperties create(final String provisioningState, final String timeCreated, final String diskState, final Integer diskSizeGB, final Integer lun, final VHD vhd, final CreationData creationData) {
|
||||||
|
return builder()
|
||||||
|
.provisioningState(provisioningState)
|
||||||
|
.timeCreated(timeCreated)
|
||||||
|
.diskState(diskState)
|
||||||
|
.diskSizeGB(diskSizeGB)
|
||||||
|
.lun(lun)
|
||||||
|
.vhd(vhd)
|
||||||
|
.creationData(creationData)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_DiskProperties.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder provisioningState(String provisioningState);
|
||||||
|
public abstract Builder timeCreated(String timeCreated);
|
||||||
|
public abstract Builder diskState(String diskState);
|
||||||
|
public abstract Builder diskSizeGB(Integer diskSizeGB);
|
||||||
|
public abstract Builder lun(Integer lun);
|
||||||
|
public abstract Builder vhd(VHD vhd);
|
||||||
|
public abstract Builder creationData(CreationData creationData);
|
||||||
|
public abstract DiskProperties build();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class DnsSettings {
|
||||||
|
|
||||||
|
public abstract String domainNameLabel();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String fqdn();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String reverseFqdn();
|
||||||
|
|
||||||
|
@SerializedNames({"domainNameLabel", "fqdn", "reverseFqdn"})
|
||||||
|
public static DnsSettings create(final String domainNameLabel, final String fqdn, final String reverseFqdn) {
|
||||||
|
return builder()
|
||||||
|
.domainNameLabel(domainNameLabel)
|
||||||
|
.fqdn(fqdn)
|
||||||
|
.reverseFqdn(reverseFqdn)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_DnsSettings.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder domainNameLabel(String domainNameLabel);
|
||||||
|
|
||||||
|
public abstract Builder fqdn(String fqdn);
|
||||||
|
|
||||||
|
public abstract Builder reverseFqdn(String reverseFqdn);
|
||||||
|
|
||||||
|
public abstract DnsSettings build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class Extension {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name reference of the extension profile
|
||||||
|
*/
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The properties reference of the extension profile
|
||||||
|
*/
|
||||||
|
public abstract ExtensionProperties properties();
|
||||||
|
|
||||||
|
|
||||||
|
@SerializedNames({"name", "properties"})
|
||||||
|
public static Extension create(final String name, final ExtensionProperties properties) {
|
||||||
|
return new AutoValue_Extension(name, properties);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class ExtensionProfile {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of extensions of the extension profile
|
||||||
|
*/
|
||||||
|
public abstract List<Extension> extensions();
|
||||||
|
|
||||||
|
|
||||||
|
@SerializedNames({"extensions"})
|
||||||
|
public static ExtensionProfile create(final List<Extension> extensions) {
|
||||||
|
return new AutoValue_ExtensionProfile(extensions == null ?
|
||||||
|
ImmutableList.<Extension>of() : ImmutableList.copyOf(extensions));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class ExtensionProfileSettings {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The fileUris reference of the extension profile settings
|
||||||
|
*/
|
||||||
|
public abstract List<String> fileUris();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The commandToExecute of the extension profile settings
|
||||||
|
*/
|
||||||
|
public abstract String commandToExecute();
|
||||||
|
|
||||||
|
@SerializedNames({"fileUris", "commandToExecute"})
|
||||||
|
public static ExtensionProfileSettings create(final List<String> fileUris, final String commandToExecute) {
|
||||||
|
return new AutoValue_ExtensionProfileSettings(fileUris == null ? ImmutableList.<String>of() : ImmutableList.copyOf(fileUris), commandToExecute);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class ExtensionProperties {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The publisher reference of the extension properties
|
||||||
|
*/
|
||||||
|
public abstract String publisher();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type reference of the extension properties
|
||||||
|
*/
|
||||||
|
public abstract String type();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The typeHandlerVersion reference of the extension properties
|
||||||
|
*/
|
||||||
|
public abstract String typeHandlerVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The autoUpgradeMinorVersion reference of the extension properties
|
||||||
|
*/
|
||||||
|
public abstract Boolean autoUpgradeMinorVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ExtensionProfileSettings of the extension properties
|
||||||
|
*/
|
||||||
|
public abstract ExtensionProfileSettings settings();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of the protectedSettings of the extension properties
|
||||||
|
*/
|
||||||
|
public abstract Map<String, String> protectedSettings();
|
||||||
|
|
||||||
|
@SerializedNames({ "publisher", "type", "typeHandlerVersion",
|
||||||
|
"autoUpgradeMinorVersion", "settings", "protectedSettings"})
|
||||||
|
public static ExtensionProperties create(final String publisher, String type,
|
||||||
|
final String typeHandlerVersion,
|
||||||
|
final Boolean autoUpgradeMinorVersion,
|
||||||
|
final ExtensionProfileSettings settings,
|
||||||
|
final Map<String, String> protectedSettings) {
|
||||||
|
return new AutoValue_ExtensionProperties(publisher, type, typeHandlerVersion, autoUpgradeMinorVersion,
|
||||||
|
settings, protectedSettings == null ?
|
||||||
|
ImmutableMap.<String, String>of() : ImmutableMap.copyOf(protectedSettings));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* 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.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class FrontendIPConfigurations {
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract FrontendIPConfigurationsProperties properties();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String etag();
|
||||||
|
|
||||||
|
@SerializedNames({ "name", "id", "properties", "etag" })
|
||||||
|
public static FrontendIPConfigurations create(final String name, final String id,
|
||||||
|
final FrontendIPConfigurationsProperties properties,
|
||||||
|
final String etag) {
|
||||||
|
return new AutoValue_FrontendIPConfigurations(name, id,
|
||||||
|
properties, etag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* 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.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class FrontendIPConfigurationsProperties {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract IdReference subnet();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String privateIPAddress();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String privateIPAllocationMethod();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract IdReference publicIPAddress();
|
||||||
|
|
||||||
|
|
||||||
|
@SerializedNames({ "subnet", "privateIPAddress", "privateIPAllocationMethod", "publicIPAddress" })
|
||||||
|
public static FrontendIPConfigurationsProperties create(final IdReference subnet, final String privateIPAddress,
|
||||||
|
final String privateIPAllocationMethod, final IdReference publicIPAddress) {
|
||||||
|
return builder().subnet(subnet).publicIPAddress(publicIPAddress).privateIPAddress(privateIPAddress)
|
||||||
|
.privateIPAllocationMethod(privateIPAllocationMethod).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_FrontendIPConfigurationsProperties.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder subnet(IdReference subnet);
|
||||||
|
|
||||||
|
public abstract Builder privateIPAddress(String privateIPAddress);
|
||||||
|
|
||||||
|
public abstract Builder privateIPAllocationMethod(String privateIPAllocationMethod);
|
||||||
|
|
||||||
|
public abstract Builder publicIPAddress(IdReference publicIPAddress);
|
||||||
|
|
||||||
|
public abstract FrontendIPConfigurationsProperties build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class HardwareProfile {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The vm size of the virtual machine.
|
||||||
|
*/
|
||||||
|
public abstract String vmSize();
|
||||||
|
|
||||||
|
@SerializedNames({"vmSize"})
|
||||||
|
public static HardwareProfile create(final String vmSize) {
|
||||||
|
return builder().vmSize(vmSize).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_HardwareProfile.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder vmSize(String vmSize);
|
||||||
|
|
||||||
|
public abstract HardwareProfile build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* 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.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
// Simple helper class to serialize / deserialize id reference.
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class IdReference {
|
||||||
|
|
||||||
|
private static final Pattern RESOURCE_GROUP_PATTERN = Pattern.compile("^.*/resourceGroups/([^/]+)(/.*)?$");
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public String resourceGroup() {
|
||||||
|
return extractResourceGroup(id());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public String name() {
|
||||||
|
return extractName(id());
|
||||||
|
}
|
||||||
|
|
||||||
|
@SerializedNames({"id"})
|
||||||
|
public static IdReference create(final String id) {
|
||||||
|
return new AutoValue_IdReference(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts the name from the given URI.
|
||||||
|
*/
|
||||||
|
public static String extractName(String uri) {
|
||||||
|
if (uri == null)
|
||||||
|
return null;
|
||||||
|
String noSlashAtEnd = uri.replaceAll("/+$", "");
|
||||||
|
return noSlashAtEnd.substring(noSlashAtEnd.lastIndexOf('/') + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts the resource group name from the given URI.
|
||||||
|
*/
|
||||||
|
public static String extractResourceGroup(String uri) {
|
||||||
|
if (uri == null)
|
||||||
|
return null;
|
||||||
|
Matcher m = RESOURCE_GROUP_PATTERN.matcher(uri);
|
||||||
|
return m.matches() ? m.group(1) : null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
/*
|
||||||
|
* 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.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 Image {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The id of the image
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the image
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The location of the image
|
||||||
|
*/
|
||||||
|
public abstract String location();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The image properties.
|
||||||
|
*/
|
||||||
|
public abstract ImageProperties properties();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the tags of the image
|
||||||
|
*/
|
||||||
|
@Nullable public abstract Map<String, String> tags();
|
||||||
|
|
||||||
|
@SerializedNames({"id", "name", "location", "properties", "tags"})
|
||||||
|
public static Image create(final String id, final String name, final String location,
|
||||||
|
final ImageProperties properties, final Map<String, String> tags) {
|
||||||
|
return builder().id(id).name(name).location(location).properties(properties).tags(tags).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_Image.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 properties(ImageProperties properties);
|
||||||
|
public abstract Builder tags(Map<String, String> tags);
|
||||||
|
|
||||||
|
abstract Map<String, String> tags();
|
||||||
|
|
||||||
|
abstract Image autoBuild();
|
||||||
|
|
||||||
|
public Image build() {
|
||||||
|
tags(tags() != null ? ImmutableMap.copyOf(tags()) : null);
|
||||||
|
return autoBuild();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* 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.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class ImageProperties implements Provisionable {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract IdReference sourceVirtualMachine();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract StorageProfile storageProfile();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String provisioningState();
|
||||||
|
|
||||||
|
@SerializedNames({ "sourceVirtualMachine", "storageProfile", "provisioningState"})
|
||||||
|
public static ImageProperties create(final IdReference sourceVirtualMachine,
|
||||||
|
final StorageProfile storageProfile,
|
||||||
|
final String provisioningState) {
|
||||||
|
return builder()
|
||||||
|
.sourceVirtualMachine(sourceVirtualMachine)
|
||||||
|
.storageProfile(storageProfile)
|
||||||
|
.provisioningState(provisioningState)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_ImageProperties.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder sourceVirtualMachine(IdReference sourceVirtualMachine);
|
||||||
|
public abstract Builder storageProfile(StorageProfile storageProfile);
|
||||||
|
public abstract Builder provisioningState(String provisioningState);
|
||||||
|
public abstract ImageProperties build();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,106 @@
|
||||||
|
/*
|
||||||
|
* 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 static org.jclouds.azurecompute.arm.domain.IdReference.extractName;
|
||||||
|
import static org.jclouds.azurecompute.arm.domain.IdReference.extractResourceGroup;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class ImageReference {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the resource identifier of a virtual machine image in your subscription. This element is only used
|
||||||
|
* for virtual machine images, not platform images or marketplace images.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String customImageId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The publisher of the image reference.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String publisher();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The offer of the image reference.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String offer();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sku of the image reference.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String sku();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The version of the image reference.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String version();
|
||||||
|
|
||||||
|
ImageReference() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SerializedNames({"id", "publisher", "offer", "sku", "version"})
|
||||||
|
public static ImageReference create(final String id,
|
||||||
|
final String publisher,
|
||||||
|
final String offer,
|
||||||
|
final String sku,
|
||||||
|
final String version) {
|
||||||
|
|
||||||
|
return builder().customImageId(id)
|
||||||
|
.publisher(publisher)
|
||||||
|
.offer(offer)
|
||||||
|
.sku(sku)
|
||||||
|
.version(version)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_ImageReference.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder customImageId(String ids);
|
||||||
|
public abstract Builder publisher(String publisher);
|
||||||
|
public abstract Builder offer(String offer);
|
||||||
|
public abstract Builder sku(String sku);
|
||||||
|
public abstract Builder version(String version);
|
||||||
|
|
||||||
|
public abstract ImageReference build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String encodeFieldsToUniqueId(String location) {
|
||||||
|
return VMImage.azureImage().location(location).publisher(publisher()).offer(offer()).sku(sku()).build()
|
||||||
|
.encodeFieldsToUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String encodeFieldsToUniqueIdCustom(String location) {
|
||||||
|
return VMImage.customImage().resourceGroup(extractResourceGroup(customImageId())).location(location)
|
||||||
|
.name(extractName(customImageId())).build().encodeFieldsToUniqueIdCustom();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* 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.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class InboundNatRule {
|
||||||
|
@Nullable
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract InboundNatRuleProperties properties();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String etag();
|
||||||
|
|
||||||
|
@SerializedNames({ "name", "id", "properties", "etag" })
|
||||||
|
public static InboundNatRule create(final String name, final String id, final InboundNatRuleProperties properties,
|
||||||
|
final String etag) {
|
||||||
|
return new AutoValue_InboundNatRule(name, id, properties, etag);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,105 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class InboundNatRuleProperties implements Provisionable {
|
||||||
|
public enum Protocol {
|
||||||
|
Tcp("Tcp"), Udp("Udp"), UNRECOGNIZED("Unrecognized");
|
||||||
|
|
||||||
|
private final String label;
|
||||||
|
|
||||||
|
private Protocol(final String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Protocol fromValue(final String text) {
|
||||||
|
return (Protocol) GetEnumValue.fromValueOrDefault(text, Protocol.UNRECOGNIZED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract IdReference frontendIPConfiguration();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract IdReference backendIPConfiguration();
|
||||||
|
|
||||||
|
public abstract Protocol protocol();
|
||||||
|
|
||||||
|
public abstract int backendPort();
|
||||||
|
|
||||||
|
public abstract int frontendPort();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Boolean enableFloatingIP();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer idleTimeoutInMinutes();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String provisioningState();
|
||||||
|
|
||||||
|
@SerializedNames({ "frontendIPConfiguration", "backendIPConfiguration", "protocol", "frontendPort", "backendPort",
|
||||||
|
"provisioningState", "enableFloatingIP", "idleTimeoutInMinutes" })
|
||||||
|
public static InboundNatRuleProperties create(final IdReference frontendIPConfiguration,
|
||||||
|
final IdReference backendIPConfiguration, final Protocol protocol, final int frontendPort,
|
||||||
|
final int backendPort, final String provisioningState, Boolean enableFloatingIP, Integer idleTimeoutInMinutes) {
|
||||||
|
return builder().frontendIPConfiguration(frontendIPConfiguration).backendIPConfiguration(backendIPConfiguration)
|
||||||
|
.protocol(protocol).frontendPort(frontendPort).backendPort(backendPort)
|
||||||
|
.provisioningState(provisioningState).enableFloatingIP(enableFloatingIP)
|
||||||
|
.idleTimeoutInMinutes(idleTimeoutInMinutes).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_InboundNatRuleProperties.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
|
||||||
|
public abstract Builder frontendIPConfiguration(IdReference frontendIPConfiguration);
|
||||||
|
|
||||||
|
public abstract Builder backendIPConfiguration(IdReference backendIPConfiguration);
|
||||||
|
|
||||||
|
public abstract Builder protocol(Protocol protocol);
|
||||||
|
|
||||||
|
public abstract Builder frontendPort(int frontendPort);
|
||||||
|
|
||||||
|
public abstract Builder backendPort(int backendPort);
|
||||||
|
|
||||||
|
public abstract Builder provisioningState(String provisioningState);
|
||||||
|
|
||||||
|
public abstract Builder enableFloatingIP(Boolean enableFloatingIP);
|
||||||
|
|
||||||
|
public abstract Builder idleTimeoutInMinutes(Integer idleTimeoutInMinutes);
|
||||||
|
|
||||||
|
public abstract InboundNatRuleProperties build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class IpConfiguration {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String etag();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Boolean primary();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract IpConfigurationProperties properties();
|
||||||
|
|
||||||
|
@SerializedNames({"name", "id", "etag", "primary", "properties"})
|
||||||
|
public static IpConfiguration create(final String name, final String id, final String etag, final Boolean primary, final IpConfigurationProperties properties) {
|
||||||
|
return builder()
|
||||||
|
.name(name)
|
||||||
|
.id(id)
|
||||||
|
.etag(etag)
|
||||||
|
.primary(primary)
|
||||||
|
.properties(properties)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_IpConfiguration.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder name(String name);
|
||||||
|
public abstract Builder id(String id);
|
||||||
|
public abstract Builder etag(String etag);
|
||||||
|
public abstract Builder primary(Boolean primary);
|
||||||
|
public abstract Builder properties(IpConfigurationProperties properties);
|
||||||
|
public abstract IpConfiguration build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,105 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class IpConfigurationProperties implements Provisionable {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String provisioningState();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String privateIPAddress();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String privateIPAllocationMethod();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract IdReference subnet();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract IdReference publicIPAddress();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<IdReference> loadBalancerBackendAddressPools();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<IdReference> loadBalancerInboundNatRules();
|
||||||
|
|
||||||
|
@SerializedNames({ "provisioningState", "privateIPAddress", "privateIPAllocationMethod", "subnet",
|
||||||
|
"publicIPAddress", "loadBalancerBackendAddressPools", "loadBalancerInboundNatRules" })
|
||||||
|
public static IpConfigurationProperties create(final String provisioningState, final String privateIPAddress,
|
||||||
|
final String privateIPAllocationMethod, final IdReference subnet, final IdReference publicIPAddress,
|
||||||
|
List<IdReference> loadBalancerBackendAddressPools, List<IdReference> loadBalancerInboundNatRules) {
|
||||||
|
|
||||||
|
return builder()
|
||||||
|
.provisioningState(provisioningState)
|
||||||
|
.privateIPAddress(privateIPAddress)
|
||||||
|
.privateIPAllocationMethod(privateIPAllocationMethod)
|
||||||
|
.subnet(subnet)
|
||||||
|
.publicIPAddress(publicIPAddress)
|
||||||
|
.loadBalancerBackendAddressPools(loadBalancerBackendAddressPools)
|
||||||
|
.loadBalancerInboundNatRules(loadBalancerInboundNatRules)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_IpConfigurationProperties.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder provisioningState(String provisioningState);
|
||||||
|
|
||||||
|
public abstract Builder privateIPAddress(String privateIPAddress);
|
||||||
|
|
||||||
|
public abstract Builder privateIPAllocationMethod(String privateIPAllocationMethod);
|
||||||
|
|
||||||
|
public abstract Builder subnet(IdReference subnet);
|
||||||
|
|
||||||
|
public abstract Builder publicIPAddress(IdReference publicIPAddress);
|
||||||
|
|
||||||
|
public abstract Builder loadBalancerBackendAddressPools(List<IdReference> loadBalancerBackendAddressPools);
|
||||||
|
|
||||||
|
public abstract Builder loadBalancerInboundNatRules(List<IdReference> loadBalancerInboundNatRules);
|
||||||
|
|
||||||
|
abstract List<IdReference> loadBalancerBackendAddressPools();
|
||||||
|
|
||||||
|
abstract List<IdReference> loadBalancerInboundNatRules();
|
||||||
|
|
||||||
|
abstract IpConfigurationProperties autoBuild();
|
||||||
|
|
||||||
|
public IpConfigurationProperties build() {
|
||||||
|
loadBalancerBackendAddressPools(loadBalancerBackendAddressPools() != null ? ImmutableList
|
||||||
|
.copyOf(loadBalancerBackendAddressPools()) : null);
|
||||||
|
loadBalancerInboundNatRules(loadBalancerInboundNatRules() != null ? ImmutableList
|
||||||
|
.copyOf(loadBalancerInboundNatRules()) : null);
|
||||||
|
return autoBuild();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,229 @@
|
||||||
|
/*
|
||||||
|
* 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.Map;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class Key {
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class JsonWebKey {
|
||||||
|
@Nullable
|
||||||
|
public abstract String crv();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String d();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String dp();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String dq();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String e();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String k();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String keyHsm();
|
||||||
|
|
||||||
|
public abstract List<String> keyOps();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String kid();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String kty();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String n();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String p();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String q();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String qi();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String x();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String y();
|
||||||
|
|
||||||
|
@SerializedNames({"crv", "d", "dp", "dq", "e", "k", "key_hsm", "key_ops", "kid", "kty", "n", "p", "q", "qi", "x", "y"})
|
||||||
|
public static JsonWebKey create(final String crv, final String d, final String dp, final String dq,
|
||||||
|
final String e, final String k, final String keyHsm, final List<String> keyOps,
|
||||||
|
final String kid, final String kty, final String n, final String p,
|
||||||
|
final String q, final String qi, final String x, final String y) {
|
||||||
|
return new AutoValue_Key_JsonWebKey(
|
||||||
|
crv, d, dp, dq, e, k, keyHsm,
|
||||||
|
keyOps != null ? ImmutableList.copyOf(keyOps) : ImmutableList.<String> of(),
|
||||||
|
kid, kty, n, p, q, qi, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class KeyAttributes {
|
||||||
|
@Nullable
|
||||||
|
public abstract Boolean enabled();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer created();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer expires();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer notBefore();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String recoveryLevel();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer updated();
|
||||||
|
|
||||||
|
@SerializedNames({"enabled", "created", "expires", "notBefore", "recoveryLevel", "updated"})
|
||||||
|
public static KeyAttributes create(final Boolean enabled,
|
||||||
|
final Integer created,
|
||||||
|
final Integer expires,
|
||||||
|
final Integer notBefore,
|
||||||
|
final String recoveryLevel,
|
||||||
|
final Integer updated) {
|
||||||
|
return new AutoValue_Key_KeyAttributes(enabled, created, expires, notBefore, recoveryLevel, updated);
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyAttributes() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class KeyBundle {
|
||||||
|
@Nullable
|
||||||
|
public abstract KeyAttributes attributes();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract JsonWebKey key();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Boolean managed();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Map<String, String> tags();
|
||||||
|
|
||||||
|
@SerializedNames({"attributes", "key", "managed", "tags"})
|
||||||
|
public static KeyBundle create(final KeyAttributes attributes, final JsonWebKey key, final boolean managed, final Map<String, String> tags) {
|
||||||
|
return new AutoValue_Key_KeyBundle(
|
||||||
|
attributes,
|
||||||
|
key,
|
||||||
|
managed,
|
||||||
|
tags != null ? ImmutableMap.copyOf(tags) : null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class DeletedKeyBundle {
|
||||||
|
@Nullable
|
||||||
|
public abstract KeyAttributes attributes();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String deletedDate();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract JsonWebKey key();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Boolean managed();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String recoveryId();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String scheduledPurgeDate();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Map<String, String> tags();
|
||||||
|
|
||||||
|
@SerializedNames({"attributes", "deletedDate", "key", "managed", "recoveryId", "scheduledPurgeDate", "tags"})
|
||||||
|
public static DeletedKeyBundle create(final KeyAttributes attributes, final String deletedDate, final JsonWebKey key, final boolean managed, final String recoveryId, final String scheduledPurgeDate, final Map<String, String> tags) {
|
||||||
|
return new AutoValue_Key_DeletedKeyBundle(
|
||||||
|
attributes,
|
||||||
|
deletedDate,
|
||||||
|
key,
|
||||||
|
managed,
|
||||||
|
recoveryId,
|
||||||
|
scheduledPurgeDate,
|
||||||
|
tags != null ? ImmutableMap.copyOf(tags) : null
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class KeyOperationResult {
|
||||||
|
@Nullable
|
||||||
|
public abstract String keyId();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String value();
|
||||||
|
|
||||||
|
@SerializedNames({"kid", "value"})
|
||||||
|
public static KeyOperationResult create(final String keyId, final String value) {
|
||||||
|
return new AutoValue_Key_KeyOperationResult(
|
||||||
|
keyId,
|
||||||
|
value
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String kid();
|
||||||
|
|
||||||
|
public abstract KeyAttributes attributes();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Boolean managed();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Map<String, String> tags();
|
||||||
|
|
||||||
|
@SerializedNames({"kid", "attributes", "managed", "tags"})
|
||||||
|
public static Key create(final String kid, final KeyAttributes attributes, final boolean managed, final Map<String, String> tags) {
|
||||||
|
return new AutoValue_Key(
|
||||||
|
kid,
|
||||||
|
attributes,
|
||||||
|
managed,
|
||||||
|
tags != null ? ImmutableMap.copyOf(tags) : null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Key() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
// Simple helper class to serialize / deserialize keyvault reference.
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class KeyVaultReference {
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class Reference {
|
||||||
|
|
||||||
|
public abstract IdReference keyVault();
|
||||||
|
|
||||||
|
public abstract String secretName();
|
||||||
|
|
||||||
|
@SerializedNames({"keyVault", "secretName"})
|
||||||
|
public static Reference create(final IdReference keyVault, final String secretName) {
|
||||||
|
return new AutoValue_KeyVaultReference_Reference(keyVault, secretName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Reference reference();
|
||||||
|
|
||||||
|
@SerializedNames({"reference"})
|
||||||
|
public static KeyVaultReference create(final Reference reference) {
|
||||||
|
return new AutoValue_KeyVaultReference(reference);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* 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.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 LoadBalancer {
|
||||||
|
|
||||||
|
@Nullable public abstract String id();
|
||||||
|
@Nullable public abstract String name();
|
||||||
|
@Nullable public abstract String location();
|
||||||
|
@Nullable public abstract String etag();
|
||||||
|
@Nullable public abstract Map<String, String> tags();
|
||||||
|
@Nullable public abstract LoadBalancerProperties properties();
|
||||||
|
|
||||||
|
@SerializedNames({ "id", "name", "location", "etag", "tags", "properties", })
|
||||||
|
public static LoadBalancer create(String id, final String name, final String location, final String etag,
|
||||||
|
final Map<String, String> tags, final LoadBalancerProperties properties) {
|
||||||
|
return builder().id(id).name(name).location(location).etag(etag).tags(tags).properties(properties).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_LoadBalancer.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 etag(String etag);
|
||||||
|
public abstract Builder tags(Map<String, String> tags);
|
||||||
|
public abstract Builder properties(LoadBalancerProperties properties);
|
||||||
|
|
||||||
|
abstract Map<String, String> tags();
|
||||||
|
|
||||||
|
abstract LoadBalancer autoBuild();
|
||||||
|
|
||||||
|
public LoadBalancer build() {
|
||||||
|
tags(tags() != null ? ImmutableMap.copyOf(tags()) : null);
|
||||||
|
return autoBuild();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,109 @@
|
||||||
|
/*
|
||||||
|
* 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.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class LoadBalancerProperties implements Provisionable {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<FrontendIPConfigurations> frontendIPConfigurations();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<BackendAddressPool> backendAddressPools();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<LoadBalancingRule> loadBalancingRules();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<Probe> probes();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<InboundNatRule> inboundNatRules();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String resourceGuid();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String provisioningState();
|
||||||
|
|
||||||
|
@SerializedNames({ "frontendIPConfigurations", "backendAddressPools", "loadBalancingRules", "probes",
|
||||||
|
"inboundNatRules", "resourceGuid", "provisioningState" })
|
||||||
|
public static LoadBalancerProperties create(final List<FrontendIPConfigurations> frontendIPConfigurations,
|
||||||
|
final List<BackendAddressPool> backendAddressPools, final List<LoadBalancingRule> loadBalancingRules,
|
||||||
|
final List<Probe> probes, final List<InboundNatRule> inboundNatRules, final String resourceGuid,
|
||||||
|
final String provisioningState) {
|
||||||
|
return builder().frontendIPConfigurations(frontendIPConfigurations)
|
||||||
|
.backendAddressPools(backendAddressPools == null ? null : ImmutableList.copyOf(backendAddressPools))
|
||||||
|
.loadBalancingRules(loadBalancingRules == null ? null : ImmutableList.copyOf(loadBalancingRules))
|
||||||
|
.probes(probes == null ? null : ImmutableList.copyOf(probes))
|
||||||
|
.inboundNatRules(inboundNatRules == null ? null : ImmutableList.copyOf(inboundNatRules))
|
||||||
|
.resourceGuid(resourceGuid).provisioningState(provisioningState).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_LoadBalancerProperties.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder frontendIPConfigurations(List<FrontendIPConfigurations> frontendIPConfigurations);
|
||||||
|
|
||||||
|
public abstract Builder backendAddressPools(List<BackendAddressPool> backendAddressPools);
|
||||||
|
|
||||||
|
public abstract Builder loadBalancingRules(List<LoadBalancingRule> networkInterfaces);
|
||||||
|
|
||||||
|
public abstract Builder probes(List<Probe> probes);
|
||||||
|
|
||||||
|
public abstract Builder inboundNatRules(List<InboundNatRule> inboundNatRules);
|
||||||
|
|
||||||
|
public abstract Builder resourceGuid(String resourceGuid);
|
||||||
|
|
||||||
|
public abstract Builder provisioningState(String provisioningState);
|
||||||
|
|
||||||
|
abstract List<FrontendIPConfigurations> frontendIPConfigurations();
|
||||||
|
|
||||||
|
abstract List<BackendAddressPool> backendAddressPools();
|
||||||
|
|
||||||
|
abstract List<LoadBalancingRule> loadBalancingRules();
|
||||||
|
|
||||||
|
abstract List<Probe> probes();
|
||||||
|
|
||||||
|
abstract List<InboundNatRule> inboundNatRules();
|
||||||
|
|
||||||
|
abstract LoadBalancerProperties autoBuild();
|
||||||
|
|
||||||
|
public LoadBalancerProperties build() {
|
||||||
|
frontendIPConfigurations(frontendIPConfigurations() != null ? ImmutableList.copyOf(frontendIPConfigurations())
|
||||||
|
: null);
|
||||||
|
backendAddressPools(backendAddressPools() != null ? ImmutableList.copyOf(backendAddressPools()) : null);
|
||||||
|
loadBalancingRules(loadBalancingRules() != null ? ImmutableList.copyOf(loadBalancingRules()) : null);
|
||||||
|
probes(probes() != null ? ImmutableList.copyOf(probes()) : null);
|
||||||
|
inboundNatRules(inboundNatRules() != null ? ImmutableList.copyOf(inboundNatRules()) : null);
|
||||||
|
return autoBuild();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* 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.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class LoadBalancingRule {
|
||||||
|
@Nullable
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract LoadBalancingRuleProperties properties();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String etag();
|
||||||
|
|
||||||
|
@SerializedNames({ "name", "id", "properties", "etag" })
|
||||||
|
public static LoadBalancingRule create(final String name, final String id,
|
||||||
|
final LoadBalancingRuleProperties properties, final String etag) {
|
||||||
|
return new AutoValue_LoadBalancingRule(name, id, properties, etag);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,135 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class LoadBalancingRuleProperties {
|
||||||
|
|
||||||
|
public enum Protocol {
|
||||||
|
Tcp("Tcp"), Udp("Udp"), UNRECOGNIZED("Unrecognized");
|
||||||
|
|
||||||
|
private final String label;
|
||||||
|
|
||||||
|
private Protocol(final String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Protocol fromValue(final String text) {
|
||||||
|
return (Protocol) GetEnumValue.fromValueOrDefault(text, Protocol.UNRECOGNIZED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum LoadDistribution {
|
||||||
|
Default("Default"), SourceIp("SourceIP"), SourceIPProtocol("SourceIPProtocol"), UNRECOGNIZED("Unrecognized");
|
||||||
|
|
||||||
|
private final String label;
|
||||||
|
|
||||||
|
private LoadDistribution(final String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LoadDistribution fromValue(final String text) {
|
||||||
|
return (LoadDistribution) GetEnumValue.fromValueOrDefault(text, LoadDistribution.UNRECOGNIZED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract IdReference frontendIPConfiguration();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract IdReference backendAddressPool();
|
||||||
|
|
||||||
|
public abstract Protocol protocol();
|
||||||
|
|
||||||
|
public abstract int frontendPort();
|
||||||
|
|
||||||
|
public abstract int backendPort();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract IdReference probe();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Boolean enableFloatingIP();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer idleTimeoutInMinutes();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract LoadDistribution loadDistribution();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String provisioningState();
|
||||||
|
|
||||||
|
@SerializedNames({ "frontendIPConfiguration", "backendAddressPool", "protocol", "frontendPort", "backendPort",
|
||||||
|
"probe", "enableFloatingIP", "idleTimeoutInMinutes", "loadDistribution", "provisioningState" })
|
||||||
|
public static LoadBalancingRuleProperties create(final IdReference frontendIPConfiguration,
|
||||||
|
final IdReference backendAddressPool, final Protocol protocol, final int frontendPort, final int backendPort,
|
||||||
|
final IdReference probe, final Boolean enableFloatingIP, final Integer idleTimeoutInMinutes,
|
||||||
|
final LoadDistribution loadDistribution, final String provisioningState) {
|
||||||
|
return builder().frontendIPConfiguration(frontendIPConfiguration).backendAddressPool(backendAddressPool)
|
||||||
|
.protocol(protocol).frontendPort(frontendPort).backendPort(backendPort).probe(probe)
|
||||||
|
.enableFloatingIP(enableFloatingIP).idleTimeoutInMinutes(idleTimeoutInMinutes)
|
||||||
|
.loadDistribution(loadDistribution).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_LoadBalancingRuleProperties.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder frontendIPConfiguration(IdReference frontendIPConfiguration);
|
||||||
|
|
||||||
|
public abstract Builder backendAddressPool(IdReference backendAddressPool);
|
||||||
|
|
||||||
|
public abstract Builder protocol(Protocol protocol);
|
||||||
|
|
||||||
|
public abstract Builder frontendPort(int frontendPort);
|
||||||
|
|
||||||
|
public abstract Builder backendPort(int backendPort);
|
||||||
|
|
||||||
|
public abstract Builder probe(IdReference probe);
|
||||||
|
|
||||||
|
public abstract Builder enableFloatingIP(Boolean enableFloatingIP);
|
||||||
|
|
||||||
|
public abstract Builder idleTimeoutInMinutes(Integer idleTimeoutInMinutes);
|
||||||
|
|
||||||
|
public abstract Builder loadDistribution(LoadDistribution loadDistribution);
|
||||||
|
|
||||||
|
public abstract Builder provisioningState(String provisioningState);
|
||||||
|
|
||||||
|
public abstract LoadBalancingRuleProperties build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A data center location that is valid for your subscription.
|
||||||
|
*/
|
||||||
|
@AutoValue
|
||||||
|
public abstract class Location {
|
||||||
|
/**
|
||||||
|
* The id of the data center.
|
||||||
|
*/
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the data center location. Ex. {@code West Europe}.
|
||||||
|
*/
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The localized name of the data center location.
|
||||||
|
*/
|
||||||
|
public abstract String displayName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The longitude of the datacenter
|
||||||
|
*/
|
||||||
|
public abstract double longitude();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The latitude of the datacenter
|
||||||
|
*/
|
||||||
|
public abstract double latitude();
|
||||||
|
|
||||||
|
@SerializedNames({"id", "name", "displayName", "longitude", "latitude"})
|
||||||
|
public static Location create(final String id, final String name, final String displayName, final double longitude,
|
||||||
|
final double latitude) {
|
||||||
|
|
||||||
|
return new AutoValue_Location(id, name, displayName, longitude, latitude);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* 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.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class ManagedDiskParameters {
|
||||||
|
|
||||||
|
@Nullable public abstract String id();
|
||||||
|
|
||||||
|
// Might be null in custom images. In that case the API returns it in the OSDisk object.
|
||||||
|
@Nullable public abstract StorageAccountType storageAccountType();
|
||||||
|
|
||||||
|
@SerializedNames({"id", "storageAccountType"})
|
||||||
|
public static ManagedDiskParameters create(final String id, final String storageAccountType) {
|
||||||
|
return new AutoValue_ManagedDiskParameters(id, StorageAccountType.fromString(storageAccountType));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* 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.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Metric with its values for a resource
|
||||||
|
*/
|
||||||
|
@AutoValue
|
||||||
|
public abstract class Metric {
|
||||||
|
|
||||||
|
public abstract List<MetricData> data();
|
||||||
|
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract MetricName name();
|
||||||
|
|
||||||
|
public abstract String type();
|
||||||
|
|
||||||
|
public abstract String unit();
|
||||||
|
|
||||||
|
@SerializedNames({ "data", "id", "name", "type", "unit" })
|
||||||
|
public static Metric create(final List<MetricData> data, final String id, final MetricName name, final String type,
|
||||||
|
final String unit) {
|
||||||
|
return new AutoValue_Metric(data == null ? ImmutableList.<MetricData> of() : ImmutableList.copyOf(data), id, name,
|
||||||
|
type, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* 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.Date;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@AutoValue
|
||||||
|
public abstract class MetricData
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The timestamp for the metric value in ISO 8601 format.
|
||||||
|
*/
|
||||||
|
public abstract Date timeStamp();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The average value in the time range
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract Double total();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sum of all of the values in the time range.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract Double average();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The least value in the time range.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract Double minimum();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The greatest value in the time range.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract Double maximum();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of samples in the time range.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract Long count();
|
||||||
|
|
||||||
|
@SerializedNames({"timeStamp", "total", "average", "minimum", "maximum", "count"})
|
||||||
|
public static MetricData create(final Date timeStamp, final Double total, final Double average,
|
||||||
|
final Double minimum, final Double maximum, final Long count)
|
||||||
|
{
|
||||||
|
return new AutoValue_MetricData(timeStamp, total, average, minimum, maximum, count);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
* 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.azurecompute.arm.util.GetEnumValue;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Metric definition for a resource
|
||||||
|
*/
|
||||||
|
@AutoValue
|
||||||
|
public abstract class MetricDefinition {
|
||||||
|
|
||||||
|
public enum AggregationType {
|
||||||
|
None("None"), Average("Average"), Count("Count"), Total("Total"), Minimum("Minimum"), Maximum(
|
||||||
|
"Maximum"), UNRECOGNIZED("Unrecognized");
|
||||||
|
|
||||||
|
private final String label;
|
||||||
|
|
||||||
|
AggregationType(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AggregationType fromValue(final String text) {
|
||||||
|
return (AggregationType) GetEnumValue.fromValueOrDefault(text, AggregationType.UNRECOGNIZED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String resourceId();
|
||||||
|
|
||||||
|
public abstract MetricName name();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Boolean isDimensionRequired();
|
||||||
|
|
||||||
|
public abstract String unit();
|
||||||
|
|
||||||
|
public abstract AggregationType primaryAggregationType();
|
||||||
|
|
||||||
|
public abstract List<MetricDefinition.MetricAvailability> metricAvailabilities();
|
||||||
|
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@SerializedNames({ "resourceId", "name", "isDimensionRequired", "unit", "primaryAggregationType",
|
||||||
|
"metricAvailabilities", "id" })
|
||||||
|
public static MetricDefinition create(final String resourceId, final MetricName name,
|
||||||
|
final Boolean isDimensionRequired, final String unit, final AggregationType primaryAggregationType,
|
||||||
|
List<MetricAvailability> metricAvailabilities, final String id) {
|
||||||
|
return new AutoValue_MetricDefinition(resourceId, name, isDimensionRequired, unit, primaryAggregationType,
|
||||||
|
metricAvailabilities == null ?
|
||||||
|
ImmutableList.<MetricAvailability> of() :
|
||||||
|
ImmutableList.copyOf(metricAvailabilities), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class MetricAvailability {
|
||||||
|
|
||||||
|
public abstract String timeGrain();
|
||||||
|
|
||||||
|
public abstract String retention();
|
||||||
|
|
||||||
|
MetricAvailability() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SerializedNames({ "timeGrain", "retention" })
|
||||||
|
public static MetricDefinition.MetricAvailability create(String timeGrain, String retention) {
|
||||||
|
return new AutoValue_MetricDefinition_MetricAvailability(timeGrain, retention);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* 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.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Metric with its values for a resource
|
||||||
|
*/
|
||||||
|
@AutoValue
|
||||||
|
public abstract class MetricName {
|
||||||
|
|
||||||
|
public abstract String value();
|
||||||
|
|
||||||
|
public abstract String localizedValue();
|
||||||
|
|
||||||
|
@SerializedNames({ "value", "localizedValue" })
|
||||||
|
public static MetricName create(String value, String localizedValue) {
|
||||||
|
return new AutoValue_MetricName(value, localizedValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class NetworkInterfaceCard {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String etag();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String location();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract NetworkInterfaceCardProperties properties();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Map<String, String> tags();
|
||||||
|
|
||||||
|
@SerializedNames({"name", "id", "etag", "location", "properties", "tags"})
|
||||||
|
public static NetworkInterfaceCard create(final String name,
|
||||||
|
final String id,
|
||||||
|
final String etag,
|
||||||
|
final String location,
|
||||||
|
final NetworkInterfaceCardProperties properties,
|
||||||
|
final Map<String, String> tags) {
|
||||||
|
return new AutoValue_NetworkInterfaceCard(name, id, etag, location, properties,
|
||||||
|
tags != null ? ImmutableMap.copyOf(tags) : null);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class NetworkInterfaceCardProperties implements Provisionable {
|
||||||
|
|
||||||
|
@Nullable public abstract String provisioningState();
|
||||||
|
@Nullable public abstract String resourceGuid();
|
||||||
|
@Nullable public abstract Boolean enableIPForwarding();
|
||||||
|
@Nullable public abstract List<IpConfiguration> ipConfigurations();
|
||||||
|
@Nullable public abstract IdReference networkSecurityGroup();
|
||||||
|
|
||||||
|
@SerializedNames({"provisioningState", "resourceGuid", "enableIPForwarding", "ipConfigurations",
|
||||||
|
"networkSecurityGroup"})
|
||||||
|
public static NetworkInterfaceCardProperties create(final String provisioningState, final String resourceGuid,
|
||||||
|
final Boolean enableIPForwarding, final List<IpConfiguration> ipConfigurations,
|
||||||
|
final IdReference networkSecurityGroup) {
|
||||||
|
NetworkInterfaceCardProperties.Builder builder = NetworkInterfaceCardProperties.builder()
|
||||||
|
.provisioningState(provisioningState)
|
||||||
|
.resourceGuid(resourceGuid)
|
||||||
|
.enableIPForwarding(enableIPForwarding)
|
||||||
|
.ipConfigurations(ipConfigurations == null ? null : ImmutableList.copyOf(ipConfigurations))
|
||||||
|
.networkSecurityGroup(networkSecurityGroup);
|
||||||
|
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkInterfaceCardProperties() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_NetworkInterfaceCardProperties.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder provisioningState(String provisioningState);
|
||||||
|
public abstract Builder resourceGuid(String resourceGuid);
|
||||||
|
public abstract Builder enableIPForwarding(Boolean enableIPForwarding);
|
||||||
|
public abstract Builder ipConfigurations(List<IpConfiguration> ipConfigurations);
|
||||||
|
public abstract Builder networkSecurityGroup(IdReference networkSecurityGroup);
|
||||||
|
|
||||||
|
abstract List<IpConfiguration> ipConfigurations();
|
||||||
|
abstract NetworkInterfaceCardProperties autoBuild();
|
||||||
|
|
||||||
|
public NetworkInterfaceCardProperties build() {
|
||||||
|
ipConfigurations(ipConfigurations() != null ? ImmutableList.copyOf(ipConfigurations()) : null);
|
||||||
|
return autoBuild();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class NetworkInterfaceConfiguration {
|
||||||
|
/**
|
||||||
|
* The name of the NetworkInterfaceConfiguration
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The networkConfigurationProperties of the NetworkInterfaceConfiguration
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract NetworkInterfaceConfigurationProperties networkInterfaceConfigurationProperties();
|
||||||
|
|
||||||
|
@SerializedNames({"name", "properties"})
|
||||||
|
public static NetworkInterfaceConfiguration create(
|
||||||
|
final String name, NetworkInterfaceConfigurationProperties networkInterfaceConfigurationProperties) {
|
||||||
|
|
||||||
|
return new AutoValue_NetworkInterfaceConfiguration(name, networkInterfaceConfigurationProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class NetworkInterfaceConfigurationProperties {
|
||||||
|
/**
|
||||||
|
* The primary of the NetworkInterfaceConfigurationProperties
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract Boolean primary();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The enableAcceleratedNetworking of the NetworkInterfaceConfigurationProperties
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract Boolean enableAcceleratedNetworking();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The networkSecurityGroup of the NetworkInterfaceConfigurationProperties
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract VirtualMachineScaleSetNetworkSecurityGroup networkSecurityGroup();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The dnsSettings of the NetworkInterfaceConfigurationProperties
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract VirtualMachineScaleSetDNSSettings dnsSettings();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ipConfigurations of the NetworkInterfaceConfigurationProperties
|
||||||
|
*/
|
||||||
|
public abstract List<VirtualMachineScaleSetIpConfiguration> ipConfigurations();
|
||||||
|
|
||||||
|
|
||||||
|
@SerializedNames({"primary", "enableAcceleratedNetworking", "networkSecurityGroup", "dnsSettings", "ipConfigurations"})
|
||||||
|
public static NetworkInterfaceConfigurationProperties create(final Boolean primary,
|
||||||
|
final Boolean enableAcceleratedNetworking,
|
||||||
|
final VirtualMachineScaleSetNetworkSecurityGroup networkSecurityGroup,
|
||||||
|
final VirtualMachineScaleSetDNSSettings dnsSettings,
|
||||||
|
final List<VirtualMachineScaleSetIpConfiguration> ipConfigurations) {
|
||||||
|
|
||||||
|
return new AutoValue_NetworkInterfaceConfigurationProperties(primary, enableAcceleratedNetworking,
|
||||||
|
networkSecurityGroup, dnsSettings, ipConfigurations);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,92 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class NetworkProfile {
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class NetworkInterface {
|
||||||
|
public abstract String id();
|
||||||
|
@Nullable public abstract NetworkInterfaceProperties properties();
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class NetworkInterfaceProperties {
|
||||||
|
public abstract boolean primary();
|
||||||
|
|
||||||
|
NetworkInterfaceProperties() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SerializedNames({"primary"})
|
||||||
|
public static NetworkInterfaceProperties create(boolean primary) {
|
||||||
|
return new AutoValue_NetworkProfile_NetworkInterface_NetworkInterfaceProperties(primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkInterface() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SerializedNames({"id", "properties"})
|
||||||
|
public static NetworkInterface create(String id, NetworkInterfaceProperties properties) {
|
||||||
|
return new AutoValue_NetworkProfile_NetworkInterface(id, properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of network interfaces
|
||||||
|
*/
|
||||||
|
public abstract List<NetworkInterface> networkInterfaces();
|
||||||
|
|
||||||
|
@SerializedNames({"networkInterfaces"})
|
||||||
|
public static NetworkProfile create(final List<NetworkInterface> networkInterfaces) {
|
||||||
|
return builder().networkInterfaces(networkInterfaces).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
NetworkProfile() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_NetworkProfile.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder networkInterfaces(List<NetworkInterface> networkInterfaces);
|
||||||
|
|
||||||
|
abstract List<NetworkInterface> networkInterfaces();
|
||||||
|
|
||||||
|
abstract NetworkProfile autoBuild();
|
||||||
|
|
||||||
|
public NetworkProfile build() {
|
||||||
|
networkInterfaces(networkInterfaces() != null ? ImmutableList.copyOf(networkInterfaces()) : ImmutableList.<NetworkInterface>of());
|
||||||
|
return autoBuild();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class NetworkSecurityGroup {
|
||||||
|
public abstract String id();
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String location();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Map<String, String> tags();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract NetworkSecurityGroupProperties properties();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String etag();
|
||||||
|
|
||||||
|
@SerializedNames({ "id", "name", "location", "tags", "properties", "etag" })
|
||||||
|
public static NetworkSecurityGroup create(final String id, final String name, final String location,
|
||||||
|
final Map<String, String> tags, final NetworkSecurityGroupProperties properties, final String etag) {
|
||||||
|
return new AutoValue_NetworkSecurityGroup(id, name, location, (tags == null) ? null : ImmutableMap.copyOf(tags),
|
||||||
|
properties, etag);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class NetworkSecurityGroupProperties implements Provisionable {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<NetworkSecurityRule> securityRules();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<NetworkSecurityRule> defaultSecurityRules();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<NetworkInterfaceCard> networkInterfaces();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract List<Subnet> subnets();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String resourceGuid();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String provisioningState();
|
||||||
|
|
||||||
|
@SerializedNames({"securityRules", "defaultSecurityRules", "networkInterfaces", "subnets", "resourceGuid",
|
||||||
|
"provisioningState"})
|
||||||
|
public static NetworkSecurityGroupProperties create(final List<NetworkSecurityRule> securityRules,
|
||||||
|
final List<NetworkSecurityRule> defaultSecurityRules,
|
||||||
|
final List<NetworkInterfaceCard> networkInterfaces,
|
||||||
|
final List<Subnet> subnets,
|
||||||
|
final String resourceGuid,
|
||||||
|
final String provisioningState) {
|
||||||
|
return builder()
|
||||||
|
.securityRules((securityRules == null) ? null : ImmutableList.copyOf(securityRules))
|
||||||
|
.defaultSecurityRules((defaultSecurityRules == null) ? null : ImmutableList.copyOf(defaultSecurityRules))
|
||||||
|
.networkInterfaces((networkInterfaces == null) ? null : ImmutableList.copyOf(networkInterfaces))
|
||||||
|
.subnets((subnets == null) ? null : ImmutableList.copyOf(subnets))
|
||||||
|
.resourceGuid(resourceGuid)
|
||||||
|
.provisioningState(provisioningState)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_NetworkSecurityGroupProperties.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder securityRules(List<NetworkSecurityRule> securityRules);
|
||||||
|
|
||||||
|
public abstract Builder defaultSecurityRules(List<NetworkSecurityRule> securityRules);
|
||||||
|
|
||||||
|
public abstract Builder networkInterfaces(List<NetworkInterfaceCard> networkInterfaces);
|
||||||
|
|
||||||
|
public abstract Builder subnets(List<Subnet> subnets);
|
||||||
|
|
||||||
|
public abstract Builder resourceGuid(String resourceGuid);
|
||||||
|
|
||||||
|
public abstract Builder provisioningState(String provisioningState);
|
||||||
|
|
||||||
|
public abstract NetworkSecurityGroupProperties build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class NetworkSecurityRule {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String etag();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract NetworkSecurityRuleProperties properties();
|
||||||
|
|
||||||
|
@SerializedNames({"name", "id", "etag", "properties"})
|
||||||
|
public static NetworkSecurityRule create(final String name,
|
||||||
|
final String id,
|
||||||
|
final String etag,
|
||||||
|
final NetworkSecurityRuleProperties properties) {
|
||||||
|
return new AutoValue_NetworkSecurityRule(name, id, etag, properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,146 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
import org.jclouds.azurecompute.arm.util.GetEnumValue;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class NetworkSecurityRuleProperties {
|
||||||
|
public enum Protocol {
|
||||||
|
// * is an allowed value, will handle in
|
||||||
|
Tcp("Tcp"),
|
||||||
|
Udp("Udp"),
|
||||||
|
All("*"),
|
||||||
|
UNRECOGNIZED("Unrecognized");
|
||||||
|
|
||||||
|
private final String label;
|
||||||
|
|
||||||
|
private Protocol(String label) { this.label = label; }
|
||||||
|
|
||||||
|
public static Protocol fromValue(final String text) {
|
||||||
|
if ("*".equals(text)) {
|
||||||
|
return All;
|
||||||
|
} else {
|
||||||
|
return (Protocol) GetEnumValue.fromValueOrDefault(text, Protocol.UNRECOGNIZED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Access {
|
||||||
|
Allow,
|
||||||
|
Deny,
|
||||||
|
UNRECOGNIZED;
|
||||||
|
|
||||||
|
public static Access fromValue(final String text) {
|
||||||
|
return (Access) GetEnumValue.fromValueOrDefault(text, Access.UNRECOGNIZED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Direction {
|
||||||
|
Inbound,
|
||||||
|
Outbound,
|
||||||
|
UNRECOGNIZED;
|
||||||
|
|
||||||
|
public static Direction fromValue(final String text) {
|
||||||
|
return (Direction) GetEnumValue.fromValueOrDefault(text, Direction.UNRECOGNIZED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String description();
|
||||||
|
|
||||||
|
public abstract Protocol protocol();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String sourcePortRange();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String destinationPortRange();
|
||||||
|
|
||||||
|
public abstract String sourceAddressPrefix();
|
||||||
|
|
||||||
|
public abstract String destinationAddressPrefix();
|
||||||
|
|
||||||
|
public abstract Access access();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer priority();
|
||||||
|
|
||||||
|
public abstract Direction direction();
|
||||||
|
|
||||||
|
@SerializedNames({"description", "protocol", "sourcePortRange", "destinationPortRange", "sourceAddressPrefix", "destinationAddressPrefix", "access", "priority", "direction"})
|
||||||
|
public static NetworkSecurityRuleProperties create(final String description,
|
||||||
|
final Protocol protocol,
|
||||||
|
final String sourcePortRange,
|
||||||
|
final String destinationPortRange,
|
||||||
|
final String sourceAddressPrefix,
|
||||||
|
final String destinationAddressPrefix,
|
||||||
|
final Access access,
|
||||||
|
final Integer priority,
|
||||||
|
final Direction direction) {
|
||||||
|
return builder()
|
||||||
|
.description(description)
|
||||||
|
.protocol(protocol)
|
||||||
|
.sourcePortRange(sourcePortRange)
|
||||||
|
.destinationPortRange(destinationPortRange)
|
||||||
|
.sourceAddressPrefix(sourceAddressPrefix)
|
||||||
|
.destinationAddressPrefix(destinationAddressPrefix)
|
||||||
|
.access(access)
|
||||||
|
.priority(priority)
|
||||||
|
.direction(direction)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_NetworkSecurityRuleProperties.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder description(String description);
|
||||||
|
|
||||||
|
public abstract Builder protocol(Protocol protocol);
|
||||||
|
|
||||||
|
public abstract Builder sourcePortRange(String sourcePortRange);
|
||||||
|
|
||||||
|
public abstract Builder destinationPortRange(String destinationPortRange);
|
||||||
|
|
||||||
|
public abstract Builder sourceAddressPrefix(String sourceAddressPrefix);
|
||||||
|
|
||||||
|
public abstract Builder destinationAddressPrefix(String sourceAddressPrefix);
|
||||||
|
|
||||||
|
public abstract Builder access(Access access);
|
||||||
|
|
||||||
|
public abstract Builder priority(Integer priority);
|
||||||
|
|
||||||
|
public abstract Builder direction(Direction direction);
|
||||||
|
|
||||||
|
public abstract NetworkSecurityRuleProperties build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
/*
|
||||||
|
* 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.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class OSDisk {
|
||||||
|
/**
|
||||||
|
* The OS type of the os disk
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String osType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the os disk
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The vhd of the os disk
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract VHD vhd();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The caching mode of the os disk
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String caching();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The create options of the os disk
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String createOption();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The url of the custom image
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract VHD image();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The managed disk parameters.
|
||||||
|
*/
|
||||||
|
@Nullable public abstract ManagedDiskParameters managedDiskParameters();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The storage account type. This field is returned in custom images.
|
||||||
|
*/
|
||||||
|
@Nullable public abstract StorageAccountType storageAccountType();
|
||||||
|
|
||||||
|
@SerializedNames({ "osType", "name", "vhd", "caching", "createOption", "image", "managedDisk", "storageAccountType" })
|
||||||
|
public static OSDisk create(final String osType, final String name, final VHD vhd, final String caching,
|
||||||
|
final String createOption, final VHD image, final ManagedDiskParameters managedDiskParamenters,
|
||||||
|
final String storageAccountType) {
|
||||||
|
return builder().osType(osType).name(name).vhd(vhd).caching(caching).createOption(createOption).image(image)
|
||||||
|
.managedDiskParameters(managedDiskParamenters)
|
||||||
|
.storageAccountType(StorageAccountType.fromString(storageAccountType)).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_OSDisk.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder osType(String osType);
|
||||||
|
public abstract Builder name(String name);
|
||||||
|
public abstract Builder caching(String caching);
|
||||||
|
public abstract Builder createOption(String createOption);
|
||||||
|
public abstract Builder vhd(VHD vhd);
|
||||||
|
public abstract Builder image(VHD image);
|
||||||
|
public abstract Builder managedDiskParameters(ManagedDiskParameters managedDiskParameters);
|
||||||
|
public abstract Builder storageAccountType(StorageAccountType storageAccountType);
|
||||||
|
public abstract OSDisk build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,277 @@
|
||||||
|
/*
|
||||||
|
* 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.azurecompute.arm.util.GetEnumValue;
|
||||||
|
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 OSProfile {
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class LinuxConfiguration {
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class SSH {
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class SSHPublicKey {
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String path();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String keyData();
|
||||||
|
|
||||||
|
@SerializedNames({"path", "keyData"})
|
||||||
|
public static SSHPublicKey create(final String path, final String keyData) {
|
||||||
|
|
||||||
|
return new AutoValue_OSProfile_LinuxConfiguration_SSH_SSHPublicKey(
|
||||||
|
path, keyData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of public keys and paths
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract List<SSHPublicKey> publicKeys();
|
||||||
|
|
||||||
|
@SerializedNames({"publicKeys"})
|
||||||
|
public static SSH create(final List<SSHPublicKey> publicKeys) {
|
||||||
|
|
||||||
|
return new AutoValue_OSProfile_LinuxConfiguration_SSH(
|
||||||
|
publicKeys);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The authentication method password or ssh
|
||||||
|
*/
|
||||||
|
public abstract String disablePasswordAuthentication();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ssh keys
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract SSH ssh();
|
||||||
|
|
||||||
|
@SerializedNames({"disablePasswordAuthentication", "ssh"})
|
||||||
|
public static LinuxConfiguration create(final String disablePasswordAuthentication,
|
||||||
|
final SSH ssh) {
|
||||||
|
|
||||||
|
return new AutoValue_OSProfile_LinuxConfiguration(disablePasswordAuthentication,
|
||||||
|
ssh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class WindowsConfiguration {
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class WinRM {
|
||||||
|
public enum Protocol {
|
||||||
|
|
||||||
|
HTTP("http"),
|
||||||
|
HTTPS("https"),
|
||||||
|
UNRECOGNIZED("Unrecognized");
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
Protocol(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Protocol fromValue(String value) {
|
||||||
|
return (Protocol) GetEnumValue.fromValueOrDefault(value, Protocol.UNRECOGNIZED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class ProtocolListener {
|
||||||
|
|
||||||
|
public abstract Protocol protocol();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String certificateUrl();
|
||||||
|
|
||||||
|
@SerializedNames({"protocol", "certificateUrl"})
|
||||||
|
public static ProtocolListener create(final Protocol protocol, final String certificateUrl) {
|
||||||
|
|
||||||
|
return new AutoValue_OSProfile_WindowsConfiguration_WinRM_ProtocolListener(
|
||||||
|
protocol, certificateUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of different settings
|
||||||
|
*/
|
||||||
|
public abstract List<ProtocolListener> listeners();
|
||||||
|
|
||||||
|
@SerializedNames({"listeners"})
|
||||||
|
public static WinRM create(final List<ProtocolListener> listeners) {
|
||||||
|
return new AutoValue_OSProfile_WindowsConfiguration_WinRM(listeners == null ? ImmutableList.<ProtocolListener>of() : ImmutableList.copyOf(listeners));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract static class AdditionalUnattendContent {
|
||||||
|
|
||||||
|
public abstract String pass();
|
||||||
|
|
||||||
|
public abstract String component();
|
||||||
|
|
||||||
|
public abstract String settingName();
|
||||||
|
|
||||||
|
@Nullable public abstract String content();
|
||||||
|
|
||||||
|
@SerializedNames({"passName", "componentName", "settingName", "content"})
|
||||||
|
public static AdditionalUnattendContent create(final String passName, final String componentName,
|
||||||
|
final String settingName,
|
||||||
|
final String content) {
|
||||||
|
|
||||||
|
return new AutoValue_OSProfile_WindowsConfiguration_AdditionalUnattendContent(
|
||||||
|
passName, componentName, settingName, content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The provision VM Agent true of false.
|
||||||
|
*/
|
||||||
|
public abstract boolean provisionVMAgent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* winR
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract WinRM winRM();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* unattend content
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract List<AdditionalUnattendContent> additionalUnattendContent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* is automatic updates enabled
|
||||||
|
*/
|
||||||
|
public abstract boolean enableAutomaticUpdates();
|
||||||
|
|
||||||
|
@SerializedNames({"provisionVMAgent", "winRM", "additionalUnattendContent", "enableAutomaticUpdates"})
|
||||||
|
public static WindowsConfiguration create(final boolean provisionVMAgent, final WinRM winRM,
|
||||||
|
final List<AdditionalUnattendContent> additionalUnattendContent,
|
||||||
|
final boolean enableAutomaticUpdates) {
|
||||||
|
|
||||||
|
return new AutoValue_OSProfile_WindowsConfiguration(provisionVMAgent, winRM,
|
||||||
|
additionalUnattendContent, enableAutomaticUpdates);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The computer name of the VM
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String computerName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The admin username of the VM
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String adminUsername();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The admin password of the VM
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String adminPassword();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The custom data of the VM
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String customData();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The linux configuration of the VM
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract LinuxConfiguration linuxConfiguration();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The windows configuration of the VM
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract WindowsConfiguration windowsConfiguration();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Secrets configuration of the VM
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract List<Secrets> secrets();
|
||||||
|
|
||||||
|
@SerializedNames({"computerName", "adminUsername", "adminPassword", "customData", "linuxConfiguration",
|
||||||
|
"windowsConfiguration", "secrets"})
|
||||||
|
public static OSProfile create(final String computerName, final String adminUsername, final String adminPassword,
|
||||||
|
final String customData, final LinuxConfiguration linuxConfiguration,
|
||||||
|
final WindowsConfiguration windowsConfiguration, final List<Secrets> secrets) {
|
||||||
|
return builder()
|
||||||
|
.computerName(computerName)
|
||||||
|
.adminUsername(adminUsername)
|
||||||
|
.adminPassword(adminPassword)
|
||||||
|
.customData(customData)
|
||||||
|
.linuxConfiguration(linuxConfiguration)
|
||||||
|
.windowsConfiguration(windowsConfiguration)
|
||||||
|
.secrets(secrets)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_OSProfile.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder computerName(String computerName);
|
||||||
|
|
||||||
|
public abstract Builder adminUsername(String adminUsername);
|
||||||
|
|
||||||
|
public abstract Builder adminPassword(String adminPassword);
|
||||||
|
|
||||||
|
public abstract Builder customData(String customData);
|
||||||
|
|
||||||
|
public abstract Builder linuxConfiguration(LinuxConfiguration linuxConfiguration);
|
||||||
|
|
||||||
|
public abstract Builder windowsConfiguration(WindowsConfiguration windowsConfiguration);
|
||||||
|
|
||||||
|
public abstract Builder secrets(List<Secrets> secrets);
|
||||||
|
|
||||||
|
public abstract OSProfile build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offer
|
||||||
|
*/
|
||||||
|
@AutoValue
|
||||||
|
public abstract class Offer {
|
||||||
|
/**
|
||||||
|
* The location of the Offer
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String location();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the Offer
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The id of the Offer
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@SerializedNames({"location", "name", "id"})
|
||||||
|
public static Offer create(final String location, final String name, final String id) {
|
||||||
|
|
||||||
|
return new AutoValue_Offer(location, name, id);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* 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.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plan
|
||||||
|
*/
|
||||||
|
@AutoValue
|
||||||
|
public abstract class Plan {
|
||||||
|
/**
|
||||||
|
* The publisher of the Plan
|
||||||
|
*/
|
||||||
|
public abstract String publisher();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the Plan
|
||||||
|
*/
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The product of the Plan
|
||||||
|
*/
|
||||||
|
public abstract String product();
|
||||||
|
|
||||||
|
@SerializedNames({"publisher", "name", "product"})
|
||||||
|
public static Plan create(final String publisher, final String name, final String product) {
|
||||||
|
return new AutoValue_Plan(publisher, name, product);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* 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.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class Probe {
|
||||||
|
@Nullable
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract ProbeProperties properties();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String etag();
|
||||||
|
|
||||||
|
@SerializedNames({ "name", "id", "properties", "etag" })
|
||||||
|
public static Probe create(final String name, final String id, final ProbeProperties properties, final String etag) {
|
||||||
|
return new AutoValue_Probe(name, id, properties, etag);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class ProbeProperties implements Provisionable {
|
||||||
|
public enum Protocol {
|
||||||
|
Tcp("Tcp"), Http("Http"), UNRECOGNIZED("Unrecognized");
|
||||||
|
|
||||||
|
private final String label;
|
||||||
|
|
||||||
|
private Protocol(final String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Protocol fromValue(final String text) {
|
||||||
|
return (Protocol) GetEnumValue.fromValueOrDefault(text, Protocol.UNRECOGNIZED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Protocol protocol();
|
||||||
|
|
||||||
|
public abstract int port();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String requestPath();
|
||||||
|
|
||||||
|
public abstract int intervalInSeconds();
|
||||||
|
|
||||||
|
public abstract int numberOfProbes();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract String provisioningState();
|
||||||
|
|
||||||
|
@SerializedNames({ "protocol", "port", "requestPath", "intervalInSeconds", "numberOfProbes", "provisioningState" })
|
||||||
|
public static ProbeProperties create(final Protocol protocol, final int port, final String requestPath,
|
||||||
|
final int intervalInSeconds, final int numberOfProbes, final String provisioningState) {
|
||||||
|
return builder().protocol(protocol).port(port).requestPath(requestPath).intervalInSeconds(intervalInSeconds)
|
||||||
|
.numberOfProbes(numberOfProbes).provisioningState(provisioningState).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_ProbeProperties.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
|
||||||
|
public abstract Builder protocol(Protocol protocol);
|
||||||
|
|
||||||
|
public abstract Builder port(int port);
|
||||||
|
|
||||||
|
public abstract Builder requestPath(String requestPath);
|
||||||
|
|
||||||
|
public abstract Builder intervalInSeconds(int intervalInSeconds);
|
||||||
|
|
||||||
|
public abstract Builder numberOfProbes(int numberOfProbes);
|
||||||
|
|
||||||
|
public abstract Builder provisioningState(String provisioningState);
|
||||||
|
|
||||||
|
public abstract ProbeProperties build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
public interface Provisionable {
|
||||||
|
|
||||||
|
String provisioningState();
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* 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.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 PublicIPAddress {
|
||||||
|
|
||||||
|
public abstract String name();
|
||||||
|
public abstract String id();
|
||||||
|
public abstract String etag();
|
||||||
|
public abstract String location();
|
||||||
|
@Nullable public abstract Map<String, String> tags();
|
||||||
|
public abstract PublicIPAddressProperties properties();
|
||||||
|
|
||||||
|
@SerializedNames({ "name", "id", "etag", "location", "tags", "properties" })
|
||||||
|
public static PublicIPAddress create(String name, String id, String etag, String location, Map<String, String> tags,
|
||||||
|
PublicIPAddressProperties properties) {
|
||||||
|
return builder().name(name).id(id).etag(etag).location(location).tags(tags).properties(properties).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
PublicIPAddress() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_PublicIPAddress.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder name(String name);
|
||||||
|
public abstract Builder id(String id);
|
||||||
|
public abstract Builder etag(String etag);
|
||||||
|
public abstract Builder location(String location);
|
||||||
|
public abstract Builder tags(Map<String, String> tags);
|
||||||
|
public abstract Builder properties(PublicIPAddressProperties properties);
|
||||||
|
|
||||||
|
abstract Map<String, String> tags();
|
||||||
|
abstract PublicIPAddress autoBuild();
|
||||||
|
|
||||||
|
public PublicIPAddress build() {
|
||||||
|
tags(tags() != null ? ImmutableMap.copyOf(tags()) : null);
|
||||||
|
return autoBuild();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class PublicIPAddressProperties implements Provisionable {
|
||||||
|
|
||||||
|
@Nullable // needs to be nullable to create the payload for create request
|
||||||
|
public abstract String provisioningState();
|
||||||
|
|
||||||
|
@Nullable // only set in succeeded provisioningState for Static IP and for Dynamic when attached to a NIC
|
||||||
|
public abstract String ipAddress();
|
||||||
|
|
||||||
|
public abstract String publicIPAllocationMethod();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public abstract Integer idleTimeoutInMinutes();
|
||||||
|
|
||||||
|
@Nullable // only if attached to NIC
|
||||||
|
public abstract IdReference ipConfiguration();
|
||||||
|
|
||||||
|
@Nullable // only if DNS name is set
|
||||||
|
public abstract DnsSettings dnsSettings();
|
||||||
|
|
||||||
|
@SerializedNames({"provisioningState", "ipAddress", "publicIPAllocationMethod", "idleTimeoutInMinutes", "ipConfiguration", "dnsSettings"})
|
||||||
|
public static PublicIPAddressProperties create(final String provisioningState,
|
||||||
|
final String ipAddress,
|
||||||
|
final String publicIPAllocationMethod,
|
||||||
|
final Integer idleTimeoutInMinutes,
|
||||||
|
final IdReference ipConfiguration,
|
||||||
|
final DnsSettings dnsSettings) {
|
||||||
|
return builder()
|
||||||
|
.provisioningState(provisioningState)
|
||||||
|
.ipAddress(ipAddress)
|
||||||
|
.publicIPAllocationMethod(publicIPAllocationMethod)
|
||||||
|
.idleTimeoutInMinutes(idleTimeoutInMinutes)
|
||||||
|
.ipConfiguration(ipConfiguration)
|
||||||
|
.dnsSettings(dnsSettings)
|
||||||
|
.publicIPAllocationMethod(publicIPAllocationMethod)
|
||||||
|
.dnsSettings(dnsSettings)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Builder toBuilder();
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new AutoValue_PublicIPAddressProperties.Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AutoValue.Builder
|
||||||
|
public abstract static class Builder {
|
||||||
|
public abstract Builder provisioningState(String provisioningState);
|
||||||
|
|
||||||
|
public abstract Builder ipAddress(String ipAddress);
|
||||||
|
|
||||||
|
public abstract Builder publicIPAllocationMethod(String publicIPAllocationMethod);
|
||||||
|
|
||||||
|
public abstract Builder idleTimeoutInMinutes(Integer idleTimeoutInMinutes);
|
||||||
|
|
||||||
|
public abstract Builder ipConfiguration(IdReference ipConfiguration);
|
||||||
|
|
||||||
|
public abstract Builder dnsSettings(DnsSettings dnsSettings);
|
||||||
|
|
||||||
|
public abstract PublicIPAddressProperties build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* 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 com.google.auto.value.AutoValue;
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Publisher
|
||||||
|
*/
|
||||||
|
@AutoValue
|
||||||
|
public abstract class Publisher {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The location of the publisher
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String location();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the publisher
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String name();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The id of the publisher
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
|
@SerializedNames({"location", "name", "id"})
|
||||||
|
public static Publisher create(final String location, final String name, final String id) {
|
||||||
|
|
||||||
|
return new AutoValue_Publisher(location, name, id);
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue