コード例 #1
0
        private Model.WindowsProvisioningConfigurationSet.WinRmConfiguration GetWinRmConfiguration()
        {
            if(this.DisableWinRMHttps.IsPresent)
            {
                return null;
            }

            var builder = new WinRmConfigurationBuilder();
            if(this.EnableWinRMHttp.IsPresent)
            {
                builder.AddHttpListener();
            }

            builder.AddHttpsListener(WinRMCertificate);
            return builder.Configuration;
        }
コード例 #2
0
        internal void ExecuteCommand()
        {
            ServiceManagementProfile.Initialize();
            var role = VM.GetInstance();
            var configSetbuilder = new ConfigurationSetsBuilder(role.ConfigurationSets);
            if (Linux.IsPresent)
            {
                role.NoSSHEndpoint = NoSSHEndpoint.IsPresent;

                if (!string.IsNullOrEmpty(this.LinuxUser))
                {
                    SetProvisioningConfiguration(configSetbuilder.LinuxConfigurationBuilder.Provisioning);
                    configSetbuilder.LinuxConfigurationBuilder.Provisioning.HostName = role.RoleName;
                }

                if (!(DisableSSH.IsPresent || NoSSHEndpoint.IsPresent))
                {
                    configSetbuilder.NetworkConfigurationBuilder.AddSshEndpoint();
                }
            }
            else
            {
                role.NoRDPEndpoint = NoRDPEndpoint.IsPresent;

                if (!string.IsNullOrEmpty(this.AdminUsername))
                {
                    SetProvisioningConfiguration(configSetbuilder.WindowsConfigurationBuilder.Provisioning);
                    configSetbuilder.WindowsConfigurationBuilder.Provisioning.ComputerName = role.RoleName;
                }

                if (!NoRDPEndpoint.IsPresent)
                {
                    configSetbuilder.NetworkConfigurationBuilder.AddRdpEndpoint();
                }

                if (!this.DisableWinRMHttps.IsPresent)
                {
                    var builder = new WinRmConfigurationBuilder();
                    if (this.EnableWinRMHttp.IsPresent)
                    {
                        builder.AddHttpListener();
                    }
                    builder.AddHttpsListener(this.WinRMCertificate);

                    if (!string.IsNullOrEmpty(AdminUsername))
                    {
                        configSetbuilder.WindowsConfigurationBuilder.Provisioning.WinRM = builder.Configuration;
                    }
    
                    if(!this.NoWinRMEndpoint.IsPresent)
                    {
                        configSetbuilder.NetworkConfigurationBuilder.AddWinRmEndpoint();
                    }
                    role.WinRMCertificate = WinRMCertificate;
                }

                role.X509Certificates = new List<X509Certificate2>();
                if (this.X509Certificates != null)
                {
                    role.X509Certificates.AddRange(this.X509Certificates);
                }

                role.NoExportPrivateKey = this.NoExportPrivateKey.IsPresent;
                role.ProvisionGuestAgent = !DisableGuestAgent.IsPresent;

                role.ResourceExtensionReferences = this.DisableGuestAgent.IsPresent ? null :
                    new VirtualMachineExtensionImageFactory(this.ComputeClient).MakeList(
                            VirtualMachineBGInfoExtensionCmdletBase.ExtensionDefaultPublisher,
                            VirtualMachineBGInfoExtensionCmdletBase.ExtensionDefaultName,
                            VirtualMachineBGInfoExtensionCmdletBase.ExtensionDefaultVersion);
            }

            WriteObject(VM, true);
        }