internal static Dictionary <AmServerName, Server> GetServersInSite(ILogTraceHelper output, IEnumerable <Server> servers, AdSiteIdParameter adSite) { if (servers == null) { throw new ArgumentNullException("servers"); } if (adSite == null) { throw new ArgumentNullException("adSite"); } Dictionary <AmServerName, Server> dictionary = new Dictionary <AmServerName, Server>(16); foreach (Server server in servers) { if (DatabaseAvailabilityGroupAction.SiteEquals(server.ServerSite, adSite)) { dictionary.Add(new AmServerName(server.Fqdn), server); } } output.AppendLogMessage("The following servers are in the site {0}:", new object[] { adSite }); foreach (AmServerName amServerName in dictionary.Keys) { output.AppendLogMessage("\t{0}", new object[] { amServerName.NetbiosName }); } return(dictionary); }
protected override void InternalValidate() { this.m_output = new HaTaskOutputHelper("restore-databaseavailabilitygroup", new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskProgressLoggingDelegate(base.WriteProgress), this.GetHashCode()); this.m_output.CreateTempLogFile(); this.LogCommandLineParameters(); this.m_output.WriteProgressIncrementalSimple(Strings.ProgressValidation, 5); this.m_dag = DagTaskHelper.DagIdParameterToDag(this.Identity, base.DataSession); DagTaskHelper.VerifyDagAndServersAreWithinScopes <DatabaseAvailabilityGroup>(this, this.m_dag, true); if (this.m_dag.DatacenterActivationMode != DatacenterActivationModeOption.DagOnly) { this.m_output.WriteErrorSimple(new TaskCanOnlyRunOnDacException(this.m_dag.Name)); } DatabaseAvailabilityGroupAction.ResolveServersBasedOnStoppedList(this.m_output, this.m_dag, this.m_servers, this.m_startedServers, this.m_stoppedServers); if (this.ActiveDirectorySite != null) { List <ADObjectId> sitesForDag = DatabaseAvailabilityGroupAction.GetSitesForDag(this.m_dag); ADObjectId adobjectId = null; foreach (ADObjectId adobjectId2 in sitesForDag) { if (DatabaseAvailabilityGroupAction.SiteEquals(adobjectId2, this.ActiveDirectorySite)) { adobjectId = adobjectId2; } } if (adobjectId == null) { this.m_output.WriteErrorSimple(new InvalidAdSiteException(this.ActiveDirectorySite.ToString())); } } this.m_isQuorumPresent = this.CheckClussvcRunningOnStartedServers(); if (this.UsePrimaryWitnessServer) { if (this.m_dag.WitnessServer == null) { this.m_output.WriteErrorSimple(new RestoreNeedsWitnessServerException(this.m_dag.Name)); } } else if (this.m_dag.AlternateWitnessServer == null && this.AlternateWitnessServer == null) { this.m_output.WriteErrorSimple(new RestoreNeedsAlternateWitnessServerException(this.m_dag.Name)); } base.InternalValidate(); }