public void AzurePlatformVMImageMultipleLocationsTest() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); try { // starting the test. PrintOSImageDetailsContext(vmPowershellCmdlets.GetAzurePlatformVMImage(image)); // Replicate the user image to "West US" and wait until the replication process is completed. ComputeImageConfig compCfg = new ComputeImageConfig { Offer = "test", Sku = "test", Version = "test" }; MarketplaceImageConfig marketCfg = null; vmPowershellCmdlets.SetAzurePlatformVMImageReplicate(image, new string[] { location1, location2 }, compCfg, marketCfg); PrintOSImageDetailsContext(vmPowershellCmdlets.GetAzurePlatformVMImage(image)); WaitForReplicationComplete(image); // Make the replicated image public and wait until the PIR image shows up. vmPowershellCmdlets.SetAzurePlatformVMImagePublic(image); OSImageContext pirImage = WaitForPIRAppear(image, publisher); PrintOSImageDetailsContext(vmPowershellCmdlets.GetAzurePlatformVMImage(image)); // Check the locations of the PIR image. string pirlocations = vmPowershellCmdlets.GetAzureVMImage(pirImage.ImageName)[0].Location; Assert.IsTrue(pirlocations.Contains(location1)); Assert.IsTrue(pirlocations.Contains(location2)); Assert.IsFalse(pirlocations.Contains(location3)); // Switch to the normal User and check the PIR image. SwitchToNormalUser(); Assert.IsTrue(Utilities.CheckRemove(vmPowershellCmdlets.GetAzureVMImage, image)); WaitForPIRAppear(image, publisher); // Switch to the publisher and make the PIR image private SwitchToPublisher(); vmPowershellCmdlets.SetAzurePlatformVMImagePrivate(image); // Switch to the normal User and wait until the PIR image disapper SwitchToNormalUser(); WaitForPIRDisappear(pirImage.ImageName); // Switch to the publisher and remove the PIR image. SwitchToPublisher(); vmPowershellCmdlets.RemoveAzurePlatformVMImage(image); Assert.AreEqual(0, vmPowershellCmdlets.GetAzurePlatformVMImage(image).ReplicationProgress.Count); PrintOSImageDetailsContext(vmPowershellCmdlets.GetAzurePlatformVMImage(image)); pass = true; } catch (Exception e) { Console.WriteLine(e.ToString()); throw; } }
protected override void ProcessRecord() { ServiceManagementProfile.Initialize(); var result = new ComputeImageConfig { Offer = Offer, Sku = Sku, Version = Version }; WriteObject(result); }
public void AzurePlatformVMImageScenarioTest() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); string vmName = Utilities.GetUniqueShortName("pirtestvm"); string svcName = Utilities.GetUniqueShortName("pirtestservice"); try { SwitchToNormalUser(); try { vmPowershellCmdlets.GetAzureStorageAccount(storageNormalUser); } catch (Exception e) { if (e.ToString().Contains("ResourceNotFound")) { vmPowershellCmdlets.NewAzureStorageAccount(storageNormalUser, location1); } else { Console.WriteLine(e.ToString()); throw; } } vmPowershellCmdlets.SetAzureSubscription(normaluser, normaluserSubId, storageNormalUser); // Replicate the user image to "West US" and wait until the replication process is completed. SwitchToPublisher(); ComputeImageConfig compCfg = new ComputeImageConfig { Offer = "test", Sku = "test", Version = "test" }; MarketplaceImageConfig marketCfg = null; vmPowershellCmdlets.SetAzurePlatformVMImageReplicate(image, new string[] { location1 }, compCfg, marketCfg); // Make the replicated image public and wait until the PIR image shows up. vmPowershellCmdlets.SetAzurePlatformVMImagePublic(image); OSImageContext pirImage = WaitForPIRAppear(image, publisher); // Switch to the normal User and check the PIR image. SwitchToNormalUser(); WaitForPIRAppear(image, publisher); // Create a VM using the PIR image vmPowershellCmdlets.NewAzureQuickVM(OS.Windows, vmName, svcName, pirImage.ImageName, username, password, location1); Console.WriteLine("VM, {0}, is successfully created using the uploaded PIR image", vmPowershellCmdlets.GetAzureVM(vmName, svcName).Name); // Remove the service and VM vmPowershellCmdlets.RemoveAzureService(svcName); // Switch to the publisher and remove the PIR image SwitchToPublisher(); vmPowershellCmdlets.RemoveAzurePlatformVMImage(image); pass = true; } catch (Exception e) { Console.WriteLine(e.ToString()); throw; } }
public SetAzurePlatformVMImageCmdletInfo(string imageName, string permission, string[] locations, ComputeImageConfig compCfg, MarketplaceImageConfig marketCfg) { this.cmdletName = Utilities.SetAzurePlatformVMImageCmdletName; this.cmdletParams.Add(new CmdletParam("ImageName", imageName)); if (permission != null) { this.cmdletParams.Add(new CmdletParam("Permission", permission)); } if (locations != null) { this.cmdletParams.Add(new CmdletParam("ReplicaLocations", locations)); } if (compCfg != null) { this.cmdletParams.Add(new CmdletParam("PlatformComputeImageConfig", compCfg)); } if (marketCfg != null) { this.cmdletParams.Add(new CmdletParam("PlatformMarketplaceImageConfig", marketCfg)); } }