예제 #1
0
        /// <summary>
        /// Converts the response from the service to a powershell database object
        /// </summary>
        /// <param name="resourceGroupName">The resource group the server is in</param>
        /// <param name="serverName">The name of the Azure Sql Database Server</param>
        /// <param name="pool">The service response</param>
        /// <returns>The converted model</returns>
        private AzureSqlFailoverGroupModel CreateFailoverGroupModelFromResponse(Management.Sql.LegacySdk.Models.FailoverGroup failoverGroup)
        {
            AzureSqlFailoverGroupModel model = new AzureSqlFailoverGroupModel();

            model.FailoverGroupName       = failoverGroup.Name;
            model.Databases               = failoverGroup.Properties.Databases;
            model.ReadOnlyFailoverPolicy  = failoverGroup.Properties.ReadOnlyEndpoint.FailoverPolicy;
            model.ReadWriteFailoverPolicy = failoverGroup.Properties.ReadWriteEndpoint.FailoverPolicy;
            model.ReplicationRole         = failoverGroup.Properties.ReplicationRole;
            model.ReplicationState        = failoverGroup.Properties.ReplicationState;
            model.PartnerServers          = failoverGroup.Properties.PartnerServers;
            model.FailoverWithDataLossGracePeriodHours = failoverGroup.Properties.ReadWriteEndpoint.FailoverWithDataLossGracePeriodMinutes == null ?
                                                         null : failoverGroup.Properties.ReadWriteEndpoint.FailoverWithDataLossGracePeriodMinutes / 60;

            model.Id       = failoverGroup.Id;
            model.Location = failoverGroup.Location;

            model.DatabaseNames = failoverGroup.Properties.Databases
                                  .Select(dbId => GetUriSegment(dbId, 10))
                                  .ToList();

            model.ResourceGroupName = GetUriSegment(failoverGroup.Id, 4);
            model.ServerName        = GetUriSegment(failoverGroup.Id, 8);

            FailoverGroupPartnerServer partnerServer = failoverGroup.Properties.PartnerServers.FirstOrDefault();

            if (partnerServer != null)
            {
                model.PartnerResourceGroupName = GetUriSegment(partnerServer.Id, 4);
                model.PartnerServerName        = GetUriSegment(partnerServer.Id, 8);
                model.PartnerLocation          = partnerServer.Location;
            }

            return(model);
        }
예제 #2
0
 /// <summary>
 /// Construct AzureSqlServerfailoverGroupModel from Management.Sql.LegacySdk.Models.FailoverGroup object
 /// </summary>
 /// <param name="resourceGroupName">Resource group</param>
 /// <param name="serverName">Server name</param>
 /// <param name="advisorName">Advisor name</param>
 /// <param name="failoverGroup">Recommended Action object</param>
 public AzureSqlFailoverGroupModel(string resourceGroupName, string serverName, string failoverGroupName, Management.Sql.LegacySdk.Models.FailoverGroup failoverGroup)
 {
     ResourceGroupName = resourceGroupName;
     ServerName        = serverName;
     FailoverGroupName = failoverGroup.Name;
     Id       = failoverGroup.Id;
     Location = failoverGroup.Location;
     ReadWriteFailoverPolicy = failoverGroup.Properties.ReadWriteEndpoint.FailoverPolicy;
     ReadOnlyFailoverPolicy  = failoverGroup.Properties.ReadOnlyEndpoint.FailoverPolicy;
     FailoverWithDataLossGracePeriodHours = failoverGroup.Properties.ReadWriteEndpoint.FailoverWithDataLossGracePeriodMinutes / 60;
     PartnerServers   = failoverGroup.Properties.PartnerServers;
     Databases        = failoverGroup.Properties.Databases;
     ReplicationRole  = failoverGroup.Properties.ReplicationRole;
     ReplicationState = failoverGroup.Properties.ReplicationState;
 }
예제 #3
0
 /// <summary>
 /// Construct AzureSqlServerfailoverGroupModel from Management.Sql.LegacySdk.Models.FailoverGroup object
 /// </summary>
 /// <param name="resourceGroupName">Resource group</param>
 /// <param name="serverName">Server name</param>
 /// <param name="advisorName">Advisor name</param>
 /// <param name="failoverGroup">Recommended Action object</param>
 public AzureSqlFailoverGroupModel(string resourceGroupName, string serverName, string failoverGroupName, Management.Sql.LegacySdk.Models.FailoverGroup failoverGroup)
 {
     ResourceGroupName = resourceGroupName;
     ServerName        = serverName;
     FailoverGroupName = failoverGroup.Name;
     Id       = failoverGroup.Id;
     Location = failoverGroup.Location;
     FailoverGroupReadOnlyEndpoint  = failoverGroup.Properties.ReadOnlyEndpoint;
     FailoverGroupReadWriteEndpoint = failoverGroup.Properties.ReadWriteEndpoint;
     PartnerServers   = failoverGroup.Properties.PartnerServers;
     Databases        = failoverGroup.Properties.Databases;
     ReplicationRole  = failoverGroup.Properties.ReplicationRole;
     ReplicationState = failoverGroup.Properties.ReplicationState;
     Tags             = TagsConversionHelper.CreateTagDictionary(TagsConversionHelper.CreateTagHashtable(failoverGroup.Tags), false);
 }
        /// <summary>
        /// Converts the response from the service to a powershell database object
        /// </summary>
        /// <param name="resourceGroupName">The resource group the server is in</param>
        /// <param name="serverName">The name of the Azure Sql Database Server</param>
        /// <param name="pool">The service response</param>
        /// <returns>The converted model</returns>
        private AzureSqlFailoverGroupModel CreateFailoverGroupModelFromResponse(string resourceGroup, string serverName, Management.Sql.LegacySdk.Models.FailoverGroup failoverGroup)
        {
            AzureSqlFailoverGroupModel model = new AzureSqlFailoverGroupModel();

            model.ResourceGroupName       = resourceGroup;
            model.ServerName              = serverName;
            model.FailoverGroupName       = failoverGroup.Name;
            model.Databases               = failoverGroup.Properties.Databases;
            model.ReadOnlyFailoverPolicy  = failoverGroup.Properties.ReadOnlyEndpoint.FailoverPolicy;
            model.ReadWriteFailoverPolicy = failoverGroup.Properties.ReadWriteEndpoint.FailoverPolicy;
            model.ReplicationRole         = failoverGroup.Properties.ReplicationRole;
            model.ReplicationState        = failoverGroup.Properties.ReplicationState;
            model.PartnerServers          = failoverGroup.Properties.PartnerServers;
            model.FailoverWithDataLossGracePeriodHours = failoverGroup.Properties.ReadWriteEndpoint.FailoverWithDataLossGracePeriodMinutes == null ?
                                                         null : failoverGroup.Properties.ReadWriteEndpoint.FailoverWithDataLossGracePeriodMinutes / 60;

            model.Tags     = TagsConversionHelper.CreateTagDictionary(TagsConversionHelper.CreateTagHashtable(failoverGroup.Tags), false);
            model.Location = failoverGroup.Location;;

            return(model);
        }