mirror of https://github.com/apache/jclouds.git
Adds method listAvailableSizes to VirtualMachineApi
Updates API version for VirtualMachineApi
This commit is contained in:
parent
b7d59e3fe9
commit
8e827d595e
|
@ -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");
|
||||
|
|
|
@ -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}")
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue