1 # Copyright (c) 2016-2017 Intel Corporation
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
17 from yardstick.common import utils
18 from yardstick.network_services.vnf_generic.vnf.sample_vnf import SampleVNF, DpdkVnfSetupEnvHelper
19 from yardstick.network_services.yang_model import YangModel
21 LOG = logging.getLogger(__name__)
23 # ACL should work the same on all systems, we can provide the binary
24 ACL_PIPELINE_COMMAND = \
25 'sudo {tool_path} -p {port_mask_hex} -f {cfg_file} -s {script} {hwlb}'
27 ACL_COLLECT_KPI = r"""\
28 ACL TOTAL:[^p]+pkts_processed"?:\s(\d+),[^p]+pkts_drop"?:\s(\d+),[^p]+pkts_received"?:\s(\d+),"""
31 class AclApproxSetupEnvSetupEnvHelper(DpdkVnfSetupEnvHelper):
34 CFG_CONFIG = "/tmp/acl_config"
35 CFG_SCRIPT = "/tmp/acl_script"
36 PIPELINE_COMMAND = ACL_PIPELINE_COMMAND
39 DEFAULT_CONFIG_TPL_CFG = "acl.cfg"
43 class AclApproxVnf(SampleVNF):
47 COLLECT_KPI = ACL_COLLECT_KPI
55 def __init__(self, name, vnfd, setup_env_helper_type=None, resource_helper_type=None):
56 if setup_env_helper_type is None:
57 setup_env_helper_type = AclApproxSetupEnvSetupEnvHelper
59 super(AclApproxVnf, self).__init__(name, vnfd, setup_env_helper_type, resource_helper_type)
63 yang_model_path = utils.find_relative_file(
64 self.scenario_helper.options['rules'],
65 self.scenario_helper.task_path)
66 yang_model = YangModel(yang_model_path)
67 self.acl_rules = yang_model.get_rules()
68 super(AclApproxVnf, self)._start_vnf()