示例#1
0
    def load_vnf_models(self, scenario_cfg=None, context_cfg=None):
        """ Create VNF objects based on YAML descriptors

        :param scenario_cfg:
        :type scenario_cfg:
        :param context_cfg:
        :return:
        """
        if scenario_cfg is None:
            scenario_cfg = self.scenario_cfg

        if context_cfg is None:
            context_cfg = self.context_cfg

        vnfs = []
        # we assume OrderedDict for consistenct in instantiation
        for node_name, node in context_cfg["nodes"].items():
            LOG.debug(node)
            file_name = node["VNF model"]
            file_path = scenario_cfg['task_path']
            with open_relative_file(file_name, file_path) as stream:
                vnf_model = stream.read()
            vnfd = vnfdgen.generate_vnfd(vnf_model, node)
            # TODO: here add extra context_cfg["nodes"] regardless of template
            vnfd = vnfd["vnfd:vnfd-catalog"]["vnfd"][0]
            self.update_interfaces_from_node(vnfd, node)
            vnf_impl = self.get_vnf_impl(vnfd['id'])
            vnf_instance = vnf_impl(node_name, vnfd)
            vnfs.append(vnf_instance)

        self.vnfs = vnfs
        return vnfs
示例#2
0
 def _render_topology(self):
     topology = self._get_topology()
     topology_args = self.scenario_cfg.get('extra_args', {})
     topolgy_data = {
         'extra_args': topology_args
     }
     topology_yaml = vnfdgen.generate_vnfd(topology, topolgy_data)
     self.topology = topology_yaml["nsd:nsd-catalog"]["nsd"][0]
示例#3
0
    def test_generate_tp_single_var(self):
        """ Function to verify traffic profile generation with imix """

        generated_tp = \
            vnfdgen.generate_vnfd(TRAFFIC_PROFILE_TPL,
                                  {"imix": {UPLINK: {"imix_small": '20'}}})
        self.maxDiff = None
        tp2 = dict(TRAFFIC_PROFILE)
        tp2[UPLINK][0]["ipv4"]["outer_l2"]["framesize"]["64B"] = '20'
        self.assertDictEqual(tp2, generated_tp)
示例#4
0
    def _fill_traffic_profile(self):
        traffic_mapping = self._get_traffic_profile()
        traffic_map_data = {
            'flow': self._get_traffic_flow(),
            'imix': self._get_traffic_imix(),
            'private': {},
            'public': {},
        }

        traffic_vnfd = vnfdgen.generate_vnfd(traffic_mapping, traffic_map_data)
        self.traffic_profile = TrafficProfile.get(traffic_vnfd)
        return self.traffic_profile
示例#5
0
 def _fill_traffic_profile(self):
     tprofile = self._get_traffic_profile()
     extra_args = self.scenario_cfg.get('extra_args', {})
     tprofile_data = {
         'flow': self._get_traffic_flow(),
         'imix': self._get_traffic_imix(),
         tprofile_base.TrafficProfile.UPLINK: {},
         tprofile_base.TrafficProfile.DOWNLINK: {},
         'extra_args': extra_args,
         'duration': self._get_duration()
     }
     traffic_vnfd = vnfdgen.generate_vnfd(tprofile, tprofile_data)
     self.traffic_profile = tprofile_base.TrafficProfile.get(traffic_vnfd)
示例#6
0
    def load_vnf_models(self, scenario_cfg=None, context_cfg=None):
        """ Create VNF objects based on YAML descriptors

        :param scenario_cfg:
        :type scenario_cfg:
        :param context_cfg:
        :return:
        """
        trex_lib_path = get_nsb_option('trex_client_lib')
        sys.path[:] = list(
            chain([trex_lib_path],
                  (x for x in sys.path if x != trex_lib_path)))

        if scenario_cfg is None:
            scenario_cfg = self.scenario_cfg

        if context_cfg is None:
            context_cfg = self.context_cfg

        vnfs = []
        # we assume OrderedDict for consistency in instantiation
        for node_name, node in context_cfg["nodes"].items():
            LOG.debug(node)
            try:
                file_name = node["VNF model"]
            except KeyError:
                LOG.debug("no model for %s, skipping", node_name)
                continue
            file_path = scenario_cfg['task_path']
            with utils.open_relative_file(file_name, file_path) as stream:
                vnf_model = stream.read()
            vnfd = vnfdgen.generate_vnfd(vnf_model, node)
            # TODO: here add extra context_cfg["nodes"] regardless of template
            vnfd = vnfd["vnfd:vnfd-catalog"]["vnfd"][0]
            # force inject pkey if it exists
            # we want to standardize Heat using pkey as a string so we don't rely
            # on the filesystem
            try:
                vnfd['mgmt-interface']['pkey'] = node['pkey']
            except KeyError:
                pass
            self.create_interfaces_from_node(vnfd, node)
            vnf_impl = self.get_vnf_impl(vnfd['id'])
            vnf_instance = vnf_impl(node_name, vnfd, scenario_cfg['task_id'])
            vnfs.append(vnf_instance)

        self.vnfs = vnfs
        return vnfs
示例#7
0
    def _fill_traffic_profile(self, scenario_cfg, context_cfg):
        flow = self._get_traffic_flow(scenario_cfg)

        imix = self._get_traffic_imix(scenario_cfg)

        traffic_mapping, private, public = \
            self._get_traffic_profile(scenario_cfg, context_cfg)

        traffic_profile = vnfdgen.generate_vnfd(traffic_mapping, {
            "imix": imix,
            "flow": flow,
            "private": private,
            "public": public
        })

        return TrafficProfile.get(traffic_profile)
示例#8
0
    def load_vnf_models(self, context_cfg):
        """ Create VNF objects based on YAML descriptors

        :param context_cfg:
        :return:
        """
        vnfs = []
        for node in context_cfg["nodes"]:
            LOG.debug(context_cfg["nodes"][node])
            with open(context_cfg["nodes"][node]["VNF model"]) as stream:
                vnf_model = stream.read()
            vnfd = vnfdgen.generate_vnfd(vnf_model, context_cfg["nodes"][node])
            vnf_impl = self.get_vnf_impl(vnfd["vnfd:vnfd-catalog"]["vnfd"][0])
            vnf_instance = vnf_impl(vnfd["vnfd:vnfd-catalog"]["vnfd"][0])
            vnf_instance.name = node
            vnfs.append(vnf_instance)

        return vnfs
示例#9
0
    def load_vnf_models(self, scenario_cfg, context_cfg):
        """ Create VNF objects based on YAML descriptors

        :param scenario_cfg:
        :type scenario_cfg:
        :param context_cfg:
        :return:
        """
        vnfs = []
        for node_name, node in context_cfg["nodes"].items():
            LOG.debug(node)
            with open_relative_file(node["VNF model"],
                                    scenario_cfg['task_path']) as stream:
                vnf_model = stream.read()
            vnfd = vnfdgen.generate_vnfd(vnf_model, node)
            vnf_impl = self.get_vnf_impl(vnfd["vnfd:vnfd-catalog"]["vnfd"][0])
            vnf_instance = vnf_impl(vnfd["vnfd:vnfd-catalog"]["vnfd"][0])
            vnf_instance.name = node_name
            vnfs.append(vnf_instance)

        return vnfs
示例#10
0
    def _fill_traffic_profile(self):
        tprofile = self._get_traffic_profile()
        extra_args = self.scenario_cfg.get('extra_args', {})
        tprofile_data = {
            'flow': self._get_traffic_flow(),
            'imix': self._get_traffic_imix(),
            tprofile_base.TrafficProfile.UPLINK: {},
            tprofile_base.TrafficProfile.DOWNLINK: {},
            'extra_args': extra_args,
            'duration': self._get_duration(),
            'page_object': self._get_page_object(),
            'simulated_users': self._get_simulated_users()
        }
        traffic_vnfd = vnfdgen.generate_vnfd(tprofile, tprofile_data)

        traffic_config = \
            self.scenario_cfg.get("options", {}).get("traffic_config", {})

        traffic_vnfd.setdefault("traffic_profile", {})
        traffic_vnfd["traffic_profile"].update(traffic_config)

        self.traffic_profile = \
            tprofile_base.TrafficProfile.get(traffic_vnfd)
示例#11
0
    def test_generate_tp_no_vars(self):
        """ Function to verify traffic profile generation without imix """

        self.maxDiff = None
        generated_tp = vnfdgen.generate_vnfd(TRAFFIC_PROFILE_TPL, {"imix": {}})
        self.assertDictEqual(TRAFFIC_PROFILE, generated_tp)
示例#12
0
 def test_generate_vnfd(self):
     """ Function to verify vnfd generation based on template """
     self.maxDiff = None
     generated_vnfd = vnfdgen.generate_vnfd(TREX_VNFD_TEMPLATE, NODE_CFG)
     self.assertDictEqual(COMPLETE_TREX_VNFD, generated_vnfd)