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; }
internal static void FixIPAddress(AmServerName nodeName, DatabaseAvailabilityGroup dag, IEnumerable <AmServerName> startedMailboxServers, ITaskOutputHelper output) { output.WriteProgressSimple(Strings.DagTaskFixingUpIpResources); MultiValuedProperty <IPAddress> databaseAvailabilityGroupIpv4Addresses = dag.DatabaseAvailabilityGroupIpv4Addresses; IPAddress[] array = new IPAddress[0]; if (databaseAvailabilityGroupIpv4Addresses.Count > 0) { array = databaseAvailabilityGroupIpv4Addresses.ToArray(); } string[] value = (from addr in array select addr.ToString()).ToArray <string>(); output.AppendLogMessage("Got the following IP addresses for the DAG (blank means DHCP):{0}", new object[] { string.Join(",", value) }); using (AmCluster amCluster = AmCluster.OpenByNames(startedMailboxServers)) { if (amCluster.CnoName != string.Empty) { using (IAmClusterGroup amClusterGroup = amCluster.FindCoreClusterGroup()) { using (IAmClusterResource amClusterResource = amClusterGroup.FindResourceByTypeName("Network Name")) { LocalizedString value2 = AmClusterResourceHelper.FixUpIpAddressesForNetName(output, amCluster, (AmClusterGroup)amClusterGroup, (AmClusterResource)amClusterResource, array); output.WriteProgressSimple(Strings.DagTaskFixedUpIpResources(value2)); DagTaskHelper.LogCnoState(output, dag.Name, amClusterResource); } } } } }
private void RemoveNodeFromCluster() { this.m_output.WriteProgressSimple(Strings.DagTaskRemovedNodeToCluster(this.m_mailboxServerName)); using (IAmClusterNode amClusterNode = this.m_clusDag.OpenNode(this.m_mailboxAmServerName)) { bool flag = false; string empty = string.Empty; string remoteServerName = "<unknown>"; try { using (IAmClusterGroup amClusterGroup = this.m_clusDag.FindCoreClusterGroup()) { AmServerName ownerNode = amClusterGroup.OwnerNode; remoteServerName = ownerNode.Fqdn; ReplayRpcClientWrapper.RunEvictNodeFromCluster(ownerNode, this.m_mailboxAmServerName, out empty); } } catch (DagTaskOperationFailedException ex) { AmClusterEvictWithoutCleanupException ex2; if (ex.TryGetTypedInnerException(out ex2)) { this.m_output.WriteWarning(ex2.LocalizedString); } else { DagTaskHelper.LogRemoteVerboseLog(this.m_output, remoteServerName, empty); this.m_output.WriteErrorSimple(ex); } } catch (LocalizedException error) { DagTaskHelper.LogRemoteVerboseLog(this.m_output, remoteServerName, empty); this.m_output.WriteErrorSimple(error); } DagTaskHelper.LogRemoteVerboseLog(this.m_output, remoteServerName, empty); if (flag) { this.m_output.WriteWarning(Strings.DagTaskRemoveNodeCleanupFailed(amClusterNode.Name.Fqdn)); } } this.m_output.WriteProgressSimple(Strings.DagTaskRemovedNodeToCluster(this.m_mailboxServerName)); if (this.m_clusDag.CnoName != string.Empty) { this.m_output.WriteProgressSimple(Strings.DagTaskFixingUpIpResources); List <AmServerName> source = this.m_clusDag.EnumerateNodeNames().ToList <AmServerName>(); IEnumerable <AmServerName> enumerable = from name in source where name != this.m_mailboxAmServerName select name; IEnumerable <string> source2 = from serverName in enumerable select serverName.NetbiosName; this.m_output.AppendLogMessage("Refreshing the cluster using the names [{0}].", new object[] { string.Join(", ", source2.ToArray <string>()) }); this.m_clusDag.Dispose(); MultiValuedProperty <IPAddress> databaseAvailabilityGroupIpv4Addresses = this.m_dag.DatabaseAvailabilityGroupIpv4Addresses; IPAddress[] array = new IPAddress[0]; if (databaseAvailabilityGroupIpv4Addresses.Count > 0) { array = databaseAvailabilityGroupIpv4Addresses.ToArray(); } string[] value = (from addr in array select addr.ToString()).ToArray <string>(); this.m_output.AppendLogMessage("Got the following IP addresses for the DAG (blank means DHCP): {0}", new object[] { string.Join(",", value) }); this.m_clusDag = AmCluster.OpenByNames(enumerable); using (IAmClusterGroup amClusterGroup2 = this.m_clusDag.FindCoreClusterGroup()) { using (IAmClusterResource amClusterResource = amClusterGroup2.FindResourceByTypeName("Network Name")) { this.m_output.AppendLogMessage("Cluster group net name = '{0}'.", new object[] { amClusterResource.Name }); LocalizedString value2 = AmClusterResourceHelper.FixUpIpAddressesForNetName(this.m_output, this.m_clusDag, (AmClusterGroup)amClusterGroup2, (AmClusterResource)amClusterResource, array); this.m_output.WriteProgressSimple(Strings.DagTaskFixedUpIpResources(value2)); } } } }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); bool flag = false; if ((base.Fields["ReplicationPort"] != null || base.Fields["NetworkCompression"] != null || base.Fields["NetworkEncryption"] != null || base.Fields["ManualDagNetworkConfiguration"] != null || base.Fields["DiscoverNetworks"] != null) && !this.m_dag.IsDagEmpty()) { flag = true; this.m_IsObjectChanged = true; } if (this.DataObject.AllowCrossSiteRpcClientAccess != this.AllowCrossSiteRpcClientAccess) { if (base.Fields["AllowCrossSiteRpcClientAccess"] != null) { this.DataObject.AllowCrossSiteRpcClientAccess = this.AllowCrossSiteRpcClientAccess; this.m_IsObjectChanged = true; } else { this.AllowCrossSiteRpcClientAccess = this.DataObject.AllowCrossSiteRpcClientAccess; } } if (this.m_fsw != null) { this.m_dag.SetWitnessServer(this.m_fsw.FileShareWitnessShare, this.m_fsw.WitnessDirectory); this.m_IsObjectChanged = true; } if (this.m_afsw != null) { this.m_dag.SetAlternateWitnessServer(this.m_afsw.FileShareWitnessShare, this.m_afsw.WitnessDirectory); this.m_IsObjectChanged = true; } else if (this.AlternateWitnessServer == null && this.m_alternateWitnessServerParameterSpecified) { this.m_dag.SetAlternateWitnessServer(null, null); } base.InternalProcessRecord(); if (flag && !this.m_dag.IsDagEmpty()) { SetDagNetworkConfigRequest setDagNetworkConfigRequest = new SetDagNetworkConfigRequest(); if (base.Fields["ReplicationPort"] != null) { setDagNetworkConfigRequest.ReplicationPort = this.ReplicationPort; } setDagNetworkConfigRequest.NetworkCompression = this.m_dag.NetworkCompression; setDagNetworkConfigRequest.NetworkEncryption = this.m_dag.NetworkEncryption; setDagNetworkConfigRequest.ManualDagNetworkConfiguration = this.m_dag.ManualDagNetworkConfiguration; if (base.Fields["DiscoverNetworks"] != null) { setDagNetworkConfigRequest.DiscoverNetworks = true; } DagNetworkRpc.SetDagNetworkConfig(this.m_dag, setDagNetworkConfigRequest); } if (!this.m_dag.IsDagEmpty()) { using (AmCluster amCluster = AmCluster.OpenDagClus(this.m_dag)) { if (amCluster.CnoName != string.Empty) { using (IAmClusterGroup amClusterGroup = amCluster.FindCoreClusterGroup()) { using (IAmClusterResource amClusterResource = amClusterGroup.FindResourceByTypeName("Network Name")) { IPAddress[] dagIpAddressesFromAd = this.GetDagIpAddressesFromAd(this.m_output, this.m_dag); AmClusterResourceHelper.FixUpIpAddressesForNetName(this.m_output, amCluster, (AmClusterGroup)amClusterGroup, (AmClusterResource)amClusterResource, dagIpAddressesFromAd); DagTaskHelper.LogCnoState(this.m_output, this.m_dag.Name, amClusterResource); } } } } this.UpdateFileShareWitness(); DagTaskHelper.NotifyServersOfConfigChange(this.m_allServers.Keys); } TaskLogger.LogExit(); }