private void DumpResourceIpAddress(AmClusterResource resource, string typeName) { this.m_indentlevel += 1U; this.WriteLine("Address = [{0}]", new object[] { resource.GetPrivateProperty <string>("Address") }); if (SharedHelper.StringIEquals(typeName, "IP Address")) { this.m_indentlevel += 1U; this.WriteLine("EnableDhcp = [{0}]", new object[] { resource.GetPrivateProperty <int>("EnableDhcp") }); this.m_indentlevel -= 1U; } string networkNameFromIpResource = AmClusterResourceHelper.GetNetworkNameFromIpResource(null, resource); this.m_indentlevel += 1U; this.WriteLine("Network = [{0}]", new object[] { networkNameFromIpResource }); this.m_indentlevel -= 1U; this.m_indentlevel -= 1U; }
// Token: 0x060008AF RID: 2223 RVA: 0x00029954 File Offset: 0x00027B54 internal static bool IsQuorumTypeFileShareWitness(IAmCluster cluster) { using (AmClusterResource amClusterResource = cluster.OpenQuorumResource()) { if (amClusterResource != null && amClusterResource.GetTypeName() == "File Share Witness") { return(true); } } return(false); }
// Token: 0x060008AE RID: 2222 RVA: 0x00029798 File Offset: 0x00027998 internal static void RevertToMnsQuorum(ILogTraceHelper output, IAmCluster cluster) { using (IAmClusterGroup amClusterGroup = cluster.FindCoreClusterGroup()) { string text; uint maxLogSize; string quorumResourceInformation = cluster.GetQuorumResourceInformation(out text, out maxLogSize); if (string.IsNullOrEmpty(quorumResourceInformation)) { output.AppendLogMessage("RevertToMnsQuorum: It's already using MNS!", new object[0]); using (IAmClusterResource amClusterResource = amClusterGroup.FindResourceByTypeName("File Share Witness")) { if (amClusterResource != null) { output.AppendLogMessage("Even though the quorum is set to MNS, there is a FSW resource present named '{0}', which will be deleted shortly.", new object[] { amClusterResource.Name }); amClusterResource.DeleteResource(); output.AppendLogMessage("The resource has been deleted!", new object[0]); } goto IL_13D; } } using (AmClusterResource amClusterResource2 = cluster.OpenResource(quorumResourceInformation)) { output.AppendLogMessage("Setting cluster quorum to MNS", new object[0]); if (cluster.CnoName == string.Empty) { cluster.ClearQuorumResource(); } else { using (IAmClusterResource amClusterResource3 = amClusterGroup.FindResourceByTypeName("Network Name")) { output.AppendLogMessage("Setting cluster quorum resource to the netname resource (i.e. MNS quorum).", new object[0]); cluster.SetQuorumResource(amClusterResource3, null, maxLogSize); if (amClusterResource2 != null && amClusterResource2.GetTypeName() == "File Share Witness") { output.AppendLogMessage("Offlining and deleting the old FSW resource '{0}'.", new object[] { quorumResourceInformation }); amClusterResource2.OfflineResource(); amClusterResource2.DeleteResource(); } } } } IL_13D :; } }
private void DumpResourceNetName(AmClusterResource resource) { this.m_indentlevel += 1U; this.WriteLine("NetName = [{0}]", new object[] { resource.GetPrivateProperty <string>("Name") }); int privateProperty = resource.GetPrivateProperty <int>("RequireKerberos"); if (privateProperty != 0) { this.m_indentlevel += 1U; this.WriteLine("RequireKerberos = 1. Computer account created on DC '{0}'.", new object[] { resource.GetPrivateProperty <string>("CreatingDC") }); this.m_indentlevel -= 1U; } this.m_indentlevel -= 1U; }
private void DumpResource(AmClusterResource resource) { string typeName = resource.GetTypeName(); List <string> list = new List <string>(resource.EnumeratePossibleOwnerNames()); string text = string.Join(",", list.ToArray()); this.WriteLine("Resource: {0} [{1}, type = {2}, PossibleOwners = {3} ]", new object[] { resource.Name, resource.GetState(), typeName, text }); if (SharedHelper.StringIEquals(typeName, "IP Address") || SharedHelper.StringIEquals(typeName, "IPv6 Address")) { this.DumpResourceIpAddress(resource, typeName); return; } if (SharedHelper.StringIEquals(typeName, "Network Name")) { this.DumpResourceNetName(resource); } }
protected override void WriteResult(IConfigurable dataObject) { TaskLogger.LogEnter(new object[] { dataObject.Identity, dataObject }); DatabaseAvailabilityGroup databaseAvailabilityGroup = (DatabaseAvailabilityGroup)dataObject; if (this.Status && !databaseAvailabilityGroup.IsDagEmpty()) { List <ADObjectId> list = new List <ADObjectId>(8); List <ADObjectId> list2 = new List <ADObjectId>(8); AmCluster amCluster = null; try { amCluster = AmCluster.OpenDagClus(databaseAvailabilityGroup); } catch (ClusterException exception) { base.WriteError(exception, ErrorCategory.InvalidArgument, null); } if (amCluster != null) { using (amCluster) { foreach (IAmClusterNode amClusterNode in amCluster.EnumerateNodes()) { using (amClusterNode) { AmNodeState state = amClusterNode.GetState(false); if (AmClusterNode.IsNodeUp(state)) { ADObjectId adobjectId = DagTaskHelper.FindServerAdObjectIdInDag(databaseAvailabilityGroup, amClusterNode.Name); if (adobjectId != null) { list.Add(adobjectId); if (state == AmNodeState.Paused) { list2.Add(adobjectId); } } else { this.WriteWarning(Strings.WarningClusterNodeNotFoundInDag(amClusterNode.Name.Fqdn, databaseAvailabilityGroup.Name)); } } } } databaseAvailabilityGroup.OperationalServers = list.ToArray(); databaseAvailabilityGroup.ServersInMaintenance = list2.ToArray(); DagNetworkConfiguration dagNetworkConfig = DagNetworkRpc.GetDagNetworkConfig(databaseAvailabilityGroup); databaseAvailabilityGroup.ReplicationPort = dagNetworkConfig.ReplicationPort; foreach (DatabaseAvailabilityGroupNetwork databaseAvailabilityGroupNetwork in dagNetworkConfig.Networks) { databaseAvailabilityGroup.NetworkNames.Add(databaseAvailabilityGroupNetwork.Name); } if (DagHelper.IsQuorumTypeFileShareWitness(amCluster)) { IAmClusterGroup amClusterGroup = amCluster.FindCoreClusterGroup(); if (amClusterGroup == null) { databaseAvailabilityGroup.WitnessShareInUse = new WitnessShareUsage?(WitnessShareUsage.InvalidConfiguration); this.WriteWarning(Strings.WarningClusterGroupNotFormed(databaseAvailabilityGroup.Name)); goto IL_306; } using (amClusterGroup) { IEnumerable <AmClusterResource> enumerable = null; try { enumerable = amClusterGroup.EnumerateResourcesOfType("File Share Witness"); AmClusterResource amClusterResource = enumerable.ElementAtOrDefault(0); if (amClusterResource == null) { databaseAvailabilityGroup.WitnessShareInUse = new WitnessShareUsage?(WitnessShareUsage.InvalidConfiguration); this.WriteWarning(Strings.WarningFswNotFound(databaseAvailabilityGroup.Name)); } else if (amClusterResource.GetState() == AmResourceState.Failed) { databaseAvailabilityGroup.WitnessShareInUse = new WitnessShareUsage?(WitnessShareUsage.InvalidConfiguration); this.WriteWarning(Strings.WarningFswFailed(databaseAvailabilityGroup.Name)); } else { string privateProperty = amClusterResource.GetPrivateProperty <string>("SharePath"); UncFileSharePath a; if (UncFileSharePath.TryParse(privateProperty, out a)) { if (a == databaseAvailabilityGroup.FileShareWitness) { databaseAvailabilityGroup.WitnessShareInUse = new WitnessShareUsage?(WitnessShareUsage.Primary); } else if (a == databaseAvailabilityGroup.AlternateFileShareWitness) { databaseAvailabilityGroup.WitnessShareInUse = new WitnessShareUsage?(WitnessShareUsage.Alternate); } else { databaseAvailabilityGroup.WitnessShareInUse = new WitnessShareUsage?(WitnessShareUsage.InvalidConfiguration); this.WriteWarning(Strings.WarningFswNotPrimaryOrAlternate(databaseAvailabilityGroup.Name)); } } else { databaseAvailabilityGroup.WitnessShareInUse = new WitnessShareUsage?(WitnessShareUsage.InvalidConfiguration); this.WriteWarning(Strings.WarningFswNotValidPath(databaseAvailabilityGroup.Name, privateProperty)); } } } finally { if (enumerable != null) { foreach (AmClusterResource amClusterResource2 in enumerable) { using (amClusterResource2) { } } } } goto IL_306; } } databaseAvailabilityGroup.WitnessShareInUse = new WitnessShareUsage?(WitnessShareUsage.None); IL_306:; } this.UpdatePam(databaseAvailabilityGroup); try { DeferredFailoverEntry[] serversInDeferredRecovery = DagTaskHelper.GetServersInDeferredRecovery(databaseAvailabilityGroup); databaseAvailabilityGroup.ServersInDeferredRecovery = serversInDeferredRecovery; } catch (AmServerException ex) { this.WriteWarning(Strings.PAMOtherError(ex.Message)); } } } base.WriteResult(databaseAvailabilityGroup); TaskLogger.LogExit(); }
private void UpdateFileShareWitness() { if (this.m_allServers.Count == 0) { this.m_output.WriteErrorSimple(new DagTaskNoServersAreStartedException(this.m_dag.Name)); } IEnumerable <AmServerName> amServerNamesFromServers = RestoreDatabaseAvailabilityGroup.GetAmServerNamesFromServers(this.m_allServers.Values); using (AmCluster amCluster = AmCluster.OpenByNames(amServerNamesFromServers)) { bool flag = DagTaskHelper.IsQuorumTypeFileShareWitness(this.m_output, amCluster); bool flag2 = DagTaskHelper.ShouldBeFileShareWitness(this.m_output, this.m_dag, amCluster, false); string fswShareCurrent = string.Empty; if (flag) { using (AmClusterResource amClusterResource = amCluster.OpenQuorumResource()) { if (amClusterResource != null) { fswShareCurrent = amClusterResource.GetPrivateProperty <string>("SharePath"); } } } if (flag2) { if (this.m_fsw != null) { try { this.m_output.AppendLogMessage("Creating/modififying the primary FSW, if needed.", new object[0]); this.m_fsw.Create(); if (this.m_dag.Servers.Count == 0 && this.m_fsw.IsJustCreated) { this.m_fsw.Delete(); } } catch (LocalizedException ex) { if (this.m_fsw.GetExceptionType(ex) != FileShareWitnessExceptionType.FswDeleteError) { this.m_output.WriteWarning(ex.LocalizedString); } } } if (this.m_afsw != null && !this.m_afsw.Equals(this.m_fsw)) { try { this.m_output.AppendLogMessage("Creating/modififying the alternate FSW, if needed.", new object[0]); this.m_afsw.Create(); if (this.m_dag.Servers.Count == 0 && this.m_afsw.IsJustCreated) { this.m_afsw.Delete(); } } catch (LocalizedException ex2) { if (this.m_afsw.GetExceptionType(ex2) != FileShareWitnessExceptionType.FswDeleteError) { this.m_output.WriteWarning(ex2.LocalizedString); } } } bool useAlternateWitnessServer = this.m_useAlternateWitnessServer; if (!this.m_skipDagValidation || (flag2 && !flag)) { DagTaskHelper.ChangeQuorumToMnsOrFswAsAppropriate(this.m_output, this, this.m_dag, amCluster, this.m_fsw, this.m_afsw, flag2, this.m_useAlternateWitnessServer); } } else if (!this.m_skipDagValidation && flag) { DagTaskHelper.RevertToMnsQuorum(this.m_output, amCluster, fswShareCurrent); } } }