internal void ExecuteCommand() { ServiceManagementProfile.Initialize(); var role = VM.GetInstance(); var configSetbuilder = new ConfigurationSetsBuilder(role.ConfigurationSets); if (Linux.IsPresent) { role.NoSSHEndpoint = NoSSHEndpoint.IsPresent; SetProvisioningConfiguration(configSetbuilder.LinuxConfigurationBuilder.Provisioning); configSetbuilder.LinuxConfigurationBuilder.Provisioning.HostName = role.RoleName; if (!(DisableSSH.IsPresent || NoSSHEndpoint.IsPresent)) { configSetbuilder.NetworkConfigurationBuilder.AddSshEndpoint(); } } else { role.NoRDPEndpoint = NoRDPEndpoint.IsPresent; 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); 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; } WriteObject(VM, true); }
internal void ExecuteCommand() { ServiceManagementProfile.Initialize(); var role = VM.GetInstance(); var configSetbuilder = new ConfigurationSetsBuilder(role.ConfigurationSets); if (Linux.IsPresent) { role.NoSSHEndpoint = NoSSHEndpoint.IsPresent; SetProvisioningConfiguration(configSetbuilder.LinuxConfigurationBuilder.Provisioning); configSetbuilder.LinuxConfigurationBuilder.Provisioning.HostName = role.RoleName; if (!(DisableSSH.IsPresent || NoSSHEndpoint.IsPresent)) { configSetbuilder.NetworkConfigurationBuilder.AddSshEndpoint(); } } else { role.NoRDPEndpoint = NoRDPEndpoint.IsPresent; 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); 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; } WriteObject(VM, true); }
private Microsoft.WindowsAzure.Commands.ServiceManagement.Model.PersistentVMModel.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; }
private 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); }
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); }
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); }
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; }
internal void ExecuteCommand() { var role = VM.GetInstance(); if (Linux.IsPresent) { var provisioningConfiguration = role.ConfigurationSets .OfType<LinuxProvisioningConfigurationSet>() .SingleOrDefault(); if (provisioningConfiguration == null) { provisioningConfiguration = new LinuxProvisioningConfigurationSet(); role.ConfigurationSets.Add(provisioningConfiguration); } SetProvisioningConfiguration(provisioningConfiguration); provisioningConfiguration.HostName = role.RoleName; if (DisableSSH.IsPresent == false || NoSSHEndpoint.IsPresent) { var netConfig = role.ConfigurationSets .OfType<NetworkConfigurationSet>() .SingleOrDefault(); if (netConfig == null) { netConfig = new NetworkConfigurationSet { InputEndpoints = new System.Collections.ObjectModel.Collection<InputEndpoint>() }; role.ConfigurationSets.Add(netConfig); } // Add check in case the settings were imported bool addSSH = true; foreach (InputEndpoint ep in netConfig.InputEndpoints) { if (string.Compare(ep.Name, "SSH", StringComparison.OrdinalIgnoreCase) == 0 || ep.LocalPort == 22) { addSSH = false; ep.Port = null; // null out to avoid conflicts break; } } if (addSSH) { InputEndpoint sshEndpoint = new InputEndpoint(); sshEndpoint.LocalPort = 22; sshEndpoint.Protocol = "tcp"; sshEndpoint.Name = "SSH"; netConfig.InputEndpoints.Add(sshEndpoint); } } } else { var provisioningConfiguration = role.ConfigurationSets .OfType<WindowsProvisioningConfigurationSet>() .SingleOrDefault(); if (provisioningConfiguration == null) { provisioningConfiguration = new WindowsProvisioningConfigurationSet(); role.ConfigurationSets.Add(provisioningConfiguration); } SetProvisioningConfiguration(provisioningConfiguration); provisioningConfiguration.ComputerName = role.RoleName; if (!NoRDPEndpoint.IsPresent) { var netConfig = role.ConfigurationSets .OfType<NetworkConfigurationSet>() .SingleOrDefault(); if (netConfig == null) { netConfig = new NetworkConfigurationSet(); role.ConfigurationSets.Add(netConfig); } if (netConfig.InputEndpoints == null) { netConfig.InputEndpoints = new System.Collections.ObjectModel.Collection<InputEndpoint>(); } bool addRDP = true; foreach (InputEndpoint ep in netConfig.InputEndpoints) { if (string.Compare(ep.Name, "RDP", StringComparison.OrdinalIgnoreCase) == 0 || ep.LocalPort == 3389) { addRDP = false; ep.Port = null; // null out to avoid conflicts break; } } if (addRDP) { InputEndpoint rdpEndpoint = new InputEndpoint { LocalPort = 3389, Protocol = "tcp", Name = "RDP" }; netConfig.InputEndpoints.Add(rdpEndpoint); } } if (!this.DisableWinRMHttps.IsPresent) { var netConfig = role.ConfigurationSets .OfType<NetworkConfigurationSet>() .SingleOrDefault(); if (netConfig == null) { netConfig = new NetworkConfigurationSet(); role.ConfigurationSets.Add(netConfig); } if (netConfig.InputEndpoints == null) { netConfig.InputEndpoints = new System.Collections.ObjectModel.Collection<InputEndpoint>(); } var builder = new WinRmConfigurationBuilder(); if (this.EnableWinRMHttp.IsPresent) { builder.AddHttpListener(); } builder.AddHttpsListener(this.WinRMCertificate); provisioningConfiguration.WinRM = builder.Configuration; var winRmEndpoint = new InputEndpoint {LocalPort = WinRMConstants.HttpsListenerPort, Protocol = "tcp", Name = WinRMConstants.EndpointName}; netConfig.InputEndpoints.Add(winRmEndpoint); role.WinRMCertificate = WinRMCertificate; } role.X509Certificates = new List<X509Certificate2>(); if (this.X509Certificates != null) { role.X509Certificates.AddRange(this.X509Certificates); } role.NoExportPrivateKey = this.NoExportPrivateKey.IsPresent; } WriteObject(VM, true); }
internal void ExecuteCommand() { var role = VM.GetInstance(); if (Linux.IsPresent) { var provisioningConfiguration = role.ConfigurationSets .OfType <LinuxProvisioningConfigurationSet>() .SingleOrDefault(); if (provisioningConfiguration == null) { provisioningConfiguration = new LinuxProvisioningConfigurationSet(); role.ConfigurationSets.Add(provisioningConfiguration); } SetProvisioningConfiguration(provisioningConfiguration); provisioningConfiguration.HostName = role.RoleName; if (DisableSSH.IsPresent == false || NoSSHEndpoint.IsPresent) { var netConfig = role.ConfigurationSets .OfType <NetworkConfigurationSet>() .SingleOrDefault(); if (netConfig == null) { netConfig = new NetworkConfigurationSet { InputEndpoints = new System.Collections.ObjectModel.Collection <InputEndpoint>() }; role.ConfigurationSets.Add(netConfig); } // Add check in case the settings were imported bool addSSH = true; foreach (InputEndpoint ep in netConfig.InputEndpoints) { if (string.Compare(ep.Name, "SSH", StringComparison.OrdinalIgnoreCase) == 0 || ep.LocalPort == 22) { addSSH = false; ep.Port = null; // null out to avoid conflicts break; } } if (addSSH) { InputEndpoint sshEndpoint = new InputEndpoint(); sshEndpoint.LocalPort = 22; sshEndpoint.Protocol = "tcp"; sshEndpoint.Name = "SSH"; netConfig.InputEndpoints.Add(sshEndpoint); } } } else { var provisioningConfiguration = role.ConfigurationSets .OfType <WindowsProvisioningConfigurationSet>() .SingleOrDefault(); if (provisioningConfiguration == null) { provisioningConfiguration = new WindowsProvisioningConfigurationSet(); role.ConfigurationSets.Add(provisioningConfiguration); } SetProvisioningConfiguration(provisioningConfiguration); provisioningConfiguration.ComputerName = role.RoleName; if (!NoRDPEndpoint.IsPresent) { var netConfig = role.ConfigurationSets .OfType <NetworkConfigurationSet>() .SingleOrDefault(); if (netConfig == null) { netConfig = new NetworkConfigurationSet(); role.ConfigurationSets.Add(netConfig); } if (netConfig.InputEndpoints == null) { netConfig.InputEndpoints = new System.Collections.ObjectModel.Collection <InputEndpoint>(); } bool addRDP = true; foreach (InputEndpoint ep in netConfig.InputEndpoints) { if (string.Compare(ep.Name, "RDP", StringComparison.OrdinalIgnoreCase) == 0 || ep.LocalPort == 3389) { addRDP = false; ep.Port = null; // null out to avoid conflicts break; } } if (addRDP) { InputEndpoint rdpEndpoint = new InputEndpoint { LocalPort = 3389, Protocol = "tcp", Name = "RDP" }; netConfig.InputEndpoints.Add(rdpEndpoint); } } if (!this.DisableWinRMHttps.IsPresent) { var netConfig = role.ConfigurationSets .OfType <NetworkConfigurationSet>() .SingleOrDefault(); if (netConfig == null) { netConfig = new NetworkConfigurationSet(); role.ConfigurationSets.Add(netConfig); } if (netConfig.InputEndpoints == null) { netConfig.InputEndpoints = new System.Collections.ObjectModel.Collection <InputEndpoint>(); } var builder = new WinRmConfigurationBuilder(); if (this.EnableWinRMHttp.IsPresent) { builder.AddHttpListener(); } builder.AddHttpsListener(this.WinRMCertificate); provisioningConfiguration.WinRM = builder.Configuration; var winRmEndpoint = new InputEndpoint { LocalPort = WinRMConstants.HttpsListenerPort, Protocol = "tcp", Name = WinRMConstants.EndpointName }; netConfig.InputEndpoints.Add(winRmEndpoint); role.WinRMCertificate = WinRMCertificate; } role.X509Certificates = new List <X509Certificate2>(); if (this.X509Certificates != null) { role.X509Certificates.AddRange(this.X509Certificates); } role.NoExportPrivateKey = this.NoExportPrivateKey.IsPresent; } WriteObject(VM, true); }