protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            DatabaseAvailabilityGroupConfiguration databaseAvailabilityGroupConfiguration = (DatabaseAvailabilityGroupConfiguration)base.PrepareDataObject();
            DagConfigurationHelper dagConfigurationHelper = DagConfigurationHelper.Deserialize(databaseAvailabilityGroupConfiguration.ConfigurationXML);

            if (dagConfigurationHelper.Version <= 1)
            {
                if (base.Fields["ServersPerDag"] != null)
                {
                    dagConfigurationHelper.ServersPerDag = this.ServersPerDag;
                }
                if (base.Fields["DatabasesPerServer"] != null)
                {
                    dagConfigurationHelper.DatabasesPerServer = this.DatabasesPerServer;
                }
                if (base.Fields["DatabasesPerVolume"] != null)
                {
                    dagConfigurationHelper.DatabasesPerVolume = this.DatabasesPerVolume;
                }
                if (base.Fields["CopiesPerDatabase"] != null)
                {
                    dagConfigurationHelper.CopiesPerDatabase = this.CopiesPerDatabase;
                }
                if (base.Fields["MinCopiesPerDatabaseForMonitoring"] != null)
                {
                    dagConfigurationHelper.MinCopiesPerDatabaseForMonitoring = this.MinCopiesPerDatabaseForMonitoring;
                }
                this.m_configXML = dagConfigurationHelper.Serialize();
                databaseAvailabilityGroupConfiguration.ConfigurationXML = this.m_configXML;
                TaskLogger.LogExit();
                return(databaseAvailabilityGroupConfiguration);
            }
            throw new DagConfigVersionConflictException(databaseAvailabilityGroupConfiguration.Name, 1, dagConfigurationHelper.Version);
        }
예제 #2
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     base.InternalValidate();
     if (this.preExistingDatabase != null)
     {
         TaskLogger.LogExit();
         return;
     }
     if (this.PublicFolderDatabase == null)
     {
         if (base.OwnerServerPublicFolderDatabases != null && base.OwnerServerPublicFolderDatabases.Length > 0)
         {
             this.DataObject.PublicFolderDatabase = (ADObjectId)base.OwnerServerPublicFolderDatabases[0].Identity;
         }
         else
         {
             base.WriteVerbose(Strings.VerboseFindClosestPublicFolderDatabaseFromServer(base.OwnerServer.Id.ToString()));
             this.DataObject.PublicFolderDatabase = Microsoft.Exchange.Data.Directory.SystemConfiguration.PublicFolderDatabase.FindClosestPublicFolderDatabase(base.DataSession, base.OwnerServer.Id);
         }
     }
     else
     {
         this.PublicFolderDatabase.AllowLegacy = true;
         IConfigurable dataObject = base.GetDataObject <PublicFolderDatabase>(this.PublicFolderDatabase, base.DataSession, null, new LocalizedString?(Strings.ErrorPublicFolderDatabaseNotFound(this.PublicFolderDatabase.ToString())), new LocalizedString?(Strings.ErrorPublicFolderDatabaseNotUnique(this.PublicFolderDatabase.ToString())));
         this.DataObject.PublicFolderDatabase = (ADObjectId)dataObject.Identity;
     }
     if (this.OfflineAddressBook != null)
     {
         IConfigurable dataObject2 = base.GetDataObject <OfflineAddressBook>(this.OfflineAddressBook, base.DataSession, null, new LocalizedString?(Strings.ErrorOfflineAddressBookNotFound(this.OfflineAddressBook.ToString())), new LocalizedString?(Strings.ErrorOfflineAddressBookNotUnique(this.OfflineAddressBook.ToString())));
         this.DataObject.OfflineAddressBook = (ADObjectId)dataObject2.Identity;
     }
     base.ValidateFilePaths(base.ParameterSetName == "Recovery");
     if (base.Fields.IsModified("AutoDagExcludeFromMonitoring"))
     {
         this.DataObject.AutoDagExcludeFromMonitoring = this.AutoDagExcludeFromMonitoring;
     }
     else
     {
         DatabaseAvailabilityGroup databaseAvailabilityGroup = DagTaskHelper.ReadDag(this.DataObject.MasterServerOrAvailabilityGroup, this.ConfigurationSession);
         if (databaseAvailabilityGroup != null)
         {
             DatabaseAvailabilityGroupConfiguration databaseAvailabilityGroupConfiguration = DagConfigurationHelper.ReadDagConfig(databaseAvailabilityGroup.DatabaseAvailabilityGroupConfiguration, this.ConfigurationSession);
             if (databaseAvailabilityGroupConfiguration != null)
             {
                 DagConfigurationHelper dagConfigurationHelper = DagConfigurationHelper.Deserialize(databaseAvailabilityGroupConfiguration.ConfigurationXML);
                 if (dagConfigurationHelper.MinCopiesPerDatabaseForMonitoring > 1)
                 {
                     this.DataObject.AutoDagExcludeFromMonitoring = true;
                 }
             }
         }
     }
     TaskLogger.LogExit();
 }
        private DagConfigurationEntry ConstructNewDagConfigEntry(DatabaseAvailabilityGroupConfiguration dagConfig)
        {
            DagConfigurationHelper dagConfigurationHelper = DagConfigurationHelper.Deserialize(dagConfig.ConfigurationXML);

            if (dagConfigurationHelper.Version <= 1)
            {
                return(new DagConfigurationEntry
                {
                    Name = dagConfig.Name,
                    Identity = dagConfig.Identity,
                    ServersPerDag = dagConfigurationHelper.ServersPerDag,
                    DatabasesPerServer = dagConfigurationHelper.DatabasesPerServer,
                    DatabasesPerVolume = dagConfigurationHelper.DatabasesPerVolume,
                    CopiesPerDatabase = dagConfigurationHelper.CopiesPerDatabase,
                    MinCopiesPerDatabaseForMonitoring = dagConfigurationHelper.MinCopiesPerDatabaseForMonitoring
                });
            }
            throw new DagConfigVersionConflictException(dagConfig.Name, 1, dagConfigurationHelper.Version);
        }
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            this.m_output = new HaTaskOutputHelper("new-databaseavailabiltygroupconfiguration", 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.m_output.AppendLogMessage("new-dagconfiguration started", new object[0]);
            this.LogCommandLineParameters();
            this.m_dagConfigName = base.Name;
            DagConfigurationHelper dagConfigurationHelper = new DagConfigurationHelper(this.ServersPerDag, this.DatabasesPerServer, this.DatabasesPerVolume, this.CopiesPerDatabase, this.MinCopiesPerDatabaseForMonitoring);

            this.m_dagConfigXML = dagConfigurationHelper.Serialize();
            QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, DatabaseAvailabilityGroupConfigurationSchema.Name, this.m_dagConfigName);

            DatabaseAvailabilityGroupConfiguration[] array = this.ConfigurationSession.Find <DatabaseAvailabilityGroupConfiguration>(null, QueryScope.SubTree, filter, null, 1);
            if (array != null && array.Length > 0)
            {
                base.WriteError(new ADObjectAlreadyExistsException(Strings.NewDagConfigurationErrorDuplicateName(this.m_dagConfigName)), ErrorCategory.InvalidArgument, this.m_dagConfigName);
            }
            base.InternalValidate();
            this.m_output.WriteVerbose(Strings.NewDagConfigurationPassedChecks);
            TaskLogger.LogExit();
        }
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            DatabaseAvailabilityGroup databaseAvailabilityGroup = (DatabaseAvailabilityGroup)base.PrepareDataObject();

            if (base.Fields["NetworkCompression"] != null)
            {
                databaseAvailabilityGroup.NetworkCompression = this.NetworkCompression;
            }
            if (base.Fields["NetworkEncryption"] != null)
            {
                databaseAvailabilityGroup.NetworkEncryption = this.NetworkEncryption;
            }
            if (base.Fields["ManualDagNetworkConfiguration"] != null)
            {
                databaseAvailabilityGroup.ManualDagNetworkConfiguration = this.ManualDagNetworkConfiguration;
            }
            if (base.Fields["DatacenterActivationMode"] != null)
            {
                databaseAvailabilityGroup.DatacenterActivationMode = this.DatacenterActivationMode;
            }
            if (base.Fields.IsChanged("DatabaseAvailabilityGroupIpAddresses"))
            {
                if (base.Fields["DatabaseAvailabilityGroupIpAddresses"] == null)
                {
                    databaseAvailabilityGroup.DatabaseAvailabilityGroupIpv4Addresses = new MultiValuedProperty <IPAddress>
                    {
                        IPAddress.Any
                    };
                }
                else
                {
                    databaseAvailabilityGroup.DatabaseAvailabilityGroupIpv4Addresses = this.DatabaseAvailabilityGroupIpAddresses;
                }
            }
            if (base.Fields["DagConfiguration"] != null)
            {
                DatabaseAvailabilityGroupConfiguration databaseAvailabilityGroupConfiguration = DagConfigurationHelper.DagConfigIdParameterToDagConfig(this.DagConfiguration, this.ConfigurationSession);
                databaseAvailabilityGroup.DatabaseAvailabilityGroupConfiguration = databaseAvailabilityGroupConfiguration.Id;
            }
            else if (this.m_dagConfigParameterSpecified)
            {
                databaseAvailabilityGroup.DatabaseAvailabilityGroupConfiguration = null;
            }
            TaskLogger.LogExit();
            return(databaseAvailabilityGroup);
        }
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            DatabaseAvailabilityGroup databaseAvailabilityGroup = new DatabaseAvailabilityGroup();

            databaseAvailabilityGroup.SetId(((ITopologyConfigurationSession)this.ConfigurationSession).GetDatabaseAvailabilityGroupContainerId().GetChildId(base.Name));
            databaseAvailabilityGroup.Name = this.m_dagName;
            databaseAvailabilityGroup.SetWitnessServer(this.m_fsw.FileShareWitnessShare, this.m_fsw.WitnessDirectory);
            databaseAvailabilityGroup.ThirdPartyReplication = this.ThirdPartyReplication;
            if (this.DagConfiguration != null)
            {
                DatabaseAvailabilityGroupConfiguration databaseAvailabilityGroupConfiguration = DagConfigurationHelper.DagConfigIdParameterToDagConfig(this.DagConfiguration, this.ConfigurationSession);
                databaseAvailabilityGroup.DatabaseAvailabilityGroupConfiguration = databaseAvailabilityGroupConfiguration.Id;
            }
            this.m_newDag = databaseAvailabilityGroup;
            TaskLogger.LogExit();
            return(databaseAvailabilityGroup);
        }