Exemplo n.º 1
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     this.m_adSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(false, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 146, "InternalValidate", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\Cluster\\DatabaseAvailabilityGroupAction.cs");
     this.m_output    = new HaTaskOutputHelper(this.TaskName, new Microsoft.Exchange.Configuration.Tasks.Task.TaskErrorLoggingDelegate(base.WriteError), new Microsoft.Exchange.Configuration.Tasks.Task.TaskWarningLoggingDelegate(this.WriteWarning), new Microsoft.Exchange.Configuration.Tasks.Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Microsoft.Exchange.Configuration.Tasks.Task.TaskProgressLoggingDelegate(base.WriteProgress), this.GetHashCode());
     this.m_output.CreateTempLogFile();
     this.NeedToUpdateAD      = true;
     this.NeedToUpdateCluster = true;
     if (this.ConfigurationOnly && this.QuorumOnly)
     {
         this.m_output.WriteErrorSimple(new TaskBothConfigurationOnlyAndQuorumOnlySpecifiedException());
     }
     if (this.ConfigurationOnly)
     {
         this.NeedToUpdateCluster = false;
     }
     if (this.QuorumOnly)
     {
         this.NeedToUpdateAD = false;
     }
     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.ResolveServers(this.m_output, this.m_dag, this.m_serversInDag, this.m_startedServers, this.m_stoppedServers);
     if (this.MailboxServer != null)
     {
         this.m_mailboxServer = (Server)base.GetDataObject <Server>(this.MailboxServer, base.DataSession, null, new LocalizedString?(Strings.ErrorServerNotFound(this.MailboxServer.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(this.MailboxServer.ToString())));
         if (!this.m_mailboxServer.IsMailboxServer)
         {
             this.m_output.WriteErrorSimple(new OperationOnlyOnMailboxServerException(this.m_mailboxServer.Name));
         }
         if (this.m_mailboxServer.MajorVersion != Server.CurrentExchangeMajorVersion)
         {
             this.m_output.WriteErrorSimple(new DagTaskErrorServerWrongVersion(this.m_mailboxServer.Name));
         }
     }
     if (this.ActiveDirectorySite != null)
     {
         IConfigurationSession configurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 225, "InternalValidate", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\Cluster\\DatabaseAvailabilityGroupAction.cs");
         configurationSession.UseConfigNC      = false;
         configurationSession.UseGlobalCatalog = true;
         ADSite adsite = (ADSite)base.GetDataObject <ADSite>(this.ActiveDirectorySite, configurationSession, null, new LocalizedString?(Strings.ErrorSiteNotFound(this.ActiveDirectorySite.ToString())), new LocalizedString?(Strings.ErrorSiteNotUnique(this.ActiveDirectorySite.ToString())));
     }
     base.InternalValidate();
     TaskLogger.LogExit();
 }
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            base.InternalValidate();
            this.m_output            = new HaTaskOutputHelper("set-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_dag               = this.DataObject;
            this.m_skipDagValidation = this.SkipDagValidation;
            DagTaskHelper.VerifyDagAndServersAreWithinScopes <DatabaseAvailabilityGroup>(this, this.m_dag, true);
            if (this.DatabaseAvailabilityGroupIpAddresses != null)
            {
                if (!this.m_dag.IsDagEmpty())
                {
                    this.PrepareServersInDagIfRequired();
                    foreach (AmServerName amServerName in this.m_serverNamesInDag)
                    {
                        DagTaskHelper.ValidateIPAddressList(this.m_output, amServerName.NetbiosName, this.DatabaseAvailabilityGroupIpAddresses, this.m_dag.Name);
                        DagTaskHelper.ValidateIPAddressList(this.m_output, amServerName.Fqdn, this.DatabaseAvailabilityGroupIpAddresses, this.m_dag.Name);
                    }
                }
                foreach (IPAddress ipaddress in this.DatabaseAvailabilityGroupIpAddresses)
                {
                    if (ipaddress.AddressFamily == AddressFamily.InterNetworkV6)
                    {
                        this.m_output.WriteErrorSimple(new DagTaskDagIpAddressesMustBeIpv4Exception());
                    }
                }
            }
            this.m_useAlternateWitnessServer = (this.m_dag.AlternateWitnessServer != null && DagTaskHelper.IsDagFailedOverToOtherSite(this.m_output, this.m_dag));
            if (!this.m_useAlternateWitnessServer)
            {
                this.m_fsw = new FileShareWitness((ITopologyConfigurationSession)base.DataSession, this.m_dag.Name, this.WitnessServer ?? this.m_dag.WitnessServer, this.WitnessDirectory ?? this.m_dag.WitnessDirectory);
                try
                {
                    this.m_fsw.Initialize();
                }
                catch (LocalizedException error)
                {
                    this.m_output.WriteErrorSimple(error);
                }
                this.CheckFsw(this.m_fsw.WitnessServerFqdn);
            }
            if (this.AlternateWitnessServer != null || this.AlternateWitnessDirectory != null || (this.m_dag.AlternateWitnessServer != null && this.m_dag.AlternateWitnessDirectory != null && !this.m_alternateWitnessServerParameterSpecified) || this.m_useAlternateWitnessServer)
            {
                this.m_afsw = new FileShareWitness((ITopologyConfigurationSession)base.DataSession, this.m_dag.Name, this.AlternateWitnessServer ?? this.m_dag.AlternateWitnessServer, this.AlternateWitnessDirectory ?? this.m_dag.AlternateWitnessDirectory);
                try
                {
                    this.m_afsw.Initialize();
                }
                catch (LocalizedException error2)
                {
                    this.m_output.WriteErrorSimple(error2);
                }
                if (this.m_fsw != null && SharedHelper.StringIEquals(this.m_afsw.WitnessServerFqdn, this.m_fsw.WitnessServerFqdn) && this.m_fsw.WitnessDirectory != this.m_afsw.WitnessDirectory)
                {
                    this.m_output.WriteErrorSimple(new DagFswAndAlternateFswOnSameWitnessServerButPointToDifferentDirectoriesException(this.m_fsw.WitnessServer.ToString(), this.m_fsw.WitnessDirectory.ToString(), this.m_afsw.WitnessDirectory.ToString()));
                }
                this.CheckFsw(this.m_afsw.WitnessServerFqdn);
            }
            Dictionary <AmServerName, Server> startedServers = new Dictionary <AmServerName, Server>();

            DatabaseAvailabilityGroupAction.ResolveServers(this.m_output, this.m_dag, this.m_allServers, startedServers, this.m_stoppedServers);
            if (!this.m_dag.IsDagEmpty())
            {
                this.PrepareServersInDagIfRequired();
                List <AmServerName>        list             = new List <AmServerName>(this.m_stoppedServers.Count);
                IEnumerable <AmServerName> serversInCluster = null;
                foreach (Server server in this.m_stoppedServers.Values)
                {
                    list.Add(new AmServerName(server.Id));
                }
                using (AmCluster amCluster = AmCluster.OpenDagClus(this.m_dag))
                {
                    serversInCluster = amCluster.EnumerateNodeNames();
                }
                if (!this.m_skipDagValidation)
                {
                    DagTaskHelper.CompareDagClusterMembership(this.m_output, this.m_dag.Name, this.m_serverNamesInDag, serversInCluster, list);
                }
            }
            if (base.Fields["DatacenterActivationMode"] != null && this.DatacenterActivationMode != DatacenterActivationModeOption.Off)
            {
                DagTaskHelper.CheckDagCanBeActivatedInDatacenter(this.m_output, this.m_dag, null, (ITopologyConfigurationSession)base.DataSession);
            }
            if (base.Fields["DatacenterActivationMode"] != null && this.DatacenterActivationMode == DatacenterActivationModeOption.Off)
            {
                this.DataObject.StartedMailboxServers = null;
                this.DataObject.StoppedMailboxServers = null;
            }
            TaskLogger.LogExit();
        }