public AddInterfaceAttachment ( string serverId, string portId ) : InterfaceAttachment | ||
serverId | string | |
portId | string | |
Résultat | InterfaceAttachment |
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 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)); } }
public void GetInterfaceAttachmentTest() { var osm = new OpenStackMember(UserName, Password, TenantName, TenantId); SimpleServer ss = osm.ListServers().FirstOrDefault(s => s.GetDetails().Status == ServerState.Active); IEnumerable<InterfaceAttachment> interfaces = osm.ListInterfaceAttachments(ss.Id); Assert.IsNotNull(interfaces); Trace.WriteLine(string.Format("InterfaceAttachments count : {0}", interfaces.Count())); if (interfaces.Count() == 0) osm.AddInterfaceAttachment(ss.Id, GetInterfaceAttachmentIdByTesterName()); foreach (var _i in interfaces) { InterfaceAttachment i = osm.GetInterfaceAttachment(ss.Id, _i.PortId); Assert.IsNotNull(i); Assert.IsNotNull(i.PortId); Assert.IsNotNull(i.NetId); Assert.IsNotNull(i.MacAddr); Assert.IsNotNull(i.PortState); Trace.WriteLine(string.Format("PortId : {0}, NetId : {1}, MacAddress : {2}, PortState : {3}", i.PortId, i.NetId, i.MacAddr, i.PortState)); } }
public void AddInterfaceAttachmentTest_PortId_Invalid() { var osm = new OpenStackMember(UserName, Password, TenantName, TenantId); SimpleServer ss = osm.ListServers().FirstOrDefault(s => s.GetDetails().Status == ServerState.Active); // expect BadServiceRequestException InterfaceAttachment i = osm.AddInterfaceAttachment(ss.Id, InvalidId); }