private PersistentVMRole CreatePersistenVMRole(PersistentVM persistentVM, CloudStorageAccount currentStorage) { var mediaLinkFactory = new MediaLinkFactory(currentStorage, this.ServiceName, persistentVM.RoleName); if (persistentVM.OSVirtualHardDisk.MediaLink == null && string.IsNullOrEmpty(persistentVM.OSVirtualHardDisk.DiskName)) { persistentVM.OSVirtualHardDisk.MediaLink = mediaLinkFactory.Create(); } foreach (DataVirtualHardDisk datadisk in persistentVM.DataVirtualHardDisks.Where(d => d.MediaLink == null && string.IsNullOrEmpty(d.DiskName))) { datadisk.MediaLink = mediaLinkFactory.Create(); } return new PersistentVMRole { AvailabilitySetName = persistentVM.AvailabilitySetName, ConfigurationSets = persistentVM.ConfigurationSets, DataVirtualHardDisks = persistentVM.DataVirtualHardDisks, OSVirtualHardDisk = persistentVM.OSVirtualHardDisk, RoleName = persistentVM.RoleName, RoleSize = persistentVM.RoleSize, RoleType = persistentVM.RoleType, Label = persistentVM.Label }; }
private PersistentVMRole CreatePersistenVMRole(CloudStorageAccount currentStorage) { var vm = new PersistentVMRole { AvailabilitySetName = AvailabilitySetName, ConfigurationSets = new Collection<ConfigurationSet>(), DataVirtualHardDisks = new Collection<DataVirtualHardDisk>(), RoleName = String.IsNullOrEmpty(Name) ? ServiceName : Name, // default like the portal RoleSize = String.IsNullOrEmpty(InstanceSize) ? null : InstanceSize, RoleType = "PersistentVMRole", Label = ServiceName, OSVirtualHardDisk = new OSVirtualHardDisk { DiskName = null, SourceImageName = ImageName, MediaLink = string.IsNullOrEmpty(MediaLocation) ? null : new Uri(MediaLocation), HostCaching = HostCaching } }; if (vm.OSVirtualHardDisk.MediaLink == null && String.IsNullOrEmpty(vm.OSVirtualHardDisk.DiskName)) { var mediaLinkFactory = new MediaLinkFactory(currentStorage, this.ServiceName, vm.RoleName); vm.OSVirtualHardDisk.MediaLink = mediaLinkFactory.Create(); } var netConfig = CreateNetworkConfigurationSet(); if (ParameterSetName.Equals("Windows", StringComparison.OrdinalIgnoreCase)) { var windowsConfig = new WindowsProvisioningConfigurationSet { AdminUsername = this.AdminUsername, AdminPassword = Password, ComputerName = string.IsNullOrEmpty(Name) ? ServiceName : Name, EnableAutomaticUpdates = true, ResetPasswordOnFirstLogon = false, StoredCertificateSettings = CertUtils.GetCertificateSettings(this.Certificates, this.X509Certificates), WinRM = GetWinRmConfiguration() }; netConfig.InputEndpoints.Add(new InputEndpoint {LocalPort = 3389, Protocol = "tcp", Name = "RemoteDesktop"}); if (!this.NoWinRMEndpoint.IsPresent && !this.DisableWinRMHttps.IsPresent) { netConfig.InputEndpoints.Add(new InputEndpoint {LocalPort = WinRMConstants.HttpsListenerPort, Protocol = "tcp", Name = WinRMConstants.EndpointName}); } vm.ConfigurationSets.Add(windowsConfig); vm.ConfigurationSets.Add(netConfig); } else { var linuxConfig = new LinuxProvisioningConfigurationSet { HostName = string.IsNullOrEmpty(this.Name) ? this.ServiceName : this.Name, UserName = this.LinuxUser, UserPassword = this.Password, DisableSshPasswordAuthentication = false }; if (this.SSHKeyPairs != null && this.SSHKeyPairs.Count > 0 || this.SSHPublicKeys != null && this.SSHPublicKeys.Count > 0) { linuxConfig.SSH = new LinuxProvisioningConfigurationSet.SSHSettings { PublicKeys = this.SSHPublicKeys, KeyPairs = this.SSHKeyPairs }; } var rdpEndpoint = new InputEndpoint {LocalPort = 22, Protocol = "tcp", Name = "SSH"}; netConfig.InputEndpoints.Add(rdpEndpoint); vm.ConfigurationSets.Add(linuxConfig); vm.ConfigurationSets.Add(netConfig); } return vm; }
private PersistentVMRole CreatePersistenVMRole(CloudStorageAccount currentStorage) { var vm = new PersistentVMRole { AvailabilitySetName = AvailabilitySetName, ConfigurationSets = new Collection <ConfigurationSet>(), DataVirtualHardDisks = new Collection <DataVirtualHardDisk>(), RoleName = String.IsNullOrEmpty(Name) ? ServiceName : Name, // default like the portal RoleSize = String.IsNullOrEmpty(InstanceSize) ? null : InstanceSize, RoleType = "PersistentVMRole", Label = ServiceName, OSVirtualHardDisk = new OSVirtualHardDisk { DiskName = null, SourceImageName = ImageName, MediaLink = string.IsNullOrEmpty(MediaLocation) ? null : new Uri(MediaLocation), HostCaching = HostCaching } }; if (vm.OSVirtualHardDisk.MediaLink == null && String.IsNullOrEmpty(vm.OSVirtualHardDisk.DiskName)) { var mediaLinkFactory = new MediaLinkFactory(currentStorage, this.ServiceName, vm.RoleName); vm.OSVirtualHardDisk.MediaLink = mediaLinkFactory.Create(); } var netConfig = CreateNetworkConfigurationSet(); if (ParameterSetName.Equals("Windows", StringComparison.OrdinalIgnoreCase)) { var windowsConfig = new WindowsProvisioningConfigurationSet { AdminUsername = this.AdminUsername, AdminPassword = Password, ComputerName = string.IsNullOrEmpty(Name) ? ServiceName : Name, EnableAutomaticUpdates = true, ResetPasswordOnFirstLogon = false, StoredCertificateSettings = CertUtils.GetCertificateSettings(this.Certificates, this.X509Certificates), WinRM = GetWinRmConfiguration() }; netConfig.InputEndpoints.Add(new InputEndpoint { LocalPort = 3389, Protocol = "tcp", Name = "RemoteDesktop" }); if (!this.NoWinRMEndpoint.IsPresent && !this.DisableWinRMHttps.IsPresent) { netConfig.InputEndpoints.Add(new InputEndpoint { LocalPort = WinRMConstants.HttpsListenerPort, Protocol = "tcp", Name = WinRMConstants.EndpointName }); } vm.ConfigurationSets.Add(windowsConfig); vm.ConfigurationSets.Add(netConfig); } else { var linuxConfig = new LinuxProvisioningConfigurationSet { HostName = string.IsNullOrEmpty(this.Name) ? this.ServiceName : this.Name, UserName = this.LinuxUser, UserPassword = this.Password, DisableSshPasswordAuthentication = false }; if (this.SSHKeyPairs != null && this.SSHKeyPairs.Count > 0 || this.SSHPublicKeys != null && this.SSHPublicKeys.Count > 0) { linuxConfig.SSH = new LinuxProvisioningConfigurationSet.SSHSettings { PublicKeys = this.SSHPublicKeys, KeyPairs = this.SSHKeyPairs }; } var rdpEndpoint = new InputEndpoint { LocalPort = 22, Protocol = "tcp", Name = "SSH" }; netConfig.InputEndpoints.Add(rdpEndpoint); vm.ConfigurationSets.Add(linuxConfig); vm.ConfigurationSets.Add(netConfig); } return(vm); }
private PersistentVMRole CreatePersistentVMRole(PersistentVM persistentVM, CloudStorageAccount currentStorage) { if (!string.IsNullOrEmpty(persistentVM.OSVirtualHardDisk.DiskName) && !NetworkConfigurationSetBuilder.HasNetworkConfigurationSet(persistentVM.ConfigurationSets)) { var networkConfigurationSetBuilder = new NetworkConfigurationSetBuilder(persistentVM.ConfigurationSets); Disk disk = this.Channel.GetDisk(CurrentSubscription.SubscriptionId, persistentVM.OSVirtualHardDisk.DiskName); if (disk.OS == OS.Windows && !persistentVM.NoRDPEndpoint) { networkConfigurationSetBuilder.AddRdpEndpoint(); } else if (disk.OS == OS.Linux && !persistentVM.NoSSHEndpoint) { networkConfigurationSetBuilder.AddSshEndpoint(); } } var mediaLinkFactory = new MediaLinkFactory(currentStorage, this.ServiceName, persistentVM.RoleName); if (persistentVM.OSVirtualHardDisk.MediaLink == null && string.IsNullOrEmpty(persistentVM.OSVirtualHardDisk.DiskName)) { persistentVM.OSVirtualHardDisk.MediaLink = mediaLinkFactory.Create(); } foreach (DataVirtualHardDisk datadisk in persistentVM.DataVirtualHardDisks.Where(d => d.MediaLink == null && string.IsNullOrEmpty(d.DiskName))) { datadisk.MediaLink = mediaLinkFactory.Create(); } return new PersistentVMRole { AvailabilitySetName = persistentVM.AvailabilitySetName, ConfigurationSets = persistentVM.ConfigurationSets, DataVirtualHardDisks = persistentVM.DataVirtualHardDisks, OSVirtualHardDisk = persistentVM.OSVirtualHardDisk, RoleName = persistentVM.RoleName, RoleSize = persistentVM.RoleSize, RoleType = persistentVM.RoleType, Label = persistentVM.Label }; }