jclouds-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From deste...@apache.org
Subject jclouds git commit: Adds method listAvailableSizes to VirtualMachineApi Updates API version for VirtualMachineApi
Date Tue, 20 Nov 2018 17:30:21 GMT
Repository: jclouds
Updated Branches:
  refs/heads/master b7d59e3fe -> 8e827d595


Adds method listAvailableSizes to VirtualMachineApi
Updates API version for VirtualMachineApi


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/8e827d59
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/8e827d59
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/8e827d59

Branch: refs/heads/master
Commit: 8e827d595e8b61f2a1d1a3f7c7c7c52f5dfddf09
Parents: b7d59e3
Author: Dani Estevez <contact@danielestevez.com>
Authored: Mon Nov 12 16:59:58 2018 -0500
Committer: Dani Estevez <contact@danielestevez.com>
Committed: Tue Nov 20 12:30:14 2018 -0500

----------------------------------------------------------------------
 .../arm/AzureComputeProviderMetadata.java       |  2 +-
 .../arm/features/VirtualMachineApi.java         | 12 ++++-
 .../arm/features/VirtualMachineApiLiveTest.java | 10 +++++
 .../arm/features/VirtualMachineApiMockTest.java | 46 ++++++++++++--------
 .../resources/virtualmachineavailablesizes.json | 20 +++++++++
 5 files changed, 70 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/8e827d59/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java
----------------------------------------------------------------------
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java
b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java
index 95856e6..85ec8b9 100644
--- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java
@@ -123,7 +123,7 @@ public class AzureComputeProviderMetadata extends BaseProviderMetadata
{
       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 + VirtualMachineApi.class.getSimpleName(), "2018-06-01");
       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");

http://git-wip-us.apache.org/repos/asf/jclouds/blob/8e827d59/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/VirtualMachineApi.java
----------------------------------------------------------------------
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/VirtualMachineApi.java
b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/VirtualMachineApi.java
index e8dc065..bc8c0e5 100644
--- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/VirtualMachineApi.java
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/VirtualMachineApi.java
@@ -32,6 +32,7 @@ import javax.ws.rs.core.MediaType;
 
 import org.jclouds.Fallbacks;
 import org.jclouds.azurecompute.arm.domain.Plan;
+import org.jclouds.azurecompute.arm.domain.VMSize;
 import org.jclouds.azurecompute.arm.domain.VirtualMachine;
 import org.jclouds.azurecompute.arm.domain.VirtualMachineInstance;
 import org.jclouds.azurecompute.arm.domain.VirtualMachineProperties;
@@ -52,7 +53,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
 /**
  * The Virtual Machine API includes operations for managing the virtual machines in your
subscription.
  *
- * @see <a href="https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/virtualmachines-rest-api">docs</a>
+ * @see <a href="https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines">docs</a>
  */
 @Path("/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines")
 @RequestFilters({ OAuthFilter.class, ApiVersionFilter.class })
@@ -91,6 +92,13 @@ public interface VirtualMachineApi {
    @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
    List<VirtualMachine> list();
 
+   @Named("ListAvailableSizes")
+   @GET
+   @SelectJson("value")
+   @Path("/{name}/vmSizes")
+   @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
+   List<VMSize> listAvailableSizes(@PathParam("name") String name);
+
    @Named("DeleteVirtualMachine")
    @DELETE
    @Path("/{name}")
@@ -139,6 +147,6 @@ public interface VirtualMachineApi {
    URI capture(@PathParam("name") String name,
                @PayloadParam("vhdPrefix") String vhdPrefix,
                @PayloadParam("destinationContainerName") String destinationContainerName);
-
+   
 }
 

http://git-wip-us.apache.org/repos/asf/jclouds/blob/8e827d59/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiLiveTest.java
b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiLiveTest.java
index 27bdc75..c2f2781 100644
--- a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiLiveTest.java
+++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiLiveTest.java
@@ -19,6 +19,7 @@ package org.jclouds.azurecompute.arm.features;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.jclouds.util.Predicates2.retry;
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertTrue;
 import static org.testng.util.Strings.isNullOrEmpty;
@@ -53,6 +54,7 @@ import org.jclouds.azurecompute.arm.domain.StorageProfile;
 import org.jclouds.azurecompute.arm.domain.StorageService;
 import org.jclouds.azurecompute.arm.domain.Subnet;
 import org.jclouds.azurecompute.arm.domain.VHD;
+import org.jclouds.azurecompute.arm.domain.VMSize;
 import org.jclouds.azurecompute.arm.domain.VaultCertificate;
 import org.jclouds.azurecompute.arm.domain.VirtualMachine;
 import org.jclouds.azurecompute.arm.domain.VirtualMachineInstance;
@@ -191,6 +193,14 @@ public class VirtualMachineApiLiveTest extends BaseAzureComputeApiLiveTest
{
       assertTrue(vmPresent);
    }
 
+   @Test(dependsOnMethods = "testCreate")
+   public void testListAvailableSizes() {
+      List<VMSize> vmSizes = api().listAvailableSizes(vmName);
+
+      assertNotNull(vmSizes);
+      assertFalse(vmSizes.isEmpty());
+   }
+
    @Test(dependsOnMethods = "testRestart")
    public void testGeneralize() throws IllegalStateException {
       api().stop(vmName);

http://git-wip-us.apache.org/repos/asf/jclouds/blob/8e827d59/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiMockTest.java
----------------------------------------------------------------------
diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiMockTest.java
b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiMockTest.java
index 7371294..642d38d 100644
--- a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiMockTest.java
+++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiMockTest.java
@@ -48,6 +48,7 @@ import org.jclouds.azurecompute.arm.domain.Secrets.SourceVault;
 import org.jclouds.azurecompute.arm.domain.Status;
 import org.jclouds.azurecompute.arm.domain.StorageProfile;
 import org.jclouds.azurecompute.arm.domain.VHD;
+import org.jclouds.azurecompute.arm.domain.VMSize;
 import org.jclouds.azurecompute.arm.domain.VaultCertificate;
 import org.jclouds.azurecompute.arm.domain.VirtualMachine;
 import org.jclouds.azurecompute.arm.domain.VirtualMachineInstance;
@@ -68,7 +69,7 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest
{
       assertEquals(vmAPI.get("windowsmachine"),
             getVM(Plan.create("thinkboxsoftware", "deadline-slave-7-2", "deadline7-2")));
       assertSent(server, "GET", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
-            + "/virtualMachines/windowsmachine?api-version=2016-04-30-preview");
+            + "/virtualMachines/windowsmachine?api-version=2018-06-01");
    }
 
    public void testGetEmpty() throws Exception {
@@ -76,7 +77,7 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest
{
       final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
       assertNull(vmAPI.get("windowsmachine"));
       assertSent(server, "GET", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
-            + "/virtualMachines/windowsmachine?api-version=2016-04-30-preview");
+            + "/virtualMachines/windowsmachine?api-version=2018-06-01");
    }
 
    public void testGetInstanceDetails() throws Exception {
@@ -91,7 +92,7 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest
{
       // assertEquals(actual.statuses().get(0).time().toString(),
       // expected.statuses().get(0).time().toString());
       assertSent(server, "GET", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
-            + "/virtualMachines/windowsmachine/instanceView?api-version=2016-04-30-preview");
+            + "/virtualMachines/windowsmachine/instanceView?api-version=2018-06-01");
    }
 
    public void testGetInstanceDetailsEmpty() throws Exception {
@@ -99,7 +100,7 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest
{
       final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
       assertNull(vmAPI.getInstanceDetails("windowsmachine"));
       assertSent(server, "GET", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
-            + "/virtualMachines/windowsmachine/instanceView?api-version=2016-04-30-preview");
+            + "/virtualMachines/windowsmachine/instanceView?api-version=2018-06-01");
    }
 
    public void testList() throws Exception {
@@ -107,7 +108,7 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest
{
       final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
       assertEquals(vmAPI.list(), getVMList());
       assertSent(server, "GET", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
-            + "/virtualMachines?api-version=2016-04-30-preview");
+            + "/virtualMachines?api-version=2018-06-01");
    }
 
    public void testListEmpty() throws Exception {
@@ -115,7 +116,17 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest
{
       final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
       assertTrue(isEmpty(vmAPI.list()));
       assertSent(server, "GET", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
-            + "/virtualMachines?api-version=2016-04-30-preview");
+            + "/virtualMachines?api-version=2018-06-01");
+   }
+
+   public void testListAvailableSizes() throws Exception {
+      server.enqueue(jsonResponse("/virtualmachineavailablesizes.json"));
+      final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
+      assertEquals(vmAPI.listAvailableSizes("windowsmachine"), ImmutableList.of(VMSize.create("Standard_A0",
1,
+            1047552, 20480, 768, 1), VMSize.create("Standard_A1", 1,
+            1047552, 71680, 1792, 2)));
+      assertSent(server, "GET", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
+            + "/virtualMachines/windowsmachine/vmSizes?api-version=2018-06-01");
    }
 
    public void testCreateWithPlan() throws Exception {
@@ -129,7 +140,7 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest
{
             server,
             "PUT",
             "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
-                  + "/virtualMachines/windowsmachine?validating=false&api-version=2016-04-30-preview",
+                  + "/virtualMachines/windowsmachine?validating=false&api-version=2018-06-01",
             "{\"location\":\"westus\",\"properties\":"
                   + "{\"vmId\":\"27ee085b-d707-xxxx-yyyy-2370e2eb1cc1\",\"licenseType\":\"Windows_Server\","
                   + "\"availabilitySet\":{\"id\":\"/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/availabilitySets/myAVSet\"},"
@@ -164,7 +175,7 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest
{
             server,
             "PUT",
             "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
-                  + "/virtualMachines/windowsmachine?validating=false&api-version=2016-04-30-preview",
+                  + "/virtualMachines/windowsmachine?validating=false&api-version=2018-06-01",
             "{\"location\":\"westus\",\"properties\":"
                   + "{\"vmId\":\"27ee085b-d707-xxxx-yyyy-2370e2eb1cc1\",\"licenseType\":\"Windows_Server\","
                   + "\"availabilitySet\":{\"id\":\"/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/availabilitySets/myAVSet\"},"
@@ -195,7 +206,7 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest
{
       assertNull(uri);
 
       assertSent(server, "DELETE", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
-            + "/virtualMachines/windowsmachine?api-version=2016-04-30-preview");
+            + "/virtualMachines/windowsmachine?api-version=2018-06-01");
    }
 
    public void testDelete() throws Exception {
@@ -209,7 +220,7 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest
{
       assertNotNull(uri);
 
       assertSent(server, "DELETE", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
-            + "/virtualMachines/windowsmachine?api-version=2016-04-30-preview");
+            + "/virtualMachines/windowsmachine?api-version=2018-06-01");
    }
 
    public void testStart() throws Exception {
@@ -220,7 +231,7 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest
{
       vmAPI.start("windowsmachine");
 
       assertSent(server, "POST", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
-            + "/virtualMachines/windowsmachine/start?api-version=2016-04-30-preview");
+            + "/virtualMachines/windowsmachine/start?api-version=2018-06-01");
    }
 
    public void testRestart() throws Exception {
@@ -231,7 +242,7 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest
{
       vmAPI.restart("windowsmachine");
 
       assertSent(server, "POST", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
-            + "/virtualMachines/windowsmachine/restart?api-version=2016-04-30-preview");
+            + "/virtualMachines/windowsmachine/restart?api-version=2018-06-01");
    }
 
    public void testStop() throws Exception {
@@ -242,7 +253,7 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest
{
       vmAPI.stop("windowsmachine");
 
       assertSent(server, "POST", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
-            + "/virtualMachines/windowsmachine/powerOff?api-version=2016-04-30-preview");
+            + "/virtualMachines/windowsmachine/powerOff?api-version=2018-06-01");
    }
 
    public void testDeallocate() throws Exception {
@@ -253,7 +264,7 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest
{
       vmAPI.deallocate("windowsmachine");
 
       assertSent(server, "POST", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
-            + "/virtualMachines/windowsmachine/deallocate?api-version=2016-04-30-preview");
+            + "/virtualMachines/windowsmachine/deallocate?api-version=2018-06-01");
    }
 
    public void testGeneralize() throws Exception {
@@ -261,7 +272,7 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest
{
       final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
       vmAPI.generalize("vm"); // IllegalStateException if failed
       assertSent(server, "POST", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
-            + "/virtualMachines/vm/generalize?api-version=2016-04-30-preview");
+            + "/virtualMachines/vm/generalize?api-version=2018-06-01");
    }
 
    public void testCapture() throws Exception {
@@ -271,7 +282,7 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest
{
       URI uri = vmAPI.capture("vm", "prefix", "container");
       assertNotNull(uri);
       assertSent(server, "POST", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
-            + "/virtualMachines/vm/capture?api-version=2016-04-30-preview",
+            + "/virtualMachines/vm/capture?api-version=2018-06-01",
             "{\"vhdPrefix\":\"prefix\",\"destinationContainerName\":\"container\",\"overwriteVhds\":\"true\"}");
    }
 
@@ -282,7 +293,7 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest
{
       URI uri = vmAPI.capture("vm", "prefix", "container");
       assertNull(uri);
       assertSent(server, "POST", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
-            + "/virtualMachines/vm/capture?api-version=2016-04-30-preview",
+            + "/virtualMachines/vm/capture?api-version=2018-06-01",
             "{\"vhdPrefix\":\"prefix\",\"destinationContainerName\":\"container\",\"overwriteVhds\":\"true\"}");
    }
 
@@ -417,4 +428,5 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest
{
       list.add(machineWithBlobDisks);
       return list;
    }
+
 }

http://git-wip-us.apache.org/repos/asf/jclouds/blob/8e827d59/providers/azurecompute-arm/src/test/resources/virtualmachineavailablesizes.json
----------------------------------------------------------------------
diff --git a/providers/azurecompute-arm/src/test/resources/virtualmachineavailablesizes.json
b/providers/azurecompute-arm/src/test/resources/virtualmachineavailablesizes.json
new file mode 100644
index 0000000..f54423b
--- /dev/null
+++ b/providers/azurecompute-arm/src/test/resources/virtualmachineavailablesizes.json
@@ -0,0 +1,20 @@
+{
+  "value": [
+    {
+      "name": "Standard_A0",
+      "numberOfCores": 1,
+      "osDiskSizeInMB": 1047552,
+      "resourceDiskSizeInMB": 20480,
+      "memoryInMB": 768,
+      "maxDataDiskCount": 1
+    },
+    {
+      "name": "Standard_A1",
+      "numberOfCores": 1,
+      "osDiskSizeInMB": 1047552,
+      "resourceDiskSizeInMB": 71680,
+      "memoryInMB": 1792,
+      "maxDataDiskCount": 2
+    }
+  ]
+}
\ No newline at end of file


Mime
View raw message