DeleteInterfaceAttachment() public method

public DeleteInterfaceAttachment ( string serverId, string portId ) : bool
serverId string
portId string
return bool
        public void AddInterfaceAttachmentTest()
        {
            var osm = new OpenStackMember(UserName, Password, TenantName, TenantId);
            SimpleServer ss = osm.ListServers().FirstOrDefault(s => s.GetDetails().Status == ServerState.Active);
            Server server = osm.GetServer(ss.Id);
            Trace.WriteLine(string.Format("s.Status : {0}", server.Status));
            Trace.WriteLine(string.Format("s.VMState : {0}", server.VMState));

            // detach all port
            foreach (var _i in osm.ListInterfaceAttachments(ss.Id))
                Assert.IsTrue(osm.DeleteInterfaceAttachment(ss.Id, _i.PortId));

            // add interface
            var portId = GetInterfaceAttachmentIdByTesterName();
            InterfaceAttachment i = osm.AddInterfaceAttachment(ss.Id, portId);

            try
            {
                Trace.WriteLine(string.Format("interface attachment added : {0}", DateTime.Now));
                Trace.WriteLine(string.Format("PortId : {0}, NetId : {1}, MacAddress : {2}, PortState : {3}", i.PortId, i.NetId, i.MacAddr, i.PortState));
                Assert.IsNotNull(i);
                Assert.IsNotNull(i.PortId);
                Assert.IsNotNull(i.NetId);
                Assert.IsNotNull(i.MacAddr);
                Assert.IsNotNull(i.PortState);
            }
            finally
            {
                // delete interface
                Assert.IsTrue(osm.DeleteInterfaceAttachment(ss.Id, i.PortId));
            }
        }
        public void DeleteInterfaceAttachmentTest_InvalidId()
        {
            var osm = new OpenStackMember(UserName, Password, TenantName, TenantId);
            SimpleServer ss = osm.ListServers().FirstOrDefault(s => s.GetDetails().Status == ServerState.ShutOff);

            bool b = osm.DeleteInterfaceAttachment(ss.Id, InvalidId);
            // 成功が返ります。(202 Accepted)
        }
        public void DeleteInterfaceAttachmentTest_2Times_Sequencely()
        {
            var osm = new OpenStackMember(UserName, Password, TenantName, TenantId);
            SimpleServer ss = osm.ListServers().FirstOrDefault(s => s.GetDetails().Status == ServerState.Active);
            string attachmentId = GetInterfaceAttachmentIdByTesterName();

            bool b = osm.DeleteInterfaceAttachment(ss.Id, attachmentId);
            Assert.IsTrue(b);
            Trace.WriteLine(string.Format("interface attachment deleted : {0}", DateTime.Now));

            b = osm.DeleteInterfaceAttachment(ss.Id, attachmentId);
        }
        public void AddInterfaceAttachmentTest_2Times_Sequencely()
        {
            var osm = new OpenStackMember(UserName, Password, TenantName, TenantId);
            SimpleServer ss = osm.ListServers().FirstOrDefault(s => s.GetDetails().Status == ServerState.ShutOff);

            if (ss != null)
            {
                Server server = osm.GetServer(ss.Id);
                Trace.WriteLine(string.Format("s.Status : {0}", server.Status));
                Trace.WriteLine(string.Format("s.VMState : {0}", server.VMState));

                string portId = GetInterfaceAttachmentIdByTesterName();

                // the first time
                InterfaceAttachment i = osm.AddInterfaceAttachment(ss.Id, portId);
                Assert.IsNotNull(i);
                Assert.IsNotNull(i.PortId);
                Assert.IsNotNull(i.NetId);
                Assert.IsNotNull(i.MacAddr);
                Assert.IsNotNull(i.PortState);
                Trace.WriteLine(string.Format("interface attachment added : {0}", DateTime.Now));
                Trace.WriteLine(string.Format("PortId : {0}, NetId : {1}, MacAddress : {2}, PortState : {3}", i.PortId, i.NetId, i.MacAddr, i.PortState));

                // the second time, expected BadServiceRequestException but ItemNotFundException occurs
                AssertCatch<BadServiceRequestException>(() => i = osm.AddInterfaceAttachment(ss.Id, portId));

                // delete interface
                Assert.IsTrue(osm.DeleteInterfaceAttachment(ss.Id, i.PortId));
            }
        }