Exemplo n.º 1
0
        public void NewAzureVMWithWinRMCertificateTest()
        {
            try
            {
                _serviceName = Utilities.GetUniqueShortName(serviceNamePrefix);
                string newAzureVMName = Utilities.GetUniqueShortName("PSWinVM");

                // Add-AzureProvisioningConfig with X509Certificate
                var          azureVMConfigInfo       = new AzureVMConfigInfo(newAzureVMName, InstanceSize.Small.ToString(), imageName);
                var          azureProvisioningConfig = new AzureProvisioningConfigInfo(username, password, _installedCert);
                var          persistentVMConfigInfo  = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
                PersistentVM vm = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);

                // New-AzureVM
                vmPowershellCmdlets.NewAzureVM(_serviceName, new[] { vm }, null);
                Console.WriteLine("New Azure service with name:{0} created successfully.", _serviceName);
                var result = vmPowershellCmdlets.GetAzureVM(newAzureVMName, _serviceName);
                Assert.AreEqual(_installedCert.Thumbprint, result.VM.WinRMCertificate.Thumbprint);
                pass = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
Exemplo n.º 2
0
        public void NewAzureVMWithLinuxAndCustomData()
        {
            try
            {
                // Add-AzureProvisioningConfig without NoSSHEndpoint or DisableSSH option
                var          azureVMConfigInfo       = new AzureVMConfigInfo(_vmName, InstanceSize.Small.ToString(), _linuxImageName);
                var          azureProvisioningConfig = new AzureProvisioningConfigInfo(username, password, false, false, null, null, false, @".\cloudinittest.sh");
                var          persistentVMConfigInfo  = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
                PersistentVM vm = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);

                // New-AzureVM
                vmPowershellCmdlets.NewAzureVM(_serviceName, new[] { vm }, locationName);
                Console.WriteLine("New Azure service with name:{0} created successfully.", _serviceName);
                Collection <InputEndpointContext> endpoints = vmPowershellCmdlets.GetAzureEndPoint(vmPowershellCmdlets.GetAzureVM(_vmName, _serviceName));

                Console.WriteLine("The number of endpoints: {0}", endpoints.Count);
                foreach (var ep in endpoints)
                {
                    Utilities.PrintContext(ep);
                }
                Assert.AreEqual(1, endpoints.Count);
                pass = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
 public PersistentVMConfigInfo(AzureVMConfigInfo vmConfig, AzureProvisioningConfigInfo provConfig, AddAzureDataDiskConfig diskConfig, AzureEndPointConfigInfo endPointConfig)
 {
     this.VmConfig = vmConfig;
     this.ProvConfig = provConfig;
     this.DiskConfig = diskConfig;
     this.EndPointConfig = endPointConfig;
 }
Exemplo n.º 4
0
 public PersistentVMConfigInfo(AzureVMConfigInfo vmConfig, AzureProvisioningConfigInfo provConfig, AddAzureDataDiskConfig diskConfig, AzureEndPointConfigInfo endPointConfig)
 {
     this.VmConfig       = vmConfig;
     this.ProvConfig     = provConfig;
     this.DiskConfig     = diskConfig;
     this.EndPointConfig = endPointConfig;
 }
Exemplo n.º 5
0
        public void NewAzureVMWithLinuxAndNoSSHEnpoint()
        {
            try
            {
                _serviceName = Utilities.GetUniqueShortName(serviceNamePrefix);
                string newAzureLinuxVMName = Utilities.GetUniqueShortName("PSLinuxVM");

                // Add-AzureProvisioningConfig with NoSSHEndpoint
                var          azureVMConfigInfo       = new AzureVMConfigInfo(newAzureLinuxVMName, InstanceSize.Small.ToString(), _linuxImageName);
                var          azureProvisioningConfig = new AzureProvisioningConfigInfo(username, password, true);
                var          persistentVMConfigInfo  = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
                PersistentVM vm = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);

                // New-AzureVM
                vmPowershellCmdlets.NewAzureVM(_serviceName, new[] { vm }, locationName);
                Console.WriteLine("New Azure service with name:{0} created successfully.", _serviceName);
                Collection <InputEndpointContext> endpoints = vmPowershellCmdlets.GetAzureEndPoint(vmPowershellCmdlets.GetAzureVM(newAzureLinuxVMName, _serviceName));

                Console.WriteLine("The number of endpoints: {0}", endpoints.Count);
                foreach (var ep in endpoints)
                {
                    Utilities.PrintContext(ep);
                }
                Assert.AreEqual(0, endpoints.Count);
                pass = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
 private PersistentVM CreateIaaSVMObject(string vmName)
 {
     //Create an IaaS VM with a static CA.
     var azureVMConfigInfo = new AzureVMConfigInfo(vmName, InstanceSize.Small.ToString(), imageName);
     var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
     var persistentVMConfigInfo = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
     return vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);
 }
        private void CreateNewAzureVM()
        {
            var          azureVMConfigInfo       = new AzureVMConfigInfo(vmName, InstanceSize.Small.ToString(), imageName);
            var          azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
            var          persistentVMConfigInfo  = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
            PersistentVM vm = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);

            vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, locationName);
        }
Exemplo n.º 8
0
        public void RestartAzureVMTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            try
            {
                DateTime prevTime = DateTime.Now;

                // starting the test.
                AzureVMConfigInfo           azureVMConfigInfo1       = new AzureVMConfigInfo(vmName1, InstanceSize.ExtraSmall, imageName);
                AzureProvisioningConfigInfo azureProvisioningConfig1 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                PersistentVMConfigInfo      persistentVMConfigInfo1  = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig1, null, null);
                PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);

                PersistentVM[] VMs = { persistentVM1 };

                Utilities.RecordTimeTaken(ref prevTime);
                vmPowershellCmdlets.NewAzureVM(svcName, VMs);
                Utilities.RecordTimeTaken(ref prevTime);

                Console.WriteLine("The VM is successfully created: {0}", vmName1);

                WaitForStartingState(svcName, vmName1);

                Console.WriteLine(vmPowershellCmdlets.GetAzureVM(vmName1, svcName).InstanceStatus);

                Utilities.RecordTimeTaken(ref prevTime);
                vmPowershellCmdlets.StopAzureVM(vmName1, svcName, true);
                Utilities.RecordTimeTaken(ref prevTime);

                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedProvisionedState }));

                Utilities.RecordTimeTaken(ref prevTime);
                vmPowershellCmdlets.StartAzureVM(vmName1, svcName);
                Utilities.RecordTimeTaken(ref prevTime);

                WaitForReadyState(svcName, vmName1);
                Utilities.RecordTimeTaken(ref prevTime);
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { readyState }));

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }
            finally
            {
                if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
                {
                    vmPowershellCmdlets.RemoveAzureService(svcName);
                }
            }
        }
Exemplo n.º 9
0
        public void NewAzureVMWithAffinityGroup()
        {
            _serviceName = Utilities.GetUniqueShortName(serviceNamePrefix);
            string _affiniyGroupName1 = Utilities.GetUniqueShortName("aff");
            string _affiniyGroupName2 = Utilities.GetUniqueShortName("aff");

            try
            {
                // New-AzureService
                vmPowershellCmdlets.NewAzureAffinityGroup(_affiniyGroupName1, locationName, "location1", "location1");
                vmPowershellCmdlets.NewAzureAffinityGroup(_affiniyGroupName2, locationName, "location2", "location2");
                vmPowershellCmdlets.NewAzureService(_serviceName, "service1", null, _affiniyGroupName1);

                // New-AzureVMConfig
                string newAzureVMName = Utilities.GetUniqueShortName("PSVM");
                string imageName      = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);

                // Add-AzureProvisioningConfig
                var          azureVMConfigInfo       = new AzureVMConfigInfo(newAzureVMName, InstanceSize.Small.ToString(), imageName);
                var          azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var          persistentVMConfigInfo  = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
                PersistentVM vm = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);

                // New-AzureVM
                try
                {
                    vmPowershellCmdlets.NewAzureVMWithAG(_serviceName, new[] { vm }, _affiniyGroupName2);
                    Assert.Fail("Should fail, but succeeded!");
                }
                catch (Exception ex)
                {
                    if (ex is AssertFailedException)
                    {
                        throw;
                    }
                    else
                    {
                        Console.WriteLine("Failure is expected.  Continue the tests...");
                    }
                }

                vmPowershellCmdlets.NewAzureVMWithAG(_serviceName, new[] { vm }, _affiniyGroupName1);
                Console.WriteLine("New Azure service with name:{0} created successfully.", _serviceName);
                var vmReturned = vmPowershellCmdlets.GetAzureVM(newAzureVMName, _serviceName);

                Utilities.PrintContext(vmReturned);
                Assert.AreEqual(_serviceName, vmReturned.ServiceName);
                pass = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
        public void HiMemVMSizeTest()
        {
            string serviceName = Utilities.GetUniqueShortName(serviceNamePrefix);
            string vmName      = Utilities.GetUniqueShortName(vmNamePrefix);

            try
            {
                PersistentVMRoleContext result;

                // New-AzureQuickVM test for VM size
                vmPowershellCmdlets.NewAzureQuickVM(OS.Windows, vmName, serviceName, imageName, username, password, locationName, InstanceSize.A6);
                result = vmPowershellCmdlets.GetAzureVM(vmName, serviceName);
                Assert.AreEqual(InstanceSize.A6.ToString(), result.InstanceSize);
                Console.WriteLine("VM size, {0}, is verified for New-AzureQuickVM", InstanceSize.A6.ToString());
                vmPowershellCmdlets.RemoveAzureService(serviceName);

                // New-AzureVMConfig test for VM size
                AzureVMConfigInfo           azureVMConfigInfo       = new AzureVMConfigInfo(vmName, InstanceSize.A7, imageName);
                AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                PersistentVMConfigInfo      persistentVMConfigInfo  = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
                PersistentVM vm = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);
                vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, locationName);
                result = vmPowershellCmdlets.GetAzureVM(vmName, serviceName);
                Assert.AreEqual(InstanceSize.A7.ToString(), result.InstanceSize);
                Console.WriteLine("VM size, {0}, is verified for New-AzureVMConfig", InstanceSize.A7.ToString());

                // Set-AzureVMSize test for Hi-MEM VM size
                vmPowershellCmdlets.SetVMSize(vmName, serviceName, new SetAzureVMSizeConfig(InstanceSize.A6));
                result = vmPowershellCmdlets.GetAzureVM(vmName, serviceName);
                Assert.AreEqual(InstanceSize.A6.ToString(), result.InstanceSize);
                Console.WriteLine("SetVMSize is verified from A7 to A6");

                vmPowershellCmdlets.SetVMSize(vmName, serviceName, new SetAzureVMSizeConfig(InstanceSize.A7));
                result = vmPowershellCmdlets.GetAzureVM(vmName, serviceName);
                Assert.AreEqual(InstanceSize.A7.ToString(), result.InstanceSize);
                Console.WriteLine("SetVMSize is verified from A6 to A7");
            }
            catch (Exception e)
            {
                pass = false;
                Console.WriteLine("Exception occurred: {0}", e.ToString());
                throw;
            }
            finally
            {
                if (!Utilities.CheckRemove(vmPowershellCmdlets.GetAzureService, serviceName))
                {
                    if ((cleanupIfFailed && !pass) || (cleanupIfPassed && pass))
                    {
                        vmPowershellCmdlets.RemoveAzureService(serviceName);
                    }
                }
            }
        }
Exemplo n.º 11
0
        public void StaticCAExhautionTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
            string vnet1   = VirtualNets[0];
            string vmName1 = Utilities.GetUniqueShortName(vmNamePrefix);

            try
            {
                //Test a static CA
                //Test-AzureStaticVNetIP-VNetName $vnet -IPAddress “10.0.0.5”
                const string ipaddress          = "10.64.0.5";
                var          availibiltyContext = vmPowershellCmdlets.TestAzureStaticVNetIP(vnet1, ipaddress);
                //Assert that it is available.
                Assert.IsTrue(availibiltyContext.IsAvailable);

                var vm = CreatIaasVMObject(vmName1, ipaddress, StaticCASubnet1);

                vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet1, new DnsServer[1] {
                    DnsServers[0]
                },
                                               serviceName, "service for DeployVMWithStaticCATest", string.Empty, string.Empty, null, AffinityGroup);
                Console.WriteLine("New Azure service with name:{0} created successfully.", serviceName);


                availibiltyContext = vmPowershellCmdlets.TestAzureStaticVNetIP(vnet1, ipaddress);
                int availableVIPsCount = availibiltyContext.AvailableAddresses.Count();
                Console.WriteLine(string.Format("AvailableAddresses:{0}{1}", Environment.NewLine, availibiltyContext.AvailableAddresses.Aggregate((current, next) => current + Environment.NewLine + next)));
                Console.WriteLine("VIPs avilable now:{0}", availableVIPsCount);
                int i = 0;
                foreach (string ip in availibiltyContext.AvailableAddresses)
                {
                    Console.WriteLine("Creating VM-{0} with IP: {1}", ++i, ip);
                    vm = CreatIaasVMObject(Utilities.GetUniqueShortName(vmNamePrefix), ip, StaticCASubnet1);
                    vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, null);
                    Console.WriteLine("Created VM-{0} with IP: {1}", i, ip);
                }

                //try to create an vm and verify that it fails
                Console.WriteLine("Creating VM-{0}", ++i);
                vm = vmPowershellCmdlets.NewAzureVMConfig(new AzureVMConfigInfo(Utilities.GetUniqueShortName(vmNamePrefix), InstanceSize.Small.ToString(), imageName));
                var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                azureProvisioningConfig.Vm = vm;
                vm = vmPowershellCmdlets.AddAzureProvisioningConfig(azureProvisioningConfig);
                vm = vmPowershellCmdlets.SetAzureSubnet(vm, new [] { StaticCASubnet1 });
                Utilities.VerifyFailure(() => vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }), BadRequestException);
                Console.WriteLine("Creating VM-{0} failed as expected.", i);
                pass = true;
            }
            catch (Exception)
            {
                pass = false;
                throw;
            }
        }
        public AddAzureProvisioningConfigCmdletInfo(AzureProvisioningConfigInfo provConfig)
        {
            this.cmdletName = Utilities.AddAzureProvisioningConfigCmdletName;

            this.cmdletParams.Add(new CmdletParam("VM", provConfig.Vm));

            this.cmdletParams.Add(new CmdletParam(provConfig.OS.ToString()));
            

            this.cmdletParams.Add(new CmdletParam("Password", provConfig.Password));

            if (provConfig.LinuxUser != null)
            {
                this.cmdletParams.Add(new CmdletParam("LinuxUser", provConfig.LinuxUser));
            }

            if (provConfig.AdminUsername != null)
            {
                this.cmdletParams.Add(new CmdletParam("AdminUsername", provConfig.AdminUsername));

            }
            if (provConfig.Option != null && provConfig.Option == "WindowsDomain")
            {
                this.cmdletParams.Add(new CmdletParam("WindowsDomain"));
            }
            if (provConfig.Domain != null)
            {
                this.cmdletParams.Add(new CmdletParam("Domain", provConfig.Domain));
            }
            if (provConfig.JoinDomain != null)
            {
                this.cmdletParams.Add(new CmdletParam("JoinDomain", provConfig.JoinDomain));
            }
            if (provConfig.DomainUserName != null)
            {
                this.cmdletParams.Add(new CmdletParam("DomainUserName", provConfig.DomainUserName));
            }
            if (provConfig.DomainPassword != null)
            {
                this.cmdletParams.Add(new CmdletParam("DomainPassword", provConfig.DomainPassword));
            }

            if (provConfig.Reset)
            {
                this.cmdletParams.Add(new CmdletParam("ResetPasswordInFirstLogon"));
            }


            if (provConfig.Certs != null && provConfig.Certs.Count != 0)
            {
                this.cmdletParams.Add(new CmdletParam("Certificates", provConfig.Certs));
            }

        }
Exemplo n.º 13
0
        public AddAzureProvisioningConfigCmdletInfo(AzureProvisioningConfigInfo provConfig)
        {
            this.cmdletName = Utilities.AddAzureProvisioningConfigCmdletName;

            this.cmdletParams.Add(new CmdletParam("VM", provConfig.Vm));

            this.cmdletParams.Add(new CmdletParam(provConfig.OS.ToString()));


            this.cmdletParams.Add(new CmdletParam("Password", provConfig.Password));

            if (provConfig.LinuxUser != null)
            {
                this.cmdletParams.Add(new CmdletParam("LinuxUser", provConfig.LinuxUser));
            }

            if (provConfig.AdminUsername != null)
            {
                this.cmdletParams.Add(new CmdletParam("AdminUsername", provConfig.AdminUsername));
            }
            if (provConfig.Option != null && provConfig.Option == "WindowsDomain")
            {
                this.cmdletParams.Add(new CmdletParam("WindowsDomain"));
            }
            if (provConfig.Domain != null)
            {
                this.cmdletParams.Add(new CmdletParam("Domain", provConfig.Domain));
            }
            if (provConfig.JoinDomain != null)
            {
                this.cmdletParams.Add(new CmdletParam("JoinDomain", provConfig.JoinDomain));
            }
            if (provConfig.DomainUserName != null)
            {
                this.cmdletParams.Add(new CmdletParam("DomainUserName", provConfig.DomainUserName));
            }
            if (provConfig.DomainPassword != null)
            {
                this.cmdletParams.Add(new CmdletParam("DomainPassword", provConfig.DomainPassword));
            }

            if (provConfig.Reset)
            {
                this.cmdletParams.Add(new CmdletParam("ResetPasswordInFirstLogon"));
            }


            if (provConfig.Certs != null && provConfig.Certs.Count != 0)
            {
                this.cmdletParams.Add(new CmdletParam("Certificates", provConfig.Certs));
            }
        }
Exemplo n.º 14
0
        public void NewAzureVMWithWindowsAndCustomData()
        {
            try
            {
                _serviceName = Utilities.GetUniqueShortName(serviceNamePrefix);
                string newAzureVMName = Utilities.GetUniqueShortName("PSWinVM");

                var customDataFile    = @".\CustomData.bin";
                var customDataContent = File.ReadAllText(customDataFile);

                // Add-AzureProvisioningConfig with X509Certificate
                var          azureVMConfigInfo       = new AzureVMConfigInfo(newAzureVMName, InstanceSize.Small.ToString(), imageName);
                var          azureProvisioningConfig = new AzureProvisioningConfigInfo(username, password, customDataFile);
                var          persistentVMConfigInfo  = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
                PersistentVM vm = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);

                // New-AzureVM
                vmPowershellCmdlets.NewAzureVM(_serviceName, new[] { vm }, locationName);
                Console.WriteLine("New Azure service with name:{0} created successfully.", _serviceName);

                StopAzureVMTest.WaitForReadyState(_serviceName, newAzureVMName, 60, 30);

                // Get-AzureVM
                var vmContext = vmPowershellCmdlets.GetAzureVM(newAzureVMName, _serviceName);

                // Get-AzureCertificate
                var winRmCert = vmPowershellCmdlets.GetAzureCertificate(_serviceName, vmContext.VM.DefaultWinRmCertificateThumbprint, "sha1").First();

                // Install the WinRM cert to the local machine's root location.
                InstallCertificate(winRmCert, StoreLocation.LocalMachine, StoreName.Root);

                var connUri = vmPowershellCmdlets.GetAzureWinRMUri(_serviceName, newAzureVMName);
                var cred    = new PSCredential(username, Utilities.convertToSecureString(password));

                Utilities.RetryActionUntilSuccess(() =>
                {
                    // Invoke Command
                    var scriptBlock = ScriptBlock.Create(@"Get-Content -Path 'C:\AzureData\CustomData.bin'");
                    var invokeInfo  = new InvokeCommandCmdletInfo(connUri, cred, scriptBlock);
                    var invokeCmd   = new PowershellCmdlet(invokeInfo);
                    var results     = invokeCmd.Run(false);
                    Assert.IsTrue(customDataContent == results.First().BaseObject as string);
                }, "Access is denied", 10, 30);

                pass = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
        private PersistentVM CreateIaaSVMObject(string vmName)
        {
            defaultAzureSubscription = vmPowershellCmdlets.SetAzureSubscription(defaultAzureSubscription.SubscriptionId, CredentialHelper.DefaultStorageName);
            vmPowershellCmdlets.SelectAzureSubscription(defaultAzureSubscription.SubscriptionId);


            //Create an IaaS VM with a static CA.
            var azureVMConfigInfo       = new AzureVMConfigInfo(vmName, InstanceSize.Small.ToString(), imageName);
            var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
            var persistentVMConfigInfo  = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);

            return(vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo));
        }
        public static PersistentVM CreateIaaSVMObject(string vmName, InstanceSize size, string imageName, bool isWindows = true, string username = null, string password = null, bool disableGuestAgent = false)
        {
            //Create an IaaS VM
            var azureVMConfigInfo = new AzureVMConfigInfo(vmName, size.ToString(), imageName);
            AzureProvisioningConfigInfo azureProvisioningConfig = null;

            if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(username))
            {
                azureProvisioningConfig = new AzureProvisioningConfigInfo(isWindows ? OS.Windows:OS.Linux, username, password, disableGuestAgent);
            }
            var persistentVMConfigInfo = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);

            return(vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo));
        }
Exemplo n.º 17
0
        private PersistentVM CreatIaasVMObject(string vmName, string ipaddress, string subnet)
        {
            //Create an IaaS VM with a static CA.
            var          azureVMConfigInfo       = new AzureVMConfigInfo(vmName, InstanceSize.Small.ToString(), imageName);
            var          azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
            var          persistentVMConfigInfo  = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
            PersistentVM vm = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);

            //Set-AzureSubnet
            vm = vmPowershellCmdlets.SetAzureSubnet(vm, new [] { subnet });

            //Set-AzureStaticVNetIP
            vm = vmPowershellCmdlets.SetAzureStaticVNetIP(ipaddress, vm);
            return(vm);
        }
Exemplo n.º 18
0
        public void StopAzureVMStayProvisionedTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            try
            {
                // starting the test.
                AzureVMConfigInfo           azureVMConfigInfo1       = new AzureVMConfigInfo(vmName1, InstanceSize.ExtraSmall, imageName);
                AzureProvisioningConfigInfo azureProvisioningConfig1 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                PersistentVMConfigInfo      persistentVMConfigInfo1  = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig1, null, null);
                PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);

                AzureVMConfigInfo           azureVMConfigInfo2       = new AzureVMConfigInfo(vmName2, InstanceSize.Small, imageName);
                AzureProvisioningConfigInfo azureProvisioningConfig2 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                PersistentVMConfigInfo      persistentVMConfigInfo2  = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig2, null, null);
                PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);

                PersistentVM[] VMs = { persistentVM1, persistentVM2 };
                vmPowershellCmdlets.NewAzureVM(svcName, VMs);
                Console.WriteLine("The VM is successfully created: {0}", vmName1);
                Console.WriteLine("The VM is successfully created: {0}", vmName2);

                WaitForStartingState(svcName, vmName1);
                vmPowershellCmdlets.StopAzureVM(vmName1, svcName, true); // Stop-AzureVM -StayProvisioned against VM1
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedProvisionedState }));

                // Stop-AzureVM -StayProvisioned against VM2
                vmPowershellCmdlets.RunPSScript(string.Format("{0} -ServiceName {1} -Name {2} | {3} -StayProvisioned",
                                                              Utilities.GetAzureVMCmdletName, svcName, vmName2, Utilities.StopAzureVMCmdletName));

                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string [] { stoppedProvisionedState }));
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string [] { stoppedProvisionedState }));

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }
            finally
            {
                if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
                {
                    vmPowershellCmdlets.RemoveAzureService(svcName);
                }
            }
        }
Exemplo n.º 19
0
        public void NewAzureVMWithLocation()
        {
            string _altLocation = GetAlternateLocation(locationName);

            try
            {
                // New-AzureService
                vmPowershellCmdlets.NewAzureService(_serviceName, locationName);

                var          azureVMConfigInfo       = new AzureVMConfigInfo(_vmName, InstanceSize.Small.ToString(), imageName);
                var          azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var          persistentVMConfigInfo  = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
                PersistentVM vm = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);

                // New-AzureVM
                try
                {
                    vmPowershellCmdlets.NewAzureVM(_serviceName, new[] { vm }, _altLocation);
                    Assert.Fail("Should fail, but succeeded!");
                }
                catch (Exception ex)
                {
                    if (ex is AssertFailedException)
                    {
                        throw;
                    }
                    else
                    {
                        Console.WriteLine("Failure is expected.  Continue the tests...");
                    }
                }

                vmPowershellCmdlets.NewAzureVM(_serviceName, new[] { vm }, locationName);
                Console.WriteLine("New Azure service with name:{0} created successfully.", _serviceName);
                var vmReturned = vmPowershellCmdlets.GetAzureVM(_vmName, _serviceName);

                Utilities.PrintContext(vmReturned);
                Assert.AreEqual(_serviceName, vmReturned.ServiceName);
                pass = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
Exemplo n.º 20
0
        public void NewAzureLinuxVMWithoutPasswordAndNoSSHEnpoint()
        {
            try
            {
                _serviceName = Utilities.GetUniqueShortName(serviceNamePrefix);

                //Create service
                vmPowershellCmdlets.NewAzureService(_serviceName, locationName);

                //Add installed certificate to the service
                PSObject certToUpload = vmPowershellCmdlets.RunPSScript(
                    String.Format("Get-Item cert:\\{0}\\{1}\\{2}", certStoreLocation.ToString(), certStoreName.ToString(), _installedCert.Thumbprint))[0];
                vmPowershellCmdlets.AddAzureCertificate(_serviceName, certToUpload);

                string newAzureLinuxVMName = Utilities.GetUniqueShortName("PSLinuxVM");

                var key         = vmPowershellCmdlets.NewAzureSSHKey(NewAzureSshKeyType.PublicKey, _installedCert.Thumbprint, keyPath);
                var sshKeysList = new Model.LinuxProvisioningConfigurationSet.SSHPublicKeyList();
                sshKeysList.Add(key);

                // Add-AzureProvisioningConfig without password and NoSSHEndpoint
                var          azureVMConfigInfo       = new AzureVMConfigInfo(newAzureLinuxVMName, InstanceSize.Small.ToString(), _linuxImageName);
                var          azureProvisioningConfig = new AzureProvisioningConfigInfo(username, noSshEndpoint: true, sSHPublicKeyList: sshKeysList);
                var          persistentVMConfigInfo  = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
                PersistentVM vm = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);

                // New-AzureVM
                vmPowershellCmdlets.NewAzureVM(_serviceName, new[] { vm });
                Console.WriteLine("New Azure service with name:{0} created successfully.", _serviceName);
                Collection <InputEndpointContext> endpoints = vmPowershellCmdlets.GetAzureEndPoint(vmPowershellCmdlets.GetAzureVM(newAzureLinuxVMName, _serviceName));

                Console.WriteLine("The number of endpoints: {0}", endpoints.Count);
                foreach (var ep in endpoints)
                {
                    Utilities.PrintContext(ep);
                }
                Assert.AreEqual(0, endpoints.Count);
                pass = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
Exemplo n.º 21
0
        public void AddEndPointACLsWithNewDeployment()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix);
            string newAzureVM2Name = Utilities.GetUniqueShortName(vmNamePrefix);

            if (string.IsNullOrEmpty(imageName))
            {
                imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows", "testvmimage" }, false);
            }

            vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);

            NetworkAclObject aclObj = vmPowershellCmdlets.NewAzureAclConfig();

            vmPowershellCmdlets.SetAzureAclConfig(SetACLConfig.AddRule, aclObj, 100, ACLAction.Permit, "172.0.0.0/8", "notes1");
            vmPowershellCmdlets.SetAzureAclConfig(SetACLConfig.AddRule, aclObj, 200, ACLAction.Deny, "10.0.0.0/8", "notes2");

            AzureVMConfigInfo           azureVMConfigInfo1      = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall, imageName);
            AzureVMConfigInfo           azureVMConfigInfo2      = new AzureVMConfigInfo(newAzureVM2Name, InstanceSize.ExtraSmall, imageName);
            AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
            AddAzureDataDiskConfig      azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0);
            AzureEndPointConfigInfo     azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.DefaultProbe, ProtocolInfo.tcp, 80, 80, "web", "lbweb", aclObj, true);

            PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);
            PersistentVMConfigInfo persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);

            PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
            PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);

            PersistentVM[] VMs = { persistentVM1, persistentVM2 };
            vmPowershellCmdlets.NewAzureVM(serviceName, VMs);

            // Cleanup
            vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, serviceName);
            vmPowershellCmdlets.RemoveAzureVM(newAzureVM2Name, serviceName);

            Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM1Name, serviceName));
            Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM2Name, serviceName));
            pass = true;
        }
Exemplo n.º 22
0
        public void AdvancedProvisioning()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix);
            string newAzureVM2Name = Utilities.GetUniqueShortName(vmNamePrefix);

            if (string.IsNullOrEmpty(imageName))
            {
                imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows", "testvmimage" }, false);
            }

            vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);

            AzureVMConfigInfo           azureVMConfigInfo1      = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall, imageName);
            AzureVMConfigInfo           azureVMConfigInfo2      = new AzureVMConfigInfo(newAzureVM2Name, InstanceSize.ExtraSmall, imageName);
            AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
            AddAzureDataDiskConfig      azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0);
            AzureEndPointConfigInfo     azureEndPointConfigInfo = new AzureEndPointConfigInfo(ProtocolInfo.tcp, 80, 80, "web", "lbweb", 80, ProtocolInfo.http, @"/", null, null);

            PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);
            PersistentVMConfigInfo persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);

            PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
            PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);

            PersistentVM[] VMs = { persistentVM1, persistentVM2 };
            vmPowershellCmdlets.NewAzureVM(serviceName, VMs);

            // Cleanup
            vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, serviceName);
            vmPowershellCmdlets.RemoveAzureVM(newAzureVM2Name, serviceName);

            Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM1Name, serviceName));
            Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM2Name, serviceName));
            pass = true;
        }
Exemplo n.º 23
0
        public void StopAzureVMOnDeallocatedVMTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            try
            {
                // starting the test.
                AzureVMConfigInfo           azureVMConfigInfo1       = new AzureVMConfigInfo(vmName1, InstanceSize.ExtraSmall, imageName);
                AzureProvisioningConfigInfo azureProvisioningConfig1 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                PersistentVMConfigInfo      persistentVMConfigInfo1  = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig1, null, null);
                PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);

                PersistentVM[] VMs = { persistentVM1 };
                vmPowershellCmdlets.NewAzureVM(svcName, VMs);
                Console.WriteLine("The VM is successfully created: {0}", vmName1);

                //WaitForStartingState(svcName, vmName1);

                // Stop and deallocate the VM
                vmPowershellCmdlets.StopAzureVM(vmName1, svcName, false, true);
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));

                try
                {
                    // Try to stop the VM with StayProvisioned.  Should fail.
                    vmPowershellCmdlets.StopAzureVM(vmName1, svcName, true);
                    Assert.Fail();
                }
                catch (Exception e)
                {
                    if (e is AssertFailedException)
                    {
                        throw;
                    }
                    else
                    {
                        Console.WriteLine(e.ToString());
                    }
                }
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));

                try
                {
                    // Try to stop the VM without any option.  Should fail and give a warning message.
                    vmPowershellCmdlets.StopAzureVM(vmName1, svcName);
                    Assert.Fail();
                }
                catch (Exception e)
                {
                    if (e is AssertFailedException)
                    {
                        throw;
                    }
                    else
                    {
                        Console.WriteLine(e.ToString());
                    }
                }
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));

                // Try to stop and deallocate the VM again.
                vmPowershellCmdlets.StopAzureVM(vmName1, svcName, false, true);
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }
            finally
            {
                if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
                {
                    vmPowershellCmdlets.RemoveAzureService(svcName);
                }
            }
        }
Exemplo n.º 24
0
        public void RestartAzureVMTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            try
            {
                DateTime prevTime = DateTime.Now;

                // starting the test.
                var azureVMConfigInfo1 = new AzureVMConfigInfo(vmName1, InstanceSize.Small.ToString(), imageName);
                var azureProvisioningConfig1 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig1, null, null);
                PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);

                PersistentVM[] VMs = { persistentVM1 };

                Utilities.RecordTimeTaken(ref prevTime);
                vmPowershellCmdlets.NewAzureVM(svcName, VMs);
                Utilities.RecordTimeTaken(ref prevTime);

                Console.WriteLine("The VM is successfully created: {0}", vmName1);

                WaitForReadyState(svcName, vmName1);

                Console.WriteLine(vmPowershellCmdlets.GetAzureVM(vmName1, svcName).InstanceStatus);

                Utilities.RecordTimeTaken(ref prevTime);
                vmPowershellCmdlets.StopAzureVM(vmName1, svcName, true);
                Utilities.RecordTimeTaken(ref prevTime);

                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedProvisionedState }));

                Utilities.RecordTimeTaken(ref prevTime);
                vmPowershellCmdlets.StartAzureVM(vmName1, svcName);
                Utilities.RecordTimeTaken(ref prevTime);

                WaitForReadyState(svcName, vmName1);
                Utilities.RecordTimeTaken(ref prevTime);
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { readyState }));

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }
            finally
            {
                if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
                {
                    vmPowershellCmdlets.RemoveAzureService(svcName);
                }
            }
        }
Exemplo n.º 25
0
        public void StopAzureVMsStayProvisionedTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            try
            {
                // starting the test.
                var azureVMConfigInfo1 = new AzureVMConfigInfo(vmName1, InstanceSize.ExtraSmall.ToString(), imageName);
                var azureProvisioningConfig1 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig1, null, null);
                PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);

                var azureVMConfigInfo2 = new AzureVMConfigInfo(vmName2, InstanceSize.Small.ToString(), imageName);
                var azureProvisioningConfig2 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig2, null, null);
                PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);

                PersistentVM[] VMs = { persistentVM1, persistentVM2 };
                vmPowershellCmdlets.NewAzureVM(svcName, VMs);
                Console.WriteLine("The VM is successfully created: {0}", vmName1);
                Console.WriteLine("The VM is successfully created: {0}", vmName2);

                WaitForStartingState(svcName, vmName1);
                WaitForStartingState(svcName, vmName2);

                vmPowershellCmdlets.StopAzureVM("*", svcName, true, true);

                WaitForStoppedState(svcName, vmName1);
                WaitForStoppedState(svcName, vmName2);

                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedProvisionedState }));
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { stoppedProvisionedState }));

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }
            finally
            {
                if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
                {
                    vmPowershellCmdlets.RemoveAzureService(svcName);
                }
            }
        }
Exemplo n.º 26
0
        public void CaptureImagingExportingImportingVMConfig()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            // Create a unique VM name
            string newAzureVMName = Utilities.GetUniqueShortName("PSTestVM");
            Console.WriteLine("VM Name: {0}", newAzureVMName);

            // Create a unique Service Name
            vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);
            Console.WriteLine("Service Name: {0}", serviceName);
            if (string.IsNullOrEmpty(imageName))
                imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);

            // starting the test.
            AzureVMConfigInfo azureVMConfigInfo = new AzureVMConfigInfo(newAzureVMName, InstanceSize.Small, imageName); // parameters for New-AzureVMConfig (-Name -InstanceSize -ImageName)
            AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password); // parameters for Add-AzureProvisioningConfig (-Windows -Password)
            PersistentVMConfigInfo persistentVMConfigInfo = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
            PersistentVM persistentVM = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo); // New-AzureVMConfig & Add-AzureProvisioningConfig

            PersistentVM[] VMs = { persistentVM };
            vmPowershellCmdlets.NewAzureVM(serviceName, VMs); // New-AzureVM
            Console.WriteLine("The VM is successfully created: {0}", persistentVM.RoleName);
            PersistentVMRoleContext vmRoleCtxt = vmPowershellCmdlets.GetAzureVM(persistentVM.RoleName, serviceName);
            Assert.AreEqual(vmRoleCtxt.Name, persistentVM.RoleName, true);


            vmPowershellCmdlets.StopAzureVM(newAzureVMName, serviceName, true); // Stop-AzureVM
            for (int i = 0; i < 3; i++)
            {
                vmRoleCtxt = vmPowershellCmdlets.GetAzureVM(persistentVM.RoleName, serviceName);
                if (vmRoleCtxt.InstanceStatus == "StoppedVM")
                    break;
                else
                {
                    Console.WriteLine("The status of the VM {0} : {1}", persistentVM.RoleName, vmRoleCtxt.InstanceStatus);
                    Thread.Sleep(120000);
                }
            }
            Assert.AreEqual(vmRoleCtxt.InstanceStatus, "StoppedVM", true);

            //TODO
            // RDP

            //TODO:
            // Run sysprep and shutdown

            // Check the status of VM
            //PersistentVMRoleContext vmRoleCtxt2 = vmPowershellCmdlets.GetAzureVM(newAzureVMName, newAzureSvcName); // Get-AzureVM -Name
            //Assert.AreEqual(newAzureVMName, vmRoleCtxt2.Name, true);  //

            // Save-AzureVMImage
            //string newImageName = "newImage";
            //string newImageLabel = "newImageLabel";
            //string postAction = "Delete";

            // Save-AzureVMImage -ServiceName -Name -NewImageName -NewImageLabel -PostCaptureAction
            //vmPowershellCmdlets.SaveAzureVMImage(newAzureSvcName, newAzureVMName, newImageName, newImageLabel, postAction);

            // Cleanup
            vmPowershellCmdlets.RemoveAzureVM(persistentVM.RoleName, serviceName);
            Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(persistentVM.RoleName, serviceName));
        }
Exemplo n.º 27
0
        public void DevTestProvisioning()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix);
            //Find a Windows VM Image
            imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);

            //vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);

            //Specify a small Windows image, with username and pw
            AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall, imageName);
            AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
            AzureEndPointConfigInfo azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, ProtocolInfo.tcp, 80, 80, "Http");

            PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, null, azureEndPointConfigInfo);
            PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);

            //Add all the endpoints that are added by the Dev Test feature in Azure Tools
            azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, ProtocolInfo.tcp, 443, 443, "Https");
            azureEndPointConfigInfo.Vm = persistentVM1;
            persistentVM1 = vmPowershellCmdlets.AddAzureEndPoint(azureEndPointConfigInfo);
            azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, ProtocolInfo.tcp, 1433, 1433, "MSSQL");
            azureEndPointConfigInfo.Vm = persistentVM1;
            persistentVM1 = vmPowershellCmdlets.AddAzureEndPoint(azureEndPointConfigInfo);
            azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, ProtocolInfo.tcp, 8172, 8172, "WebDeploy");
            azureEndPointConfigInfo.Vm = persistentVM1;
            persistentVM1 = vmPowershellCmdlets.AddAzureEndPoint(azureEndPointConfigInfo);

            // Make a storage account named "devtestNNNNN"
            string storageAcctName = "devtest" + new Random().Next(10000, 99999);
            vmPowershellCmdlets.NewAzureStorageAccount(storageAcctName, locationName);
            vmPowershellCmdlets.SetAzureSubscription(defaultAzureSubscription.SubscriptionName, storageAcctName);

            // When making a new azure VM, you can't specify a location if you want to use the existing service
            PersistentVM[] VMs = { persistentVM1 };
            vmPowershellCmdlets.NewAzureVM(serviceName, VMs, locationName);

            var svcDeployment = vmPowershellCmdlets.GetAzureDeployment(serviceName);
            Assert.AreEqual(svcDeployment.ServiceName, serviceName);
            var vmDeployment = vmPowershellCmdlets.GetAzureVM(newAzureVM1Name, serviceName);
            Assert.AreEqual(vmDeployment.InstanceName, newAzureVM1Name);

            // Cleanup
            vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, serviceName);
            Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM1Name, serviceName));
            //TODO: Is failing for me because of active containers
            //Utilities.RetryActionUntilSuccess(() => vmPowershellCmdlets.RemoveAzureStorageAccount(storageAcctName), "in use", 10, 30);
            ServiceManagementTest.SetDefaultStorage();
            pass = true;
        }
Exemplo n.º 28
0
        public void CaptureImagingExportingImportingVMConfig()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            // Create a unique VM name
            string newAzureVMName = Utilities.GetUniqueShortName("PSTestVM");
            Console.WriteLine("VM Name: {0}", newAzureVMName);

            // Create a unique Service Name
            vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);
            Console.WriteLine("Service Name: {0}", serviceName);
            if (string.IsNullOrEmpty(imageName))
                imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);

            // starting the test.
            var azureVMConfigInfo = new AzureVMConfigInfo(newAzureVMName, InstanceSize.Small.ToString(), imageName); // parameters for New-AzureVMConfig (-Name -InstanceSize -ImageName)
            var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password); // parameters for Add-AzureProvisioningConfig (-Windows -Password)
            var persistentVMConfigInfo = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
            PersistentVM persistentVM = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo); // New-AzureVMConfig & Add-AzureProvisioningConfig

            PersistentVM[] VMs = { persistentVM };
            vmPowershellCmdlets.NewAzureVM(serviceName, VMs); // New-AzureVM
            Console.WriteLine("The VM is successfully created: {0}", persistentVM.RoleName);
            PersistentVMRoleContext vmRoleCtxt = vmPowershellCmdlets.GetAzureVM(persistentVM.RoleName, serviceName);
            Assert.AreEqual(vmRoleCtxt.Name, persistentVM.RoleName, true);


            vmPowershellCmdlets.StopAzureVM(newAzureVMName, serviceName, true); // Stop-AzureVM
            for (int i = 0; i < 3; i++)
            {
                vmRoleCtxt = vmPowershellCmdlets.GetAzureVM(persistentVM.RoleName, serviceName);
                if (vmRoleCtxt.InstanceStatus == "StoppedVM")
                {
                    break;
                }
                Console.WriteLine("The status of the VM {0} : {1}", persistentVM.RoleName, vmRoleCtxt.InstanceStatus);
                Thread.Sleep(120000);
            }
            Assert.AreEqual(vmRoleCtxt.InstanceStatus, "StoppedVM", true);

            // Save-AzureVMImage
            vmPowershellCmdlets.SaveAzureVMImage(serviceName, newAzureVMName, newAzureVMName);

            // Verify VM image.
            var image = vmPowershellCmdlets.GetAzureVMImage(newAzureVMName)[0];

            Assert.AreEqual("Windows", image.OS, "OS is not matching!");
            Assert.AreEqual(newAzureVMName, image.ImageName, "Names are not matching!");

            // Verify that the VM is removed
            Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(persistentVM.RoleName, serviceName));

            // Cleanup the registered image
            vmPowershellCmdlets.RemoveAzureVMImage(newAzureVMName, true);

            pass = true;
        }
Exemplo n.º 29
0
        public void CreateDeploymentWithReservedIPNegativeTest()
        {
            try
            {

                string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix);
                string newAzureVM2Name = Utilities.GetUniqueShortName(vmNamePrefix);
                if (string.IsNullOrEmpty(imageName))
                {
                    imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);
                }

                var azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall.ToString(), imageName);
                var azureVMConfigInfo2 = new AzureVMConfigInfo(newAzureVM2Name, InstanceSize.Small.ToString(), imageName);
                var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0);
                var azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, 80, 80, "web", "lbweb", 80, ProtocolInfo.http, @"/", null, null);

                var persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);
                var persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig, azureDataDiskConfigInfo, null);

                PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
                PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);

                PersistentVM[] VMs = { persistentVM1, persistentVM2 };


                // AG1 on location 1
                vmPowershellCmdlets.NewAzureAffinityGroup(affName1, locationName, null, null);

                // AG2 on location 2
                var anotherLocation = GetLocation("PersistentVMRole", locationName);
                vmPowershellCmdlets.NewAzureAffinityGroup(affName2, anotherLocation.Name, null, null);

                // Reserve an ip on AG1
                vmPowershellCmdlets.NewAzureReservedIP(rsvIpName1, affName2);
                var rsvIPreturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
                Verify.AzureReservedIPNotInUse(rsvIPreturned, rsvIpName1, null, affName2);
                
                // Try to create a new deployment with AG2 and the reserved IP 
                Utilities.VerifyFailure(
                    () => vmPowershellCmdlets.NewAzureVMWithReservedIP(svcNameAG, VMs, rsvIpName1, affName1),
                    BadRequestException);

                // Create a new deployment with location 2, and then reserved the IP of it
                vmPowershellCmdlets.NewAzureVM(svcNameLoc, VMs, locationName);

                Utilities.VerifyFailure(
                    () => vmPowershellCmdlets.NewAzureReservedIP(rsvIpName2, affName2, svcNameLoc, svcNameLoc),
                    BadRequestException);

                // Remove the reserved IP and verify
                vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1);
                Utilities.VerifyFailure(
                        () => vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1), ResourceNotFoundException);

                pass = true;

            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Exemplo n.º 30
0
        public void RemoveAndCreateDeploymentWithReservedIP()
        {
            try
            {

                vmPowershellCmdlets.NewAzureAffinityGroup(affName1, locationName, null, null);

                string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix);                
                string newAzureVM2Name = Utilities.GetUniqueShortName(vmNamePrefix);
                if (string.IsNullOrEmpty(imageName))
                {
                    imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);
                }

                AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall, imageName);                
                AzureVMConfigInfo azureVMConfigInfo2 = new AzureVMConfigInfo(newAzureVM2Name, InstanceSize.Small, imageName);
                AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                AddAzureDataDiskConfig azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0);
                AzureEndPointConfigInfo azureEndPointConfigInfo =
                    new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, 80,
                        80, "web", "lbweb", 80, ProtocolInfo.http, @"/", null, null);

                PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);                
                PersistentVMConfigInfo persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);
                

                PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);                
                PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);

                // Create a new deployment
                vmPowershellCmdlets.NewAzureVM(svcNameLoc, new [] {persistentVM1}, locationName);                

                // Reserve the ip of the deployment                
                vmPowershellCmdlets.NewAzureReservedIP(rsvIpName1, affName1, svcNameLoc, svcNameLoc, rsvIPLabel);

                // Get the deployment and verify
                var deploymentReturned = vmPowershellCmdlets.GetAzureDeployment(svcNameLoc);
                Utilities.PrintContext(deploymentReturned);

                // Verify the reserved ip
                var reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
                Verify.AzureReservedIPInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1,
                    deploymentReturned.VirtualIPs[0].Address, deploymentReturned.DeploymentName,
                    deploymentReturned.ServiceName);

                // Remove the VMs and verify
                Console.WriteLine("\nRemoving VMs...\n");
                vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, svcNameLoc);                

                // Verify the reserved ip
                reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
                Verify.AzureReservedIPNotInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1);
                
                // Remove the service
                Console.WriteLine("\nRemoving the service...\n");
                vmPowershellCmdlets.RemoveAzureService(svcNameLoc);

                // Verify the reserved ip
                reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
                Verify.AzureReservedIPNotInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1);

                // Re-deploy the VM and verify
                vmPowershellCmdlets.NewAzureVMWithReservedIP(svcNameAG, new[] { persistentVM2 },rsvIpName1, affName1);

                // Get the deployment and verify
                deploymentReturned = vmPowershellCmdlets.GetAzureDeployment(svcNameAG);
                Utilities.PrintContext(deploymentReturned);

                // Verify the reserved ip
                reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
                Verify.AzureReservedIPInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1,
                    deploymentReturned.VirtualIPs[0].Address, deploymentReturned.DeploymentName,
                    deploymentReturned.ServiceName);

                // Remove the VM
                vmPowershellCmdlets.RemoveAzureService(svcNameAG);

                // Remove the reserved IP and verify
                vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1);
                Utilities.VerifyFailure(
                        () => vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1), ResourceNotFoundException);

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Exemplo n.º 31
0
        public void RestartAzureVMAfterDeallocateTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            try
            {
                DateTime prevTime = DateTime.Now;

                // starting the test.
                var azureVMConfigInfo1 = new AzureVMConfigInfo(vmName1, InstanceSize.Small.ToString(), imageName);
                var azureProvisioningConfig1 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig1, null, null);
                PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);

                PersistentVM[] VMs = { persistentVM1 };

                Utilities.RecordTimeTaken(ref prevTime);
                vmPowershellCmdlets.NewAzureVM(svcName, VMs);
                Utilities.RecordTimeTaken(ref prevTime);

                Console.WriteLine("The VM is successfully created: {0}", vmName1);

                WaitForReadyState(svcName, vmName1);

                Console.WriteLine(vmPowershellCmdlets.GetAzureVM(vmName1, svcName).InstanceStatus);

                Utilities.RecordTimeTaken(ref prevTime);
                vmPowershellCmdlets.StopAzureVM(vmName1, svcName, false, true);
                Utilities.RecordTimeTaken(ref prevTime);

                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));

                for (int i = 0 ; i < 10 ; i++)
                {
                    try
                    {
                        Utilities.RecordTimeTaken(ref prevTime);
                        vmPowershellCmdlets.StartAzureVM(vmName1, svcName);
                        Utilities.RecordTimeTaken(ref prevTime);
                        break;
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                        Thread.Sleep(60 * 1000);
                    }
                }

                WaitForReadyState(svcName, vmName1);
                Utilities.RecordTimeTaken(ref prevTime);
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new [] { readyState }));

                var vm = vmPowershellCmdlets.GetAzureVM(vmName1, svcName).VM;
                var vmSizeConfig = new SetAzureVMSizeConfig(InstanceSize.Medium.ToString());
                vmSizeConfig.Vm = vm;
                vm = vmPowershellCmdlets.SetAzureVMSize(vmSizeConfig);
                vmPowershellCmdlets.UpdateAzureVM(vmName1, svcName, vm);

                vm = vmPowershellCmdlets.GetAzureVM(vmName1, svcName).VM;
                Console.WriteLine("RoleSize: {0}", vm.RoleSize);
                Assert.AreEqual(InstanceSize.Medium.ToString(), vm.RoleSize);

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }
            finally
            {
                if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
                {
                    vmPowershellCmdlets.RemoveAzureService(svcName);
                }
            }
        }
        public PersistentVM AddAzureProvisioningConfig(AzureProvisioningConfigInfo provConfig)
        {
            AddAzureProvisioningConfigCmdletInfo addAzureProvisioningConfigCmdletInfog = new AddAzureProvisioningConfigCmdletInfo(provConfig);
            WindowsAzurePowershellCmdlet addAzureProvisioningConfigCmdlet = new WindowsAzurePowershellCmdlet(addAzureProvisioningConfigCmdletInfog);

            Collection<PSObject> result = addAzureProvisioningConfigCmdlet.Run();
            if (result.Count == 1)
            {
                return (PersistentVM)result[0].BaseObject;
            }
            return null;
        }
        public AddAzureProvisioningConfigCmdletInfo(AzureProvisioningConfigInfo provConfig)
        {
            this.cmdletName = Utilities.AddAzureProvisioningConfigCmdletName;

            this.cmdletParams.Add(new CmdletParam("VM", provConfig.Vm));

            var parameterSet = string.IsNullOrEmpty(provConfig.Option) ? provConfig.OS.ToString() : provConfig.Option;

            this.cmdletParams.Add(new CmdletParam(parameterSet));

            this.cmdletParams.Add(new CmdletParam("Password", provConfig.Password));

            // For Linux parameter set
            if (parameterSet.Equals(OS.Linux.ToString()))
            {
                this.cmdletParams.Add(new CmdletParam("LinuxUser", provConfig.LinuxUser));

                if (provConfig.DisableSSH)
                {
                    this.cmdletParams.Add(new CmdletParam("DisableSSH"));
                }
                if (provConfig.NoSSHEndpoint)
                {
                    this.cmdletParams.Add(new CmdletParam("NoSSHEndpoint"));
                }
                if (provConfig.SSHKeyPairs != null && provConfig.SSHKeyPairs.Count != 0)
                {
                    this.cmdletParams.Add(new CmdletParam("SSHKeyPairs", provConfig.SSHKeyPairs));
                }
                if (provConfig.SshPublicKeys != null && provConfig.SshPublicKeys.Count != 0)
                {
                    this.cmdletParams.Add(new CmdletParam("SSHPublicKeys", provConfig.SshPublicKeys));
                }
            }

            // For Windows/WindowsDomain parameter set
            if (parameterSet.Equals(provConfig.WindowsDomain) || parameterSet.Equals(OS.Windows.ToString()))
            {
                this.cmdletParams.Add(new CmdletParam("AdminUsername", provConfig.AdminUsername));

                if (provConfig.DisableAutomaticUpdate)
                {
                    this.cmdletParams.Add(new CmdletParam("DisableAutomaticUpdates"));
                }
                if (provConfig.DisableGuestAgent)
                {
                    this.cmdletParams.Add(new CmdletParam("DisableGuestAgent"));
                }
                if (provConfig.DisableWinRMHttps)
                {
                    this.cmdletParams.Add(new CmdletParam("DisableWinRMHttps"));
                }
                if (provConfig.EnableWinRMHttp)
                {
                    this.cmdletParams.Add(new CmdletParam("EnableWinRMHttp"));
                }
                if (provConfig.NoWinRMEndpoint)
                {
                    this.cmdletParams.Add(new CmdletParam("NoWinRMEndpoint"));
                }
                if (provConfig.Reset)
                {
                    this.cmdletParams.Add(new CmdletParam("ResetPasswordOnFirstLogon"));
                }
                if (provConfig.NoExportPrivateKey)
                {
                    this.cmdletParams.Add(new CmdletParam("NoExportPrivateKey"));
                }
                if (provConfig.NoRDPEndpoint)
                {
                    this.cmdletParams.Add(new CmdletParam("NoRDPEndpoint"));
                }
                if (!string.IsNullOrEmpty(provConfig.TimeZone))
                {
                    this.cmdletParams.Add(new CmdletParam("TimeZone", provConfig.TimeZone));
                }

                if (provConfig.Certs != null && provConfig.Certs.Count != 0)
                {
                    this.cmdletParams.Add(new CmdletParam("Certificates", provConfig.Certs));
                }
                if (provConfig.WinRMCertificate != null)
                {
                    this.cmdletParams.Add(new CmdletParam("WinRMCertificate", provConfig.WinRMCertificate));
                }
                if (provConfig.X509Certificates != null)
                {
                    this.cmdletParams.Add(new CmdletParam("X509Certificates", provConfig.X509Certificates));
                }
            }

            // For WindowsDomain parameter set
            if (parameterSet.Equals(provConfig.WindowsDomain))
            {
                this.cmdletParams.Add(new CmdletParam("Domain", provConfig.Domain));
                this.cmdletParams.Add(new CmdletParam("JoinDomain", provConfig.JoinDomain));
                this.cmdletParams.Add(new CmdletParam("DomainUserName", provConfig.DomainUserName));
                this.cmdletParams.Add(new CmdletParam("DomainPassword", provConfig.DomainPassword));

                if (!string.IsNullOrEmpty(provConfig.MachineObjectOU))
                {
                    this.cmdletParams.Add(new CmdletParam("MachineObjectOU", provConfig.MachineObjectOU));
                }
            }
        }
Exemplo n.º 34
0
        public void CreateDeploymentWithReservedIPNegativeTest()
        {
            try
            {
                string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix);
                string newAzureVM2Name = Utilities.GetUniqueShortName(vmNamePrefix);
                if (string.IsNullOrEmpty(imageName))
                {
                    imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);
                }

                var azureVMConfigInfo1      = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall.ToString(), imageName);
                var azureVMConfigInfo2      = new AzureVMConfigInfo(newAzureVM2Name, InstanceSize.Small.ToString(), imageName);
                var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0);
                var azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, 80, 80, "web", "lbweb", 80, ProtocolInfo.http, @"/", null, null);

                var persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);
                var persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig, azureDataDiskConfigInfo, null);

                PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
                PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);

                PersistentVM[] VMs = { persistentVM1, persistentVM2 };


                // AG1 on location 1
                vmPowershellCmdlets.NewAzureAffinityGroup(affName1, locationName, null, null);

                // AG2 on location 2
                var anotherLocation = GetLocation("PersistentVMRole", locationName);
                vmPowershellCmdlets.NewAzureAffinityGroup(affName2, anotherLocation.Name, null, null);

                // Reserve an ip on AG1
                vmPowershellCmdlets.NewAzureReservedIP(rsvIpName1, affName2);
                var rsvIPreturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
                Verify.AzureReservedIPNotInUse(rsvIPreturned, rsvIpName1, null, affName2);

                // Try to create a new deployment with AG2 and the reserved IP
                Utilities.VerifyFailure(
                    () => vmPowershellCmdlets.NewAzureVMWithReservedIP(svcNameAG, VMs, rsvIpName1, affName1),
                    BadRequestException);

                // Create a new deployment with location 2, and then reserved the IP of it
                vmPowershellCmdlets.NewAzureVM(svcNameLoc, VMs, locationName);

                Utilities.VerifyFailure(
                    () => vmPowershellCmdlets.NewAzureReservedIP(rsvIpName2, affName2, svcNameLoc, svcNameLoc),
                    BadRequestException);

                // Remove the reserved IP and verify
                vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1);
                Utilities.VerifyFailure(
                    () => vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1), ResourceNotFoundException);

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Exemplo n.º 35
0
        public void RemoveAzureReservedIPWithDeploymentTest()
        {
            try
            {
                vmPowershellCmdlets.NewAzureAffinityGroup(affName1, locationName, null, null);

                string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix);

                if (string.IsNullOrEmpty(imageName))
                {
                    imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);
                }

                var azureVMConfigInfo1      = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall.ToString(), imageName);
                var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0);
                var azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, 80, 80, "web", "lbweb", 80, ProtocolInfo.http, @"/", null, null);

                var persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);

                PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);


                //PersistentVM[] VMs = { persistentVM1, persistentVM2 };
                PersistentVM[] VMs = { persistentVM1 };

                // Create a new deployment
                vmPowershellCmdlets.NewAzureVMWithAG(svcNameAG, VMs, affName1);

                // Reserve the ip of the deployment
                vmPowershellCmdlets.NewAzureReservedIP(rsvIpName1, affName1, svcNameAG, svcNameAG, rsvIPLabel);

                // Get the deployment and verify
                var deploymentReturned = vmPowershellCmdlets.GetAzureDeployment(svcNameAG);

                // Verify the reserved ip
                var reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
                Verify.AzureReservedIPInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1,
                                            deploymentReturned.VirtualIPs[0].Address, deploymentReturned.DeploymentName,
                                            deploymentReturned.ServiceName);

                // Stop-deallocate the first VM and verify reserved ip
                Utilities.VerifyFailure(() => vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1), BadRequestException);

                vmPowershellCmdlets.StopAzureVM(newAzureVM1Name, svcNameAG, false, true);

                // Verify the reserved ip
                reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
                Verify.AzureReservedIPInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1,
                                            deploymentReturned.VirtualIPs[0].Address, deploymentReturned.DeploymentName,
                                            deploymentReturned.ServiceName);

                // Stop-deallocate the second VM and verify reserved ip
                Utilities.VerifyFailure(() => vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1), BadRequestException);

                // Remove all VMs and service and verify reserved ip
                vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, svcNameAG, true);

                // Verify the reserved ip
                reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
                Verify.AzureReservedIPNotInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1);

                // Remove the reserved IP and verify
                vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1);
                Utilities.VerifyFailure(
                    () => vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1), ResourceNotFoundException);

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Exemplo n.º 36
0
        public void AzureDnsTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            const string dnsName = "OpenDns1";
            const string ipAddress = "208.67.222.222";

            try
            {
                vmPowershellCmdlets.NewAzureService(serviceName, locationName);

                DnsServer dns = vmPowershellCmdlets.NewAzureDns(dnsName, ipAddress);

                var azureVMConfigInfo = new AzureVMConfigInfo(vmName, InstanceSize.ExtraSmall.ToString(), imageName);
                var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var persistentVMConfigInfo = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
                PersistentVM vm = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);
           
                vmPowershellCmdlets.NewAzureVM(serviceName, new []{vm}, null, new[]{dns}, null, null, null, null);

                Assert.IsTrue(Verify.AzureDns(vmPowershellCmdlets.GetAzureDeployment(serviceName).DnsSettings, dns));
                pass = true;

            }
            catch (Exception e)
            {
                pass = false;
                Console.WriteLine("Exception occurred: {0}", e.ToString());
                throw;
            }
        }
Exemplo n.º 37
0
        public void AzureSubnetTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            try
            {
                //vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);

                var azureVMConfigInfo = new AzureVMConfigInfo(vmName, InstanceSize.Small.ToString(), imageName);
                var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var persistentVMConfigInfo = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
                vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);

                string [] subs = {"subnet1", "subnet2", "subnet3"};
                PersistentVM vm = vmPowershellCmdlets.SetAzureSubnet(vmPowershellCmdlets.AddAzureProvisioningConfig(azureProvisioningConfig), subs);
                
                SubnetNamesCollection subnets = vmPowershellCmdlets.GetAzureSubnet(vm);
                foreach (string subnet in subnets)
                {
                    Console.WriteLine("Subnet: {0}", subnet);
                }                
                CollectionAssert.AreEqual(subnets, subs);
                
                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception occurred: {0}", e);
                throw;
            }
        }
Exemplo n.º 38
0
        public void AzureCertificateSettingTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            // Create a certificate
            string cerFileName = Convert.ToString(TestContext.DataRow["cerFileName"]);
            X509Certificate2 certCreated = Utilities.CreateCertificate(password);
            byte[] certData2 = certCreated.Export(X509ContentType.Cert);
            File.WriteAllBytes(cerFileName, certData2);

            // Install the .cer file to local machine.
            StoreLocation certStoreLocation = StoreLocation.CurrentUser;
            StoreName certStoreName = StoreName.My;
            X509Certificate2 installedCert = Utilities.InstallCert(cerFileName, certStoreLocation, certStoreName);

            PSObject certToUpload = vmPowershellCmdlets.RunPSScript(
                String.Format("Get-Item cert:\\{0}\\{1}\\{2}", certStoreLocation.ToString(), certStoreName.ToString(), installedCert.Thumbprint))[0];

            try
            {
                vmPowershellCmdlets.NewAzureService(serviceName, locationName);
                vmPowershellCmdlets.AddAzureCertificate(serviceName, certToUpload);

                CertificateSettingList certList = new CertificateSettingList();
                certList.Add(vmPowershellCmdlets.NewAzureCertificateSetting(certStoreName.ToString(), installedCert.Thumbprint));

                AzureVMConfigInfo azureVMConfigInfo = new AzureVMConfigInfo(vmName, InstanceSize.Small, imageName);
                AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, certList, username, password);

                PersistentVMConfigInfo persistentVMConfigInfo = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);

                PersistentVM vm = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);

                vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm });

                PersistentVMRoleContext result = vmPowershellCmdlets.GetAzureVM(vmName, serviceName);

                Console.WriteLine("{0} is created", result.Name);

                pass = true;
            }
            catch (Exception e)
            {
                pass = false;                
                Assert.Fail(e.ToString());
            }
            finally
            {
                Utilities.UninstallCert(installedCert, certStoreLocation, certStoreName);
            }

        }
Exemplo n.º 39
0
        public void RemoveAzureReservedIPWithDeploymentTest()
        {
            try
            {
                vmPowershellCmdlets.NewAzureAffinityGroup(affName1, locationName, null, null);

                string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix);
                
                if (string.IsNullOrEmpty(imageName))
                {
                    imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);
                }

                var azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall.ToString(), imageName);
                var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0);
                var azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, 80, 80, "web", "lbweb", 80, ProtocolInfo.http, @"/", null, null);

                var persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);
                
                PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
                

                //PersistentVM[] VMs = { persistentVM1, persistentVM2 };
                PersistentVM[] VMs = { persistentVM1 };

                // Create a new deployment
                vmPowershellCmdlets.NewAzureVMWithAG(svcNameAG, VMs, affName1);

                // Reserve the ip of the deployment                
                vmPowershellCmdlets.NewAzureReservedIP(rsvIpName1, affName1, svcNameAG, svcNameAG, rsvIPLabel);

                // Get the deployment and verify
                var deploymentReturned = vmPowershellCmdlets.GetAzureDeployment(svcNameAG);

                // Verify the reserved ip
                var reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
                Verify.AzureReservedIPInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1,
                    deploymentReturned.VirtualIPs[0].Address, deploymentReturned.DeploymentName,
                    deploymentReturned.ServiceName);

                // Stop-deallocate the first VM and verify reserved ip
                Utilities.VerifyFailure(() => vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1), BadRequestException);
                
                vmPowershellCmdlets.StopAzureVM(newAzureVM1Name, svcNameAG, false, true);

                // Verify the reserved ip
                reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
                Verify.AzureReservedIPInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1,
                    deploymentReturned.VirtualIPs[0].Address, deploymentReturned.DeploymentName,
                    deploymentReturned.ServiceName);

                // Stop-deallocate the second VM and verify reserved ip
                Utilities.VerifyFailure(() => vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1), BadRequestException);
                
                // Remove all VMs and service and verify reserved ip
                vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, svcNameAG, true);

                // Verify the reserved ip
                reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0];
                Verify.AzureReservedIPNotInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1);

                // Remove the reserved IP and verify
                vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1);
                Utilities.VerifyFailure(
                        () => vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1), ResourceNotFoundException);

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Exemplo n.º 40
0
        public void AzureDnsTest2()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            const string dnsName = "OpenDns1";
            const string ipAddress = "208.67.222.222";
            const string ipAddress2 = "127.0.0.1";

            try
            {
                vmPowershellCmdlets.NewAzureService(serviceName, locationName);

                // Create a VM
                var azureVMConfigInfo = new AzureVMConfigInfo(vmName, InstanceSize.ExtraSmall.ToString(), imageName);
                var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var persistentVMConfigInfo = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
                PersistentVM vm = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);
                vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm });

                // Add a DNS server
                vmPowershellCmdlets.AddAzureDns(dnsName, ipAddress, serviceName);

                var dnsServer = vmPowershellCmdlets.GetAzureDeployment(serviceName).DnsSettings.DnsServers[0];
                Assert.AreEqual(dnsName, dnsServer.Name);
                Assert.AreEqual(ipAddress, dnsServer.Address);

                // Edit the DNS server 
                vmPowershellCmdlets.SetAzureDns(dnsName, ipAddress2, serviceName);

                dnsServer = vmPowershellCmdlets.GetAzureDeployment(serviceName).DnsSettings.DnsServers[0];
                Assert.AreEqual(dnsName, dnsServer.Name);
                Assert.AreEqual(ipAddress2, dnsServer.Address);

                // Remove the DNS server 
                vmPowershellCmdlets.RemoveAzureDns(dnsName, serviceName, force:true);

                Assert.IsNull(vmPowershellCmdlets.GetAzureDeployment(serviceName).DnsSettings);

                pass = true;

            }
            catch (Exception e)
            {
                pass = false;
                Console.WriteLine("Exception occurred: {0}", e.ToString());
                throw;
            }
        }
Exemplo n.º 41
0
        public void CaptureImagingExportingImportingVMConfig()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            // Create a unique VM name
            string newAzureVMName = Utilities.GetUniqueShortName("PSTestVM");

            Console.WriteLine("VM Name: {0}", newAzureVMName);

            // Create a unique Service Name
            vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);
            Console.WriteLine("Service Name: {0}", serviceName);
            if (string.IsNullOrEmpty(imageName))
            {
                imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows", "testvmimage" }, false);
            }

            // starting the test.
            AzureVMConfigInfo           azureVMConfigInfo       = new AzureVMConfigInfo(newAzureVMName, InstanceSize.Small, imageName); // parameters for New-AzureVMConfig (-Name -InstanceSize -ImageName)
            AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);      // parameters for Add-AzureProvisioningConfig (-Windows -Password)
            PersistentVMConfigInfo      persistentVMConfigInfo  = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
            PersistentVM persistentVM = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);                                    // New-AzureVMConfig & Add-AzureProvisioningConfig

            PersistentVM[] VMs = { persistentVM };
            vmPowershellCmdlets.NewAzureVM(serviceName, VMs); // New-AzureVM
            Console.WriteLine("The VM is successfully created: {0}", persistentVM.RoleName);
            PersistentVMRoleContext vmRoleCtxt = vmPowershellCmdlets.GetAzureVM(persistentVM.RoleName, serviceName);

            Assert.AreEqual(vmRoleCtxt.Name, persistentVM.RoleName, true);


            vmPowershellCmdlets.StopAzureVM(newAzureVMName, serviceName); // Stop-AzureVM
            for (int i = 0; i < 3; i++)
            {
                vmRoleCtxt = vmPowershellCmdlets.GetAzureVM(persistentVM.RoleName, serviceName);
                if (vmRoleCtxt.InstanceStatus == "StoppedVM")
                {
                    break;
                }
                else
                {
                    Console.WriteLine("The status of the VM {0} : {1}", persistentVM.RoleName, vmRoleCtxt.InstanceStatus);
                    Thread.Sleep(120000);
                }
            }
            Assert.AreEqual(vmRoleCtxt.InstanceStatus, "StoppedVM", true);

            //TODO
            // RDP

            //TODO:
            // Run sysprep and shutdown

            // Check the status of VM
            //PersistentVMRoleContext vmRoleCtxt2 = vmPowershellCmdlets.GetAzureVM(newAzureVMName, newAzureSvcName); // Get-AzureVM -Name
            //Assert.AreEqual(newAzureVMName, vmRoleCtxt2.Name, true);  //

            // Save-AzureVMImage
            //string newImageName = "newImage";
            //string newImageLabel = "newImageLabel";
            //string postAction = "Delete";

            // Save-AzureVMImage -ServiceName -Name -NewImageName -NewImageLabel -PostCaptureAction
            //vmPowershellCmdlets.SaveAzureVMImage(newAzureSvcName, newAzureVMName, newImageName, newImageLabel, postAction);

            // Cleanup
            vmPowershellCmdlets.RemoveAzureVM(persistentVM.RoleName, serviceName);
            Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(persistentVM.RoleName, serviceName));
        }
Exemplo n.º 42
0
        public void StopAzureVMsDeprovisionedTest()
        {

            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            try
            {
                // starting the test.
                var azureVMConfigInfo1 = new AzureVMConfigInfo(vmName1, InstanceSize.ExtraSmall.ToString(), imageName);
                var azureProvisioningConfig1 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig1, null, null);
                PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);

                var azureVMConfigInfo2 = new AzureVMConfigInfo(vmName2, InstanceSize.Small.ToString(), imageName);
                var azureProvisioningConfig2 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig2, null, null);
                PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);

                PersistentVM[] VMs = { persistentVM1, persistentVM2 };
                vmPowershellCmdlets.NewAzureVM(svcName, VMs);
                Console.WriteLine("The VM is successfully created: {0}", vmName1);
                Console.WriteLine("The VM is successfully created: {0}", vmName2);

                WaitForReadyState(svcName, vmName1);
                WaitForReadyState(svcName, vmName2);

                var vm1 = vmPowershellCmdlets.GetAzureVM(vmName1, svcName);
                var vm2 = vmPowershellCmdlets.GetAzureVM(vmName2, svcName);

                Assert.AreEqual(vm1.HostName, vmName1);
                Assert.AreEqual(vm2.HostName, vmName2);

                // Stop and deallocate the VMs
                vmPowershellCmdlets.StopAzureVM("*", svcName, false, true);

                WaitForStoppedState(svcName, vmName1);
                WaitForStoppedState(svcName, vmName2);

                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { stoppedDeallocatedState }));

                // Start the VMs
                Utilities.RetryActionUntilSuccess(() => vmPowershellCmdlets.StartAzureVM("*", svcName), "HTTP Status Code: 409", 10, 60);
                //StartAzureVMs("*", svcName);

                WaitForStartedState(svcName, vmName1);
                WaitForStartedState(svcName, vmName2);

                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { readyState, provisioningState }));
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { readyState, provisioningState }));

                try
                {
                    // Try to Stop and deallocate VM2 without Force.  Should fail and give a warning message.
                    vmPowershellCmdlets.StopAzureVM("*", svcName);
                    Assert.Fail();
                }
                catch (Exception e)
                {
                    if (e is AssertFailedException)
                    {
                        throw;
                    }
                    else
                    {
                        Console.WriteLine(e.ToString());
                    }
                }
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { readyState, provisioningState }));
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { readyState, provisioningState }));

                // Stop and deallocate VMs
                vmPowershellCmdlets.StopAzureVM("*", svcName, false, true);

                WaitForStoppedState(svcName, vmName1);
                WaitForStoppedState(svcName, vmName2);

                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { stoppedDeallocatedState }));

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }
            finally
            {
                if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
                {
                    vmPowershellCmdlets.RemoveAzureService(svcName);
                }
            }
        }
Exemplo n.º 43
0
        public void NewAzureVMDomainJoinTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            var newAzureVMName = Utilities.GetUniqueShortName(vmNamePrefix);

            const string joinDomainStr = "www.microsoft.com";
            const string domainStr = "microsoft.com";
            const string domainUser = "******";
            const string domainPassword = "******";

            try
            {
                if (string.IsNullOrEmpty(imageName))
                {
                    imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] {"Windows"}, false);
                }

                vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);

                var azureVMConfigInfo = new AzureVMConfigInfo(newAzureVMName, InstanceSize.Small, imageName);
                var azureProvisioningConfig = new AzureProvisioningConfigInfo("WindowsDomain", username, password,
                                                                              joinDomainStr, domainStr, domainUser,
                                                                              domainPassword);
                var persistentVMConfigInfo = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null,
                                                                        null);
                PersistentVM persistentVM = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);

                PersistentVM[] VMs = {persistentVM};
                vmPowershellCmdlets.NewAzureVM(serviceName, VMs);

                // Todo: Check the domain of the VM
                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }
        }
Exemplo n.º 44
0
        public void StopAzureVMOnStoppedVMTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            try
            {
                // starting the test.
                AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(vmName1, InstanceSize.Small, imageName);
                AzureProvisioningConfigInfo azureProvisioningConfig1 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig1, null, null);
                PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);

                PersistentVM[] VMs = { persistentVM1 };
                vmPowershellCmdlets.NewAzureVM(svcName, VMs);
                Console.WriteLine("The VM is successfully created: {0}", vmName1);

                WaitForStartingState(svcName, vmName1);

                // Stop the VM with StayProvisioned
                vmPowershellCmdlets.StopAzureVM(vmName1, svcName, true);
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedProvisionedState }));

                // Try to stop it again.  Should not change the state.
                vmPowershellCmdlets.StopAzureVM(vmName1, svcName, true);
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedProvisionedState }));

                try
                {
                    // Try to stop without any option.  Should fail with a warning message.
                    vmPowershellCmdlets.StopAzureVM(vmName1, svcName);
                    Assert.Fail();
                }
                catch (Exception e)
                {
                    if (e is AssertFailedException)
                    {
                        throw;
                    }
                    else
                    {
                        Console.WriteLine(e.ToString());
                    }
                }
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedProvisionedState }));

                // Stop the VM with Force option.   Should deallocate the VM.
                vmPowershellCmdlets.StopAzureVM(vmName1, svcName, false, true);
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }
            finally
            {
                if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
                {
                    vmPowershellCmdlets.RemoveAzureService(svcName);
                }
            }
        }
Exemplo n.º 45
0
        public void AdvancedProvisioning()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix);
            string newAzureVM2Name = Utilities.GetUniqueShortName(vmNamePrefix);
            if (string.IsNullOrEmpty(imageName))
            {
                imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);
            }

            vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);

            AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall, imageName);
            AzureVMConfigInfo azureVMConfigInfo2 = new AzureVMConfigInfo(newAzureVM2Name, InstanceSize.ExtraSmall, imageName);
            AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
            AddAzureDataDiskConfig azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0);
            AzureEndPointConfigInfo azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, 80, 80, "web", "lbweb", 80, ProtocolInfo.http, @"/", null, null);

            PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);
            PersistentVMConfigInfo persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);

            PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
            PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);

            PersistentVM[] VMs = { persistentVM1, persistentVM2 };
            vmPowershellCmdlets.NewAzureVM(serviceName, VMs);

            // Cleanup
            vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, serviceName);
            vmPowershellCmdlets.RemoveAzureVM(newAzureVM2Name, serviceName);

            Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM1Name, serviceName));
            Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM2Name, serviceName));
            pass = true;
        }
Exemplo n.º 46
0
        public void StopAzureVMDeprovisionedTest()
        {

            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            try
            {
                // starting the test.
                AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(vmName1, InstanceSize.ExtraSmall, imageName);
                AzureProvisioningConfigInfo azureProvisioningConfig1 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig1, null, null);
                PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);

                AzureVMConfigInfo azureVMConfigInfo2 = new AzureVMConfigInfo(vmName2, InstanceSize.Small, imageName);
                AzureProvisioningConfigInfo azureProvisioningConfig2 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                PersistentVMConfigInfo persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig2, null, null);
                PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);

                PersistentVM[] VMs = { persistentVM1, persistentVM2 };
                vmPowershellCmdlets.NewAzureVM(svcName, VMs);
                Console.WriteLine("The VM is successfully created: {0}", vmName1);
                Console.WriteLine("The VM is successfully created: {0}", vmName2);

                // Stop and deallocate VM1
                vmPowershellCmdlets.StopAzureVM(vmName1, svcName);
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));

                WaitForStartedState(svcName, vmName2);
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { readyState, provisioningState }));

                try
                {
                    // Try to Stop and deallocate VM2 without Force.  Should fail and give a warning message.
                    vmPowershellCmdlets.RunPSScript(string.Format("{0} -ServiceName {1} -Name {2} | {3}",
                        Utilities.GetAzureVMCmdletName, svcName, vmName2, Utilities.StopAzureVMCmdletName));
                    Assert.Fail();
                }
                catch (Exception e)
                {
                    if (e is AssertFailedException)
                    {
                        throw;
                    }
                    else
                    {
                        Console.WriteLine(e.ToString());
                    }
                }
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { readyState, provisioningState }));

                // Stop and deallocate VM2
                vmPowershellCmdlets.StopAzureVM(vmName2, svcName, false, true);

                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { stoppedDeallocatedState }));

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }
            finally
            {
                if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
                {
                    vmPowershellCmdlets.RemoveAzureService(svcName);
                }
            }
        }
        public AddAzureProvisioningConfigCmdletInfo(AzureProvisioningConfigInfo provConfig)
        {
            this.cmdletName = Utilities.AddAzureProvisioningConfigCmdletName;

            this.cmdletParams.Add(new CmdletParam("VM", provConfig.Vm));

            var parameterSet = string.IsNullOrEmpty(provConfig.Option) ? provConfig.OS.ToString() : provConfig.Option;

            this.cmdletParams.Add(new CmdletParam(parameterSet));

            if (!string.IsNullOrEmpty(provConfig.Password))
            {
                this.cmdletParams.Add(new CmdletParam("Password", provConfig.Password));
            }

            if (!string.IsNullOrEmpty(provConfig.CustomDataFile))
            {
                this.cmdletParams.Add(new CmdletParam("CustomDataFile", provConfig.CustomDataFile));
            }

            // For Linux parameter set
            if (parameterSet.Equals(OS.Linux.ToString()))
            {
                this.cmdletParams.Add(new CmdletParam("LinuxUser", provConfig.LinuxUser));

                if (provConfig.DisableSSH)
                {
                    this.cmdletParams.Add(new CmdletParam("DisableSSH"));
                }
                if (provConfig.NoSSHEndpoint)
                {
                    this.cmdletParams.Add(new CmdletParam("NoSSHEndpoint"));
                }
                if (provConfig.SSHKeyPairs != null && provConfig.SSHKeyPairs.Count != 0)
                {
                    this.cmdletParams.Add(new CmdletParam("SSHKeyPairs", provConfig.SSHKeyPairs));
                }
                if (provConfig.SshPublicKeys != null && provConfig.SshPublicKeys.Count != 0)
                {
                    this.cmdletParams.Add(new CmdletParam("SSHPublicKeys", provConfig.SshPublicKeys));
                }
                if(provConfig.NoSSHPassword)
                {
                    this.cmdletParams.Add(new CmdletParam("NoSSHPassword"));
                }
            }

            // For Windows/WindowsDomain parameter set
            if (parameterSet.Equals(provConfig.WindowsDomain) || parameterSet.Equals(OS.Windows.ToString()))
            {
                this.cmdletParams.Add(new CmdletParam("AdminUsername", provConfig.AdminUsername));

                if (provConfig.DisableAutomaticUpdate)
                {
                    this.cmdletParams.Add(new CmdletParam("DisableAutomaticUpdates"));
                }
                if (provConfig.DisableGuestAgent)
                {
                    this.cmdletParams.Add(new CmdletParam("DisableGuestAgent"));
                }
                if (provConfig.DisableWinRMHttps)
                {
                    this.cmdletParams.Add(new CmdletParam("DisableWinRMHttps"));
                }
                if (provConfig.EnableWinRMHttp)
                {
                    this.cmdletParams.Add(new CmdletParam("EnableWinRMHttp"));
                }
                if (provConfig.NoWinRMEndpoint)
                {
                    this.cmdletParams.Add(new CmdletParam("NoWinRMEndpoint"));
                }
                if (provConfig.Reset)
                {
                    this.cmdletParams.Add(new CmdletParam("ResetPasswordOnFirstLogon"));
                }
                if (provConfig.NoExportPrivateKey)
                {
                    this.cmdletParams.Add(new CmdletParam("NoExportPrivateKey"));
                }
                if (provConfig.NoRDPEndpoint)
                {
                    this.cmdletParams.Add(new CmdletParam("NoRDPEndpoint"));
                }
                if (!string.IsNullOrEmpty(provConfig.TimeZone))
                {
                    this.cmdletParams.Add(new CmdletParam("TimeZone", provConfig.TimeZone));
                }

                if (provConfig.Certs != null && provConfig.Certs.Count != 0)
                {
                    this.cmdletParams.Add(new CmdletParam("Certificates", provConfig.Certs));
                }
                if (provConfig.WinRMCertificate != null)
                {
                    this.cmdletParams.Add(new CmdletParam("WinRMCertificate", provConfig.WinRMCertificate));
                }
                if (provConfig.X509Certificates != null)
                {
                    this.cmdletParams.Add(new CmdletParam("X509Certificates", provConfig.X509Certificates));
                }
            }

            // For WindowsDomain parameter set
            if (parameterSet.Equals(provConfig.WindowsDomain))
            {
                this.cmdletParams.Add(new CmdletParam("Domain", provConfig.Domain));
                this.cmdletParams.Add(new CmdletParam("JoinDomain", provConfig.JoinDomain));
                this.cmdletParams.Add(new CmdletParam("DomainUserName", provConfig.DomainUserName));
                this.cmdletParams.Add(new CmdletParam("DomainPassword", provConfig.DomainPassword));

                if (!string.IsNullOrEmpty(provConfig.MachineObjectOU))
                {
                    this.cmdletParams.Add(new CmdletParam("MachineObjectOU", provConfig.MachineObjectOU));
                }
            }
        }
Exemplo n.º 48
0
        public void AzureIaaSBVT()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);
            DateTime prevTime = DateTime.Now;

            string diskLabel1 = "disk1";
            int    diskSize1  = 30;
            int    lunSlot1   = 0;

            string diskLabel2 = "disk2";
            int    diskSize2  = 50;
            int    lunSlot2   = 2;


            string           ep1Name               = "tcp1";
            int              ep1LocalPort          = 60010;
            int              ep1PublicPort         = 60011;
            string           ep1LBSetName          = "lbset1";
            int              ep1ProbePort          = 60012;
            string           ep1ProbePath          = string.Empty;
            int?             ep1ProbeInterval      = 7;
            int?             ep1ProbeTimeout       = null;
            NetworkAclObject ep1AclObj             = vmPowershellCmdlets.NewAzureAclConfig();
            bool             ep1DirectServerReturn = false;

            string           ep2Name               = "tcp2";
            int              ep2LocalPort          = 60020;
            int              ep2PublicPort         = 60021;
            int              ep2LocalPortChanged   = 60030;
            int              ep2PublicPortChanged  = 60031;
            string           ep2LBSetName          = "lbset2";
            int              ep2ProbePort          = 60022;
            string           ep2ProbePath          = @"/";
            int?             ep2ProbeInterval      = null;
            int?             ep2ProbeTimeout       = 32;
            NetworkAclObject ep2AclObj             = vmPowershellCmdlets.NewAzureAclConfig();
            bool             ep2DirectServerReturn = false;

            string cerFileName         = "testcert.cer";
            string thumbprintAlgorithm = "sha1";

            try
            {
                // Create a certificate
                X509Certificate2 certCreated = Utilities.CreateCertificate(password);
                byte[]           certData2   = certCreated.Export(X509ContentType.Cert);
                File.WriteAllBytes(cerFileName, certData2);

                // Install the .cer file to local machine.
                StoreLocation    certStoreLocation = StoreLocation.CurrentUser;
                StoreName        certStoreName     = StoreName.My;
                X509Certificate2 installedCert     = Utilities.InstallCert(cerFileName, certStoreLocation, certStoreName);

                PSObject certToUpload = vmPowershellCmdlets.RunPSScript(
                    String.Format("Get-Item cert:\\{0}\\{1}\\{2}", certStoreLocation.ToString(), certStoreName.ToString(), installedCert.Thumbprint))[0];
                string certData = Convert.ToBase64String(((X509Certificate2)certToUpload.BaseObject).RawData);

                string newAzureVMName = Utilities.GetUniqueShortName(vmNamePrefix);
                if (string.IsNullOrEmpty(imageName))
                {
                    imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);
                }

                RecordTimeTaken(ref prevTime);

                //
                // New-AzureService and verify with Get-AzureService
                //
                vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);
                Assert.IsTrue(Verify.AzureService(serviceName, serviceName, locationName));
                RecordTimeTaken(ref prevTime);

                //
                // Add-AzureCertificate and verify with Get-AzureCertificate
                //
                vmPowershellCmdlets.AddAzureCertificate(serviceName, certToUpload);
                Assert.IsTrue(Verify.AzureCertificate(serviceName, certCreated.Thumbprint, thumbprintAlgorithm, certData));
                RecordTimeTaken(ref prevTime);

                //
                // Remove-AzureCertificate
                //
                vmPowershellCmdlets.RemoveAzureCertificate(serviceName, certCreated.Thumbprint, thumbprintAlgorithm);
                Assert.IsTrue(Utilities.CheckRemove(vmPowershellCmdlets.GetAzureCertificate, serviceName, certCreated.Thumbprint, thumbprintAlgorithm));
                RecordTimeTaken(ref prevTime);

                //
                // New-AzureVMConfig
                //
                var          azureVMConfigInfo = new AzureVMConfigInfo(newAzureVMName, InstanceSize.Small.ToString(), imageName);
                PersistentVM vm = vmPowershellCmdlets.NewAzureVMConfig(azureVMConfigInfo);

                RecordTimeTaken(ref prevTime);

                //
                // Add-AzureCertificate
                //
                vmPowershellCmdlets.AddAzureCertificate(serviceName, certToUpload);

                //
                // New-AzureCertificateSetting
                //
                CertificateSettingList certList = new CertificateSettingList();
                certList.Add(vmPowershellCmdlets.NewAzureCertificateSetting(certStoreName.ToString(), installedCert.Thumbprint));
                RecordTimeTaken(ref prevTime);

                //
                // Add-AzureProvisioningConfig
                //
                AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, certList, username, password);
                azureProvisioningConfig.Vm = vm;
                vm = vmPowershellCmdlets.AddAzureProvisioningConfig(azureProvisioningConfig);
                RecordTimeTaken(ref prevTime);

                //
                // Add-AzureDataDisk (two disks)
                //
                AddAzureDataDiskConfig azureDataDiskConfigInfo1 = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, diskSize1, diskLabel1, lunSlot1);
                azureDataDiskConfigInfo1.Vm = vm;
                vm = vmPowershellCmdlets.AddAzureDataDisk(azureDataDiskConfigInfo1);

                AddAzureDataDiskConfig azureDataDiskConfigInfo2 = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, diskSize2, diskLabel2, lunSlot2);
                azureDataDiskConfigInfo2.Vm = vm;
                vm = vmPowershellCmdlets.AddAzureDataDisk(azureDataDiskConfigInfo2);

                RecordTimeTaken(ref prevTime);

                //
                // Add-AzureEndpoint (two endpoints)
                //
                AzureEndPointConfigInfo azureEndPointConfigInfo1 = new AzureEndPointConfigInfo(
                    AzureEndPointConfigInfo.ParameterSet.CustomProbe,
                    ProtocolInfo.tcp,
                    ep1LocalPort,
                    ep1PublicPort,
                    ep1Name,
                    ep1LBSetName,
                    ep1ProbePort,
                    ProtocolInfo.tcp,
                    ep1ProbePath,
                    ep1ProbeInterval,
                    ep1ProbeTimeout,
                    ep1AclObj,
                    ep1DirectServerReturn,
                    null,
                    null,
                    LoadBalancerDistribution.SourceIP);

                azureEndPointConfigInfo1.Vm = vm;
                vm = vmPowershellCmdlets.AddAzureEndPoint(azureEndPointConfigInfo1);

                AzureEndPointConfigInfo azureEndPointConfigInfo2 = new AzureEndPointConfigInfo(
                    AzureEndPointConfigInfo.ParameterSet.CustomProbe,
                    ProtocolInfo.tcp,
                    ep2LocalPort,
                    ep2PublicPort,
                    ep2Name,
                    ep2LBSetName,
                    ep2ProbePort,
                    ProtocolInfo.http,
                    ep2ProbePath,
                    ep2ProbeInterval,
                    ep2ProbeTimeout,
                    ep2AclObj,
                    ep2DirectServerReturn);

                azureEndPointConfigInfo2.Vm = vm;
                vm = vmPowershellCmdlets.AddAzureEndPoint(azureEndPointConfigInfo2);

                RecordTimeTaken(ref prevTime);

                //
                // Set-AzureAvailabilitySet
                //

                string testAVSetName = "testAVSet1";
                vm = vmPowershellCmdlets.SetAzureAvailabilitySet(testAVSetName, vm);
                RecordTimeTaken(ref prevTime);

                //
                // New-AzureDns
                //

                string dnsName   = "OpenDns1";
                string ipAddress = "208.67.222.222";

                DnsServer dns = vmPowershellCmdlets.NewAzureDns(dnsName, ipAddress);

                RecordTimeTaken(ref prevTime);

                //
                // New-AzureVM
                //
                vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, null, new[] { dns }, null, null, null, null);
                RecordTimeTaken(ref prevTime);

                //
                // Get-AzureVM without any parameter (List VMs)
                //
                var vmlist = vmPowershellCmdlets.GetAzureVM();
                Console.WriteLine("The number of VMs: {0}", vmlist.Count);
                Assert.AreNotSame(0, vmlist.Count, "No VM exists!!!");
                PersistentVMRoleListContext returnedVMlist =
                    vmlist.First(item => item.ServiceName.Equals(serviceName) && item.Name.Equals(newAzureVMName));
                Assert.IsNotNull(returnedVMlist, "Created VM does not exist!!!");
                Utilities.PrintContext((PersistentVMRoleContext)returnedVMlist);

                //
                // Get-AzureVM
                //
                PersistentVMRoleContext returnedVM = vmPowershellCmdlets.GetAzureVM(newAzureVMName, serviceName);
                vm = returnedVM.VM;
                RecordTimeTaken(ref prevTime);

                //
                // Verify AzureDataDisk
                //
                Assert.IsTrue(Verify.AzureDataDisk(vm, diskLabel1, diskSize1, lunSlot1, HostCaching.None), "Data disk is not properly added");
                Assert.IsTrue(Verify.AzureDataDisk(vm, diskLabel2, diskSize2, lunSlot2, HostCaching.None), "Data disk is not properly added");
                Console.WriteLine("Data disk added correctly.");

                RecordTimeTaken(ref prevTime);

                //
                // Verify AzureEndpoint
                //
                Assert.IsTrue(Verify.AzureEndpoint(vm, new[] { azureEndPointConfigInfo1, azureEndPointConfigInfo2 }));

                //
                // Verify RDP & PowerShell Endpoints
                //
                var endpoints = vmPowershellCmdlets.GetAzureEndPoint(vm);
                Assert.IsTrue(endpoints.Count(e => e.Name == "PowerShell" && e.LocalPort == 5986 && e.Protocol == "tcp") == 1);
                Assert.IsTrue(endpoints.Count(e => e.Name == "RemoteDesktop" && e.LocalPort == 3389 && e.Protocol == "tcp") == 1);

                //
                // Verify AzureDns
                //
                Assert.IsTrue(Verify.AzureDns(vmPowershellCmdlets.GetAzureDeployment(serviceName).DnsSettings, dns));

                //
                // Verify AzureAvailibilitySet
                //
                Assert.IsTrue(Verify.AzureAvailabilitySet(vm, testAVSetName));

                //
                // Verify AzureOsDisk
                //
                Assert.IsTrue(Verify.AzureOsDisk(vm, "Windows", HostCaching.ReadWrite));

                //
                // Set-AzureDataDisk
                //
                SetAzureDataDiskConfig setAzureDataDiskConfigInfo = new SetAzureDataDiskConfig(HostCaching.ReadOnly, lunSlot1);
                setAzureDataDiskConfigInfo.Vm = vm;
                vm = vmPowershellCmdlets.SetAzureDataDisk(setAzureDataDiskConfigInfo);
                RecordTimeTaken(ref prevTime);

                //
                // Remove-AzureDataDisk
                //
                RemoveAzureDataDiskConfig removeAzureDataDiskConfig = new RemoveAzureDataDiskConfig(lunSlot2, vm);
                vm = vmPowershellCmdlets.RemoveAzureDataDisk(removeAzureDataDiskConfig);
                RecordTimeTaken(ref prevTime);

                //
                // Set-AzureEndpoint
                //
                azureEndPointConfigInfo2 = new AzureEndPointConfigInfo(
                    AzureEndPointConfigInfo.ParameterSet.CustomProbe,
                    ProtocolInfo.tcp,
                    ep2LocalPortChanged,
                    ep2PublicPortChanged,
                    ep2Name,
                    ep2LBSetName,
                    ep2ProbePort,
                    ProtocolInfo.http,
                    ep2ProbePath,
                    ep2ProbeInterval,
                    ep2ProbeTimeout,
                    ep2AclObj,
                    ep2DirectServerReturn);

                azureEndPointConfigInfo2.Vm = vm;
                vm = vmPowershellCmdlets.SetAzureEndPoint(azureEndPointConfigInfo2);
                RecordTimeTaken(ref prevTime);

                //
                // Remove-AzureEndpoint
                //
                vm = vmPowershellCmdlets.RemoveAzureEndPoint(azureEndPointConfigInfo1.EndpointName, vm);
                RecordTimeTaken(ref prevTime);

                //
                // Set-AzureVMSize
                //
                var vmSizeConfig = new SetAzureVMSizeConfig(InstanceSize.Medium.ToString());
                vmSizeConfig.Vm = vm;
                vm = vmPowershellCmdlets.SetAzureVMSize(vmSizeConfig);
                RecordTimeTaken(ref prevTime);

                //
                // Set-AzureOSDisk
                //
                vm = vmPowershellCmdlets.SetAzureOSDisk(HostCaching.ReadOnly, vm);


                //
                // Update-AzureVM
                //
                vmPowershellCmdlets.UpdateAzureVM(newAzureVMName, serviceName, vm);
                RecordTimeTaken(ref prevTime);

                //
                // Get-AzureVM and Verify the VM
                //
                vm = vmPowershellCmdlets.GetAzureVM(newAzureVMName, serviceName).VM;

                // Verify setting data disk
                Assert.IsTrue(Verify.AzureDataDisk(vm, diskLabel1, diskSize1, lunSlot1, HostCaching.ReadOnly), "Data disk is not properly added");

                // Verify removing a data disk
                Assert.AreEqual(1, vmPowershellCmdlets.GetAzureDataDisk(vm).Count, "DataDisk is not removed.");

                // Verify setting an endpoint
                Assert.IsTrue(Verify.AzureEndpoint(vm, new[] { azureEndPointConfigInfo2 }));

                // Verify removing an endpoint
                Assert.IsFalse(Verify.AzureEndpoint(vm, new[] { azureEndPointConfigInfo1 }));

                // Verify os disk
                Assert.IsTrue(Verify.AzureOsDisk(vm, "Windows", HostCaching.ReadOnly));

                //
                // Remove-AzureVM
                //
                vmPowershellCmdlets.RemoveAzureVM(newAzureVMName, serviceName);

                RecordTimeTaken(ref prevTime);

                Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVMName, serviceName));
                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }
        }
Exemplo n.º 49
0
        public void StopAzureVMsOnDeallocatedVMTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            try
            {
                // Configure VM1
                var azureVMConfigInfo1 = new AzureVMConfigInfo(vmName1, InstanceSize.ExtraSmall.ToString(), imageName);
                var azureProvisioningConfig1 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig1, null, null);
                PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);

                // Configure VM2
                var azureVMConfigInfo2 = new AzureVMConfigInfo(vmName2, InstanceSize.Small.ToString(), imageName);
                var azureProvisioningConfig2 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig2, null, null);
                PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);

                PersistentVM[] VMs = { persistentVM1, persistentVM2 };
                vmPowershellCmdlets.NewAzureVM(svcName, VMs);
                Console.WriteLine("The VM is successfully created: {0}", vmName1);
                Console.WriteLine("The VM is successfully created: {0}", vmName2);

                WaitForReadyState(svcName, vmName1);
                WaitForReadyState(svcName, vmName2);

                // Stop and deallocate the VMs
                vmPowershellCmdlets.StopAzureVM("*", svcName, false, true);
                
                WaitForStoppedState(svcName, vmName1);
                WaitForStoppedState(svcName, vmName2);

                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { stoppedDeallocatedState }));

                try
                {
                    // Try to stop the VMs with StayProvisioned.  Should fail.
                    vmPowershellCmdlets.StopAzureVM("*", svcName, true, true);
                    Assert.Fail();
                }
                catch (Exception e)
                {
                    if (e is AssertFailedException)
                    {
                        throw;
                    }
                    else
                    {
                        Console.WriteLine(e.ToString());
                    }
                }

                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { stoppedDeallocatedState }));

                try
                {
                    // Try to stop the VMs without any option.  Should fail and give a warning message.
                    vmPowershellCmdlets.StopAzureVM("*", svcName);
                    Assert.Fail();
                }
                catch (Exception e)
                {
                    if (e is AssertFailedException)
                    {
                        throw;
                    }
                    else
                    {
                        Console.WriteLine(e.ToString());
                    }
                }

                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { stoppedDeallocatedState }));

                // Try to stop and deallocate the VM again.
                vmPowershellCmdlets.StopAzureVM("*", svcName, false, true);
                WaitForStoppedState(svcName, vmName1);
                WaitForStoppedState(svcName, vmName2);

                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { stoppedDeallocatedState }));

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }
            finally
            {
                if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
                {
                    vmPowershellCmdlets.RemoveAzureService(svcName);
                }
            }
        }
Exemplo n.º 50
0
        public void AzureCertificateSettingTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            // Create a certificate
            string cerFileName = Convert.ToString(TestContext.DataRow["cerFileName"]);
            X509Certificate2 certCreated = Utilities.CreateCertificate(password);
            byte[] certData2 = certCreated.Export(X509ContentType.Cert);
            File.WriteAllBytes(cerFileName, certData2);

            // Install the .cer file to local machine.
            StoreLocation certStoreLocation = StoreLocation.CurrentUser;
            StoreName certStoreName = StoreName.My;
            X509Certificate2 installedCert = Utilities.InstallCert(cerFileName, certStoreLocation, certStoreName);

            PSObject certToUpload = vmPowershellCmdlets.RunPSScript(
                String.Format("Get-Item cert:\\{0}\\{1}\\{2}", certStoreLocation.ToString(), certStoreName.ToString(), installedCert.Thumbprint))[0];

            try
            {
                vmPowershellCmdlets.NewAzureService(serviceName, locationName);
                var certList = new CertificateSettingList();
                certList.Add(vmPowershellCmdlets.NewAzureCertificateSetting(certStoreName.ToString(), installedCert.Thumbprint));

                var azureVMConfigInfo = new AzureVMConfigInfo(vmName, InstanceSize.Small.ToString(), imageName);
                var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, certList, username, password);
                var persistentVMConfigInfo = new PersistentVMConfigInfo(azureVMConfigInfo, azureProvisioningConfig, null, null);
                PersistentVM vm = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo);

                // Negative Test:
                //   Try to deploy a VM with a certificate that does not exist in the hosted service.
                //   This should fail.
                try
                {
                    vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm });
                    Assert.Fail(
                        "Should have failed, but it succeeded !!  New-AzureVM should fail if it contains a thumbprint that does not exist in the hosted service.");
                }
                catch (Exception e)
                {
                    if (e is AssertFailedException)
                    {
                        throw;
                    }
                    Console.WriteLine("This exception is expected: {0}", e);
                }

                // Now we add the certificate to the hosted service.
                vmPowershellCmdlets.AddAzureCertificate(serviceName, certToUpload);
                vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm });

                PersistentVMRoleContext result = vmPowershellCmdlets.GetAzureVM(vmName, serviceName);
                Console.WriteLine("{0} is created", result.Name);

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.WriteLine(e.InnerException);
                throw;
            }
            finally
            {
                Utilities.UninstallCert(installedCert, certStoreLocation, certStoreName);
            }
        }
Exemplo n.º 51
0
        public void StopAzureVMStayProvisionedTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            try
            {
                // starting the test.
                var azureVMConfigInfo1 = new AzureVMConfigInfo(vmName1, InstanceSize.ExtraSmall.ToString(), imageName);
                var azureProvisioningConfig1 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig1, null, null);
                PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);

                var azureVMConfigInfo2 = new AzureVMConfigInfo(vmName2, InstanceSize.Small.ToString(), imageName);
                var azureProvisioningConfig2 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig2, null, null);
                PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);

                PersistentVM[] VMs = { persistentVM1, persistentVM2 };
                vmPowershellCmdlets.NewAzureVM(svcName, VMs);
                Console.WriteLine("The VM is successfully created: {0}", vmName1);
                Console.WriteLine("The VM is successfully created: {0}", vmName2);

                WaitForStartingState(svcName, vmName1);
                vmPowershellCmdlets.StopAzureVM(vmName1, svcName, true); // Stop-AzureVM -StayProvisioned against VM1

                for (int i = 0; i < 10 ; i++)
                {
                    if (CheckRoleInstanceState(svcName, vmName1, new string[] {stoppedProvisionedState}))
                    {
                        break;
                    }
                    Thread.Sleep(1000);
                }

                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedProvisionedState }));

                // Stop-AzureVM -StayProvisioned against VM2
                vmPowershellCmdlets.RunPSScript(string.Format("{0} -ServiceName {1} -Name {2} | {3} -StayProvisioned",
                    Utilities.GetAzureVMCmdletName, svcName, vmName2, Utilities.StopAzureVMCmdletName));

                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string [] {stoppedProvisionedState}));
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string [] {stoppedProvisionedState}));

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }
            finally
            {
                if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
                {
                    vmPowershellCmdlets.RemoveAzureService(svcName);
                }
            }
        }
        public void AddEndPointACLsWithNewDeployment()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix);
            string newAzureVM2Name = Utilities.GetUniqueShortName(vmNamePrefix);
            if (string.IsNullOrEmpty(imageName))
                imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);

            vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName);

            NetworkAclObject aclObj = vmPowershellCmdlets.NewAzureAclConfig();
            vmPowershellCmdlets.SetAzureAclConfig(SetACLConfig.AddRule, aclObj, 100, ACLAction.Permit, "172.0.0.0/8", "notes1");
            vmPowershellCmdlets.SetAzureAclConfig(SetACLConfig.AddRule, aclObj, 200, ACLAction.Deny, "10.0.0.0/8", "notes2");

            AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall, imageName);
            AzureVMConfigInfo azureVMConfigInfo2 = new AzureVMConfigInfo(newAzureVM2Name, InstanceSize.ExtraSmall, imageName);
            AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password);
            AddAzureDataDiskConfig azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0);
            AzureEndPointConfigInfo azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.DefaultProbe, ProtocolInfo.tcp, 80, 80, "web", "lbweb", aclObj, true);

            PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);
            PersistentVMConfigInfo persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo);

            PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);
            PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);

            PersistentVM[] VMs = { persistentVM1, persistentVM2 };
            vmPowershellCmdlets.NewAzureVM(serviceName, VMs);

            // Cleanup
            vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, serviceName);
            vmPowershellCmdlets.RemoveAzureVM(newAzureVM2Name, serviceName);

            Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM1Name, serviceName));
            Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM2Name, serviceName));
            pass = true;
        }
Exemplo n.º 53
0
        public void RestartAzureVMsAfterDeallocateTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            try
            {
                // starting the test.
                DateTime prevTime = DateTime.Now;

                // Configure VM1
                var azureVMConfigInfo1 = new AzureVMConfigInfo(vmName1, InstanceSize.ExtraSmall.ToString(), imageName);
                var azureProvisioningConfig1 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig1, null, null);
                PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1);

                // Configure VM2
                var azureVMConfigInfo2 = new AzureVMConfigInfo(vmName2, InstanceSize.Small.ToString(), imageName);
                var azureProvisioningConfig2 = new AzureProvisioningConfigInfo(OS.Windows, username, password);
                var persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig2, null, null);
                PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2);

                PersistentVM[] VMs = { persistentVM1, persistentVM2 };

                Utilities.RecordTimeTaken(ref prevTime);
                vmPowershellCmdlets.NewAzureVM(svcName, VMs);
                Utilities.RecordTimeTaken(ref prevTime);

                Console.WriteLine("The VM is successfully created: {0}", vmName1);
                Console.WriteLine("The VM is successfully created: {0}", vmName2);

                WaitForReadyState(svcName, vmName1);
                WaitForReadyState(svcName, vmName2);

                Console.WriteLine(vmPowershellCmdlets.GetAzureVM(vmName1, svcName).InstanceStatus);
                Console.WriteLine(vmPowershellCmdlets.GetAzureVM(vmName2, svcName).InstanceStatus);

                // Stop VM1 one only using wildcard name
                string vm1WildcardName = vmName1.Replace(prefixVMName, "*");
                Utilities.RecordTimeTaken(ref prevTime);
                Utilities.RetryActionUntilSuccess(() => vmPowershellCmdlets.StopAzureVM(vm1WildcardName, svcName, false, true), "HTTP Status Code: 409", 10, 60);
                //StopAzureVMs(vm1WildcardName, svcName, false, true);
                Utilities.RecordTimeTaken(ref prevTime);

                WaitForStoppedState(svcName, vmName1);
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));

                // Start VM1 one only using wildcard name
                Utilities.RecordTimeTaken(ref prevTime);
                Utilities.RetryActionUntilSuccess(() => vmPowershellCmdlets.StartAzureVM(vm1WildcardName, svcName), "HTTP Status Code: 409", 10, 60);
                //StartAzureVMs(vm1WildcardName, svcName);
                Utilities.RecordTimeTaken(ref prevTime);

                WaitForReadyState(svcName, vmName1);
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { readyState }));

                Utilities.RecordTimeTaken(ref prevTime);
                vmPowershellCmdlets.StopAzureVM("*", svcName, false, true);
                Utilities.RecordTimeTaken(ref prevTime);

                WaitForStoppedState(svcName, vmName1);
                WaitForStoppedState(svcName, vmName2);

                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { stoppedDeallocatedState }));
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { stoppedDeallocatedState }));

                Utilities.RecordTimeTaken(ref prevTime);
                Utilities.RetryActionUntilSuccess(() => vmPowershellCmdlets.StartAzureVM("*", svcName), "HTTP Status Code: 409", 10, 60);
                //StartAzureVMs("*", svcName);
                Utilities.RecordTimeTaken(ref prevTime);

                WaitForReadyState(svcName, vmName1);
                WaitForReadyState(svcName, vmName2);
                Utilities.RecordTimeTaken(ref prevTime);
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName1, new string[] { readyState }));
                Assert.IsTrue(CheckRoleInstanceState(svcName, vmName2, new string[] { readyState }));

                pass = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw;
            }
            finally
            {
                if ((cleanupIfPassed && pass) || (cleanupIfFailed && !pass))
                {
                    vmPowershellCmdlets.RemoveAzureService(svcName);
                }
            }
        }
Exemplo n.º 54
0
 public PersistentVM AddAzureProvisioningConfig(AzureProvisioningConfigInfo provConfig)
 {
     return(RunPSCmdletAndReturnFirst <PersistentVM>(new AddAzureProvisioningConfigCmdletInfo(provConfig)));
 }