diff --git a/sdk/resourcemanager/azure-resourcemanager-compute/CHANGELOG.md b/sdk/resourcemanager/azure-resourcemanager-compute/CHANGELOG.md index 0057b6b992d8c..b80bc2e1c5d17 100644 --- a/sdk/resourcemanager/azure-resourcemanager-compute/CHANGELOG.md +++ b/sdk/resourcemanager/azure-resourcemanager-compute/CHANGELOG.md @@ -10,6 +10,8 @@ ### Bugs Fixed +- Fixed a bug that `VirtualMachineCustomImages.getById()` returns `HyperVGenerationTypes.V1` for all instances. ([#36619](https://github.com/Azure/azure-sdk-for-java/issues/36619)) + ### Other Changes ## 2.30.0 (2023-08-25) diff --git a/sdk/resourcemanager/azure-resourcemanager-compute/assets.json b/sdk/resourcemanager/azure-resourcemanager-compute/assets.json index 6982f9b7c03ce..a01e76564a6ba 100644 --- a/sdk/resourcemanager/azure-resourcemanager-compute/assets.json +++ b/sdk/resourcemanager/azure-resourcemanager-compute/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "java", "TagPrefix": "java/resourcemanager/azure-resourcemanager-compute", - "Tag": "java/resourcemanager/azure-resourcemanager-compute_f41c201e0a" + "Tag": "java/resourcemanager/azure-resourcemanager-compute_e09f72a36a" } diff --git a/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineCustomImageImpl.java b/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineCustomImageImpl.java index c532ef1369f19..2cf05a2ba7a4d 100644 --- a/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineCustomImageImpl.java +++ b/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineCustomImageImpl.java @@ -33,8 +33,6 @@ class VirtualMachineCustomImageImpl VirtualMachineCustomImageImpl(final String name, ImageInner innerModel, final ComputeManager computeManager) { super(name, innerModel, computeManager); - // set the default value for the hyper-v generation - this.innerModel().withHyperVGeneration(HyperVGenerationTypes.V1); } @Override @@ -284,7 +282,7 @@ VirtualMachineCustomImageImpl withCustomImageDataDisk(CustomImageDataDiskImpl cu } @Override - public VirtualMachineCustomImage.DefinitionStages.WithOSDiskImageSourceAltVirtualMachineSource withHyperVGeneration( + public VirtualMachineCustomImageImpl withHyperVGeneration( HyperVGenerationTypes hyperVGeneration) { this.innerModel().withHyperVGeneration(hyperVGeneration); return this; diff --git a/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineCustomImagesImpl.java b/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineCustomImagesImpl.java index 4bafc3e3c102f..f233e4040bccd 100644 --- a/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineCustomImagesImpl.java +++ b/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineCustomImagesImpl.java @@ -4,6 +4,7 @@ package com.azure.resourcemanager.compute.implementation; import com.azure.resourcemanager.compute.ComputeManager; +import com.azure.resourcemanager.compute.models.HyperVGenerationTypes; import com.azure.resourcemanager.compute.models.VirtualMachineCustomImage; import com.azure.resourcemanager.compute.models.VirtualMachineCustomImages; import com.azure.resourcemanager.compute.fluent.models.ImageInner; @@ -35,6 +36,6 @@ protected VirtualMachineCustomImageImpl wrapModel(ImageInner inner) { @Override public VirtualMachineCustomImageImpl define(String name) { - return this.wrapModel(name); + return this.wrapModel(name).withHyperVGeneration(HyperVGenerationTypes.V1); } } diff --git a/sdk/resourcemanager/azure-resourcemanager-compute/src/test/java/com/azure/resourcemanager/compute/VirtualMachineCustomImageOperationsTest.java b/sdk/resourcemanager/azure-resourcemanager-compute/src/test/java/com/azure/resourcemanager/compute/VirtualMachineCustomImageOperationsTest.java index 1c5bdfe30585d..4365b412b5564 100644 --- a/sdk/resourcemanager/azure-resourcemanager-compute/src/test/java/com/azure/resourcemanager/compute/VirtualMachineCustomImageOperationsTest.java +++ b/sdk/resourcemanager/azure-resourcemanager-compute/src/test/java/com/azure/resourcemanager/compute/VirtualMachineCustomImageOperationsTest.java @@ -155,6 +155,9 @@ public void canCreateImageFromNativeVhd() throws IOException { Assertions.assertNotNull(customImageGen2.dataDiskImages()); Assertions.assertEquals(customImageGen2.dataDiskImages().size(), 0); Assertions.assertTrue(customImageGen2.hyperVGeneration().equals(HyperVGenerationTypes.V2)); + + customImageGen2 = this.computeManager.virtualMachineCustomImages().getById(customImageGen2.id()); + Assertions.assertEquals(HyperVGenerationTypes.V2, customImageGen2.hyperVGeneration()); } @Test @@ -204,7 +207,6 @@ public void canCreateImageFromManagedDisk() { final String vmName = generateRandomResourceName("vm7-", 20); final String storageAccountName = generateRandomResourceName("stg", 17); final String uname = "juser"; - final String password = password(); VirtualMachine nativeVm = computeManager @@ -344,7 +346,6 @@ public void canCreateImageFromManagedDisk() { private VirtualMachine prepareGeneralizedVmWith2EmptyDataDisks( String rgName, String vmName, Region region, ComputeManager computeManager) { final String uname = "javauser"; - final String password = password(); final KnownLinuxVirtualMachineImage linuxImage = KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS; final String publicIpDnsLabel = generateRandomResourceName("pip", 20);