Exemplo n.º 1
0
    def get_vnf_impl(cls, vnf_model_id):  # pragma: no cover
        """ Find the implementing class from vnf_model["vnf"]["name"] field

        :param vnf_model_id: parsed vnfd model ID field
        :return: subclass of GenericVNF
        """
        utils.import_modules_from_package(
            "yardstick.network_services.vnf_generic.vnf")
        expected_name = vnf_model_id
        classes_found = []

        def impl():
            for name, class_ in ((c.__name__, c)
                                 for c in utils.itersubclasses(GenericVNF)):
                if name == expected_name:
                    yield class_
                classes_found.append(name)

        try:
            return next(impl())
        except StopIteration:
            pass

        message = ('No implementation for %s found in %s' %
                   (expected_name, classes_found))
        raise exceptions.IncorrectConfig(error_msg=message)
Exemplo n.º 2
0
    def __init__(self, dpdk_node, interface):
        super(DpdkInterface, self).__init__()
        self.dpdk_node = dpdk_node
        self.interface = interface

        try:
            assert self.local_mac
        except (AssertionError, KeyError):
            raise exceptions.IncorrectConfig(error_msg='')
Exemplo n.º 3
0
        def update():
            if not mock_force_rebind.called:
                raise exceptions.IncorrectConfig(error_msg='')

            interfaces[0]['virtual-interface'].update({
                'vpci': '0000:01:02.1',
                'local_ip': '10.20.30.40',
                'netmask': '255.255.0.0',
                'driver': 'ixgbe',
            })
Exemplo n.º 4
0
    def instantiate(self, scenario_cfg, context_cfg):
        self._update_collectd_options(scenario_cfg, context_cfg)
        self.scenario_helper.scenario_cfg = scenario_cfg
        self.context_cfg = context_cfg

        options = scenario_cfg.get('options', {})

        try:
            self.vcmts_influxdb_ip = options['vcmts_influxdb_ip']
            self.vcmts_influxdb_port = options['vcmts_influxdb_port']
        except KeyError:
            raise KeyError("Missing destination InfluxDB details in scenario" \
                           " section of the task definition file")

        try:
            vcmtsd_values_filepath = options['vcmtsd_values']
        except KeyError:
            raise KeyError("Missing vcmtsd_values key in scenario options" \
                           "section of the task definition file")

        if not os.path.isfile(vcmtsd_values_filepath):
            raise RuntimeError("The vcmtsd_values file path provided " \
                               "does not exists")

        # The yaml_loader.py (SafeLoader) underlying regex has an issue
        # with reading PCI addresses (processed as double). so the
        # BaseLoader is used here.
        with open(vcmtsd_values_filepath) as stream:
            vcmtsd_values = yaml.load(stream, Loader=yaml.BaseLoader)

        if vcmtsd_values == None:
            raise RuntimeError("Error reading vcmtsd_values file provided (" +
                               vcmtsd_values_filepath + ")")

        vnf_options = options.get(self.name, {})
        sg_id = str(vnf_options['sg_id'])
        stream_dir = vnf_options['stream_dir']

        try:
            vcmts_pods_cfg = vcmtsd_values['topology']['vcmts_pods']
        except KeyError:
            raise KeyError("Missing vcmts_pods key in the " \
                           "vcmtsd_values file provided")

        pod_cfg = self.extract_pod_cfg(vcmts_pods_cfg, sg_id)
        if pod_cfg == None:
            raise exceptions.IncorrectConfig(error_msg="Service group " + sg_id + " not found")

        self.setup_helper.run_vcmtsd(stream_dir, pod_cfg)
Exemplo n.º 5
0
    def probe_missing_values(self):
        try:
            for netdev in self.dpdk_node.netdevs.values():
                if netdev['address'].lower() == self.mac_lower:
                    socket = self._detect_socket(netdev)
                    self.interface.update({
                        'vpci': netdev['pci_bus_id'],
                        'driver': netdev['driver'],
                        'socket': socket,
                        # don't need ifindex
                    })

        except KeyError:
            # if we don't find all the keys then don't update
            pass

        except (exceptions.IncorrectNodeSetup, exceptions.SSHError,
                exceptions.SSHTimeout):
            message = ('Unable to probe missing interface fields "%s", on '
                       'node %s SSH Error' % (', '.join(self.missing_fields),
                                              self.dpdk_node.node_key))
            raise exceptions.IncorrectConfig(error_msg=message)
Exemplo n.º 6
0
    def _resolve_topology(self):
        for vld in self.topology["vld"]:
            try:
                node0_data, node1_data = vld["vnfd-connection-point-ref"]
            except (ValueError, TypeError):
                raise exceptions.IncorrectConfig(
                    error_msg='Topology file corrupted, wrong endpoint count '
                    'for connection')

            node0_name = self._find_vnf_name_from_id(
                node0_data["member-vnf-index-ref"])
            node1_name = self._find_vnf_name_from_id(
                node1_data["member-vnf-index-ref"])

            node0_if_name = node0_data["vnfd-connection-point-ref"]
            node1_if_name = node1_data["vnfd-connection-point-ref"]

            try:
                nodes = self.context_cfg["nodes"]
                node0_if = self.find_node_if(nodes, node0_name, node0_if_name,
                                             vld["id"])
                node1_if = self.find_node_if(nodes, node1_name, node1_if_name,
                                             vld["id"])

                # names so we can do reverse lookups
                node0_if["ifname"] = node0_if_name
                node1_if["ifname"] = node1_if_name

                node0_if["node_name"] = node0_name
                node1_if["node_name"] = node1_name

                node0_if["vld_id"] = vld["id"]
                node1_if["vld_id"] = vld["id"]

                # set peer name
                node0_if["peer_name"] = node1_name
                node1_if["peer_name"] = node0_name

                # set peer interface name
                node0_if["peer_ifname"] = node1_if_name
                node1_if["peer_ifname"] = node0_if_name

                # just load the network
                vld_networks = {
                    n.get('vld_id', name): n
                    for name, n in self.context_cfg["networks"].items()
                }

                node0_if["network"] = vld_networks.get(vld["id"], {})
                node1_if["network"] = vld_networks.get(vld["id"], {})

                node0_if["dst_mac"] = node1_if["local_mac"]
                node0_if["dst_ip"] = node1_if["local_ip"]

                node1_if["dst_mac"] = node0_if["local_mac"]
                node1_if["dst_ip"] = node0_if["local_ip"]

            except KeyError:
                LOG.exception("")
                raise exceptions.IncorrectConfig(
                    error_msg='Required interface not found, topology file '
                    'corrupted')

        for vld in self.topology['vld']:
            try:
                node0_data, node1_data = vld["vnfd-connection-point-ref"]
            except (ValueError, TypeError):
                raise exceptions.IncorrectConfig(
                    error_msg='Topology file corrupted, wrong endpoint count '
                    'for connection')

            node0_name = self._find_vnf_name_from_id(
                node0_data["member-vnf-index-ref"])
            node1_name = self._find_vnf_name_from_id(
                node1_data["member-vnf-index-ref"])

            node0_if_name = node0_data["vnfd-connection-point-ref"]
            node1_if_name = node1_data["vnfd-connection-point-ref"]

            nodes = self.context_cfg["nodes"]
            node0_if = self.find_node_if(nodes, node0_name, node0_if_name,
                                         vld["id"])
            node1_if = self.find_node_if(nodes, node1_name, node1_if_name,
                                         vld["id"])

            # add peer interface dict, but remove circular link
            # TODO: don't waste memory
            node0_copy = node0_if.copy()
            node1_copy = node1_if.copy()
            node0_if["peer_intf"] = node1_copy
            node1_if["peer_intf"] = node0_copy