ConoHaNet.OpenStackMember.CreateVIP C# (CSharp) Method

CreateVIP() public method

public CreateVIP ( string name, string protocol, string protocolPort, string poolId, string subnetId, string address, bool adminStateUp, string description = null, string sessionPpersistence = null, int connectionLimit = null ) : VIP
name string
protocol string
protocolPort string
poolId string
subnetId string
address string
adminStateUp bool
description string
sessionPpersistence string
connectionLimit int
return VIP
        public VIP CreateVIP(string name, string protocol, string protocolPort, string poolId, string subnetId, string address, bool adminStateUp, string description = null, string sessionPpersistence = null, int? connectionLimit = null)
        {
            return NetworksProvider.CreateVIP(name, protocol, protocolPort, poolId, subnetId, address, adminStateUp, description, sessionPpersistence, connectionLimit, this.DefaultRegion, this.Identity);
        }

Usage Example

        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);
        }
OpenStackMember