Microsoft.WindowsAzure.Management.ServiceManagement.Test.FunctionalTests.ServiceManagementCmdletTestHelper.NewAzureQuickLinuxVM C# (CSharp) Method

NewAzureQuickLinuxVM() public method

public NewAzureQuickLinuxVM ( OS os, string name, string serviceName, string imageName, string userName, string password, string locationName ) : Microsoft.WindowsAzure.Management.ServiceManagement.Model.PersistentVMRoleContext
os OS
name string
serviceName string
imageName string
userName string
password string
locationName string
return Microsoft.WindowsAzure.Management.ServiceManagement.Model.PersistentVMRoleContext
        public PersistentVMRoleContext NewAzureQuickLinuxVM(OS os, string name, string serviceName, string imageName, string userName, string password, string locationName)
        {
            NewAzureQuickVMCmdletInfo newAzureQuickVMLinuxCmdlet = new NewAzureQuickVMCmdletInfo(os, name, serviceName, imageName, userName, password, locationName);
            WindowsAzurePowershellCmdletSequence sequence = new WindowsAzurePowershellCmdletSequence();

            SubscriptionData currentSubscription;
            if ((currentSubscription = GetCurrentAzureSubscription()) == null)
            {
                currentSubscription = GetCurrentAzureSubscription();
            }
            if (string.IsNullOrEmpty(currentSubscription.CurrentStorageAccount))
            {
                StorageServicePropertiesOperationContext storageAccount = NewAzureStorageAccount(Utilities.GetUniqueShortName("storage"), locationName);
                if (storageAccount != null)
                {
                    SetAzureSubscription(currentSubscription.SubscriptionName, storageAccount.StorageAccountName);
                    currentSubscription = GetCurrentAzureSubscription();
                }
            }

            if (!string.IsNullOrEmpty(currentSubscription.CurrentStorageAccount))
            {
                sequence.Add(newAzureQuickVMLinuxCmdlet);
                sequence.Run();
                return GetAzureVM(name, serviceName);
            }
            return null;
        }

Usage Example

Exemplo n.º 1
0
        public void ProvisionLinuxVM()
        {
            ServiceManagementCmdletTestHelper vmPowershellCmdlets = new ServiceManagementCmdletTestHelper();
            //vmPowershellCmdlets.ImportAzurePublishSettingsFile(Resource.PublishSettingsFile);
            vmPowershellCmdlets.ImportAzurePublishSettingsFile();

            string locationName = vmPowershellCmdlets.GetAzureLocationName(new[] { Resource.Location }, false);
            string newAzureQuickVMSvcName = Utilities.GetUniqueShortName("PSTestService");
            //Assert.IsFalse(vmPowershellCmdlets.TestAzureServiceName(newAzureQuickVMSvcName));

            string newAzureQuickVMName = Utilities.GetUniqueShortName("PSLinuxVM");
            string imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Linux", "testvmimage" }, false);

            vmPowershellCmdlets.NewAzureQuickLinuxVM(OS.Linux, newAzureQuickVMName, newAzureQuickVMSvcName, imageName, "user", "p@ssw0rd", locationName);

            // Verify
            PersistentVMRoleContext vmRoleCtxt = vmPowershellCmdlets.GetAzureVM(newAzureQuickVMName, newAzureQuickVMSvcName);
            Assert.AreEqual(newAzureQuickVMName, vmRoleCtxt.Name, true);

            // Disabling Stop / start / restart tests for now due to timing isues
            /*
            // Stop & start the VM
            vmPowershellCmdlets.StopAzureVM(newAzureQuickVMName, newAzureQuickVMSvcName);
            vmRoleCtxt = vmPowershellCmdlets.GetAzureVM(newAzureQuickVMName, newAzureQuickVMSvcName);
            Assert.AreEqual(vmRoleCtxt.PowerState, VMPowerState.Stopped);
            vmPowershellCmdlets.StartAzureVM(newAzureQuickVMName, newAzureQuickVMSvcName);
            vmRoleCtxt = vmPowershellCmdlets.GetAzureVM(newAzureQuickVMName, newAzureQuickVMSvcName);
            Assert.AreEqual(vmRoleCtxt.PowerState, VMPowerState.Started.ToString());

            // Restart the VM
            vmPowershellCmdlets.StopAzureVM(newAzureQuickVMName, newAzureQuickVMSvcName);
            vmRoleCtxt = vmPowershellCmdlets.GetAzureVM(newAzureQuickVMName, newAzureQuickVMSvcName);
            Assert.AreEqual(vmRoleCtxt.PowerState, VMPowerState.Stopped);
            vmPowershellCmdlets.RestartAzureVM(newAzureQuickVMName, newAzureQuickVMSvcName);
            vmRoleCtxt = vmPowershellCmdlets.GetAzureVM(newAzureQuickVMName, newAzureQuickVMSvcName);
            Assert.AreEqual(vmRoleCtxt.PowerState, VMPowerState.Started.ToString());
             * */

            // Cleanup
            vmPowershellCmdlets.RemoveAzureVM(newAzureQuickVMName, newAzureQuickVMSvcName);
            // RemoveAzureService is failing. Need to investigate furnter */
            //vmPowershellCmdlets.RemoveAzureService(newAzureQuickVMSvcName);
            Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureQuickVMName, newAzureQuickVMSvcName));

            //TODO: Need to do proper cleanup of the service
            //            vmPowershellCmdlets.RemoveAzureService(newAzureQuickVMSvcName);
            //            Assert.AreEqual(null, vmPowershellCmdlets.GetAzureService(newAzureQuickVMSvcName));
        }
ServiceManagementCmdletTestHelper