예제 #1
0
        protected override ClusterManifestTypeInfrastructure OnGetInfrastructure(IClusterTopology topology, IEnumerable <NodeDescription> seedNodes, IEnumerable <ClusterManifestTypeNodeType> nodeTypes)
        {
            var serverInfra = new ClusterManifestTypeInfrastructureWindowsServer {
                NodeList = new FabricNodeType[topology.Nodes.Count]
            };
            int index = 0;
            var distinctIpAddreses = new HashSet <string>();

            foreach (var node in topology.Nodes.Values)
            {
                serverInfra.NodeList[index] = new FabricNodeType()
                {
                    NodeName        = node.NodeName,
                    FaultDomain     = node.FaultDomain,
                    UpgradeDomain   = node.UpgradeDomain,
                    IPAddressOrFQDN = node.IPAddress,
                    IsSeedNode      = seedNodes.Any(seedNode => string.Equals(seedNode.NodeName, node.NodeName, StringComparison.OrdinalIgnoreCase)),
                    NodeTypeRef     = node.NodeTypeRef
                };
                distinctIpAddreses.Add(node.IPAddress);
                index++;
            }

            if (distinctIpAddreses.Count < topology.Nodes.Count)
            {
                serverInfra.IsScaleMin = true;
            }

            return(new ClusterManifestTypeInfrastructure()
            {
                Item = serverInfra
            });
        }
        public void TestRemoveSeedNodesValidation()
        {
            var clusterManifest = new ClusterManifestHelper(true, false).ClusterManifest;
            ClusterManifestTypeInfrastructureWindowsServer infra = new ClusterManifestTypeInfrastructureWindowsServer();

            infra.IsScaleMin  = true;
            infra.NodeList    = new FabricNodeType[2];
            infra.NodeList[0] = new FabricNodeType()
            {
                FaultDomain     = "fd:/RACK1",
                UpgradeDomain   = "MYUD1",
                NodeName        = "Node1",
                NodeTypeRef     = "NodeType1",
                IPAddressOrFQDN = "localhost",
                IsSeedNode      = true
            };
            infra.NodeList[1] = new FabricNodeType()
            {
                FaultDomain     = "fd:/RACK1",
                UpgradeDomain   = "MYUD1",
                NodeName        = "Node2",
                NodeTypeRef     = "NodeType1",
                IPAddressOrFQDN = "localhost",
                IsSeedNode      = true
            };
            clusterManifest.Infrastructure.Item = infra;

            var targetClusterManifest = new ClusterManifestHelper(true, false).ClusterManifest;
            ClusterManifestTypeInfrastructureWindowsServer infraT = new ClusterManifestTypeInfrastructureWindowsServer();

            infraT.IsScaleMin  = true;
            infraT.NodeList    = new FabricNodeType[1];
            infraT.NodeList[0] = new FabricNodeType()
            {
                FaultDomain     = "fd:/RACK1",
                UpgradeDomain   = "MYUD1",
                NodeName        = "Node1",
                NodeTypeRef     = "NodeType1",
                IPAddressOrFQDN = "localhost",
                IsSeedNode      = true
            };

            targetClusterManifest.Infrastructure.Item = infraT;

            var            dParameters    = new DeploymentParameters();
            Infrastructure infrastructure = Infrastructure.Create(targetClusterManifest.Infrastructure, null, targetClusterManifest.NodeTypes);

            Verify.Throws <FabricHostRestartNotRequiredException>(
                () => FabricValidatorWrapper.CompareAndAnalyze(
                    clusterManifest,
                    targetClusterManifest,
                    infrastructure,
                    dParameters));
        }
예제 #3
0
        internal static ClusterManifestTypeInfrastructureWindowsServer GetInfrastructureWindowsServerFromClusterManifest(string clusterManifestPath)
        {
            ClusterManifestType cm = XMLHelper.ReadClusterManifest(clusterManifestPath);
            ClusterManifestTypeInfrastructureWindowsServer infrastructure = cm.Infrastructure.Item as ClusterManifestTypeInfrastructureWindowsServer;

            if (infrastructure == null)
            {
                throw new InvalidOperationException("The ClusterConfig file is invalid. Only Server deployments are supported by this api");
            }

            return(infrastructure);
        }
예제 #4
0
 private static void VerifyAreEqual(ClusterManifestTypeInfrastructureWindowsServer infrastructure1, ClusterManifestTypeInfrastructureWindowsServer infrastructure2)
 {
     Assert.AreEqual(infrastructure1.IsScaleMin, infrastructure2.IsScaleMin, "Infrastructure.IsScaleMin");
     Assert.AreEqual(infrastructure1.NodeList.Length, infrastructure2.NodeList.Length, "Infrastructure.NodeList.Length");
     for (int i = 0; i < infrastructure1.NodeList.Length; i++)
     {
         FabricNodeType node1 = infrastructure1.NodeList[i];
         FabricNodeType node2 = infrastructure2.NodeList[i];
         Assert.AreEqual(node1.FaultDomain, node2.FaultDomain, string.Format(CultureInfo.InvariantCulture, "Infrastrucuture.NodeList[{0}]", i));
         Assert.AreEqual(node1.IPAddressOrFQDN, node2.IPAddressOrFQDN, string.Format(CultureInfo.InvariantCulture, "Infrastructure.NodeList[{0}].IPAddressOrFQDNL", i));
         Assert.AreEqual(node1.IsSeedNode, node2.IsSeedNode, string.Format("Infrastructure.NodeList[{0}].IsSeedNode", i));
         Assert.AreEqual(node1.NodeName, node2.NodeName, string.Format("Infrastructure.NodeList[{0}].NodeName", i));
         Assert.AreEqual(node1.NodeTypeRef, node2.NodeTypeRef, string.Format("Infrastructure.NodeList[{0}].NodeTypeRef", i));
         Assert.AreEqual(node1.UpgradeDomain, node2.UpgradeDomain, string.Format("Infrastructure.NodeList[{0}].UpgradeDomain", i));
     }
 }
예제 #5
0
        internal static List <string> GetMachineNamesFromClusterManifest(string clusterManifestPath)
        {
            List <string> machineAddresses = new List <string>();
            ClusterManifestTypeInfrastructureWindowsServer serverCm = GetInfrastructureWindowsServerFromClusterManifest(clusterManifestPath);

            foreach (FabricNodeType n in serverCm.NodeList)
            {
                machineAddresses.Add(n.IPAddressOrFQDN);
            }

            machineAddresses = machineAddresses.Distinct().ToList();
            if (machineAddresses.Count == 0)
            {
                throw new InvalidOperationException("Could not find machines in cluster manifest");
            }

            return(machineAddresses);
        }
예제 #6
0
        // The FabricSettings require some hard coding to make the generated clustermanifest exactly the same as sdk clustermanifest
        internal static void TuneGeneratedManifest(ClusterManifestType clustermanifest, List <SettingsSectionDescription> userFabricSettings)
        {
            ClusterManifestTypeInfrastructureWindowsServer winserverinfra = clustermanifest.Infrastructure.Item as ClusterManifestTypeInfrastructureWindowsServer;

            if (winserverinfra != null)
            {
                if (clustermanifest.NodeTypes.Count() == 1)
                {
                    winserverinfra.IsScaleMin = true;
                }
                else if (clustermanifest.NodeTypes.Count() == 5)
                {
                    // Manually set the last two nodes to be non-seed nodes.
                    winserverinfra.NodeList[3].IsSeedNode = false;
                    winserverinfra.NodeList[4].IsSeedNode = false;
                }
            }

            List <SettingsOverridesTypeSection> targetFabricSettings = new List <SettingsOverridesTypeSection>();
            List <string> consumerInstances = new List <string>();
            List <string> producerInstances = new List <string>();

            foreach (SettingsOverridesTypeSection sourceSetting in clustermanifest.FabricSettings)
            {
                if (IsSectionToDrop(clustermanifest.NodeTypes.Count(), sourceSetting.Name))
                {
                    continue;
                }
                else if (sourceSetting.Name == StringConstants.SectionName.Diagnostics)
                {
                    List <SettingsOverridesTypeSectionParameter> parameters = new List <SettingsOverridesTypeSectionParameter>();
                    SettingsOverridesTypeSectionParameter        param      = sourceSetting.Parameter.FirstOrDefault(x => x.Name == StringConstants.ParameterName.ConsumerInstances);
                    if (param != null)
                    {
                        foreach (string item in param.Value.Split(','))
                        {
                            consumerInstances.Add(item.Trim());
                        }
                    }

                    param = sourceSetting.Parameter.FirstOrDefault(x => x.Name == StringConstants.ParameterName.ProducerInstances);
                    if (param != null)
                    {
                        foreach (string item in param.Value.Split(','))
                        {
                            if (!item.Contains("CrashDump"))
                            {
                                producerInstances.Add(item.Trim().Replace("WinFab", "ServiceFabric"));
                            }
                            else
                            {
                                consumerInstances.Add(item.Trim().Replace("ServiceFabric", "WinFab"));
                            }
                        }

                        param.Value = string.Join(", ", producerInstances.ToArray());
                        parameters.Add(param);
                    }

                    param = sourceSetting.Parameter.FirstOrDefault(x => x.Name == StringConstants.ParameterName.MaxDiskQuotaInMb);
                    if (param != null)
                    {
                        parameters.Add(param);
                    }

                    param = sourceSetting.Parameter.FirstOrDefault(x => x.Name == StringConstants.ParameterName.EnableCircularTraceSession);
                    if (param != null)
                    {
                        parameters.Add(param);
                    }

                    sourceSetting.Parameter = parameters.ToArray();
                }
                else if (sourceSetting.Name == StringConstants.SectionName.Hosting)
                {
                    List <SettingsOverridesTypeSectionParameter> parameters = sourceSetting.Parameter.ToList();
                    SettingsOverridesTypeSectionParameter        param      = parameters.FirstOrDefault(x => x.Name == StringConstants.ParameterName.FirewallPolicyEnabled);
                    parameters.Remove(param);
                    sourceSetting.Parameter = parameters.ToArray();
                }
                else if (sourceSetting.Name == StringConstants.SectionName.Security)
                {
                    List <SettingsOverridesTypeSectionParameter> parameters = sourceSetting.Parameter.ToList();
                    foreach (string securityparam in securityParamsToDrop)
                    {
                        SettingsOverridesTypeSectionParameter param = parameters.FirstOrDefault(x => x.Name == securityparam);
                        parameters.Remove(param);
                    }

                    sourceSetting.Parameter = parameters.ToArray();
                }
                else if (sourceSetting.Name == StringConstants.SectionName.HttpApplicationGateway)
                {
                    List <SettingsOverridesTypeSectionParameter> parameters = sourceSetting.Parameter.ToList();
                    SettingsOverridesTypeSectionParameter        param      = parameters.FirstOrDefault(x => x.Name == StringConstants.ParameterName.GatewayX509CertificateStoreName);
                    parameters.Remove(param);
                    sourceSetting.Parameter = parameters.ToArray();
                }
                else if (sourceSetting.Name == StringConstants.SectionName.PlacementAndLoadBalancing)
                {
                    List <SettingsOverridesTypeSectionParameter> parameters = sourceSetting.Parameter.ToList();
                    SettingsOverridesTypeSectionParameter        param      = parameters.FirstOrDefault(x => x.Name == StringConstants.ParameterName.QuorumBasedReplicaDistributionPerUpgradeDomains);
                    parameters.Remove(param);
                    sourceSetting.Parameter = parameters.ToArray();
                }
                else if (sourceSetting.Name == StringConstants.SectionName.ClusterManager)
                {
                    List <SettingsOverridesTypeSectionParameter> parameters = sourceSetting.Parameter.ToList();
                    SettingsOverridesTypeSectionParameter        param      = parameters.FirstOrDefault(x => x.Name == StringConstants.ParameterName.EnableAutomaticBaseline);
                    parameters.Remove(param);
                    sourceSetting.Parameter = parameters.ToArray();
                }

                List <SettingsOverridesTypeSectionParameter> paramList = sourceSetting.Parameter.ToList();
                SettingsOverridesTypeSectionParameter        placementConstraintsparam = paramList.FirstOrDefault(x => x.Name == StringConstants.ParameterName.PlacementConstraints);
                paramList.Remove(placementConstraintsparam);

                SettingsOverridesTypeSectionParameter targetReplicaSetSize = paramList.FirstOrDefault(x => x.Name == StringConstants.ParameterName.TargetReplicaSetSize);
                if (targetReplicaSetSize != null)
                {
                    targetReplicaSetSize.Value = Math.Min(Convert.ToInt32(targetReplicaSetSize.Value), 3).ToString();
                }

                sourceSetting.Parameter = paramList.ToArray();

                targetFabricSettings.Add(sourceSetting);
            }

            ApplyParamOverride(targetFabricSettings, clustermanifest.NodeTypes.Count(), IsSecureCluster(clustermanifest.FabricSettings), IsWin7());

            foreach (string settingName in consumerInstances)
            {
                SettingsOverridesTypeSection item = targetFabricSettings.FirstOrDefault(x => x.Name == settingName);
                targetFabricSettings.Remove(item);
            }

            foreach (string settingName in producerInstances)
            {
                SettingsOverridesTypeSection settingLegacy = targetFabricSettings.FirstOrDefault(x => x.Name == settingName.Replace("ServiceFabric", "WinFab"));
                if (settingLegacy == null)
                {
                    continue;
                }

                SettingsOverridesTypeSection settingNew = targetFabricSettings.FirstOrDefault(x => x.Name == settingName);

                if (settingNew == null)
                {
                    settingLegacy.Name = settingName;

                    SettingsOverridesTypeSectionParameter param = settingLegacy.Parameter.FirstOrDefault(x => x.Name == StringConstants.ParameterName.FolderType);
                    if (param != null)
                    {
                        param.Value = param.Value.Replace("WindowsFabric", "ServiceFabric");
                    }
                }
                else
                {
                    List <SettingsOverridesTypeSectionParameter> paramNewList = settingNew.Parameter.ToList();
                    foreach (SettingsOverridesTypeSectionParameter paramLegacy in settingLegacy.Parameter)
                    {
                        SettingsOverridesTypeSectionParameter param = paramNewList.FirstOrDefault(x => x.Name == paramLegacy.Name);
                        if (param == null)
                        {
                            paramNewList.Add(paramLegacy);
                        }
                    }

                    targetFabricSettings.Remove(settingLegacy);
                }
            }

            ApplyUserSettings(targetFabricSettings, userFabricSettings);
            clustermanifest.FabricSettings = targetFabricSettings.ToArray();
        }
예제 #7
0
        private void InitializeInfrastructureSettings(InfrastructureType infrastructureType, bool isScaleMin, int nNodeTypes, int[] nSeedNodes)
        {
            switch (infrastructureType)
            {
            case InfrastructureType.Blackbird:
                return;

            case InfrastructureType.VMM:
                return;

            case InfrastructureType.PaaS:
                var paasInfra = new ClusterManifestTypeInfrastructurePaaS();
                paasInfra.Roles = new PaaSRoleType[nNodeTypes];
                for (int i = 0; i < nNodeTypes; i++)
                {
                    paasInfra.Roles[i]               = new PaaSRoleType();
                    paasInfra.Roles[i].RoleName      = GetRoleOrTiername(i);
                    paasInfra.Roles[i].NodeTypeRef   = GetRoleOrTiername(i);
                    paasInfra.Roles[i].RoleNodeCount = nSeedNodes[i];
                }
                var paasVotes = new List <PaaSVoteType>();
                foreach (var node in this.infraNodes)
                {
                    if (node.IsSeedNode)
                    {
                        paasVotes.Add(new PaaSVoteType()
                        {
                            NodeName        = node.NodeName,
                            IPAddressOrFQDN = node.IPAddressOrFQDN,
                            Port            = Convert.ToInt32(node.Endpoints.ClusterConnectionEndpoint.Port)
                        });
                    }
                }
                paasInfra.Votes          = paasVotes.ToArray();
                this.infrastructure      = new ClusterManifestTypeInfrastructure();
                this.infrastructure.Item = paasInfra;
                return;

            case InfrastructureType.WindowsAzure:
                var azureInfra = new ClusterManifestTypeInfrastructureWindowsAzure();
                azureInfra.Roles = new AzureRoleType[nNodeTypes];
                for (int i = 0; i < nNodeTypes; i++)
                {
                    azureInfra.Roles[i]               = new AzureRoleType();
                    azureInfra.Roles[i].RoleName      = GetRoleOrTiername(i);
                    azureInfra.Roles[i].NodeTypeRef   = GetRoleOrTiername(i);
                    azureInfra.Roles[i].SeedNodeCount = nSeedNodes[i];
                }
                this.infrastructure      = new ClusterManifestTypeInfrastructure();
                this.infrastructure.Item = azureInfra;
                return;

            case InfrastructureType.WindowsServer:
                var infra = new ClusterManifestTypeInfrastructureWindowsServer();
                infra.IsScaleMin         = isScaleMin;
                infra.NodeList           = this.nodes;
                this.infrastructure      = new ClusterManifestTypeInfrastructure();
                this.infrastructure.Item = infra;
                return;
            }
        }
예제 #8
0
        private void GenerateValidClusterManifest(InfrastructureType infaType)
        {
            this.ClusterManifest                = new ClusterManifestType();
            this.ClusterManifest.Name           = "TestClusterManifestAllSettings";
            this.ClusterManifest.Version        = "1.0";
            this.ClusterManifest.Infrastructure = new ClusterManifestTypeInfrastructure();

            if (infaType == InfrastructureType.WindowsServer)
            {
                ClusterManifestTypeInfrastructureWindowsServer infra =
                    new ClusterManifestTypeInfrastructureWindowsServer();
                infra.IsScaleMin  = false;
                infra.NodeList    = new FabricNodeType[1];
                infra.NodeList[0] = new FabricNodeType()
                {
                    FaultDomain     = "fd:/RACK1",
                    UpgradeDomain   = "MYUD1",
                    NodeName        = "Node1",
                    NodeTypeRef     = "NodeType1",
                    IPAddressOrFQDN = "localhost",
                    IsSeedNode      = true
                };

                this.ClusterManifest.Infrastructure.Item = infra;
            }
            else
            {
                ClusterManifestTypeInfrastructurePaaS infra = new ClusterManifestTypeInfrastructurePaaS();
                infra.Roles = new PaaSRoleType[]
                {
                    new PaaSRoleType()
                    {
                        NodeTypeRef = "NodeType1", RoleName = "NodeType1", RoleNodeCount = 5
                    }
                };

                infra.Votes = new PaaSVoteType[]
                {
                    new PaaSVoteType()
                    {
                        IPAddressOrFQDN = "10.0.0.1", NodeName = "_NodeType1_0", Port = 19005
                    },
                    new PaaSVoteType()
                    {
                        IPAddressOrFQDN = "10.0.0.2", NodeName = "_NodeType1_1", Port = 19005
                    },
                    new PaaSVoteType()
                    {
                        IPAddressOrFQDN = "10.0.0.3", NodeName = "_NodeType1_2", Port = 19005
                    }
                };

                this.ClusterManifest.Infrastructure.Item = infra;
            }


            this.ClusterManifest.NodeTypes              = new ClusterManifestTypeNodeType[1];
            this.ClusterManifest.NodeTypes[0]           = new ClusterManifestTypeNodeType();
            this.ClusterManifest.NodeTypes[0].Name      = "NodeType1";
            this.ClusterManifest.NodeTypes[0].Endpoints = new FabricEndpointsType()
            {
                ClientConnectionEndpoint = new InputEndpointType()
                {
                    Port = "19000"
                },
                LeaseDriverEndpoint = new InternalEndpointType()
                {
                    Port = "19001"
                },
                ClusterConnectionEndpoint = new InternalEndpointType()
                {
                    Port = "19002"
                },
                ServiceConnectionEndpoint = new InternalEndpointType()
                {
                    Port = "19003"
                },
                HttpGatewayEndpoint = new InputEndpointType()
                {
                    Port = "19004"
                },
                ApplicationEndpoints = new FabricEndpointsTypeApplicationEndpoints()
                {
                    StartPort = 30001, EndPort = 31000
                },
            };

            this.ClusterManifest.FabricSettings = new SettingsOverridesTypeSection[3];
            List <SettingsOverridesTypeSectionParameter> parameters = new List <SettingsOverridesTypeSectionParameter>();

            parameters.Add(new SettingsOverridesTypeSectionParameter()
            {
                Name = FabricValidatorConstants.ParameterNames.ClusterCredentialType, Value = "None", IsEncrypted = false
            });
            parameters.Add(new SettingsOverridesTypeSectionParameter()
            {
                Name = FabricValidatorConstants.ParameterNames.ServerAuthCredentialType, Value = "None", IsEncrypted = false
            });
            this.ClusterManifest.FabricSettings[0] = new SettingsOverridesTypeSection()
            {
                Name = FabricValidatorConstants.SectionNames.Security, Parameter = parameters.ToArray()
            };
            parameters = new List <SettingsOverridesTypeSectionParameter>();
            parameters.Add(new SettingsOverridesTypeSectionParameter()
            {
                Name = "ExpectedClustersize", Value = "1", IsEncrypted = false
            });
            this.ClusterManifest.FabricSettings[1] = new SettingsOverridesTypeSection()
            {
                Name = "FailoverManager", Parameter = parameters.ToArray()
            };
            parameters = new List <SettingsOverridesTypeSectionParameter>();
            parameters.Add(new SettingsOverridesTypeSectionParameter()
            {
                Name = "ImageStoreConnectionString", Value = "_default_", IsEncrypted = false
            });
            this.ClusterManifest.FabricSettings[2] = new SettingsOverridesTypeSection()
            {
                Name = "Management", Parameter = parameters.ToArray()
            };
        }