Code Review
/
yardstick.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Adding 2 node ixia generic scale-out test case generation"
[yardstick.git]
/
yardstick
/
network_services
/
vnf_generic
/
vnf
/
base.py
diff --git
a/yardstick/network_services/vnf_generic/vnf/base.py
b/yardstick/network_services/vnf_generic/vnf/base.py
index
42e3d2a
..
7781195
100644
(file)
--- a/
yardstick/network_services/vnf_generic/vnf/base.py
+++ b/
yardstick/network_services/vnf_generic/vnf/base.py
@@
-64,6
+64,8
@@
class VnfdHelper(dict):
def __init__(self, *args, **kwargs):
super(VnfdHelper, self).__init__(*args, **kwargs)
self.port_pairs = PortPairs(self['vdu'][0]['external-interface'])
def __init__(self, *args, **kwargs):
super(VnfdHelper, self).__init__(*args, **kwargs)
self.port_pairs = PortPairs(self['vdu'][0]['external-interface'])
+ # port num is not present until binding so we have to memoize
+ self._port_num_map = {}
@property
def mgmt_interface(self):
@property
def mgmt_interface(self):
@@
-91,12
+93,14
@@
class VnfdHelper(dict):
virtual_intf = interface["virtual-interface"]
if virtual_intf[key] == value:
return interface
virtual_intf = interface["virtual-interface"]
if virtual_intf[key] == value:
return interface
+ raise KeyError()
def find_interface(self, **kwargs):
key, value = next(iter(kwargs.items()))
for interface in self.interfaces:
if interface[key] == value:
return interface
def find_interface(self, **kwargs):
key, value = next(iter(kwargs.items()))
for interface in self.interfaces:
if interface[key] == value:
return interface
+ raise KeyError()
# hide dpdk_port_num key so we can abstract
def find_interface_by_port(self, port):
# hide dpdk_port_num key so we can abstract
def find_interface_by_port(self, port):
@@
-105,21
+109,31
@@
class VnfdHelper(dict):
# we have to convert to int to compare
if int(virtual_intf['dpdk_port_num']) == port:
return interface
# we have to convert to int to compare
if int(virtual_intf['dpdk_port_num']) == port:
return interface
+ raise KeyError()
- def port_num(self,
name
):
+ def port_num(self,
port
):
# we need interface name -> DPDK port num (PMD ID) -> LINK ID
# LINK ID -> PMD ID is governed by the port mask
"""
:rtype: int
# 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
+ :type
port
: str
"""
"""
- intf = self.find_interface(name=name)
- return int(intf["virtual-interface"]["dpdk_port_num"])
+ if isinstance(port, dict):
+ intf = port
+ else:
+ intf = self.find_interface(name=port)
+ return self._port_num_map.setdefault(intf["name"],
+ int(intf["virtual-interface"]["dpdk_port_num"]))
def port_nums(self, intfs):
return [self.port_num(i) for i in intfs]
def port_nums(self, intfs):
return [self.port_num(i) for i in intfs]
+ def ports_iter(self):
+ for port_name in self.port_pairs.all_ports:
+ port_num = self.port_num(port_name)
+ yield port_name, port_num
+
class VNFObject(object):
class VNFObject(object):
@@
-162,6
+176,13
@@
class GenericVNF(VNFObject):
"""
raise NotImplementedError()
"""
raise NotImplementedError()
+ def wait_for_instantiate(self):
+ """ Wait for VNF to start
+
+ :return: True/False
+ """
+ raise NotImplementedError()
+
def terminate(self):
""" Kill all VNF processes
def terminate(self):
""" Kill all VNF processes