public LogicalDirectoryType ToLogicalDirectoryType() { LogicalDirectoryType logicalDirectory = new LogicalDirectoryType() { LogicalDirectoryName = this.LogicalDirectoryName, MappedTo = this.MappedTo, Context = this.Context }; return(logicalDirectory); }
public ClusterManifestTypeNodeType ToClusterManifestTypeNodeType() { var endpoints = new FabricEndpointsType() { ClientConnectionEndpoint = new InputEndpointType() { Port = this.ClientConnectionEndpointPort.ToString(), Protocol = InputEndpointTypeProtocol.tcp }, HttpGatewayEndpoint = new InputEndpointType() { Port = this.HttpGatewayEndpointPort.ToString(), Protocol = InputEndpointTypeProtocol.http }, }; if (this.HttpApplicationGatewayEndpointPort != null) { endpoints.HttpApplicationGatewayEndpoint = new InputEndpointType() { Port = this.HttpApplicationGatewayEndpointPort.ToString(), Protocol = InputEndpointTypeProtocol.http }; } LogicalDirectoryType[] logicalDirectories = null; if (this.LogicalDirectories != null && this.LogicalDirectories.Length > 0) { logicalDirectories = new LogicalDirectoryType[this.LogicalDirectories.Count()]; var i = 0; foreach (var dir in this.LogicalDirectories) { logicalDirectories[i++] = dir.ToLogicalDirectoryType(); } } return(new ClusterManifestTypeNodeType() { Name = this.Name, PlacementProperties = (this.PlacementProperties == null) ? null : this.PlacementProperties.Select( property => new KeyValuePairType() { Name = property.Key, Value = property.Value }).ToArray(), Capacities = (this.Capacities == null) ? null : this.Capacities.Select( capacity => new KeyValuePairType() { Name = capacity.Key, Value = capacity.Value }).ToArray(), SfssRgPolicies = (this.SfssRgPolicies == null) ? null : this.SfssRgPolicies.Select( rgPolicy => new KeyValuePairType() { Name = rgPolicy.Key, Value = rgPolicy.Value }).ToArray(), Endpoints = endpoints, KtlLoggerSettings = (this.KtlLogger == null) ? null : this.KtlLogger.ToFabricKtlLoggerSettingsType(), LogicalDirectories = logicalDirectories }); }
protected IEnumerable <ClusterManifestTypeNodeType> GetNodeTypes( IEnumerable <NodeTypeDescription> nodeTypeDescriptions, Security security, ClusterManifestType existingClusterManifestType = null) { //// TODO: Implement smarter port selection to avoid conflicts with ports specified by the user var result = new List <ClusterManifestTypeNodeType>(); foreach (var nodeTypeDescription in nodeTypeDescriptions) { ClusterManifestTypeNodeType matchigExistingNodeType = null; if (existingClusterManifestType != null) { matchigExistingNodeType = existingClusterManifestType.NodeTypes.FirstOrDefault( existingNodeType => existingNodeType.Name.Equals(nodeTypeDescription.Name)); } var clusterConnectionEndpointPort = matchigExistingNodeType == null ? this.ClusterManifestGeneratorSettings.ClusterConnectionEndpointPort.ToString() : matchigExistingNodeType.Endpoints.ClusterConnectionEndpoint.Port; var leaseDriverEndpointPort = matchigExistingNodeType == null ? this.ClusterManifestGeneratorSettings.LeaseDriverEndpointPort.ToString() : matchigExistingNodeType.Endpoints.LeaseDriverEndpoint.Port; var serviceConnectionEndpointPort = matchigExistingNodeType == null ? this.ClusterManifestGeneratorSettings.ServiceConnectionEndpointPort.ToString() : matchigExistingNodeType.Endpoints.ServiceConnectionEndpoint.Port; var nodeType = nodeTypeDescription.ToClusterManifestTypeNodeType(); var defaultPlacementProperty = new KeyValuePairType() { Name = StringConstants.DefaultPlacementConstraintsKey, Value = nodeType.Name }; if (nodeType.PlacementProperties == null) { nodeType.PlacementProperties = new[] { defaultPlacementProperty }; } else { var existingPlacementProperties = nodeType.PlacementProperties.ToList(); existingPlacementProperties.Add(defaultPlacementProperty); nodeType.PlacementProperties = existingPlacementProperties.ToArray(); } nodeType.Endpoints.ClusterConnectionEndpoint = new InternalEndpointType() { Port = nodeTypeDescription.ClusterConnectionEndpointPort == 0 ? clusterConnectionEndpointPort : nodeTypeDescription.ClusterConnectionEndpointPort.ToString(), Protocol = InternalEndpointTypeProtocol.tcp }; nodeType.Endpoints.LeaseDriverEndpoint = new InternalEndpointType() { Port = nodeTypeDescription.LeaseDriverEndpointPort == 0 ? leaseDriverEndpointPort : nodeTypeDescription.LeaseDriverEndpointPort.ToString(), Protocol = InternalEndpointTypeProtocol.tcp }; nodeType.Endpoints.ServiceConnectionEndpoint = new InternalEndpointType() { Port = nodeTypeDescription.ServiceConnectionEndpointPort == 0 ? serviceConnectionEndpointPort : nodeTypeDescription.ServiceConnectionEndpointPort.ToString(), Protocol = InternalEndpointTypeProtocol.tcp }; nodeType.Endpoints.ApplicationEndpoints = new FabricEndpointsTypeApplicationEndpoints() { StartPort = nodeTypeDescription.ApplicationPorts.StartPort, EndPort = nodeTypeDescription.ApplicationPorts.EndPort }; if (nodeTypeDescription.EphemeralPorts != null) { nodeType.Endpoints.EphemeralEndpoints = new FabricEndpointsTypeEphemeralEndpoints() { StartPort = nodeTypeDescription.EphemeralPorts.StartPort, EndPort = nodeTypeDescription.EphemeralPorts.EndPort }; } if (nodeTypeDescription.KtlLogger != null) { nodeType.KtlLoggerSettings = nodeTypeDescription.KtlLogger.ToFabricKtlLoggerSettingsType(); } if (nodeTypeDescription.LogicalDirectories != null && nodeTypeDescription.LogicalDirectories.Length > 0) { LogicalDirectoryType[] logicalDirectories = new LogicalDirectoryType[nodeTypeDescription.LogicalDirectories.Count()]; var i = 0; foreach (var dir in nodeTypeDescription.LogicalDirectories) { logicalDirectories[i++] = dir.ToLogicalDirectoryType(); } nodeType.LogicalDirectories = logicalDirectories; } if (security != null && security.CertificateInformation != null && (security.CertificateInformation.ClusterCertificate != null || security.CertificateInformation.ClusterCertificateCommonNames != null || security.CertificateInformation.ServerCertificate != null || security.CertificateInformation.ServerCertificateCommonNames != null)) { nodeType.Endpoints.HttpGatewayEndpoint.Protocol = InputEndpointTypeProtocol.https; FabricCertificateType clusterCertificate = null; FabricCertificateType serverCertificate = null; if (security.CertificateInformation.ClusterCertificate != null) { clusterCertificate = security.CertificateInformation.ClusterCertificate.ToFabricCertificateType(); } else if (security.CertificateInformation.ClusterCertificateCommonNames != null) { clusterCertificate = security.CertificateInformation.ClusterCertificateCommonNames.ToFabricCertificateType(); } if (security.CertificateInformation.ServerCertificate != null) { serverCertificate = security.CertificateInformation.ServerCertificate.ToFabricCertificateType(); } else if (security.CertificateInformation.ServerCertificateCommonNames != null) { serverCertificate = security.CertificateInformation.ServerCertificateCommonNames.ToFabricCertificateType(); } nodeType.Certificates = new CertificatesType() { ClientCertificate = clusterCertificate != null ? clusterCertificate : serverCertificate, ClusterCertificate = clusterCertificate, ServerCertificate = serverCertificate }; } if (nodeType.Endpoints.HttpApplicationGatewayEndpoint != null && this.TargetCsmConfig.Security != null && this.TargetCsmConfig.Security.CertificateInformation != null && (this.TargetCsmConfig.Security.CertificateInformation.ReverseProxyCertificate != null || (this.TargetCsmConfig.Security.CertificateInformation.ReverseProxyCertificateCommonNames != null && this.TargetCsmConfig.Security.CertificateInformation.ReverseProxyCertificateCommonNames.Any()))) { nodeType.Endpoints.HttpApplicationGatewayEndpoint.Protocol = InputEndpointTypeProtocol.https; } result.Add(nodeType); } return(result); }