コード例 #1
0
        /// <summary>
        ///     Destroy an instance of SQL Server.
        /// </summary>
        /// <returns>
        ///     A <see cref="Task"/> representing the operation.
        /// </returns>
        async Task DeprovisionServer()
        {
            switch (Provisioner.State.Phase)
            {
            case ServerProvisioningPhase.None:
            {
                goto case ServerProvisioningPhase.Ingress;
            }

            case ServerProvisioningPhase.Ingress:
            {
                StartDeprovisioningPhase(ServerProvisioningPhase.Ingress);

                await Provisioner.EnsureExternalServiceAbsent();

                goto case ServerProvisioningPhase.Monitoring;
            }

            case ServerProvisioningPhase.Monitoring:
            {
                StartDeprovisioningPhase(ServerProvisioningPhase.Monitoring);

                await Provisioner.EnsureServiceMonitorAbsent();

                goto case ServerProvisioningPhase.Network;
            }

            case ServerProvisioningPhase.Network:
            {
                StartDeprovisioningPhase(ServerProvisioningPhase.Network);

                await Provisioner.EnsureInternalServiceAbsent();

                goto case ServerProvisioningPhase.Instance;
            }

            case ServerProvisioningPhase.Instance:
            {
                StartDeprovisioningPhase(ServerProvisioningPhase.Instance);

                await Provisioner.EnsureDeploymentAbsent();

                goto case ServerProvisioningPhase.Security;
            }

            case ServerProvisioningPhase.Security:
            {
                StartDeprovisioningPhase(ServerProvisioningPhase.Security);

                await CredentialsProvisioner.EnsureCredentialsSecretAbsent();

                goto case ServerProvisioningPhase.Storage;
            }

            case ServerProvisioningPhase.Storage:
            {
                StartDeprovisioningPhase(ServerProvisioningPhase.Storage);

                await Provisioner.EnsureDataVolumeClaimAbsent();

                goto case ServerProvisioningPhase.Done;
            }

            case ServerProvisioningPhase.Done:
            {
                CompleteCurrentAction();

                break;
            }
            }
        }
コード例 #2
0
        /// <summary>
        ///     Reconfigure / repair an instance of SQL Server.
        /// </summary>
        /// <returns>
        ///     A <see cref="Task"/> representing the operation.
        /// </returns>
        async Task ReconfigureServer()
        {
            switch (Provisioner.State.Phase)
            {
            case ServerProvisioningPhase.None:
            {
                goto case ServerProvisioningPhase.Storage;
            }

            case ServerProvisioningPhase.Storage:
            {
                StartReconfigurationPhase(ServerProvisioningPhase.Storage);

                await Provisioner.EnsureDataVolumeClaimPresent();

                goto case ServerProvisioningPhase.Security;
            }

            case ServerProvisioningPhase.Security:
            {
                StartReconfigurationPhase(ServerProvisioningPhase.Security);

                await CredentialsProvisioner.EnsureCredentialsSecretPresent();

                goto case ServerProvisioningPhase.Instance;
            }

            case ServerProvisioningPhase.Instance:
            {
                StartReconfigurationPhase(ServerProvisioningPhase.Instance);

                await Provisioner.EnsureDeploymentPresent();

                goto case ServerProvisioningPhase.Network;
            }

            case ServerProvisioningPhase.Network:
            {
                StartReconfigurationPhase(ServerProvisioningPhase.Network);

                await Provisioner.EnsureInternalServicePresent();

                goto case ServerProvisioningPhase.Monitoring;
            }

            case ServerProvisioningPhase.Monitoring:
            {
                StartReconfigurationPhase(ServerProvisioningPhase.Monitoring);

                await Provisioner.EnsureServiceMonitorPresent();

                Become(WaitForServerAvailable);     // We can't proceed until the deployment becomes available.

                break;
            }

            case ServerProvisioningPhase.Configuration:
            {
                StartReconfigurationPhase(ServerProvisioningPhase.Configuration);

                await Provisioner.InitialiseServerConfiguration();

                goto case ServerProvisioningPhase.Ingress;
            }

            case ServerProvisioningPhase.Ingress:
            {
                StartReconfigurationPhase(ServerProvisioningPhase.Ingress);

                await Provisioner.EnsureExternalServicePresent();

                break;
            }

                // Reconfiguration completes when the server has valid Ingress details.
            }
        }