示例#1
0
        public void DisassociateFloatingIPFromServer()
        {
            var compute = new ComputeService(Stubs.AuthenticationProvider, "region");

            using (var httpTest = new HttpTest())
            {
                Identifier   serverId = Guid.NewGuid();
                const string ip       = "10.0.0.1";
                httpTest.RespondWithJson(new Server
                {
                    Id        = serverId,
                    Addresses =
                    {
                        ["network1"] = new List <ServerAddress>
                                              {
                                              new ServerAddress {
                                                  IP = ip, Type = AddressType.Floating
                                              }
                                              }
                    }
                });
                httpTest.RespondWith((int)HttpStatusCode.OK, "ip disassociated!");

                var server = compute.GetServer(serverId);
                server.DisassociateFloatingIP(ip);

                Assert.Null(server.Addresses["network1"].FirstOrDefault(a => a.IP == ip && a.Type == AddressType.Floating));
            }
        }
示例#2
0
        public async Task EvacuateServer()
        {
            using (var httpTest = new HttpTest())
            {
                Identifier serverId = Guid.NewGuid();
                httpTest.RespondWithJson(new Server {
                    Id = serverId
                });
                httpTest.RespondWith((int)HttpStatusCode.Accepted, "Roger that, boss");

                var server = _compute.GetServer(serverId);
                await server.EvacuateAsync(new EvacuateServerRequest(false));

                httpTest.ShouldHaveCalled($"*/servers/{serverId}/action");
                string lastRequest = httpTest.CallLog.Last().RequestBody;
                Assert.True(lastRequest.Contains("evacuate"));
            }
        }
示例#3
0
        public void DisassociateFloatingIPFromServer()
        {
            var compute = new ComputeService(Stubs.AuthenticationProvider, "region");

            using (var httpTest = new HttpTest())
            {
                Identifier serverId = Guid.NewGuid();
                const string ip = "10.0.0.1";
                httpTest.RespondWithJson(new Server
                {
                    Id = serverId,
                    Addresses =
                    {
                        ["network1"] = new List<ServerAddress>
                        {
                            new ServerAddress {IP = ip, Type = AddressType.Floating}
                        }
                    }
                });
                httpTest.RespondWith((int)HttpStatusCode.OK, "ip disassociated!");

                var server = compute.GetServer(serverId);
                server.DisassociateFloatingIP(ip);

                Assert.Null(server.Addresses["network1"].FirstOrDefault(a => a.IP == ip && a.Type == AddressType.Floating));
            }
        }