public void UpdatePoolTest() { var os = new OpenStackMember(UserName, Password, TenantName, TenantId); // string tenantId = os.IdentityProvider.GetToken(os.Identity).Tenant.Id; // create pool string pool_name = GetTesterNameByEnv(); string TokyoLBaas_subnetId = GetSubnetIdByRegion(region: null); string[] lbMethods = { "ROUND_ROBIN", "LEAST_CONNECTIONS" }; string protocol = "TCP"; foreach (var lbMethod in lbMethods) { var p = os.CreatePool(pool_name, TokyoLBaas_subnetId, lbMethod, protocol); Trace.WriteLine(string.Format("pool Status : {0}", p.Status)); System.Threading.Thread.Sleep(1000 * 10); Trace.WriteLine(string.Format("pool Status : {0}", p.Status)); try { foreach (var newLbMethod in lbMethods) { os.UpdatePool(p.Id, "newName", newLbMethod); // not tested yet. //os.UpdatePool(p.Id, "日本語", lbMethod); //os.UpdatePool(p.Id, "//", lbMethod); } } finally { Assert.IsTrue(os.DeletePool(p.Id)); } } }
public void CreatePoolTest() { var osm = new OpenStackMember(UserName, Password, TenantName, TenantId); // create pool string pool_name = GetTesterNameByEnv(); string TokyoLBaas_subnetId = GetSubnetIdByRegion(region: null); string[] lbMethods = { "ROUND_ROBIN", "LEAST_CONNECTIONS" }; string protocol = "TCP"; foreach (var lbMethod in lbMethods) { var p = osm.CreatePool(pool_name, TokyoLBaas_subnetId, lbMethod, protocol); try { Assert.IsNotNull(p); Trace.WriteLine(string.Format("pool Name : {0}", p.Name)); Trace.WriteLine(string.Format("pool Id : {0}", p.Id)); Trace.WriteLine(string.Format("pool Protocol : {0}", p.Protocol)); Trace.WriteLine(string.Format("pool Description : {0}", p.Description)); Trace.WriteLine(string.Format("pool LbMethod : {0}", p.LbMethod)); Trace.WriteLine(string.Format("pool HealthMonitors : {0}", string.Join(",", p.HealthMonitors))); Trace.WriteLine(string.Format("pool Members : {0}", string.Join(",", p.Members))); } finally { Assert.IsTrue(osm.DeletePool(p.Id)); } } }
public void UpdateLBMemberTest() { var osm = new OpenStackMember(UserName, Password, TenantName, TenantId); // get server SimpleServer ss = osm.ListServers().FirstOrDefault(s => s.GetDetails().Status == ServerState.Active); // get ipv4, sometimes server does not have network interface. ServerAddresses addresses = ss.GetDetails().ListAddresses(); Assert.IsNotNull(addresses["default_global"]); Assert.IsTrue(addresses["default_global"].Count() > 0); var ip = addresses["default_global"]. Where(a => a.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) .First <System.Net.IPAddress>(); // create pool string pool_name = GetTesterNameByEnv(); string TokyoLBaas_subnetId = GetSubnetIdByRegion(region: null); int weight = 1; string[] lbMethods = { "ROUND_ROBIN", "LEAST_CONNECTIONS" }; string protocol = "TCP"; foreach (var lbMethod in lbMethods) { // create pool var p = osm.CreatePool(pool_name, TokyoLBaas_subnetId, lbMethod, protocol); try { // create member string address = ip.ToString(); // ip address virtual machine is having. ? string protocolPort = "80"; // a valid value is from 0 to 65535. var member = osm.CreateLBMember(p.Id, address, protocolPort, weight); Assert.IsNotNull(member); try { // update member(toggle adminStateUp) var updatedMember = osm.UpdateLBMember(member.Id, (weight == 1 ? 0 : 1)); Assert.IsNotNull(updatedMember); Assert.IsTrue(updatedMember.Weight != (weight == 1 ? 0 : 1)); } finally { // delete member Assert.IsTrue(osm.DeleteLBMember(member.Id)); } } finally { // Assert.IsTrue(os.DeletePool(p.Id)); } } }
public void CreateVIPTest() { var os = new OpenStackMember(UserName, Password, TenantName, TenantId); // Get Pool Pool pool; try { pool = GetPoolByName(TesterName, ref os); } catch (ArgumentException pae) { if (pae.Message.Equals("no pool found")) { // Get Subnet Subnet subnet; try { // subnet = GetSubnetByName(TesterName, ref os); subnet = os.GetSubnet("20f429bb-472c-403d-b9ec-e637475f1602"); // fixed tyo1 subnet } catch (ArgumentException sae) { if (sae.Message.Equals("no subnet found")) { // Get Network Network network; try { network = GetNetworkByName(TesterName, ref os); } catch (ArgumentException nae) { if (nae.Message.Equals("no network found")) { // var tenantId = os.IdentityProvider.GetToken(os.Identity).Tenant.Id; network = os.CreateNetwork(TesterName); Assert.IsNotNull(network); } else { throw; } } subnet = os.CreateSubnet(TesterName, network.Id, ipVersion: 4, cidr: "192.168.2.0/24"); Assert.IsNotNull(subnet); } else { throw; } } var subnetId = GetSubnetIdByRegion(region: null); pool = os.CreatePool(TesterName, TenantId, subnetId); Assert.IsNotNull(pool); } else { throw; } } string name = GetTesterNameByEnv();; string protocol = "TCP"; // TCP Only string protocolPort = "80"; // A valid value is from 0 to 65535. string poolId = GetPoolByName(TesterName, ref os).Id; string TokyoLBaas_subnetId = GetSubnetIdByRegion(region: null); string address = "157.7.81.200"; // cidr of (subnetid=20f429bb-472c-403d-b9ec-e637475f1602) is "157.7.81.128/27" bool adminStateUp = true; string description = null; string sessionPpersistence = null; int? connectionLimit = null; var vip = os.CreateVIP(name, protocol, protocolPort, poolId, TokyoLBaas_subnetId, address, adminStateUp, description, sessionPpersistence, connectionLimit); Assert.IsNotNull(vip); }