private static void PopulateRequiredFields(SenderLookupInfo senderInfo, Dictionary <string, string> infoKeysWithGroupTypes, string thirdPartyType, List <KeyValuePairType> fldValues, List <string> reqFld) { foreach (var key in reqFld) { KeyValuePairType newFldVal = FromSenderInfo(senderInfo, key); if (newFldVal == null) { if (key == InfoKeyNames.thirdParty_Sender_Type) //TODO: Verify whether ThirdPartyType.NONE/null works. { newFldVal = GetFieldValueItem(key, thirdPartyType ?? TestThirdPartyType.None); } else if (infoKeysWithGroupTypes.Keys.Contains(key) && (infoKeysWithGroupTypes[key] == InfoKeyGroups.PersonalIdNumber)) { var correspondingIdTypeInfoKey = key.Substring(0, key.LastIndexOf("_") + 1) + "Type"; var idType = fldValues.FirstOrDefault(x => x.InfoKey == correspondingIdTypeInfoKey).Value; newFldVal = GetFieldValueItem(key, DataGenerator.PersonalIdNumber(idType)); } else { newFldVal = GetFieldValueItem(key, infoKeysWithGroupTypes.Keys.Contains(key) ? DataGenerator.GetRandomData(infoKeysWithGroupTypes[key]) : string.Empty); } } fldValues.Add(newFldVal); } }
private static KeyValuePairType FromSenderInfo(SenderLookupInfo senderInfo, string reqInfoKey) { KeyValuePairType currVal = senderInfo.CurrentValues.Exists(x => x.InfoKey == reqInfoKey) ? senderInfo.CurrentValues.First(x => x.InfoKey == reqInfoKey) : null; return(currVal); }
private static KeyValuePairType FromTransactionLookupResponsePayload(TransactionLookupResponsePayload transactionLookupResponsePayload, string reqInfoKey) { KeyValuePairType currVal = transactionLookupResponsePayload.CurrentValues.Exists(x => x.InfoKey == reqInfoKey) ? transactionLookupResponsePayload.CurrentValues.First(x => x.InfoKey == reqInfoKey) : null; return(currVal); }
private ClusterManifestTypeNodeType GetCMNodeTypeFromNodeDescription(NodeTypeDescription nodeTypeDescription) { 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.ToString(), Protocol = InternalEndpointTypeProtocol.tcp }; nodeType.Endpoints.LeaseDriverEndpoint = new InternalEndpointType() { Port = nodeTypeDescription.LeaseDriverEndpointPort.ToString(), Protocol = InternalEndpointTypeProtocol.tcp }; nodeType.Endpoints.ServiceConnectionEndpoint = new InternalEndpointType() { Port = 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(); } return(nodeType); }
private void AddNodeProperties(ClusterManifestTypeNodeType nodeType) { List <SettingsTypeSectionParameter> parameters = GetSectionProperties(nodeType.PlacementProperties); if (parameters != null) { this.Settings.Add(new SettingsTypeSection() { Name = Constants.SectionNames.NodeProperties, Parameter = parameters.ToArray() }); } parameters = GetSectionProperties(nodeType.Capacities); if (parameters != null) { this.Settings.Add(new SettingsTypeSection() { Name = Constants.SectionNames.NodeCapacities, Parameter = parameters.ToArray() }); } parameters = GetSectionProperties(nodeType.SfssRgPolicies); if (parameters != null) { this.Settings.Add(new SettingsTypeSection() { Name = Constants.SectionNames.NodeSfssRgPolicies, Parameter = parameters.ToArray() }); } if (nodeType.LogicalDirectories != null) { List <KeyValuePairType> logicalApplicationDirectories = new List <KeyValuePairType>(); List <KeyValuePairType> logicalNodeDirectories = new List <KeyValuePairType>(); foreach (var dir in nodeType.LogicalDirectories) { KeyValuePairType pair = new KeyValuePairType { Name = dir.LogicalDirectoryName, Value = dir.MappedTo }; if (dir.Context == LogicalDirectoryTypeContext.application) { logicalApplicationDirectories.Add(pair); } else { logicalNodeDirectories.Add(pair); } } if (logicalApplicationDirectories.Count > 0) { parameters = GetSectionProperties(logicalApplicationDirectories.ToArray()); if (parameters != null && parameters.Count > 0) { this.Settings.Add(new SettingsTypeSection() { Name = Constants.SectionNames.LogicalApplicationDirectories, Parameter = parameters.ToArray() }); } } if (logicalNodeDirectories.Count > 0) { parameters = GetSectionProperties(logicalNodeDirectories.ToArray()); if (parameters != null && parameters.Count > 0) { this.Settings.Add(new SettingsTypeSection() { Name = Constants.SectionNames.LogicalNodeDirectories, Parameter = parameters.ToArray() }); } } } #if false parameters = GetSectionProperties(nodeType.CapacityRatios); if (parameters != null) { this.Settings.Add(new SettingsTypeSection() { Name = FabricValidatorConstants.SectionNames.NodeCapacityRatios, Parameter = parameters.ToArray() }); } #endif }
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); }