'create_ovs_vif_port' function moved to os-vif

A few functions from nova migrated to os-vif, and two were the
create_ovs_vif_port and delete_ovs_vif_port that nova-lxd uses to
do the post vif wiring on the container to connect it to the appropriate
bridge.  This just gets the correct import, and adds a bit to the
docstrings to help maintainers understand the code.

Change-Id: I0787a919275c544e4faddc9d42d8db5880ba57ee
Closes-Bug: #1776205
This commit is contained in:
Alex Kavanagh 2018-06-11 18:10:45 +01:00
parent 84a7945bca
commit b4c89d0677
1 changed files with 29 additions and 7 deletions

View File

@ -18,12 +18,12 @@ from oslo_log import log as logging
from nova import conf from nova import conf
from nova import exception from nova import exception
from nova import utils from nova import utils
from nova.network import linux_net
from nova.network import model as network_model from nova.network import model as network_model
from nova.network import os_vif_util from nova.network import os_vif_util
from nova.network import linux_utils as network_utils from nova.network import linux_utils as network_utils
import os_vif import os_vif
from vif_plug_ovs import linux_net
CONF = conf.CONF CONF = conf.CONF
@ -112,6 +112,14 @@ def get_config(vif):
# VIF_TYPE_OVS = 'ovs' # VIF_TYPE_OVS = 'ovs'
# VIF_TYPE_BRIDGE = 'bridge' # VIF_TYPE_BRIDGE = 'bridge'
def _post_plug_wiring_veth_and_bridge(instance, vif): def _post_plug_wiring_veth_and_bridge(instance, vif):
"""Wire/plug the virtual interface for the instance into the bridge that
lxd is using.
:param instance: the instance to plug into the bridge
:type instance: ???
:param vif: the virtual interface to plug into the bridge
:type vif: :class:`nova.network.model.VIF`
"""
config = get_config(vif) config = get_config(vif)
network = vif.get('network') network = vif.get('network')
mtu = network.get_meta('mtu') if network else None mtu = network.get_meta('mtu') if network else None
@ -143,11 +151,14 @@ POST_PLUG_WIRING = {
def _post_plug_wiring(instance, vif): def _post_plug_wiring(instance, vif):
"""Perform nova-lxd specific post os-vif plug processing """Perform nova-lxd specific post os-vif plug processing
:param vif: a nova.network.model.VIF instance Perform any post os-vif plug wiring required to network
Perform any post os-vif plug wiring requires to network
the instance LXD container with the underlying Neutron the instance LXD container with the underlying Neutron
network infrastructure network infrastructure
:param instance: the instance to plug into the bridge
:type instance: ???
:param vif: the virtual interface to plug into the bridge
:type vif: :class:`nova.network.model.VIF`
""" """
LOG.debug("Performing post plug wiring for VIF {}".format(vif)) LOG.debug("Performing post plug wiring for VIF {}".format(vif))
@ -164,6 +175,14 @@ def _post_plug_wiring(instance, vif):
# VIF_TYPE_OVS = 'ovs' # VIF_TYPE_OVS = 'ovs'
# VIF_TYPE_BRIDGE = 'bridge' # VIF_TYPE_BRIDGE = 'bridge'
def _post_unplug_wiring_delete_veth(instance, vif): def _post_unplug_wiring_delete_veth(instance, vif):
"""Wire/plug the virtual interface for the instance into the bridge that
lxd is using.
:param instance: the instance to plug into the bridge
:type instance: ???
:param vif: the virtual interface to plug into the bridge
:type vif: :class:`nova.network.model.VIF`
"""
v1_name = get_vif_devname(vif) v1_name = get_vif_devname(vif)
try: try:
if _is_ovs_vif_port(vif): if _is_ovs_vif_port(vif):
@ -185,10 +204,13 @@ POST_UNPLUG_WIRING = {
def _post_unplug_wiring(instance, vif): def _post_unplug_wiring(instance, vif):
"""Perform nova-lxd specific post os-vif unplug processing """Perform nova-lxd specific post os-vif unplug processing
:param vif: a nova.network.model.VIF instance Perform any post os-vif unplug wiring required to remove
Perform any post os-vif unplug wiring requires to remove
network interfaces assocaited with a lxd container. network interfaces assocaited with a lxd container.
:param instance: the instance to plug into the bridge
:type instance: :class:`nova.db.sqlalchemy.models.Instance`
:param vif: the virtual interface to plug into the bridge
:type vif: :class:`nova.network.model.VIF`
""" """
LOG.debug("Performing post unplug wiring for VIF {}".format(vif)) LOG.debug("Performing post unplug wiring for VIF {}".format(vif))