aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/objects.py
diff options
context:
space:
mode:
authorFeng Pan <fpan@redhat.com>2017-07-17 16:25:25 -0400
committerFeng Pan <fpan@redhat.com>2017-07-24 16:15:47 -0400
commit9ecc15f0edf2460c2eb2cac8e9ccca8cbb8d3808 (patch)
tree665bb067f795505f77d0d1eba98204e02dd11dec /os_net_config/objects.py
parent02da9fd51b454b1954b04a462cb05a14598fa172 (diff)
Merge Newton private changes
- Add interface mapping data to hiera - Add support for VPP interfaces - Continue bringing up interfaces even if one fails - Change hiera to json format List of commits: https://github.com/openstack/os-net-config/compare/stable/newton...trozet:stable/danube Change-Id: If7a2c6119bf613f1fc8846237b077cd8f0e26015 Signed-off-by: Feng Pan <fpan@redhat.com>
Diffstat (limited to 'os_net_config/objects.py')
-rw-r--r--os_net_config/objects.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/os_net_config/objects.py b/os_net_config/objects.py
index 9b6a06f..9287601 100644
--- a/os_net_config/objects.py
+++ b/os_net_config/objects.py
@@ -68,6 +68,8 @@ def object_from_json(json):
return OvsDpdkPort.from_json(json)
elif obj_type == "ovs_dpdk_bond":
return OvsDpdkBond.from_json(json)
+ elif obj_type == "vpp_interface":
+ return VppInterface.from_json(json)
def _get_required_field(json, name, object_name):
@@ -198,6 +200,7 @@ class _BaseOpts(object):
routes = routes or []
dns_servers = dns_servers or []
mapped_nic_names = _mapped_nics(nic_mapping)
+ utils.write_hiera(utils.HIERADATA_FILE, mapped_nic_names)
self.hwaddr = None
self.hwname = None
self.renamed = False
@@ -346,6 +349,7 @@ class Vlan(_BaseOpts):
self.vlan_id = int(vlan_id)
mapped_nic_names = _mapped_nics(nic_mapping)
+ utils.write_hiera(utils.HIERADATA_FILE, mapped_nic_names)
if device in mapped_nic_names:
self.device = mapped_nic_names[device]
else:
@@ -1129,3 +1133,57 @@ class OvsDpdkBond(_BaseOpts):
defroute=defroute, dhclient_args=dhclient_args,
dns_servers=dns_servers,
nm_controlled=nm_controlled)
+
+
+class VppInterface(_BaseOpts):
+ """Base class for VPP Interface.
+
+ Vector Packet Processing (VPP) is a high performance packet processing
+ stack that runs in user space in Linux. VPP is used as an alternative to
+ kernel networking stack for accelerated network data path. VPP uses DPDK
+ poll-mode drivers to bind system interfaces rather than kernel drivers.
+ VPP bound interfacees are not visible to kernel networking stack, so we
+ must handle them separately.
+
+ The following parameters can be specified in addition to base Interface:
+ - uio_driver: DPDK poll-mode driver name. Defaults to 'vfio-pci', valid
+ values are 'uio_pci_generic' and 'vfio-pci'.
+ - options: Interface options such as vlan stripping and tx/rx transmit
+ queues specification. Defaults to None. Reference for those
+ configurations can be found at
+ https://wiki.fd.io/view/VPP/Command-line_Arguments
+ Example: 'vlan-strip-offload on num-rx-queues 3'
+
+ Note that 'name' attribute is used to indicate the kernel nic that should
+ be bound to VPP. Once VPP binds the interface, a mapping file will be
+ updated with the interface's information, and this file will be used in
+ subsequent runs of os-net-config.
+ """
+ def __init__(self, name, use_dhcp=False, use_dhcpv6=False, addresses=None,
+ routes=None, mtu=None, primary=False, nic_mapping=None,
+ persist_mapping=False, defroute=True, dhclient_args=None,
+ dns_servers=None, nm_controlled=False,
+ uio_driver='vfio-pci', options=None):
+ addresses = addresses or []
+
+ super(VppInterface, self).__init__(name, use_dhcp, use_dhcpv6,
+ addresses, routes, mtu, primary,
+ nic_mapping, persist_mapping,
+ defroute, dhclient_args,
+ dns_servers, nm_controlled)
+ self.uio_driver = uio_driver
+ self.options = options
+ # pci_dev contains pci address for the interface, it will be populated
+ # when interface is added to config object. It will be determined
+ # either through ethtool or by looking up the dpdk mapping file.
+ self.pci_dev = None
+
+ @staticmethod
+ def from_json(json):
+ name = _get_required_field(json, 'name', 'VppInterface')
+ uio_driver = json.get('uio_driver', 'vfio-pci')
+ options = json.get('options', '')
+
+ opts = _BaseOpts.base_opts_from_json(json)
+ return VppInterface(name, *opts, uio_driver=uio_driver,
+ options=options)