Beispiel #1
0
 public SetAzureVMImageDataDiskConfigInfo(VirtualMachineImageDiskConfigSet diskConfig, string dataDiskName, int lun, string hostCaching)
 {
     this.cmdletName = Utilities.SetAzureVMImageDataDiskConfigCmdletName;
     this.cmdletParams.Add(new CmdletParam("DiskConfig", diskConfig));
     this.cmdletParams.Add(new CmdletParam("DataDiskName", dataDiskName));
     this.cmdletParams.Add(new CmdletParam("Lun", lun));
     this.cmdletParams.Add(new CmdletParam("HostCaching", hostCaching));
 }
Beispiel #2
0
        public void AzureVMImageTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
            vhdName = "os1.vhd";
            string newImageName  = Utilities.GetUniqueShortName("vmimage");
            string mediaLocation = string.Format("{0}{1}/{2}", blobUrlRoot, vhdContainerName, vhdName);

            string oldLabel     = "old label";
            string newLabel     = "new label";
            string vmSize       = "Small";
            var    iconUri      = "http://www.bing.com";
            var    smallIconUri = "http://www.bing.com";
            bool   showInGui    = true;

            try
            {
                // BVT Tests for OS Images
                OSImageContext result = vmPowershellCmdlets.AddAzureVMImage(newImageName, mediaLocation, OS.Windows, oldLabel, vmSize, iconUri, smallIconUri, showInGui);

                OSImageContext resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
                Assert.IsTrue(!string.IsNullOrEmpty(resultReturned.IOType));
                Assert.IsTrue(CompareContext <OSImageContext>(result, resultReturned));

                result         = vmPowershellCmdlets.UpdateAzureVMImage(newImageName, newLabel);
                resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
                Assert.IsTrue(!string.IsNullOrEmpty(resultReturned.IOType));
                Assert.IsTrue(CompareContext <OSImageContext>(result, resultReturned));

                result         = vmPowershellCmdlets.UpdateAzureVMImage(newImageName, newLabel, true);
                resultReturned = vmPowershellCmdlets.GetAzureVMImage(newImageName)[0];
                Assert.IsTrue(resultReturned.ShowInGui.HasValue && !resultReturned.ShowInGui.Value);
                Assert.IsTrue(CompareContext <OSImageContext>(result, resultReturned));

                vmPowershellCmdlets.RemoveAzureVMImage(newImageName, false);
                Assert.IsTrue(Utilities.CheckRemove(vmPowershellCmdlets.GetAzureVMImage, newImageName));

                // BVT Tests for VM Images
                // Unique Container Prefix
                var containerPrefix = Utilities.GetUniqueShortName("vmimg");

                // Disk Blobs
                var srcVhdName        = "os1.vhd";
                var srcVhdContainer   = vhdContainerName;
                var dstOSVhdContainer = containerPrefix.ToLower() + "os" + vhdContainerName;
                CredentialHelper.CopyTestData(srcVhdContainer, srcVhdName, dstOSVhdContainer);
                string osVhdLink = string.Format("{0}{1}/{2}", blobUrlRoot, dstOSVhdContainer, srcVhdName);

                var dstDataVhdContainer = containerPrefix.ToLower() + "data" + vhdContainerName;
                CredentialHelper.CopyTestData(srcVhdContainer, srcVhdName, dstDataVhdContainer);
                string dataVhdLink = string.Format("{0}{1}/{2}", blobUrlRoot, dstDataVhdContainer, srcVhdName);

                // VM Image OS/Data Disk Configuration
                var addVMImageName = containerPrefix + "Image";
                var diskConfig     = new VirtualMachineImageDiskConfigSet
                {
                    OSDiskConfiguration = new OSDiskConfiguration
                    {
                        HostCaching = HostCaching.ReadWrite.ToString(),
                        OS          = OSType.Windows.ToString(),
                        OSState     = "Generalized",
                        MediaLink   = new Uri(osVhdLink)
                    },
                    DataDiskConfigurations = new DataDiskConfigurationList
                    {
                        new DataDiskConfiguration
                        {
                            HostCaching = HostCaching.ReadOnly.ToString(),
                            Lun         = 0,
                            MediaLink   = new Uri(dataVhdLink)
                        }
                    }
                };

                // Add-AzureVMImage
                string   label             = addVMImageName;
                string   description       = "test";
                string   eula              = "http://www.bing.com/";
                string   imageFamily       = "Windows";
                DateTime?publishedDate     = new DateTime(2015, 1, 1);
                string   privacyUri        = "http://www.bing.com/";
                string   recommendedVMSize = vmSize;
                string   iconName          = "iconName";
                string   smallIconName     = "smallIconName";

                vmPowershellCmdlets.AddAzureVMImage(
                    addVMImageName,
                    label,
                    diskConfig,
                    description,
                    eula,
                    imageFamily,
                    publishedDate,
                    privacyUri,
                    recommendedVMSize,
                    iconName,
                    smallIconName,
                    showInGui);

                // Get-AzureVMImage
                var vmImage = vmPowershellCmdlets.GetAzureVMImageReturningVMImages(addVMImageName).First();

                Assert.IsTrue(vmImage.ImageName == addVMImageName);
                Assert.IsTrue(vmImage.Label == label);
                Assert.IsTrue(vmImage.Description == description);
                Assert.IsTrue(vmImage.Eula == eula);
                Assert.IsTrue(vmImage.ImageFamily == imageFamily);
                Assert.IsTrue(vmImage.PublishedDate.Value.Year == publishedDate.Value.Year);
                Assert.IsTrue(vmImage.PublishedDate.Value.Month == publishedDate.Value.Month);
                Assert.IsTrue(vmImage.PublishedDate.Value.Day == publishedDate.Value.Day);
                Assert.IsTrue(vmImage.PrivacyUri.AbsoluteUri.ToString() == privacyUri);
                Assert.IsTrue(vmImage.RecommendedVMSize == recommendedVMSize);
                Assert.IsTrue(vmImage.IconName == iconName);
                Assert.IsTrue(vmImage.IconUri == iconName);
                Assert.IsTrue(vmImage.SmallIconName == smallIconName);
                Assert.IsTrue(vmImage.SmallIconUri == smallIconName);
                Assert.IsTrue(vmImage.ShowInGui == showInGui);
                Assert.IsTrue(vmImage.OSDiskConfiguration.HostCaching == diskConfig.OSDiskConfiguration.HostCaching);
                Assert.IsTrue(vmImage.OSDiskConfiguration.OS == diskConfig.OSDiskConfiguration.OS);
                Assert.IsTrue(vmImage.OSDiskConfiguration.OSState == diskConfig.OSDiskConfiguration.OSState);
                Assert.IsTrue(vmImage.OSDiskConfiguration.MediaLink == diskConfig.OSDiskConfiguration.MediaLink);
                Assert.IsTrue(vmImage.DataDiskConfigurations.First().HostCaching == diskConfig.DataDiskConfigurations.First().HostCaching);
                Assert.IsTrue(vmImage.DataDiskConfigurations.First().Lun == diskConfig.DataDiskConfigurations.First().Lun);
                Assert.IsTrue(vmImage.DataDiskConfigurations.First().MediaLink == diskConfig.DataDiskConfigurations.First().MediaLink);

                // Remove-AzureVMImage
                vmPowershellCmdlets.RemoveAzureVMImage(addVMImageName);

                pass = true;
            }
            catch (Exception e)
            {
                pass = false;
                Assert.Fail("Exception occurred: {0}", e.ToString());
            }
            finally
            {
                if (!Utilities.CheckRemove(vmPowershellCmdlets.GetAzureVMImage, newImageName))
                {
                    vmPowershellCmdlets.RemoveAzureVMImage(newImageName, false);
                }
            }
        }
        public UpdateAzureVMImageCmdletInfo(string imageName, string label, string recommendedSize, VirtualMachineImageDiskConfigSet diskConfig, bool?dontShowInGui)
        {
            cmdletName = Utilities.UpdateAzureVMImageCmdletName;

            cmdletParams.Add(new CmdletParam("ImageName", imageName));

            cmdletParams.Add(new CmdletParam("Label", label));

            if (!string.IsNullOrEmpty(recommendedSize))
            {
                cmdletParams.Add(new CmdletParam("RecommendedVMSize", recommendedSize));
            }
            if (diskConfig != null)
            {
                cmdletParams.Add(new CmdletParam("DiskConfig", diskConfig));
            }
            if (dontShowInGui.HasValue && dontShowInGui.Value)
            {
                cmdletParams.Add(new CmdletParam("DontShowInGui"));
            }
        }
 public SetAzureVMImageOSDiskConfigInfo(VirtualMachineImageDiskConfigSet diskConfig, string hostCaching)
 {
     this.cmdletName = Utilities.SetAzureVMImageOSDiskConfigCmdletName;
     this.cmdletParams.Add(new CmdletParam("DiskConfig", diskConfig));
     this.cmdletParams.Add(new CmdletParam("HostCaching", hostCaching));
 }
        public AddAzureVMImageCmdletInfo(
            string imageName,
            string label,
            VirtualMachineImageDiskConfigSet diskConfig,
            string description,
            string eula,
            string imageFamily,
            DateTime?publishedDate,
            string privacyUri,
            string recommendedVMSize,
            string iconName,
            string smallIconName,
            bool?showInGui)
        {
            cmdletName = Utilities.AddAzureVMImageCmdletName;

            cmdletParams.Add(new CmdletParam("ImageName", imageName));

            cmdletParams.Add(new CmdletParam("Label", label));

            if (diskConfig != null)
            {
                cmdletParams.Add(new CmdletParam("DiskConfig", diskConfig));
            }

            if (!string.IsNullOrEmpty(description))
            {
                cmdletParams.Add(new CmdletParam("Description", description));
            }

            if (!string.IsNullOrEmpty(eula))
            {
                cmdletParams.Add(new CmdletParam("Eula", eula));
            }

            if (!string.IsNullOrEmpty(imageFamily))
            {
                cmdletParams.Add(new CmdletParam("ImageFamily", imageFamily));
            }

            if (publishedDate != null)
            {
                cmdletParams.Add(new CmdletParam("PublishedDate", publishedDate));
            }

            if (!string.IsNullOrEmpty(privacyUri))
            {
                cmdletParams.Add(new CmdletParam("PrivacyUri", privacyUri));
            }

            if (!string.IsNullOrEmpty(recommendedVMSize))
            {
                cmdletParams.Add(new CmdletParam("RecommendedVMSize", recommendedVMSize));
            }

            if (!string.IsNullOrEmpty(iconName))
            {
                cmdletParams.Add(new CmdletParam("IconName", iconName));
            }

            if (!string.IsNullOrEmpty(smallIconName))
            {
                cmdletParams.Add(new CmdletParam("SmallIconName", smallIconName));
            }

            if (showInGui != null)
            {
                cmdletParams.Add(new CmdletParam("ShowInGui", showInGui));
            }
        }