diff --git a/configs/images.cfg b/configs/images.cfg index f126325e5..668fac03c 100644 --- a/configs/images.cfg +++ b/configs/images.cfg @@ -97,6 +97,13 @@ username = root password = c0ntrail123 params = --container-format ovf --disk-format qcow2 --property hypervisor_type=qemu +[vsrx-fw] +name = junos-vsrx-12.1-in-network-fw.img.gz +location = /images/vsrx/ +username = root +password = c0ntrail123 +params = --container-format ovf --disk-format qcow2 --property hypervisor_type=qemu + [tiny_nat_fw] name = tinycore-in-network-nat.qcow2.gz location = /images/tinycore/ diff --git a/fixtures/heat_test.py b/fixtures/heat_test.py index 471dcd1fa..f0760caa0 100644 --- a/fixtures/heat_test.py +++ b/fixtures/heat_test.py @@ -9,7 +9,7 @@ from heatclient import client as heat_client from heatclient.common import utils from heatclient import exc -from heatclient.openstack.common import strutils +from oslo.utils import strutils logger = logging.getLogger(__name__) from tcutils.util import get_plain_uuid, get_dashed_uuid import os diff --git a/scripts/heat/base.py b/scripts/heat/base.py index 2ae54f80a..c8ce7217f 100644 --- a/scripts/heat/base.py +++ b/scripts/heat/base.py @@ -17,6 +17,7 @@ import env as env import ConfigParser import re +import copy contrail_api_conf = '/etc/contrail/contrail-api.conf' @@ -61,7 +62,7 @@ def get_template(self, template_name): def get_env(self, env_name): env_name = '%s' % env_name - return getattr(env, env_name) + return copy.deepcopy(getattr(env, env_name)) # end get_env def verify_vn(self, stack, env, stack_name): @@ -154,8 +155,11 @@ def config_svc_template(self, stack_name=None, scaling=False, mode='in-network-n template = self.get_template(template_name='svc_temp_template') env = self.get_env(env_name='svc_temp_env') env['parameters']['mode'] = mode + env['parameters']['name'] = stack_name if mode == 'transparent': env['parameters']['image'] = 'vsrx-bridge' + if mode == 'in-network': + env['parameters']['image'] = 'vsrx-fw' if scaling: env['parameters']['service_scaling'] = "True" if mode != 'in-network-nat': diff --git a/scripts/heat/template.py b/scripts/heat/template.py index 3ec3a554c..2319d2ca1 100644 --- a/scripts/heat/template.py +++ b/scripts/heat/template.py @@ -181,7 +181,9 @@ u'type': u'number'}, u'src_vn_id': {u'description': u'ID of the source network', u'type': u'string'}}, - u'resources': {u'private_policy': {u'properties': {u'entries': {u'policy_rule': [{u'action_list': {u'apply_service': [{u'get_param': u'apply_service'}]}, + u'resources': {u'private_policy': {u'properties': {u'entries': {u'policy_rule': [{u'action_list': {u'apply_service': + {u'Fn::Split': [u',', + {u'Ref': u'apply_service'}]}}, u'direction': {u'get_param': u'direction'}, u'dst_addresses': [{u'virtual_network': {u'get_param': u'dst_vn_id'}}], u'dst_ports': [{u'end_port': {u'get_param': u'dst_port_end'}, diff --git a/scripts/heat/test_heat.py b/scripts/heat/test_heat.py index ba07a899a..9ad0a0b26 100644 --- a/scripts/heat/test_heat.py +++ b/scripts/heat/test_heat.py @@ -106,6 +106,116 @@ def test_transit_vn_with_svc(self): assert vms[0].ping_with_certainty(vms[1].vm_ip, expectation=False) # end test_transit_vn_with_svc + def transit_vn_with_left_right_svc(self, left_svcs, right_svcs): + ''' + Validate Transit VN with multi transparent service chain using heat + ''' + vn_list = [] + right_net_fix, r_hs_obj = self.config_vn(stack_name='right_net') + transit_net_fix, t_hs_obj = self.config_vn(stack_name='transit_net') + left_net_fix, l_hs_obj = self.config_vn(stack_name='left_net') + vn_list1 = [left_net_fix, transit_net_fix] + vn_list2 = [transit_net_fix, right_net_fix] + end_vn_list = [left_net_fix, right_net_fix] + vms = [] + vms = self.config_vms(end_vn_list) + svc_tmpls = {} + for mode in set(left_svcs + right_svcs): + tmpl = self.config_svc_template(stack_name='st_%s' % mode, + mode=mode) + svc_tmpls[mode] = {} + svc_tmpls[mode]['tmpl'] = tmpl + svc_tmpls[mode]['obj'] = tmpl.st_obj + svc_tmpls[mode]['fq_name'] = ':'.join(tmpl.st_fq_name) + + left_sis = [] + for i, svc in enumerate(left_svcs): + left_sis.append(self.config_svc_instance( + 'svc_left_%d' % i, svc_tmpls[svc]['fq_name'], + svc_tmpls[svc]['obj'], vn_list1, svc_mode=svc)) + right_sis = [] + for i, svc in enumerate(right_svcs): + right_sis.append(self.config_svc_instance( + 'svc_right_%d' % i, svc_tmpls[svc]['fq_name'], + svc_tmpls[svc]['obj'], vn_list2, svc_mode=svc)) + left_si_names = ','.join([(':').join(si[0].si_fq_name) for si in left_sis]) + right_si_names = ','.join([(':').join(si[0].si_fq_name) for si in right_sis]) + left_chain = self.config_svc_chain( + left_si_names, vn_list1, 'left_chain') + right_chain = self.config_svc_chain( + right_si_names, vn_list2, 'right_chain') + assert vms[0].ping_with_certainty(vms[1].vm_ip, expectation=True) + # end transit_vn_with_left_right_svc + + @preposttest_wrapper + def test_transit_vn_sym_1_innetnat(self): + svcs= ['in-network-nat'] + self.transit_vn_with_left_right_svc(svcs, svcs) + return True + + @preposttest_wrapper + def test_transit_vn_sym_1_innet(self): + svcs= ['in-network'] + self.transit_vn_with_left_right_svc(svcs, svcs) + return True + + @preposttest_wrapper + def test_transit_vn_sym_1_trans(self): + svcs= ['transparent'] + self.transit_vn_with_left_right_svc(svcs, svcs) + return True + + @preposttest_wrapper + def test_transit_vn_asym_innetnat_trans(self): + left= ['in-network-nat'] + right= ['transparent'] + self.transit_vn_with_left_right_svc(left, right) + return True + + @preposttest_wrapper + def test_transit_vn_asym_innet_trans(self): + left= ['in-network'] + right= ['transparent'] + self.transit_vn_with_left_right_svc(left, right) + return True + + @preposttest_wrapper + def test_transit_vn_asym_innet_nat(self): + left= ['in-network'] + right= ['in-network-nat'] + self.transit_vn_with_left_right_svc(left, right) + return True + + @preposttest_wrapper + def test_transit_vn_sym_2_innet_svc(self): + svcs= ['in-network', 'in-network'] + self.transit_vn_with_left_right_svc(svcs, svcs) + return True + + @preposttest_wrapper + def test_transit_vn_sym_2_trans_svc(self): + svcs= ['transparent', 'transparent'] + self.transit_vn_with_left_right_svc(svcs, svcs) + return True + + @preposttest_wrapper + def test_transit_vn_sym_innet_nat(self): + svcs= ['in-network', 'in-network-nat'] + self.transit_vn_with_left_right_svc(svcs, svcs) + return True + + @preposttest_wrapper + def test_transit_vn_sym_trans_nat(self): + svcs= ['transparent', 'in-network-nat'] + self.transit_vn_with_left_right_svc(svcs, svcs) + return True + + @preposttest_wrapper + def test_transit_vn_sym_trans_innet(self): + svcs= ['transparent', 'in-network'] + self.transit_vn_with_left_right_svc(svcs, svcs) + return True + @preposttest_wrapper def test_max_inst_change_in_ecmp_svc(self): '''