Skip to content

Commit

Permalink
mgmt, fix VirtualMachineCustomImage hyperv (#36659)
Browse files Browse the repository at this point in the history
* code fix

* assets.json

* update
  • Loading branch information
XiaofeiCao authored Sep 7, 2023
1 parent 8d1552b commit db5547e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit db5547e

Please sign in to comment.