public RequestUri BeginCreate(DeploymentSlotUri deploymentUri, IDeploymentConfiguration configuration)
 {
     BeginCreateDeploymentUri = deploymentUri;
     BeginCreateConfiguration = configuration;
     RunScript();
     return deploymentUri.ToRequestUri(NextRequestId);
 }
 public AzureDeploymentCheckOutcome CheckDeploymentStatus(DeploymentSlotUri deploymentUri)
 {
     CheckStatusCounter++;
     CheckStatusDeploymentUri = deploymentUri;
     RunScript();
     return NextDeploymentCheckOutcome;
 }
        public RequestUri BeginDelete(DeploymentSlotUri deploymentUri)
        {
            OurTrace.TraceVerbose("BeginDelete");
            var response = _http.Delete(deploymentUri.ToString());
            var statusCode = response.StatusCode;

            if (statusCode.IsAccepted())
                return deploymentUri.ToRequestUri(response.AzureRequestIdHeader);

            if (statusCode.IsConflict())
                return null;

            ThrowUnexpectedHttpResponse(response);
            return null; // can't be reached
        }
        public RequestUri BeginUpgrade(DeploymentSlotUri deploymentUri, DeploymentConfiguration configuration)
        {
            OurTrace.TraceVerbose("BeginUpgrade");
            var xml = configuration.MakeUpgradeDeploymentMessage();
            OurTrace.TraceInfo(xml);

            var response = _http.Post(deploymentUri + "/?comp=upgrade", xml);
            var statusCode = response.StatusCode;

            if (statusCode.IsAccepted())
                return deploymentUri.ToRequestUri(response.AzureRequestIdHeader);

            if (statusCode.IsConflict())
                return null;

            ThrowUnexpectedHttpResponse(response);
            return null; // can't be reached.
        }
        public bool DoesDeploymentExist(DeploymentSlotUri deploymentUri)
        {
            var outcome = AzureDeploymentCheckOutcome.None;

            var retry = new RetryLogic(_maxRetries, _sleepIntervalMilliseconds);
            retry.Execute(
                () => outcome = _managementLowLevelApi.CheckDeploymentStatus(deploymentUri),
                ex => RetryOrRethrow.Rethrow,
                () => outcome != AzureDeploymentCheckOutcome.Failed);

            switch (outcome)
            {
                case AzureDeploymentCheckOutcome.Running:
                case AzureDeploymentCheckOutcome.Suspended:
                    return true;
                case AzureDeploymentCheckOutcome.NotFound:
                    return false;
                default:
                    FailFast.WithMessage("Unexpected AzureDeploymentCheckOutcome: " + outcome);
                    // ReSharper disable HeuristicUnreachableCode
                    return false;
                    // ReSharper restore HeuristicUnreachableCode
            }
        }
            public void WaitForDeploymentStatus(DeploymentSlotUri deploymentUri, AzureDeploymentCheckOutcome status)
            {
                Assert.That(WaitCompleted, Is.False);

                Assert.That(deploymentUri, Is.EqualTo(ExpectedDeploymentUri));
                Assert.That(status, Is.EqualTo(CurrentState));

                WaitCompleted = true;
            }
 public void Upgrade(DeploymentSlotUri deploymentSlotUri, DeploymentConfiguration configuration)
 {
     throw new NotImplementedException();
 }
            public void Suspend(DeploymentSlotUri deploymentUri)
            {
                if (CurrentState != AzureDeploymentCheckOutcome.Suspended)
                {
                    Assert.That(WaitCompleted, Is.True);

                    Assert.That(deploymentUri, Is.EqualTo(ExpectedDeploymentUri));
                    Assert.That(CurrentState, Is.EqualTo(AzureDeploymentCheckOutcome.Running));
                }

                WaitCompleted = false;
                CurrentState = AzureDeploymentCheckOutcome.Suspended;
            }
 public bool DoesDeploymentExist(DeploymentSlotUri deploymentUri)
 {
     Assert.That(deploymentUri, Is.EqualTo(ExpectedDeploymentUri));
     return CurrentState == AzureDeploymentCheckOutcome.Running
            || CurrentState == AzureDeploymentCheckOutcome.Suspended;
 }
 public RequestUri BeginUpgrade(DeploymentSlotUri deploymentSlotUri, DeploymentConfiguration configuration)
 {
     throw new NotImplementedException();
 }
 public RequestUri BeginSuspend(DeploymentSlotUri deploymentUri)
 {
     BeginSuspendDeploymentUri = deploymentUri;
     RunScript();
     return deploymentUri.ToRequestUri(NextRequestId);
 }
 public RequestUri BeginDelete(DeploymentSlotUri deploymentUri)
 {
     BeginDeleteDeploymentUri = deploymentUri;
     RunScript();
     return deploymentUri.ToRequestUri(NextRequestId);
 }
        public void WaitForDeploymentStatus(DeploymentSlotUri deploymentUri, AzureDeploymentCheckOutcome status)
        {
            FailFast.Unless(
                status != AzureDeploymentCheckOutcome.Failed,
                "can't wait on Failed!");

            var outcome = AzureDeploymentCheckOutcome.None;

            var retry = new RetryLogic(_maxRetries, _sleepIntervalMilliseconds);
            retry.Execute(
                () => outcome = _managementLowLevelApi.CheckDeploymentStatus(deploymentUri),
                ex => RetryOrRethrow.Rethrow,
                () => outcome == status);
        }
 public void Upgrade(DeploymentSlotUri deploymentSlotUri, DeploymentConfiguration configuration)
 {
     ExecuteAsynchronousAction(() => _managementLowLevelApi.BeginUpgrade(deploymentSlotUri, configuration));
 }
 public void Suspend(DeploymentSlotUri deploymentUri)
 {
     ExecuteAsynchronousAction(() => _managementLowLevelApi.BeginSuspend(deploymentUri));
 }
Ejemplo n.º 16
0
 public AzureDeploymentSlot(IAzureManagementApiWithRetries azureManagementApi, DeploymentSlotUri deploymentSlotUri)
 {
     _apiWithRetries = azureManagementApi;
     _deploymentSlotUri = deploymentSlotUri;
 }
        private RequestUri ChangeStatus(DeploymentSlotUri deploymentUri, string newStatus)
        {
            OurTrace.TraceVerbose("Changing status to:" + newStatus);
            FailFast.Unless(newStatus == "Suspended" || newStatus == "Running",
                            "status must be 'Running' or 'Suspended'");

            var updateDeploymentUri = string.Format("{0}/?comp=status", deploymentUri);
            var suspendXml = BuildUpdateDeploymentStatusXml(newStatus);

            var response = _http.Post(updateDeploymentUri, suspendXml);
            var statusCode = response.StatusCode;

            if (statusCode.IsAccepted())
                return deploymentUri.ToRequestUri(response.AzureRequestIdHeader);

            if (statusCode.IsConflict())
                return null;

            ThrowUnexpectedHttpResponse(response);
            return null; // can't be reached.
        }
            public bool WaitCompleted = true; // always start with true.

            #endregion Fields

            #region Methods

            public void Create(DeploymentSlotUri deploymentUri, IDeploymentConfiguration configuration)
            {
                Assert.That(WaitCompleted, Is.True);

                LastDeploymentConfiguration = configuration;

                Assert.That(deploymentUri, Is.EqualTo(ExpectedDeploymentUri));
                Assert.That(CurrentState, Is.EqualTo(AzureDeploymentCheckOutcome.NotFound));

                WaitCompleted = false;
                CurrentState = AzureDeploymentCheckOutcome.Running;
            }
 public RequestUri BeginSuspend(DeploymentSlotUri deploymentUri)
 {
     OurTrace.TraceVerbose("BeginSuspend");
     return ChangeStatus(deploymentUri, "Suspended");
 }
            public void Delete(DeploymentSlotUri deploymentUri)
            {
                Assert.That(WaitCompleted, Is.True);

                Assert.That(deploymentUri, Is.EqualTo(ExpectedDeploymentUri));
                Assert.That(CurrentState, Is.EqualTo(AzureDeploymentCheckOutcome.Suspended));

                WaitCompleted = false;
                CurrentState = AzureDeploymentCheckOutcome.NotFound;
                DeletedAtLeastOnce = true;
            }
        public AzureDeploymentCheckOutcome CheckDeploymentStatus(DeploymentSlotUri deploymentUri)
        {
            try
            {
                var response = _http.Get(deploymentUri.ToString());

                if (response.StatusCode == HttpStatusCode.NotFound)
                    return AzureDeploymentCheckOutcome.NotFound;
                if (response.StatusCode != HttpStatusCode.OK)
                    return AzureDeploymentCheckOutcome.Failed;
                var statusText = CrackStatusTextFromResponse(response);
                OurTrace.TraceVerbose("CheckDeploymentStatus: " + statusText);
                return TranslateStatusText(statusText);
            }
            catch(UnhandledHttpException)
            {
                return AzureDeploymentCheckOutcome.Failed;
            }
        }
 public void Delete(DeploymentSlotUri deploymentUri)
 {
     ExecuteAsynchronousAction(() => _managementLowLevelApi.BeginDelete(deploymentUri));
 }