Пример #1
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.PersistentVMModel.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;
            }
        }
Пример #2
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.PersistentVMModel.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;
            }
        }