public void ListPortsTest() { var os = new OpenStackMember(UserName, Password, TenantName, TenantId); var ports = os.ListPorts(); Assert.IsNotNull(ports); foreach (var p in ports) { Trace.WriteLine(string.Format("portId : {0}", p.Id)); Trace.WriteLine(string.Format("portName : {0}", p.Name)); Trace.WriteLine(string.Format("portMacAddress : {0}", p.MacAddress)); Trace.WriteLine(string.Format("portnetworkId : {0}", p.NetworkId)); Trace.WriteLine(string.Format("portTenantId : {0}", p.TenantId)); Trace.WriteLine(string.Format("portStatus : {0}", p.Status)); Trace.WriteLine(string.Format("portSecurityGroups : {0}", string.Join(",", p.SecurityGroups))); } }
private string GetInterfaceAttachmentIdByTesterName(string testerName = null) { testerName = testerName ?? TesterName; var os = new OpenStackMember(UserName, Password, TenantName); IEnumerable <Network> networks = os.ListNetworks(); Network n = networks.Where <Network>(x => x.Name == testerName).FirstOrDefault <Network>(); if (n == null) { try { n = os.CreateNetwork(testerName); Trace.WriteLine(string.Format("network added : {0}", DateTime.Now)); Trace.WriteLine(string.Format("NetworkId : {0}, Name : {1}", n.Id, n.Name)); } catch (Exception) { throw; } } IEnumerable <Port> ports = os.ListPorts(); Port p = ports.Where <Port>(x => x.Name == testerName).FirstOrDefault <Port>(); if (p == null) { try { p = os.CreatePort(n.Id); Trace.WriteLine(string.Format("port added : {0}", DateTime.Now)); Trace.WriteLine(string.Format("PortId : {0}, Name : {1}", p.Id, p.Name)); } catch (Exception) { throw; } } return(p.Id); }