/// <summary>
        /// Waits for the image to enter a specified state.
        /// </summary>
        /// <remarks>
        /// When the method returns, the current instance is updated to reflect the state
        /// of the image at the end of the operation.
        ///
        /// <note type="caller">
        /// This is a blocking operation and will not return until the image enters either the expected state, an error state, or the retry count is exceeded.
        /// </note>
        /// </remarks>
        /// <param name="expectedState">The expected state.</param>
        /// <param name="errorStates">The error state(s) in which to throw an exception if the image enters.</param>
        /// <param name="refreshCount">Number of times to poll the image's status.</param>
        /// <param name="refreshDelay">The time to wait between polling requests for the image status. If this value is <see langword="null"/>, the default is 2.4 seconds.</param>
        /// <param name="progressUpdatedCallback">A callback delegate to execute each time the <see cref="ServerImage.Progress"/> value increases. If this value is <see langword="null"/>, progress updates are not reported.</param>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="expectedState"/> is <see langword="null"/>.
        /// <para>-or-</para>
        /// <para>If <paramref name="errorStates"/> is <see langword="null"/>.</para>
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// If <paramref name="refreshCount"/> is less than 0.
        /// <para>-or-</para>
        /// <para>If <paramref name="refreshDelay"/> is negative.</para>
        /// </exception>
        /// <exception cref="ImageEnteredErrorStateException">If the method returned due to the image entering one of the <paramref name="errorStates"/>.</exception>
        /// <exception cref="ResponseException">If the REST API request failed.</exception>
        /// <seealso cref="IComputeProvider.WaitForImageState(string, ImageState, ImageState[], int, TimeSpan?, Action{int}, string, CloudIdentity)"/>
        public void WaitForState(ImageState expectedState, ImageState[] errorStates, int refreshCount = 600, TimeSpan?refreshDelay = null, Action <int> progressUpdatedCallback = null)
        {
            if (expectedState == null)
            {
                throw new ArgumentNullException("expectedState");
            }
            if (errorStates == null)
            {
                throw new ArgumentNullException("errorStates");
            }
            if (refreshCount < 0)
            {
                throw new ArgumentOutOfRangeException("refreshCount");
            }
            if (refreshDelay < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException("refreshDelay");
            }

            var details = Provider.WaitForImageState(Id, expectedState, errorStates, refreshCount, refreshDelay, progressUpdatedCallback, Region, Identity);

            UpdateThis(details);
        }
示例#2
0
 /// <inheritdoc/>
 protected override ImageState FromName(string name)
 {
     return(ImageState.FromName(name));
 }
示例#3
0
        /// <summary>
        /// Waits for the image to enter a particular <see cref="ImageState"/>
        /// </summary>
        /// <param name="expectedState">The expected <see cref="ImageState"/></param>
        /// <param name="errorStates">A list of <see cref="ImageState"/>s in which to throw an exception if the server enters. </param>
        /// <param name="refreshCount">Number of times to check the images status</param>
        /// <param name="refreshDelay">The time to wait each time before requesting the status for the image. If this value is <c>null</c>, the default is 2.4 seconds.</param>
        /// <param name="progressUpdatedCallback">A callback delegate to execute each time the <see cref="SimpleServer"/>s Progress value increases.</param>
        public void WaitForState(ImageState expectedState, ImageState[] errorStates, int refreshCount = 600, TimeSpan?refreshDelay = null, Action <int> progressUpdatedCallback = null)
        {
            var details = Provider.WaitForImageState(Id, expectedState, errorStates, refreshCount, refreshDelay, progressUpdatedCallback, Region);

            UpdateThis(details);
        }