public async Task EvacuateServerTest() { var server = await _testData.CreateServer(); await server.WaitUntilActiveAsync(); Trace.WriteLine($"Created server named: {server.Name}"); Trace.WriteLine("Evacuating the server to a new host..."); var request = new EvacuateServerRequest(false) { AdminPassword = "******" }; // Our service isn't down, so we can't really evacuate. // Just check that the request would have gone through (i.e. was valid) // and only was rejected because the compute service is healthy try { await server.EvacuateAsync(request); } catch (FlurlHttpException httpError) when(httpError.Call.ErrorResponseBody.Contains("is still in use")) { // Hurray! the test passed } }
public async Task EvacuateServerTest() { var server = await _testData.CreateServer(); await server.WaitUntilActiveAsync(); Trace.WriteLine($"Created server named: {server.Name}"); Trace.WriteLine("Evacuating the server to a new host..."); var request = new EvacuateServerRequest(false) { AdminPassword = "******" }; // Our service isn't down, so we can't really evacuate. // Just check that the request would have gone through (i.e. was valid) // and only was rejected because the compute service is healthy try { await server.EvacuateAsync(request); } catch (FlurlHttpException httpError) when (httpError.Call.ErrorResponseBody.Contains("is still in use")) { // Hurray! the test passed } }
/// <inheritdoc cref="ComputeApi.EvacuateServerAsync" /> /// <summary /> /// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception> public static async Task EvacuateAsync(this ServerReference server, EvacuateServerRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var compute = server.GetOwnerOrThrow<ComputeApi>(); await compute.EvacuateServerAsync(server.Id, request, cancellationToken).ConfigureAwait(false); }
/// <inheritdoc cref="ComputeApi.EvacuateServerAsync" /> public static Task EvacuateServerAsync(this ComputeService service, Identifier serverId, EvacuateServerRequest request, CancellationToken cancellationToken = default(CancellationToken)) { return service._computeApi.EvacuateServerAsync(serverId, request, cancellationToken); }
/// <inheritdoc cref="ComputeApi.EvacuateServerAsync" /> public static Task EvacuateServerAsync(this ComputeService service, Identifier serverId, EvacuateServerRequest request, CancellationToken cancellationToken = default(CancellationToken)) { return(service._computeApi.EvacuateServerAsync(serverId, request, cancellationToken)); }
/// <inheritdoc cref="ComputeApi.EvacuateServerAsync" /> /// <summary /> /// <exception cref="InvalidOperationException">When this instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception> public static async Task EvacuateAsync(this ServerReference server, EvacuateServerRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var compute = server.GetOwnerOrThrow <ComputeApi>(); await compute.EvacuateServerAsync(server.Id, request, cancellationToken).ConfigureAwait(false); }