Skip to content

Commit

Permalink
update known vm images to newest (#12352)
Browse files Browse the repository at this point in the history
* update known vm images to newest

* fix compile error

* add live test and fix image gen2
  • Loading branch information
ChenTanyi authored Jun 22, 2020
1 parent 58e8a64 commit 72d5383
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,24 @@

/** The popular Azure Linux images. */
public enum KnownLinuxVirtualMachineImage {
/** UbuntuServer 14.04LTS. */
UBUNTU_SERVER_14_04_LTS("Canonical", "UbuntuServer", "14.04.4-LTS"),
/** UbuntuServer 16.04LTS. */
UBUNTU_SERVER_16_04_LTS("Canonical", "UbuntuServer", "16.04.0-LTS"),
/** Debian 8. */
DEBIAN_8("credativ", "Debian", "8"),
/** CentOS 7.2. */
CENTOS_7_2("OpenLogic", "CentOS", "7.2"),
/**
* OpenSUSE-Leap 42.1.
*
* @deprecated for virtual machine use {@link VirtualMachine.DefinitionShared#withLatestLinuxImage(String, String,
* String)}(String publisher, String offer, String sku)} and for virtual machine scale set use {@link
* VirtualMachineScaleSet.DefinitionShared#withLatestLinuxImage(String, String, String)}(String publisher,
* String offer, String sku)} with publisher as "SUSE", offer as "openSUSE-Leap" and sku as "42.3")}.
*/
@Deprecated
OPENSUSE_LEAP_42_1("SUSE", "openSUSE-Leap", "42.1"),
/**
* SLES 12-SP1.
*
* @deprecated for virtual machine use {@link VirtualMachine.DefinitionShared#withLatestLinuxImage(String, String,
* String)}(String publisher, String offer, String sku)} and for virtual machine scale set use {@link
* VirtualMachineScaleSet.DefinitionShared#withLatestLinuxImage(String, String, String)}(String publisher,
* String offer, String sku)} with publisher as "SUSE", offer as "SLES" and sku as "12-SP3")}.
*/
@Deprecated
SLES_12_SP1("SUSE", "SLES", "12-SP1");
/** UbuntuServer 18.04LTS. */
UBUNTU_SERVER_18_04_LTS("Canonical", "UbuntuServer", "18.04-LTS"),
/** Debian 9. */
DEBIAN_9("credativ", "Debian", "9"),
/** Debian 10. */
DEBIAN_10("Debian", "debian-10", "10"),
/** CentOS 8.1. */
CENTOS_8_1("OpenLogic", "CentOS", "8_1"),
/** OpenSUSE-Leap 15.1. */
OPENSUSE_LEAP_15_1("SUSE", "openSUSE-Leap", "15-1"),
/** SLES 15-SP1-gen1. */
SLES_15_SP1("SUSE", "sles-15-sp1", "gen1"),
/** RedHat RHEL 8.2. */
REDHAT_RHEL_8_2("RedHat", "RHEL", "8.2"),
/** Oracle Linux 8.1. */
ORACLE_LINUX_8_1("Oracle", "Oracle-Linux", "81");

private final String publisher;
private final String offer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,17 @@

/** The popular Azure Windows images. */
public enum KnownWindowsVirtualMachineImage {
/** Windows Server 2008 R2 SP1. */
WINDOWS_SERVER_2008_R2_SP1("MicrosoftWindowsServer", "WindowsServer", "2008-R2-SP1"),
/** Windows Server 2012 Data center. */
WINDOWS_SERVER_2012_DATACENTER("MicrosoftWindowsServer", "WindowsServer", "2012-Datacenter"),
/** Windows 10 2020 H1 Pro */
WINDOWS_DESKTOP_10_20H1_PRO("MicrosoftWindowsDesktop", "Windows-10", "20h1-pro"),
/** Windows Server 2019 Data center. */
WINDOWS_SERVER_2019_DATACENTER("MicrosoftWindowsServer", "WindowsServer", "2019-Datacenter"),
/** Windows Server 2019 Data center with containers. */
WINDOWS_SERVER_2019_DATACENTER_WITH_CONTAINERS(
"MicrosoftWindowsServer", "WindowsServer", "2019-Datacenter-with-Containers"),
/** Windows Server 2016 Data center. */
WINDOWS_SERVER_2016_DATACENTER("MicrosoftWindowsServer", "WindowsServer", "2016-Datacenter"),
/** Windows Server 2012 R2 Data center. */
WINDOWS_SERVER_2012_R2_DATACENTER("MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter"),
/**
* Windows Server 2016 technical preview with container.
*
* @deprecated for virtual machine use {@link VirtualMachine.DefinitionShared#withLatestWindowsImage(String
* publisher, String offer, String sku)} and for virtual machine scale set use {@link
* VirtualMachineScaleSet.DefinitionShared#withLatestWindowsImage(String publisher, String offer, String sku)}
* with publisher as "MicrosoftWindowsServer", offer as "WindowsServer" and sku as
* "2016-Datacenter-with-Containers")}.
*/
@Deprecated
WINDOWS_SERVER_2016_TECHNICAL_PREVIEW_WITH_CONTAINERS(
"MicrosoftWindowsServer", "WindowsServer", "2016-Technical-Preview-with-Containers"),
/**
* Windows Server 2016 technical preview.
*
* @deprecated for virtual machine use {@link VirtualMachine.DefinitionShared#withLatestWindowsImage(String
* publisher, String offer, String sku)} and for virtual machine scale set use {@link
* VirtualMachineScaleSet.DefinitionShared#withLatestWindowsImage(String publisher, String offer, String sku)}
* with publisher as "MicrosoftWindowsServer", offer as "WindowsServer" and sku as "2016-Datacenter")}.
*/
@Deprecated
WINDOWS_SERVER_TECHNICAL_PREVIEW("MicrosoftWindowsServer", "WindowsServer", "Windows-Server-Technical-Preview");
WINDOWS_SERVER_2012_R2_DATACENTER("MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter");

private final String publisher;
private final String offer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void canEnableDiagnosticsExtension() throws Exception {
.withNewPrimaryNetwork("10.0.0.0/28")
.withPrimaryPrivateIPAddressDynamic()
.withoutPrimaryPublicIPAddress()
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS)
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_18_04_LTS)
.withRootUsername("Foo12")
.withRootPassword("BaR@12abc!")
.withSize(VirtualMachineSizeTypes.STANDARD_D3)
Expand Down Expand Up @@ -121,7 +121,7 @@ public void canResetPasswordUsingVMAccessExtension() throws Exception {
.withNewPrimaryNetwork("10.0.0.0/28")
.withPrimaryPrivateIPAddressDynamic()
.withoutPrimaryPublicIPAddress()
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS)
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
.withRootUsername("Foo12")
.withRootPassword("BaR@12abc!")
.withSize(VirtualMachineSizeTypes.STANDARD_D3)
Expand Down Expand Up @@ -178,7 +178,7 @@ public void canInstallUninstallCustomExtension() throws Exception {
.withNewPrimaryNetwork("10.0.0.0/28")
.withPrimaryPrivateIPAddressDynamic()
.withoutPrimaryPublicIPAddress()
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS)
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_18_04_LTS)
.withRootUsername("Foo12")
.withRootPassword("BaR@12abc!")
.withSize(VirtualMachineSizeTypes.STANDARD_D3)
Expand Down Expand Up @@ -224,7 +224,7 @@ public void canHandleExtensionReference() throws Exception {
.withNewPrimaryNetwork("10.0.0.0/28")
.withPrimaryPrivateIPAddressDynamic()
.withoutPrimaryPublicIPAddress()
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS)
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_18_04_LTS)
.withRootUsername("Foo12")
.withRootPassword("BaR@12abc!")
.withSize(VirtualMachineSizeTypes.STANDARD_D3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void canCreateVirtualMachine() throws Exception {
.withNewPrimaryNetwork("10.0.0.0/28")
.withPrimaryPrivateIPAddressDynamic()
.withoutPrimaryPublicIPAddress()
.withPopularWindowsImage(KnownWindowsVirtualMachineImage.WINDOWS_SERVER_2012_DATACENTER)
.withPopularWindowsImage(KnownWindowsVirtualMachineImage.WINDOWS_SERVER_2012_R2_DATACENTER)
.withAdminUsername("Foo12")
.withAdminPassword("abc!@#F0orL")
.withUnmanagedDisks()
Expand Down Expand Up @@ -197,7 +197,7 @@ public void canCreateUpdatePriorityAndPrice() throws Exception {
.withNewPrimaryNetwork("10.0.0.0/28")
.withPrimaryPrivateIPAddressDynamic()
.withoutPrimaryPublicIPAddress()
.withPopularWindowsImage(KnownWindowsVirtualMachineImage.WINDOWS_SERVER_2012_DATACENTER)
.withPopularWindowsImage(KnownWindowsVirtualMachineImage.WINDOWS_SERVER_2016_DATACENTER)
.withAdminUsername("Foo12")
.withAdminPassword("abc!@#F0orL")
.withUnmanagedDisks()
Expand Down Expand Up @@ -312,7 +312,7 @@ public void cannotUpdateProximityPlacementGroupForVirtualMachine() throws Except
.withPrimaryPrivateIPAddressDynamic()
.withoutPrimaryPublicIPAddress()
.withProximityPlacementGroup(setCreated.proximityPlacementGroup().id())
.withPopularWindowsImage(KnownWindowsVirtualMachineImage.WINDOWS_SERVER_2012_DATACENTER)
.withPopularWindowsImage(KnownWindowsVirtualMachineImage.WINDOWS_SERVER_2019_DATACENTER)
.withAdminUsername("Foo12")
.withAdminPassword("abc!@#F0orL")
.withUnmanagedDisks()
Expand Down Expand Up @@ -407,7 +407,7 @@ public void canCreateVirtualMachinesAndAvailabilitySetInSameProximityPlacementGr
.withPrimaryPrivateIPAddressDynamic()
.withoutPrimaryPublicIPAddress()
.withProximityPlacementGroup(setCreated.proximityPlacementGroup().id())
.withPopularWindowsImage(KnownWindowsVirtualMachineImage.WINDOWS_SERVER_2012_DATACENTER)
.withPopularWindowsImage(KnownWindowsVirtualMachineImage.WINDOWS_SERVER_2019_DATACENTER)
.withAdminUsername("Foo12")
.withAdminPassword("abc!@#F0orL")
.withUnmanagedDisks()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.resourcemanager.compute;

import com.azure.resourcemanager.compute.models.KnownLinuxVirtualMachineImage;
import com.azure.resourcemanager.compute.models.KnownWindowsVirtualMachineImage;
import com.azure.resourcemanager.compute.models.VirtualMachineSizeTypes;
import com.azure.resourcemanager.resources.core.TestBase;
import com.azure.resourcemanager.resources.fluentcore.arm.Region;
import com.azure.resourcemanager.resources.fluentcore.model.Indexable;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;

import java.util.ArrayList;
import java.util.List;

public class VirtualMachinePopularImageTests extends ComputeManagementTest {
private final String rgName = generateRandomResourceName("rg", 10);

public VirtualMachinePopularImageTests() {
super(TestBase.RunCondition.LIVE_ONLY);
}

@Test
public void canCreateAllPopularImageVM() {
List<Flux<Indexable>> vmFluxes = new ArrayList<>();
for (KnownWindowsVirtualMachineImage image : KnownWindowsVirtualMachineImage.values()) {
Flux<Indexable> flux = computeManager.virtualMachines()
.define(generateRandomResourceName("vm", 10))
.withRegion(Region.US_SOUTH_CENTRAL)
.withNewResourceGroup(rgName)
.withNewPrimaryNetwork("10.0.0.0/24")
.withPrimaryPrivateIPAddressDynamic()
.withoutPrimaryPublicIPAddress()
.withPopularWindowsImage(image)
.withAdminUsername("testUser")
.withAdminPassword(password())
.withSize(VirtualMachineSizeTypes.STANDARD_B1S)
.createAsync();
vmFluxes.add(flux);
}

for (KnownLinuxVirtualMachineImage image : KnownLinuxVirtualMachineImage.values()) {
Flux<Indexable> flux = computeManager.virtualMachines()
.define(generateRandomResourceName("vm", 10))
.withRegion(Region.US_SOUTH_CENTRAL)
.withNewResourceGroup(rgName)
.withNewPrimaryNetwork("10.0.0.0/24")
.withPrimaryPrivateIPAddressDynamic()
.withoutPrimaryPublicIPAddress()
.withPopularLinuxImage(image)
.withRootUsername("testUser")
.withRootPassword(password())
.withSize(VirtualMachineSizeTypes.STANDARD_B1S)
.createAsync();
vmFluxes.add(flux);
}

Flux.merge(vmFluxes).blockLast();
}

@Override
protected void cleanUpResources() {
resourceManager.resourceGroups().beginDeleteByName(rgName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ private VirtualMachine[] ensureVMs(Networks networks, ComputeManager computeMana
.withSubnet(network.subnets().values().iterator().next().name())
.withPrimaryPrivateIPAddressDynamic()
.withoutPrimaryPublicIPAddress()
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS)
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_18_04_LTS)
.withRootUsername(userName)
.withRootPassword("Abcdef.123456")
.withNewAvailabilitySet(availabilitySetDefinition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ VirtualMachine[] ensureNetwork(Networks networks, VirtualMachines vms, NetworkIn
.withRegion(REGION)
.withExistingResourceGroup(groupName)
.withExistingPrimaryNetworkInterface(nic)
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS)
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_18_04_LTS)
.withRootUsername(userName)
.withRootPassword("Abcdef.123456")
.withSize(VirtualMachineSizeTypes.STANDARD_A1)
Expand All @@ -139,7 +139,7 @@ VirtualMachine[] ensureNetwork(Networks networks, VirtualMachines vms, NetworkIn
.withSubnet(network.subnets().values().iterator().next().name())
.withPrimaryPrivateIPAddressDynamic()
.withoutPrimaryPublicIPAddress()
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS)
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_18_04_LTS)
.withRootUsername(userName)
.withRootPassword("Abcdef.123456")
.withSize(VirtualMachineSizeTypes.STANDARD_A1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public VirtualMachine createResource(VirtualMachines virtualMachines) throws Exc
.withNewPrimaryNetwork(networkCreatable)
.withPrimaryPrivateIPAddressStatic("10.0.0.4")
.withNewPrimaryPublicIPAddress(primaryPipName)
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS)
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_18_04_LTS)
.withRootUsername("testuser")
.withRootPassword("12NewPA$$w0rd!")
.withSize(VirtualMachineSizeTypes.STANDARD_A9)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public VirtualMachine createResource(VirtualMachines virtualMachines) throws Exc
.withNewPrimaryNetwork("10.0.0.0/28")
.withPrimaryPrivateIPAddressDynamic()
.withExistingPrimaryPublicIPAddress(pip)
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS)
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_18_04_LTS)
.withRootUsername("testuser")
.withRootPassword("12NewPA$$w0rd!")
.withSsh(sshKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public static boolean runSample(Azure azure) {
.withNewPrimaryNetwork("10.0.0.0/28")
.withPrimaryPrivateIPAddressDynamic()
.withNewPrimaryPublicIPAddress(pipDnsLabelLinuxVM)
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS)
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_18_04_LTS)
.withRootUsername(firstLinuxUserName)
.withRootPassword(firstLinuxUserPassword)
.withSize(VirtualMachineSizeTypes.STANDARD_D3_V2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public static boolean runSample(Azure azure) {
.withNewPrimaryNetwork(virtualNetworkDefinition)
.withPrimaryPrivateIPAddressDynamic()
.withNewPrimaryPublicIPAddress(dnsLabel)
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS)
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_18_04_LTS)
.withRootUsername(userName)
.withRootPassword("Abcdef.123456")
.withSize(VirtualMachineSizeTypes.STANDARD_A1)
Expand Down

0 comments on commit 72d5383

Please sign in to comment.