当前位置: 首页>>代码示例>>C#>>正文


C# AzureVMConfigInfo类代码示例

本文整理汇总了C#中AzureVMConfigInfo的典型用法代码示例。如果您正苦于以下问题:C# AzureVMConfigInfo类的具体用法?C# AzureVMConfigInfo怎么用?C# AzureVMConfigInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AzureVMConfigInfo类属于命名空间,在下文中一共展示了AzureVMConfigInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PersistentVMConfigInfo

 public PersistentVMConfigInfo(AzureVMConfigInfo vmConfig, AzureProvisioningConfigInfo provConfig, AddAzureDataDiskConfig diskConfig, AzureEndPointConfigInfo endPointConfig)
 {
     this.VmConfig = vmConfig;
     this.ProvConfig = provConfig;
     this.DiskConfig = diskConfig;
     this.EndPointConfig = endPointConfig;
 }
开发者ID:EmmaZhu,项目名称:azure-sdk-tools,代码行数:7,代码来源:PersistentVMConfigInfo.cs

示例2: NewAzureVMConfigCmdletInfo

        public NewAzureVMConfigCmdletInfo(AzureVMConfigInfo vmConfig)
        {
            this.cmdletName = Utilities.NewAzureVMConfigCmdletName;

            this.cmdletParams.Add(new CmdletParam("Name", vmConfig.vmName));
            this.cmdletParams.Add(new CmdletParam("ImageName", vmConfig.imageName));
            this.cmdletParams.Add(new CmdletParam("InstanceSize", vmConfig.vmSize));
        }
开发者ID:EmmaZhu,项目名称:azure-sdk-tools,代码行数:8,代码来源:NewAzureVMConfigCmdletInfo.cs

示例3: DevTestProvisioning

        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;
        }
开发者ID:rmattsampson,项目名称:azure-sdk-tools,代码行数:51,代码来源:ScenarioTest.cs

示例4: RemoveAzureReservedIPWithDeploymentTest

        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;
            }
        }
开发者ID:takekazuomi,项目名称:azure-sdk-tools,代码行数:75,代码来源:ReservedIPTest.cs

示例5: NewAzureVMDomainJoinTest

        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 = "pstestdomainuser";
            const string domainPassword = "[email protected]";

            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;
            }
        }
开发者ID:rmattsampson,项目名称:azure-sdk-tools,代码行数:40,代码来源:ScenarioTest.cs

示例6: AzureCertificateSettingTest

        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);
            }

        }
开发者ID:ranjitk9,项目名称:azure-sdk-tools,代码行数:52,代码来源:FunctionalTest.cs

示例7: CreateDeploymentWithReservedIPNegativeTest

        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;
            }
        }
开发者ID:takekazuomi,项目名称:azure-sdk-tools,代码行数:65,代码来源:ReservedIPTest.cs

示例8: StopAzureVMOnStoppedVMTest

        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);
                }
            }
        }
开发者ID:nakidsworks,项目名称:azure-sdk-tools,代码行数:64,代码来源:StopAzureVMTest.cs

示例9: RestartAzureVMAfterDeallocateTest

        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);
                }
            }
        }
开发者ID:takekazuomi,项目名称:azure-sdk-tools,代码行数:77,代码来源:StopAzureVMTest.cs

示例10: AddEndPointACLsWithNewDeployment

        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;
        }
开发者ID:ranjitk9,项目名称:azure-sdk-tools,代码行数:38,代码来源:LBandEndPointACLsTest.cs

示例11: StopAzureVMsStayProvisionedTest

        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);
                }
            }
        }
开发者ID:takekazuomi,项目名称:azure-sdk-tools,代码行数:48,代码来源:StopAzureVMTest.cs

示例12: CaptureImagingExportingImportingVMConfig

        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;
        }
开发者ID:EmmaZhu,项目名称:azure-sdk-tools,代码行数:57,代码来源:ScenarioTest.cs

示例13: AzureDnsTest2

        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;
            }
        }
开发者ID:kenazk,项目名称:azure-sdk-tools,代码行数:48,代码来源:FunctionalTest.cs

示例14: NewAzureVMConfig

        public PersistentVM NewAzureVMConfig(AzureVMConfigInfo vmConfig)
        {
            NewAzureVMConfigCmdletInfo newAzureVMConfigCmdletInfo = new NewAzureVMConfigCmdletInfo(vmConfig);
            WindowsAzurePowershellCmdlet newAzureServiceCmdlet = new WindowsAzurePowershellCmdlet(newAzureVMConfigCmdletInfo);

            Collection<PSObject> result = newAzureServiceCmdlet.Run();
            if (result.Count == 1)
            {
                return (PersistentVM)result[0].BaseObject;
            }
            return null;
        }
开发者ID:huangpf,项目名称:azure-sdk-tools,代码行数:12,代码来源:ServiceManagementCmdletTestHelper.cs

示例15: RemoveAndCreateDeploymentWithReservedIP

        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;
            }
        }
开发者ID:nakidsworks,项目名称:azure-sdk-tools,代码行数:90,代码来源:ReservedIPTest.cs


注:本文中的AzureVMConfigInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。