Esempio n. 1
0
        public void Initialize()
        {
            vhdName = Utilities.GetUniqueShortName(vhdNamePrefix);
            image   = Utilities.GetUniqueShortName(imageNamePrefix);

            vhdBlobLocation = string.Format("{0}{1}/{2}", blobUrlRoot, vhdContainerName, vhdName);

            try
            {
                if (string.IsNullOrEmpty(localFile))
                {
                    CredentialHelper.CopyTestData(testDataContainer, osVhdName, vhdContainerName, vhdName);
                }
                else
                {
                    vmPowershellCmdlets.AddAzureVhd(new FileInfo(localFile), vhdBlobLocation);
                }
            }
            catch (Exception e)
            {
                if (e.ToString().Contains("already exists") || e.ToString().Contains("currently a lease"))
                {
                    // Use the already uploaded vhd.
                    Console.WriteLine("Using already uploaded blob..");
                }
                else
                {
                    Console.WriteLine(e.ToString());
                    Assert.Inconclusive("Upload vhd is not set!");
                }
            }

            try
            {
                vmPowershellCmdlets.AddAzureVMImage(image, vhdBlobLocation, OS.Windows);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }

            pass          = false;
            testStartTime = DateTime.Now;
        }
Esempio n. 2
0
        public static void ClassInit(TestContext context)
        {
            //SetTestSettings();

            if (defaultAzureSubscription.Equals(null))
            {
                Assert.Inconclusive("No Subscription is selected!");
            }

            vhdBlobLocation = string.Format("{0}{1}/{2}", blobUrlRoot, vhdContainerName, vhdName);

            if (string.IsNullOrEmpty(localFile))
            {
                try
                {
                    CredentialHelper.CopyTestData(testDataContainer, osVhdName, vhdContainerName, vhdName);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    Assert.Inconclusive("No vhd exists for Save-AzureVhd tests!");
                }
            }
            else
            {
                try
                {
                    vmPowershellCmdlets.AddAzureVhd(new FileInfo(localFile), vhdBlobLocation);
                }
                catch (Exception e)
                {
                    if (e.ToString().Contains("already exists"))
                    {
                        // Use the already uploaded vhd.
                        Console.WriteLine("Using already uploaded blob..");
                    }
                    else
                    {
                        Assert.Inconclusive("No vhd exists for Save-AzureVhd tests!");
                    }
                }
            }
        }