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 AssignFloatingIP() { // 1. Make an internal network and subnet. var internalNetwork = await _testData.CreateNetwork(); var internalSubnet = await _testData.CreateSubnet(internalNetwork); // 2. Make an external network and subnet. Operator.NetworkDefinition externalNetworkDefinition = _testData.BuildNetwork(); externalNetworkDefinition.IsExternal = true; var externalNetwork = await _testData.CreateNetwork(externalNetworkDefinition); var externalSubnet = await _testData.CreateSubnet(externalNetwork); // 3. Make a router on the external network. var routerDefinition = new RouterCreateDefinition { Name = TestData.GenerateName(), ExternalGateway = new ExternalGatewayDefinition(externalNetwork.Id) }; var router = await _networkingService.CreateRouterAsync(routerDefinition); _testData.Register(router); // 4. Attach the router to the internal network. var internalPortId = await router.AttachSubnetAsync(internalSubnet.Id); _testData.Register(new Port { Id = internalPortId }); // 5. Make a floating ip on the external network. var floatingIPDefinition = new FloatingIPCreateDefinition(externalNetwork.Id); var floatingIP = await _networkingService.CreateFloatingIPAsync(floatingIPDefinition); _testData.Register(floatingIP); // 6. Make a server on the internal network. var serverDefinition = _computeTestData.BuildServer(); serverDefinition.Networks.Add(new ServerNetworkDefinition { NetworkId = internalNetwork.Id }); var server = await _computeTestData.CreateServer(serverDefinition); await server.WaitUntilActiveAsync(); // 7.Associate the floating ip to the server. await server.AssociateFloatingIPAsync(new AssociateFloatingIPRequest(floatingIP.FloatingIPAddress)); // 8. Disassociate the floating ip from the server await server.DisassociateFloatingIPAsync(floatingIP.FloatingIPAddress); }