LBaaS V1 removal from nfp for newton support.
1) Removed LBaaS V1 code from nfp. 2) LBaaSV2 will be default LB service. 3) Renamed 'haproxy_lbaasv2' vendor to 'haproxy'. Change-Id: Ieb0db3ce00f36f69d2587db278f1f9adc8de8666
This commit is contained in:
@@ -20,70 +20,80 @@ class DummyDictionaries(object):
|
||||
testing the heat_driver test cases.
|
||||
"""
|
||||
|
||||
DEFAULT_LB_CONFIG = {
|
||||
u'heat_template_version': u'2013-05-23',
|
||||
u'description': u'Configuration for Haproxy Neutron LB service',
|
||||
u'parameters': {
|
||||
u'Subnet': {
|
||||
u'type': u'string',
|
||||
u'description': u'Pool Subnet-CIDR, on which VIP port created'
|
||||
DEFAULT_LBV2_CONFIG = {
|
||||
"heat_template_version": "2015-10-15",
|
||||
"description": "Configuration for Haproxy Neutron LB V2 service",
|
||||
"parameters": {
|
||||
"lb_port": {
|
||||
"type": "number",
|
||||
"default": 80,
|
||||
"description": "Port used by the load balancer"
|
||||
},
|
||||
u'vip_ip': {
|
||||
u'type': u'string',
|
||||
u'description': u'VIP IP Address'
|
||||
"app_port": {
|
||||
"type": "number",
|
||||
"default": 80,
|
||||
"description": "Port used by the servers"
|
||||
},
|
||||
u'service_chain_metadata': {
|
||||
u'type': u'string',
|
||||
u'description': u'sc metadata'
|
||||
"Subnet": {
|
||||
"type": "string",
|
||||
"description": "Subnet on which the LB will be located"
|
||||
},
|
||||
"vip_ip": {
|
||||
"type": "string",
|
||||
"description": "VIP IP Address"
|
||||
},
|
||||
"service_chain_metadata": {
|
||||
"type": "string",
|
||||
"description": "sc metadata"
|
||||
}
|
||||
},
|
||||
u'resources': {
|
||||
u'LoadBalancerPool': {
|
||||
u'type': u'OS::Neutron::Pool',
|
||||
u'properties': {
|
||||
u'lb_method': u'ROUND_ROBIN',
|
||||
u'protocol': u'TCP',
|
||||
u'name': u'Haproxy pool-lb-chain',
|
||||
u'admin_state_up': True,
|
||||
u'subnet_id': {
|
||||
u'get_param': u'Subnet'
|
||||
},
|
||||
u'vip': {
|
||||
u'subnet': {
|
||||
u'get_param': u'Subnet'
|
||||
},
|
||||
u'description': {
|
||||
u'get_param': u'service_chain_metadata'
|
||||
},
|
||||
u'admin_state_up': True,
|
||||
u'connection_limit': -1,
|
||||
u'address': {
|
||||
u'get_param': u'vip_ip'
|
||||
},
|
||||
u'protocol_port': 3939,
|
||||
u'name': u'LoadBalancerPool vip-lb-chain'
|
||||
},
|
||||
u'provider': u'haproxy_on_vm',
|
||||
u'monitors': [{u'get_resource': u'HealthMonitor'}],
|
||||
u'description': u'Haproxy pool from template'
|
||||
"resources": {
|
||||
"monitor": {
|
||||
"type": "OS::Neutron::LBaaS::HealthMonitor",
|
||||
"properties": {
|
||||
"delay": 3,
|
||||
"type": "HTTP",
|
||||
"timeout": 3,
|
||||
"max_retries": 3,
|
||||
"pool": {
|
||||
"get_resource": "pool"
|
||||
}
|
||||
}
|
||||
},
|
||||
u'HealthMonitor': {
|
||||
u'type': u'OS::Neutron::HealthMonitor',
|
||||
u'properties': {
|
||||
u'delay': 20,
|
||||
u'max_retries': 5,
|
||||
u'type': u'PING',
|
||||
u'timeout': 10,
|
||||
u'admin_state_up': True
|
||||
"pool": {
|
||||
"type": "OS::Neutron::LBaaS::Pool",
|
||||
"properties": {
|
||||
"lb_algorithm": "ROUND_ROBIN",
|
||||
"protocol": "HTTP",
|
||||
"listener": {
|
||||
"get_resource": "listener"
|
||||
}
|
||||
}
|
||||
},
|
||||
u'LoadBalancer': {
|
||||
u'type': u'OS::Neutron::LoadBalancer',
|
||||
u'properties': {
|
||||
u'protocol_port': 101,
|
||||
u'pool_id': {
|
||||
u'get_resource': u'LoadBalancerPool'
|
||||
"listener": {
|
||||
"type": "OS::Neutron::LBaaS::Listener",
|
||||
"properties": {
|
||||
"loadbalancer": {
|
||||
"get_resource": "loadbalancer"
|
||||
},
|
||||
"protocol": "HTTP",
|
||||
"protocol_port": {
|
||||
"get_param": "lb_port"
|
||||
}
|
||||
}
|
||||
},
|
||||
"loadbalancer": {
|
||||
"type": "OS::Neutron::LBaaS::LoadBalancer",
|
||||
"properties": {
|
||||
"vip_subnet": {
|
||||
"get_param": "Subnet"
|
||||
},
|
||||
"provider": "loadbalancerv2",
|
||||
"vip_address": {
|
||||
"get_param": "vip_ip"
|
||||
},
|
||||
"description": {
|
||||
"get_param": "service_chain_metadata"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -493,17 +503,6 @@ class DummyDictionaries(object):
|
||||
'fw_policy_key': u'sc_firewall_policy'
|
||||
}
|
||||
|
||||
pool_members = {
|
||||
'type': 'OS::Neutron::PoolMember',
|
||||
'properties': {
|
||||
'protocol_port': 101,
|
||||
'admin_state_up': True,
|
||||
'pool_id': {'get_resource': u'LoadBalancerPool'},
|
||||
'weight': 1,
|
||||
'address': u'42.0.0.13'
|
||||
}
|
||||
}
|
||||
|
||||
fw_scn_config = "{\"heat_template_version\": \"2013-05-23\",\
|
||||
\"description\": \"Template to deploy firewall\", \"resources\":\
|
||||
{\"sc_firewall_rule3\": {\"type\": \"OS::Neutron::FirewallRule\",\
|
||||
@@ -531,28 +530,30 @@ class DummyDictionaries(object):
|
||||
\'vm_management_ip\': u'192.168.20.138', \'provider_ptg_info\':\
|
||||
[\'fa:16:3e:28:7d:b2\']}\", \"name\": \"serviceVM_infra_FW\"}}}}"
|
||||
|
||||
lb_scn_config = "{\"heat_template_version\": \"2013-05-23\",\
|
||||
\"description\": \"Configuration for F5 Neutron Loadbalacer service\",\
|
||||
lbv2_scn_config = "{\"heat_template_version\": \"2015-10-15\",\
|
||||
\"description\": \"Configuration for Haproxy Neutron LB V2 service\",\
|
||||
\"parameters\": {\"Subnet\": {\"type\": \"string\", \"description\":\
|
||||
\"Pool Subnet CIDR, on which VIP port should be created\"},\
|
||||
\"Subnet on which the load balancer will be located\"}, \
|
||||
\"service_chain_metadata\": {\"type\": \"string\", \"description\":\
|
||||
\"sc metadata\"}, \"vip_ip\": {\"type\": \"string\", \"description\":\
|
||||
\"VIP IP Address\"}}, \"resources\": {\"LoadBalancerPool\": {\"type\":\
|
||||
\"OS::Neutron::Pool\", \"properties\": {\"lb_method\":\
|
||||
\"ROUND_ROBIN\", \"protocol\": \"TCP\", \"name\": \"F5 LB pool\",\
|
||||
\"admin_state_up\": true, \"subnet_id\": {\"get_param\": \"Subnet\"},\
|
||||
\"vip\": {\"subnet\": {\"get_param\": \"Subnet\"}, \"description\":\
|
||||
{\"get_param\": \"service_chain_metadata\"}, \"admin_state_up\": true,\
|
||||
\"connection_limit\": -1, \"address\": {\"get_param\": \"vip_ip\"},\
|
||||
\"protocol_port\": 80, \"name\": \"LoadBalancerPool vip\"},\
|
||||
\"provider\": \"F5\", \"monitors\": [{\"get_resource\":\
|
||||
\"HealthMonitor\"}], \"description\": \"F5 LB pool from template\"}},\
|
||||
\"HealthMonitor\": {\"type\": \"OS::Neutron::HealthMonitor\",\
|
||||
\"properties\": {\"delay\": 20, \"max_retries\": 5, \"type\":\
|
||||
\"PING\", \"timeout\": 10, \"admin_state_up\": true}},\
|
||||
\"LoadBalancer\": {\"type\": \"OS::Neutron::LoadBalancer\",\
|
||||
\"properties\": {\"protocol_port\": 80, \"pool_id\": {\"get_resource\"\
|
||||
:\"LoadBalancerPool\"}}}}}"
|
||||
\"VIP IP Address\"}, \"app_port\": {\"default\": 80, \"type\":\
|
||||
\"number\", \"description\": \"Port used by the servers\"}, \
|
||||
\"lb_port\": {\"default\": 80, \"type\": \"number\", \"description\":\
|
||||
\"Port used by the load balancer\"}}, \"resources\": {\"listener\":\
|
||||
{\"type\": \"OS::Neutron::LBaaS::Listener\", \"properties\":\
|
||||
{\"protocol_port\": {\"get_param\": \"lb_port\"}, \"protocol\":\
|
||||
\"HTTP\", \"loadbalancer\": {\"get_resource\": \"loadbalancer\"}}},\
|
||||
\"loadbalancer\": {\"type\": \"OS::Neutron::LBaaS::LoadBalancer\",\
|
||||
\"properties\": {\"vip_subnet\": {\"get_param\": \"Subnet\"},\
|
||||
\"vip_address\": {\"get_param\": \"vip_ip\"}, \"description\":\
|
||||
{\"get_param\": \"service_chain_metadata\"}, \"provider\":\
|
||||
\"loadbalancerv2\"}}, \"monitor\": {\"type\":\
|
||||
\"OS::Neutron::LBaaS::HealthMonitor\", \"properties\": {\"delay\": 3,\
|
||||
\"max_retries\": 3, \"type\": \"HTTP\", \"pool\": {\"get_resource\":\
|
||||
\"pool\"}, \"timeout\": 3}}, \"pool\": {\"type\": \
|
||||
\"OS::Neutron::LBaaS::Pool\", \"properties\":\
|
||||
{\"lb_algorithm\": \"ROUND_ROBIN\", \"listener\": {\"get_resource\":\
|
||||
\"listener\"}, \"protocol\": \"HTTP\"}}}}"
|
||||
|
||||
vpn_scn_config = "{\"description\":\"Createsnewvpnservice-ike+ipsec+\
|
||||
vpnservice+site-siteconnection(s)\", \"heat_template_version\
|
||||
@@ -594,9 +595,9 @@ class DummyDictionaries(object):
|
||||
u'service_type': u'VPN'
|
||||
}
|
||||
|
||||
lb_service_profile = {
|
||||
lbv2_service_profile = {
|
||||
u'service_flavor': u'haproxy',
|
||||
u'service_type': u'LOADBALANCER'
|
||||
u'service_type': u'LOADBALANCERV2'
|
||||
}
|
||||
|
||||
fw_service_chain_node = {
|
||||
@@ -611,10 +612,10 @@ class DummyDictionaries(object):
|
||||
u'config': vpn_scn_config
|
||||
}
|
||||
|
||||
lb_service_chain_node = {
|
||||
lbv2_service_chain_node = {
|
||||
u'id': u'012345678919',
|
||||
u'name': u'scn_lb',
|
||||
u'config': lb_scn_config
|
||||
u'config': lbv2_scn_config
|
||||
}
|
||||
|
||||
service_chain_instance = {
|
||||
|
||||
@@ -234,24 +234,6 @@ class TestHeatDriver(unittest2.TestCase):
|
||||
auth_token, self.mock_dict.provider_ptg)
|
||||
self.assertEqual(member_ips, expected_member_ips)
|
||||
|
||||
def test_generate_lb_member_template(self):
|
||||
is_template_aws_version = False
|
||||
member_ip = '11.0.0.4'
|
||||
pool_res_name = 'HaproxyPool'
|
||||
stack_template = self.mock_dict.DEFAULT_LB_CONFIG
|
||||
expected_member_template = {
|
||||
'type': 'OS::Neutron::PoolMember',
|
||||
'properties': {
|
||||
'protocol_port': 101, 'admin_state_up': True,
|
||||
'pool_id': {'get_resource': 'HaproxyPool'},
|
||||
'weight': 1, 'address': '11.0.0.4'
|
||||
}
|
||||
}
|
||||
member_template = self.heat_driver_obj._generate_lb_member_template(
|
||||
is_template_aws_version,
|
||||
pool_res_name, member_ip, stack_template)
|
||||
self.assertEqual(member_template, expected_member_template)
|
||||
|
||||
def test_modify_fw_resources_name(self):
|
||||
is_template_aws_version = False
|
||||
stack_template = copy.deepcopy(self.mock_dict.DEFAULT_FW_CONFIG)
|
||||
@@ -266,43 +248,24 @@ class TestHeatDriver(unittest2.TestCase):
|
||||
|
||||
def test_get_heat_resource_key(self):
|
||||
is_template_aws_version = False
|
||||
resource_name = 'OS::Neutron::Pool'
|
||||
template_resource_dict = self.mock_dict.DEFAULT_LB_CONFIG['resources']
|
||||
expected_heat_resource_key = 'LoadBalancerPool'
|
||||
resource_name = 'OS::Neutron::Firewall'
|
||||
template_resource_dict = self.mock_dict.DEFAULT_FW_CONFIG['resources']
|
||||
expected_heat_resource_key = 'sc_firewall'
|
||||
heat_resource_key = self.heat_driver_obj._get_heat_resource_key(
|
||||
template_resource_dict, is_template_aws_version, resource_name)
|
||||
self.assertEqual(heat_resource_key, expected_heat_resource_key)
|
||||
|
||||
def test_get_all_heat_resource_keys(self):
|
||||
is_template_aws_version = False
|
||||
resource_name = 'OS::Neutron::Pool'
|
||||
template_resource_dict = self.mock_dict.DEFAULT_LB_CONFIG['resources']
|
||||
expected_heat_resource_keys = ['LoadBalancerPool']
|
||||
resource_name = 'OS::Neutron::Firewall'
|
||||
template_resource_dict = self.mock_dict.DEFAULT_FW_CONFIG['resources']
|
||||
expected_heat_resource_keys = ['sc_firewall']
|
||||
all_heat_resource_keys = (
|
||||
self.heat_driver_obj._get_all_heat_resource_keys(
|
||||
template_resource_dict, is_template_aws_version,
|
||||
resource_name))
|
||||
self.assertEqual(all_heat_resource_keys, expected_heat_resource_keys)
|
||||
|
||||
@mock.patch.object(neutron_client.Client, "show_port")
|
||||
@mock.patch.object(gbp_client.Client, "list_policy_targets")
|
||||
def test_generate_pool_members(self, list_pt_mock_obj, show_port_mock_obj):
|
||||
list_pt_mock_obj.return_value = self.mock_dict.policy_targets
|
||||
show_port_mock_obj.return_value = self.mock_dict.port_info
|
||||
is_template_aws_version = False
|
||||
stack_template = self.mock_dict.DEFAULT_LB_CONFIG
|
||||
auth_token = "81273djs138"
|
||||
config_param_values = {}
|
||||
expected_pool_members = self.mock_dict.pool_members
|
||||
self.heat_driver_obj._generate_pool_members(
|
||||
auth_token,
|
||||
stack_template,
|
||||
config_param_values,
|
||||
self.mock_dict.provider_ptg,
|
||||
is_template_aws_version)
|
||||
generated_pool_members = stack_template['resources']['mem-42.0.0.13']
|
||||
self.assertEqual(generated_pool_members, expected_pool_members)
|
||||
|
||||
def test_append_firewall_rule(self):
|
||||
stack_template = copy.deepcopy(self.mock_dict.DEFAULT_FW_CONFIG)
|
||||
provider_cidr = '192.169.0.0/29'
|
||||
@@ -429,44 +392,6 @@ class TestHeatDriver(unittest2.TestCase):
|
||||
stack_template['resources']['sc_firewall_policy'],
|
||||
copy.deepcopy(self.mock_dict.updated_template_sc_firewall_policy))
|
||||
|
||||
@mock.patch.object(gbp_client.Client, "create_policy_target")
|
||||
@mock.patch.object(gbp_client.Client, "update_policy_target")
|
||||
@mock.patch.object(neutron_client.Client, "list_subnets")
|
||||
@mock.patch.object(neutron_client.Client, "list_pools")
|
||||
@mock.patch.object(neutron_client.Client, "show_vip")
|
||||
def test_create_policy_target_for_vip(self, vip, pools, subnets,
|
||||
pt, pt_update):
|
||||
pt.return_value = {
|
||||
'policy_target': {
|
||||
'name': 'service_target_provider_0132c_00b93'
|
||||
}
|
||||
}
|
||||
subnets.return_value = self.mock_dict.subnets_info
|
||||
pools.return_value = {
|
||||
'pools': [{
|
||||
'vip_id': '1234'
|
||||
}]
|
||||
}
|
||||
vip.return_value = {
|
||||
'vip': {
|
||||
'port_id': '1234'
|
||||
}
|
||||
}
|
||||
auth_token = 'adsdsdd'
|
||||
provider_tenant_id = '8ae6701128994ab281dde6b92207bb19'
|
||||
provider = self.mock_dict.provider_ptg
|
||||
self.heat_driver_obj.gbp_client.get_policy_targets = (
|
||||
mock.MagicMock(
|
||||
return_value=self.mock_dict.policy_targets[
|
||||
'policy_targets']))
|
||||
self.heat_driver_obj.keystoneclient.get_admin_token = (
|
||||
mock.MagicMock(return_value='token'))
|
||||
self.heat_driver_obj._create_policy_target_for_vip(
|
||||
auth_token, provider_tenant_id, provider,
|
||||
'LOADBALANCER')
|
||||
pools.assert_called_once_with(
|
||||
subnet_id=[subnets.return_value['subnets'][0]['id']])
|
||||
|
||||
@mock.patch.object(neutron_client.Client, "list_networks")
|
||||
def test_create_node_config_data_vpn(self, mock_list_networks):
|
||||
self.mock_objects()
|
||||
@@ -621,9 +546,10 @@ class TestHeatDriver(unittest2.TestCase):
|
||||
return_value={'auth_token': '7fd6701128994ab281ccb6b92207bb15'})
|
||||
|
||||
service_details = {}
|
||||
service_details['service_profile'] = self.mock_dict.lb_service_profile
|
||||
service_details['service_profile'] = (
|
||||
self.mock_dict.lbv2_service_profile)
|
||||
service_details['servicechain_node'] = (
|
||||
self.mock_dict.lb_service_chain_node)
|
||||
self.mock_dict.lbv2_service_chain_node)
|
||||
service_details['servicechain_instance'] = (
|
||||
self.mock_dict.service_chain_instance)
|
||||
service_details['policy_target_group'] = self.mock_dict.provider_ptg
|
||||
|
||||
Reference in New Issue
Block a user