public void CreateUserAccessTest() { foreach (var m in TestEnvMembers.Members) { var os = new OpenStackMember(m.UserName, m.Password); var ua = os.CreateUserAccess(); Assert.IsNotNull(ua); Assert.IsNull(ua.Token.Tenant); os = new OpenStackMember(m.UserName, m.Password, m.TenantName); ua = os.CreateUserAccess(); Assert.IsNotNull(ua); Assert.IsNotNull(ua.Token.Tenant); Assert.IsNotNull(ua.Token.Tenant.Id); os = new OpenStackMember(m.UserName, m.Password, m.TenantName, m.TenantId); ua = os.CreateUserAccess(); Assert.IsNotNull(ua); Assert.IsNotNull(ua.Token.Tenant); os = new OpenStackMember(m.UserName, m.Password, m.TenantName, m.TenantId, "tyo1"); ua = os.CreateUserAccess(); Assert.IsNotNull(ua); Assert.IsNotNull(ua.Token.Tenant); os = new OpenStackMember(m.UserName, m.Password, null, m.TenantId, "tyo1"); ua = os.CreateUserAccess(); Assert.IsNotNull(ua); Assert.IsNotNull(ua.Token.Tenant); } }
public void ListFlavorsDetailsTest() { foreach (var m in TestEnvMembers.Members) { var os = new OpenStackMember(m.UserName, m.Password, m.TenantName); // without tenant, can not get endpoints. IEnumerable<Flavor> flavors = null; try { flavors = os.ListFlavors(); } catch (net.openstack.Core.Exceptions.UserAuthorizationException uae) { Assert.IsTrue(uae.Message.Equals("The user does not have access to the requested service or region.")); return; } os = new OpenStackMember(m.UserName, m.Password, m.TenantName); // with tenant flavors = os.ListFlavorsDetails(); Assert.IsNotNull(flavors); foreach (var f in flavors) { Assert.IsNotNull(f.Id); Assert.IsNotNull(f.Name); Assert.IsNotNull(f.Links); } } }
static void Main(string[] args) { string username = ""; // input your user name like gncu12345678 string password = ""; // input your own password string tenantname = ""; // input your own tenant name like gnct12345678 string tenantid = ""; // input your tenant id, which is 32 characters string region = "tyo1"; var osm = new OpenStackMember( username, password, tenantname, tenantid, defaultregion: region, bLazyProviderSetting: false ); var activeServer = osm.ListServers().FirstOrDefault(s => s.GetDetails().Status == ServerState.Active); if (activeServer != null) { Console.WriteLine(String.Format("{0} is active.", activeServer.Id)); var console = osm.GetVncConsole(activeServer.Id); Console.WriteLine(console.Url); System.Diagnostics.Process.Start(console.Url); } else { Console.WriteLine("there is no active servers."); } }
public Network GetNetworkByName(string name, ref OpenStackMember os) { var networks = (os ?? new OpenStackMember(UserName, Password, TenantName, TenantId)) .ListNetworks().Where<Network>(n => n.Name == name); if (networks != null && networks.Count() > 0) return networks.First<Network>(); else throw new ArgumentException("no network found"); }
public void ListEndpointsTest() { var os = new OpenStackMember(UserName, Password, TenantName, TenantId); var endpoints = os.ListEndpoints(); foreach (var ep in endpoints) { Trace.WriteLine(string.Format("{0} / {1} / {2} / {3}", ep.Name, ep.Region, ep.Type, ep.Url)); } }
public Pool GetPoolByName(string name, ref OpenStackMember os) { var pools = (os ?? new OpenStackMember(UserName, Password, TenantName, TenantId)) .ListPools().Where<Pool>(n => n.Name == name); if (pools != null && pools.Count() > 0) return pools.First<Pool>(); else throw new ArgumentException("no pool found"); }
public void GetVolumeTest() { var os = new OpenStackMember(UserName, Password, TenantName, TenantId); // with tenant var volumes = os.ListVolumesDetails(); Assert.IsNotNull(volumes); foreach (var v in volumes) { Assert.IsNotNull(v); } }
public void ListNetworksTest() { var os = new OpenStackMember(UserName, Password, TenantName, TenantId); var networks = os.ListNetworks(); Assert.IsNotNull(networks); foreach (var n in networks) { Trace.WriteLine(string.Format("networkid : {0}, name : {1}", n.Id, n.Name)); } }
public void GetVolumeTypeTest() { var os = new OpenStackMember(UserName, Password, TenantName, TenantId); // with tenant var types = os.ListVolumeTypes(); Assert.IsNotNull(types); foreach (var t in types) { var type = os.GetVolumeType(t.Id); Assert.IsNotNull(t); } }
public void GetGlanceImageTest() { var os = new OpenStackMember(UserName, Password, TenantName, TenantId); var images = os.ListGlanceImages(); Assert.IsNotNull(images); foreach (var i in images) { var image = os.GetGlanceImage(i.Id); Assert.IsNotNull(image); } }
public void GetOrderItemTest() { var os = new OpenStackMember(UserName, Password, TenantName); // with tenant var items = os.ListOrderItems(); Assert.IsNotNull(items); foreach (var i in items) { var item = os.GetOrderItem(i.Id); Assert.IsNotNull(item); Trace.WriteLine(string.Format("ItemId : {0}", item.Id)); Trace.WriteLine(string.Format("ServiceName : {0}", item.ServiceName)); Trace.WriteLine(string.Format("ItemStatus : {0}", item.Status)); Trace.WriteLine(string.Format("ServiceStartDate : {0}", item.ServiceStartDate)); Trace.WriteLine(string.Format("ProductName : {0}", item.ProductName)); Trace.WriteLine(string.Format("ProductName : {0}", item.UnitPrice)); } }
public void ListOrderItemsTest() { var os = new OpenStackMember(UserName, Password, TenantName); // with tenant var items = os.ListOrderItems(); Assert.IsNotNull(items); foreach (var i in items) { Assert.IsTrue(! string.IsNullOrEmpty(i.Id)); Trace.WriteLine(string.Format("Id : {0}", i.Id)); Assert.IsTrue(! string.IsNullOrEmpty(i.ServiceName)); Trace.WriteLine(string.Format("ServiceName : {0}", i.ServiceName)); Assert.IsTrue(! string.IsNullOrEmpty(i.ItemStatus)); Trace.WriteLine(string.Format("ItemStatus : {0}", i.ItemStatus)); Trace.WriteLine(string.Format("ServiceStartDate : {0}", i.ServiceStartDate)); } }
public void ListProductItemsTest() { var os = new OpenStackMember(UserName, Password, TenantName); // with tenant var productitems = os.ListProducts(); Assert.IsNotNull(productitems); foreach (var productitem in productitems) { Trace.WriteLine("======================================================="); Trace.WriteLine(string.Format("ServiceName : {0}", productitem.ServiceName)); if (productitem.Products != null) foreach (var p in productitem.Products) { Trace.WriteLine("\t======================================================="); Trace.WriteLine(string.Format("\tProductId : {0}", p.ProductId)); Trace.WriteLine(string.Format("\tProductName : {0}", p.ProductName)); Trace.WriteLine(string.Format("\tMnemonic : {0}", p.Mnemonic)); Trace.WriteLine(string.Format("\tProductPriceId : {0}", p.ProductPriceId)); Trace.WriteLine(string.Format("\tUnitPrice : {0}", p.UnitPrice)); Trace.WriteLine(string.Format("\tStartDate : {0}", p.StartDate)); } } }
public void TestMethod1() { var osm = new OpenStackMember( username, password, tenantname, tenantid, defaultregion: region, bLazyProviderSetting: false ); var activeServer = osm.ListServers().FirstOrDefault(s => s.GetDetails().Status == ServerState.Active); if (activeServer != null) { Trace.WriteLine(String.Format("{0} is active.", activeServer.Id)); var console = osm.GetVncConsole(activeServer.Id); Console.WriteLine(console.Url); System.Diagnostics.Process.Start(console.Url); } else { Console.WriteLine("there is no active servers."); } }
public void CreateVolumeTest() { int size = 200; var os = new OpenStackMember(UserName, Password, TenantName, TenantId); // with tenant var v = os.CreateVolume(size, name:"testVolume"); Assert.IsNotNull(v); os.WaitForVolumeAvailable(v.Id); bool b = os.DeleteVolume(v.Id); Assert.IsTrue(b); }
public void ListVolumesTest() { var os = new OpenStackMember(UserName, Password, TenantName, TenantId); // with tenant var volumes = os.ListVolumes(); Assert.IsNotNull(volumes); }
public Volume GetVolumeByName(string name) { var os = new OpenStackMember(UserName, Password, TenantName, TenantId); // with tenant var volumes = os.ListVolumes(); if (volumes != null) return volumes.First<Volume>(); else throw new ArgumentException("no item found"); }
public void GetHealthMonitorTest() { var os = new OpenStackMember(UserName, Password, TenantName, TenantId); var monitors = os.ListHealthMonitors(); Assert.IsNotNull(monitors); foreach (var m in monitors) { var monitor = os.GetHealthMonitor(m.Id); Assert.IsNotNull(monitor); Trace.WriteLine(string.Format("monitor.Id : {0}", monitor.Id)); Trace.WriteLine(string.Format("monitor.MaxRetries : {0}", monitor.MaxRetries)); Trace.WriteLine(string.Format("monitor.HttpMethod : {0}", monitor.HttpMethod)); Trace.WriteLine(string.Format("monitor.Timeout : {0}", monitor.Timeout)); Trace.WriteLine(string.Format("monitor.Type : {0}", monitor.Type)); Trace.WriteLine(string.Format("monitor.UrlPath : {0}", monitor.UrlPath)); } }
public void ListNetworkSecurityRulesTest() { var os = new OpenStackMember(UserName, Password, TenantName, TenantId); var rules = os.ListNetworkSecurityGroupRules(); Assert.IsNotNull(rules); }
public void DeleteNetworkSecurityGroupTest() { string name = "test_security_group"; string description = null; var os = new OpenStackMember(UserName, Password, TenantName, TenantId); var group = os.CreateNetworkSecurityGroup(name, description); Assert.IsNotNull(group); bool b = os.DeleteNetworkSecurityGroup(group.Id); Assert.IsTrue(b); }
public void CreateNetworkSecurityGroupTest() { string name = "test_security_group"; string description = string.Empty; var os = new OpenStackMember(UserName, Password, TenantName, TenantId); var group = os.CreateNetworkSecurityGroup(name, description); Assert.IsNotNull(group); }
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 GetNetworkTest() { var os = new OpenStackMember(UserName, Password, TenantName, TenantId); var networks = os.ListNetworks(); Assert.IsNotNull(networks); foreach (var n in networks) { var network = os.GetNetwork(n.Id); Assert.IsNotNull(network); } }
public void UpdateHealthMonitorTest() { var os = new OpenStackMember(UserName, Password, TenantName, TenantId); string monitorType = "TCP"; // PING or TCP or HTTP int delay = 5; // 5-10 int maxRetries = 1; // 1-5 string urlPath = null; string expectedCodes = null; // create var monitor = os.CreateHealthMonitor(monitorType, delay, maxRetries, urlPath, expectedCodes); try { // update int newDelay = 6; int newMaxRetries = 3; string newUrlPath = "http://www.google.com"; monitor = os.UpdateHealthMonitor(monitor.Id, newDelay, newMaxRetries, newUrlPath); Assert.IsNotNull(monitor); } finally { Assert.IsTrue(os.DeleteHealthMonitor(monitor.Id)); } }
public void CreateHealthMonitorTest() { var os = new OpenStackMember(UserName, Password, TenantName, TenantId); string monitorType = "TCP"; // PING or TCP or HTTP int delay = 10; // 5-10 int maxRetries = 1; // 1-5 string urlPath = null; string expectedCodes = null; var monitor = os.CreateHealthMonitor(monitorType, delay, maxRetries, urlPath, expectedCodes); Assert.IsNotNull(monitor); Assert.IsTrue(os.DeleteHealthMonitor(monitor.Id)); }
public void GetNetworkSecurityRuleTest() { string name = TesterName; string description = null; var os = new OpenStackMember(UserName, Password, TenantName, TenantId); var group = os.CreateNetworkSecurityGroup(name, description); Assert.IsNotNull(group); try { string direction = "ingress"; // "ingress" or "egress" string etherType = "IPv4"; // "IPv4" or "IPv6" string portRangeMin = null; string portRangeMax = null; string protocol = null; string remoteGroupId = null; string remoteIpPrefix = null; var rule = os.CreateNetworkSecurityGroupRule(group.Id, direction, etherType, portRangeMin, portRangeMax, protocol, remoteGroupId, remoteIpPrefix); Assert.IsNotNull(rule); rule = os.GetNetworkSecurityGroupRule(rule.Id); Trace.WriteLine(string.Format("rule id : {0}", rule.Id)); Trace.WriteLine(string.Format("rule EtherType : {0}", rule.EtherType)); Trace.WriteLine(string.Format("rule PortRangeMin : {0}", rule.PortRangeMin)); Trace.WriteLine(string.Format("rule PortRangeMax : {0}", rule.PortRangeMax)); Trace.WriteLine(string.Format("rule Protocol : {0}", rule.Protocol)); Trace.WriteLine(string.Format("rule RemoteIpPrefix : {0}", rule.RemoteIpPrefix)); Trace.WriteLine(string.Format("rule SecurityGroupId : {0}", rule.SecurityGroupId)); Trace.WriteLine(string.Format("rule RemoteGroupId : {0}", rule.RemoteGroupId)); Assert.IsTrue(os.DeleteNetworkSecurityGroupRule(rule.Id)); } finally { Assert.IsTrue(os.DeleteNetworkSecurityGroup(group.Id)); } }
public void GetIdentityApiEndPointTest() { var os = new OpenStackMember(UserName, Password, TenantName, TenantId); Assert.IsNotNull(os.IdentityProvider); }
public void CreateNetworkSecurityRuleTest() { string name = TesterName; string description = null; var os = new OpenStackMember(UserName, Password, TenantName, TenantId); var group = os.CreateNetworkSecurityGroup(name, description); Assert.IsNotNull(group); try { string direction = "ingress"; // "ingress" or "egress" string etherType = "IPv4"; // "IPv4" or "IPv6" string portRangeMin = null; string portRangeMax = null; string protocol = null; string remoteGroupId = null; string remoteIpPrefix = null; var rule = os.CreateNetworkSecurityGroupRule(group.Id, direction, etherType, portRangeMin, portRangeMax, protocol, remoteGroupId, remoteIpPrefix); Assert.IsNotNull(rule); Assert.IsTrue(os.DeleteNetworkSecurityGroupRule(rule.Id)); } finally { Assert.IsTrue(os.DeleteNetworkSecurityGroup(group.Id)); } }
public void GetNetworkSecurityGroupTest() { var os = new OpenStackMember(UserName, Password, TenantName, TenantId); var groups = os.ListNetworkSecurityGroups(); Assert.IsNotNull(groups); foreach (var g in groups) { var group = os.GetNetworkSecurityGroup(g.Id); Assert.IsNotNull(group); } }
public void DeleteLBMemberTest() { // hard to write code briefly. but deleted surely. string memberId = string.Empty; var os = new OpenStackMember(UserName, Password, TenantName, TenantId); bool b = os.DeleteLBMember(memberId); Assert.IsTrue(b); }