From 50ad0d757b2015067c2b13adbbe59b746477b207 Mon Sep 17 00:00:00 2001 From: gvrangan Date: Thu, 3 Jan 2019 11:32:11 +0000 Subject: Fix Two Chains Test and Enabled all Testcases - Method added to support Port Chain update - Used the new method to modify the test as follows - Create two Port Chains (one VNF per chain) - Block ssh in one vnf and http in the other - Test communication - Swap the flow classifiers in the chains so that ssh packets are sent to vnf where http is blocked and vice versa - Fix extracting odl username/password from ml2_conf - Checking flow classifiers are implemented - Fixed odl cleanup Change-Id: I1f0f3a3b829d6c73d1bb1a774ebf3484912b84b7 Signed-off-by: gvrangan --- sfc/lib/openstack_utils.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'sfc/lib/openstack_utils.py') diff --git a/sfc/lib/openstack_utils.py b/sfc/lib/openstack_utils.py index 3d620e2b..8bc4543a 100644 --- a/sfc/lib/openstack_utils.py +++ b/sfc/lib/openstack_utils.py @@ -400,6 +400,31 @@ class OpenStackSFC: return port_pair_group_info['port_pair_group']['id'] + def create_classifier(self, neutron_port, port, protocol, fc_name, + symmetrical, server_port=None, server_ip=None): + ''' + Create the classifier + ''' + logger.info("Creating the classifier...") + + if symmetrical: + sfc_classifier_params = {'name': fc_name, + 'destination_ip_prefix': server_ip, + 'logical_source_port': neutron_port, + 'logical_destination_port': server_port, + 'destination_port_range_min': port, + 'destination_port_range_max': port, + 'protocol': protocol} + else: + sfc_classifier_params = {'name': fc_name, + 'logical_source_port': neutron_port, + 'destination_port_range_min': port, + 'destination_port_range_max': port, + 'protocol': protocol} + + fc_config = {'flow_classifier': sfc_classifier_params} + self.neutron_client.create_sfc_flow_classifier(fc_config) + def create_chain(self, port_groups, neutron_port, port, protocol, vnffg_name, symmetrical, server_port=None, server_ip=None): @@ -440,6 +465,38 @@ class OpenStackSFC: chain_config = {'port_chain': port_chain} return self.neutron_client.create_sfc_port_chain(chain_config) + def update_chain(self, vnffg_name, fc_name, symmetrical): + ''' + Update the new Flow Classifier ID + ''' + fc_id = self.neutron_client.find_resource('flow_classifier', + fc_name)['id'] + logger.info("Update the chain...") + port_chain = {} + port_chain['name'] = vnffg_name + '-port-chain' + port_chain['flow_classifiers'] = [] + port_chain['flow_classifiers'].append(fc_id) + if symmetrical: + port_chain['chain_parameters'] = {} + port_chain['chain_parameters']['symmetric'] = True + chain_config = {'port_chain': port_chain} + pc_id = self.neutron_client.find_resource('port_chain', + port_chain['name'])['id'] + return self.neutron_client.update_sfc_port_chain(pc_id, chain_config) + + def swap_classifiers(self, vnffg_1_name, vnffg_2_name, symmetric=False): + + ''' + Swap Classifiers + ''' + logger.info("Swap classifiers...") + + self.update_chain(vnffg_1_name, 'dummy', symmetric) + vnffg_1_classifier_name = vnffg_1_name + '-classifier' + self.update_chain(vnffg_2_name, vnffg_1_classifier_name, symmetric) + vnffg_2_classifier_name = vnffg_2_name + '-classifier' + self.update_chain(vnffg_1_name, vnffg_2_classifier_name, symmetric) + def delete_port_groups(self): ''' Delete all port groups and port pairs -- cgit 1.2.3-korg