X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2Fnetwork_services%2Fvnf_generic%2Fvnf%2Fbase.py;h=42e3d2a48dbedec25f24a47824d16a70dc89d08a;hb=409f095546903a6b60a6d9c2dfd6905e9e42e816;hp=955f9f03d4984d54e80453dac06f990b01d8733a;hpb=0949884ab431a16dc1841118e13c0b893fa11b85;p=yardstick.git diff --git a/yardstick/network_services/vnf_generic/vnf/base.py b/yardstick/network_services/vnf_generic/vnf/base.py index 955f9f03d..42e3d2a48 100644 --- a/yardstick/network_services/vnf_generic/vnf/base.py +++ b/yardstick/network_services/vnf_generic/vnf/base.py @@ -16,6 +16,8 @@ from __future__ import absolute_import import logging +from yardstick.network_services.helpers.samplevnf_helper import PortPairs + LOG = logging.getLogger(__name__) @@ -59,6 +61,10 @@ class QueueFileWrapper(object): class VnfdHelper(dict): + def __init__(self, *args, **kwargs): + super(VnfdHelper, self).__init__(*args, **kwargs) + self.port_pairs = PortPairs(self['vdu'][0]['external-interface']) + @property def mgmt_interface(self): return self["mgmt-interface"] @@ -92,9 +98,35 @@ class VnfdHelper(dict): if interface[key] == value: return interface + # hide dpdk_port_num key so we can abstract + def find_interface_by_port(self, port): + for interface in self.interfaces: + virtual_intf = interface["virtual-interface"] + # we have to convert to int to compare + if int(virtual_intf['dpdk_port_num']) == port: + return interface + + def port_num(self, name): + # we need interface name -> DPDK port num (PMD ID) -> LINK ID + # LINK ID -> PMD ID is governed by the port mask + """ + + :rtype: int + :type name: str + """ + intf = self.find_interface(name=name) + return int(intf["virtual-interface"]["dpdk_port_num"]) + + def port_nums(self, intfs): + return [self.port_num(i) for i in intfs] + class VNFObject(object): + # centralize network naming convention + UPLINK = PortPairs.UPLINK + DOWNLINK = PortPairs.DOWNLINK + def __init__(self, name, vnfd): super(VNFObject, self).__init__() self.name = name