Exemple #1
0
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)
    network = vif.get('network')
    mtu = network.get_meta('mtu') if network else None
    v1_name = get_vif_devname(vif)
    v2_name = get_vif_internal_devname(vif)
    if not network_utils.device_exists(v1_name):
        _create_veth_pair(v1_name, v2_name, mtu)
        if _is_ovs_vif_port(vif):
            # NOTE(jamespage): wire tap device directly to ovs bridge
            linux_net.create_ovs_vif_port(vif['network']['bridge'], v1_name,
                                          vif['id'], vif['address'],
                                          instance.uuid, mtu)
        else:
            # NOTE(jamespage): wire tap device linux bridge
            _add_bridge_port(config['bridge'], v1_name)
    else:
        network_utils.set_device_mtu(v1_name, mtu)
Exemple #2
0
 def plug_tap(self, instance, vif):
     """Plug a VIF_TYPE_TAP virtual interface."""
     dev = self.get_vif_devname(vif)
     mac = vif['details'].get(network_model.VIF_DETAILS_TAP_MAC_ADDRESS)
     linux_net_utils.create_tap_dev(dev, mac)
     network = vif.get('network')
     mtu = network.get_meta('mtu') if network else None
     linux_net_utils.set_device_mtu(dev, mtu)
Exemple #3
0
 def plug_tap(self, instance, vif):
     """Plug a VIF_TYPE_TAP virtual interface."""
     dev = self.get_vif_devname(vif)
     mac = vif['details'].get(network_model.VIF_DETAILS_TAP_MAC_ADDRESS)
     linux_net_utils.create_tap_dev(dev, mac)
     network = vif.get('network')
     mtu = network.get_meta('mtu') if network else None
     linux_net_utils.set_device_mtu(dev, mtu)
Exemple #4
0
 def plug_tap(self, instance, vif):
     """Plug a VIF_TYPE_TAP virtual interface."""
     v1_name = get_vif_devname(vif)
     v2_name = get_vif_internal_devname(vif)
     network = vif.get('network')
     mtu = network.get_meta('mtu') if network else None
     # NOTE(jamespage): For nova-lxd this is really a veth pair
     #                  so that a) security rules get applied on the host
     #                  and b) that the container can still be wired.
     if not network_utils.device_exists(v1_name):
         _create_veth_pair(v1_name, v2_name, mtu)
     else:
         network_utils.set_device_mtu(v1_name, mtu)
Exemple #5
0
 def plug_tap(self, instance, vif):
     """Plug a VIF_TYPE_TAP virtual interface."""
     dev = self.get_vif_devname(vif)
     mac = vif['details'].get(network_model.VIF_DETAILS_TAP_MAC_ADDRESS)
     image_meta = instance.image_meta
     vif_model = self.get_vif_model(image_meta=image_meta)
     # TODO(ganso): explore whether multiqueue works for other vif models
     # that go through this code path.
     multiqueue = (self._requests_multiqueue(image_meta)
                   and vif_model == network_model.VIF_MODEL_VIRTIO)
     linux_net_utils.create_tap_dev(dev, mac, multiqueue=multiqueue)
     network = vif.get('network')
     mtu = network.get_meta('mtu') if network else None
     linux_net_utils.set_device_mtu(dev, mtu)
Exemple #6
0
def _post_plug_wiring_veth_and_bridge(instance, vif):
    config = get_config(vif)
    network = vif.get('network')
    mtu = network.get_meta('mtu') if network else None
    v1_name = get_vif_devname(vif)
    v2_name = get_vif_internal_devname(vif)
    if not network_utils.device_exists(v1_name):
        _create_veth_pair(v1_name, v2_name, mtu)
        if _is_ovs_vif_port(vif):
            # NOTE(jamespage): wire tap device directly to ovs bridge
            linux_net.create_ovs_vif_port(vif['network']['bridge'], v1_name,
                                          vif['id'], vif['address'],
                                          instance.uuid, mtu)
        else:
            # NOTE(jamespage): wire tap device linux bridge
            _add_bridge_port(config['bridge'], v1_name)
    else:
        network_utils.set_device_mtu(v1_name, mtu)
Exemple #7
0
def _create_veth_pair(dev1_name, dev2_name, mtu=None):
    """Create a pair of veth devices with the specified names,
    deleting any previous devices with those names.
    """
    for dev in [dev1_name, dev2_name]:
        network_utils.delete_net_dev(dev)

    utils.execute('ip',
                  'link',
                  'add',
                  dev1_name,
                  'type',
                  'veth',
                  'peer',
                  'name',
                  dev2_name,
                  run_as_root=True)

    for dev in [dev1_name, dev2_name]:
        utils.execute('ip', 'link', 'set', dev, 'up', run_as_root=True)
        network_utils.set_device_mtu(dev, mtu)
Exemple #8
0
 def test_set_device_mtu_default(self):
     calls = []
     with mock.patch('nova.utils.execute', return_value=('', '')) as ex:
         net_utils.set_device_mtu('fake-dev')
         ex.assert_has_calls(calls)