/// <summary> /// Initializes a new instance of the <see cref="ServerEnteredErrorStateException"/> class /// with the specified error state. /// </summary> /// <param name="status">The error state entered by the server.</param> /// <exception cref="ArgumentNullException">If <paramref name="status"/> is <c>null</c>.</exception> public ServerEnteredErrorStateException(ServerState status) : base(string.Format("The server entered an error state: '{0}'", status)) { if (status == null) throw new ArgumentNullException("status"); _state.Status = status.Name; #if !NET35 SerializeObjectState += (ex, args) => args.AddSerializedState(_state); #endif }
public static IEnumerable<Server> ListAllServersWithDetails(IComputeProvider provider, int? blockSize = null, string imageId = null, string flavorId = null, string name = null, ServerState status = null, DateTimeOffset? changesSince = null, string region = null, CloudIdentity identity = null) { if (blockSize <= 0) throw new ArgumentOutOfRangeException("blockSize"); Server lastServer = null; do { string marker = lastServer != null ? lastServer.Id : null; IEnumerable<Server> servers = provider.ListServersWithDetails(imageId, flavorId, name, status, marker, blockSize, changesSince, region, identity); lastServer = null; foreach (Server server in servers) { lastServer = server; yield return server; } } while (lastServer != null); }
/// <summary> /// Waits for the server to enter a specified state. /// </summary> /// <remarks> /// When the method returns, the current instance is updated to reflect the state /// of the server at the end of the operation. /// /// <note type="caller"> /// This is a blocking operation and will not return until the server enters either an 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 server enters.</param> /// <param name="refreshCount">Number of times to poll the server's status.</param> /// <param name="refreshDelay">The time to wait between polling requests for the server 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="Server.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="ServerEnteredErrorStateException">If the method returned due to the server entering one of the <paramref name="errorStates"/>.</exception> /// <exception cref="ResponseException">If the REST API request failed.</exception> public void WaitForState(ServerState expectedState, ServerState[] 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.WaitForServerState(Id, expectedState, errorStates, refreshCount, refreshDelay ?? TimeSpan.FromMilliseconds(2400), progressUpdatedCallback, Region, Identity); UpdateThis(details); }
/// <summary> /// Waits for the server to enter a particular <see cref="ServerState"/> /// </summary> /// <param name="expectedState">The expected <see cref="ServerState"/></param> /// <param name="errorStates">A list of <see cref="ServerState"/>s in which to throw an exception if the server enters. </param> /// <param name="refreshCount">Number of times to check the server status</param> /// <param name="refreshDelay">The time to wait each time before requesting the status for the server. 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(ServerState expectedState, ServerState[] errorStates, int refreshCount = 600, TimeSpan?refreshDelay = null, Action <int> progressUpdatedCallback = null) { var details = Provider.WaitForServerState(Id, expectedState, errorStates, refreshCount, refreshDelay ?? TimeSpan.FromMilliseconds(2400), progressUpdatedCallback, Region); UpdateThis(details); }
/// <inheritdoc/> protected override ServerState FromName(string name) { return(ServerState.FromName(name)); }