Exemplo n.º 1
0
    def _plug_os_vif(self, instance, vif, raw_vif):
        instance_info = os_vif_util.nova_to_osvif_instance(instance)

        try:
            os_vif.plug(vif, instance_info)
        except osv_exception.ExceptionBase as ex:
            msg = (_("Failure running os_vif plugin plug method: %(ex)s") % {
                'ex': ex
            })
            raise exception.NovaException(msg)

        # TODO(johngarbutt) remove this hack once 1623876 is fixed in os-vif
        network = raw_vif.get('network')
        mtu = network.get_meta('mtu') if network else None
        if mtu is not None:
            linux_net._set_device_mtu(network["bridge"], mtu)

        if (type(vif) == os_vif.objects.vif.VIFBridge
                and hasattr(vif, "port_profile")
                and isinstance(vif.port_profile,
                               os_vif.objects.vif.VIFPortProfileOpenVSwitch)):
            veths = [("qvb%s" % vif.id)[:network_model.NIC_NAME_LEN],
                     ("qvo%s" % vif.id)[:network_model.NIC_NAME_LEN]]
            for veth in veths:
                linux_net._set_device_mtu(veth, mtu)
Exemplo n.º 2
0
    def _plug_os_vif(self, instance, vif, raw_vif):
        instance_info = os_vif_util.nova_to_osvif_instance(instance)

        try:
            os_vif.plug(vif, instance_info)
        except osv_exception.ExceptionBase as ex:
            msg = (_("Failure running os_vif plugin plug method: %(ex)s")
                   % {'ex': ex})
            raise exception.NovaException(msg)

        # TODO(johngarbutt) remove this hack once 1623876 is fixed in os-vif
        network = raw_vif.get('network')
        mtu = network.get_meta('mtu') if network else None
        if mtu is not None:
            linux_net._set_device_mtu(network["bridge"], mtu)

        if (type(vif) == os_vif.objects.vif.VIFBridge and
            hasattr(vif, "port_profile") and
            isinstance(vif.port_profile,
                       os_vif.objects.vif.VIFPortProfileOpenVSwitch)):
            veths = [
                ("qvb%s" % vif.id)[:network_model.NIC_NAME_LEN],
                ("qvo%s" % vif.id)[:network_model.NIC_NAME_LEN]]
            for veth in veths:
                linux_net._set_device_mtu(veth, mtu)
Exemplo n.º 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.create_tap_dev(dev, mac)
     network = vif.get('network')
     mtu = network.get_meta('mtu') if network else None
     linux_net._set_device_mtu(dev, mtu)
Exemplo n.º 4
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.create_tap_dev(dev, mac)
     network = vif.get('network')
     mtu = network.get_meta('mtu') if network else None
     linux_net._set_device_mtu(dev, mtu)
Exemplo n.º 5
0
 def test_set_device_mtu_configured(self):
     self.flags(network_device_mtu=10000)
     calls = [
         mock.call("ip", "link", "set", "fake-dev", "mtu", 10000, run_as_root=True, check_exit_code=[0, 2, 254])
     ]
     with mock.patch.object(utils, "execute", return_value=("", "")) as ex:
         linux_net._set_device_mtu("fake-dev")
         ex.assert_has_calls(calls)
Exemplo n.º 6
0
 def test_set_device_mtu_configured(self):
     self.flags(network_device_mtu=10000)
     calls = [
             mock.call('ip', 'link', 'set', 'fake-dev', 'mtu',
                       10000, run_as_root=True,
                       check_exit_code=[0, 2, 254])
             ]
     with mock.patch.object(utils, 'execute', return_value=('', '')) as ex:
         linux_net._set_device_mtu('fake-dev')
         ex.assert_has_calls(calls)
Exemplo n.º 7
0
 def test_set_device_mtu_configured(self):
     self.flags(network_device_mtu=10000)
     calls = [
             mock.call('ip', 'link', 'set', 'fake-dev', 'mtu',
                       10000, run_as_root=True,
                       check_exit_code=[0, 2, 254])
             ]
     with mock.patch.object(utils, 'execute', return_value=('', '')) as ex:
         linux_net._set_device_mtu('fake-dev')
         ex.assert_has_calls(calls)
Exemplo n.º 8
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 linux_net.device_exists(v1_name):
         _create_veth_pair(v1_name, v2_name, mtu)
     else:
         linux_net._set_device_mtu(v1_name, mtu)
Exemplo n.º 9
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 linux_net.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:
        linux_net._set_device_mtu(v1_name, mtu)
Exemplo n.º 10
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]:
        linux_net.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)
        linux_net._set_device_mtu(dev, mtu)
Exemplo n.º 11
0
 def test_set_device_mtu_default(self):
     calls = []
     with mock.patch.object(utils, 'execute', return_value=('', '')) as ex:
         linux_net._set_device_mtu('fake-dev')
         ex.assert_has_calls(calls)
Exemplo n.º 12
0
 def test_set_device_mtu_default(self):
     calls = []
     with mock.patch.object(utils, 'execute', return_value=('', '')) as ex:
         linux_net._set_device_mtu('fake-dev')
         ex.assert_has_calls(calls)
Exemplo n.º 13
0
 def test_set_device_mtu_default(self):
     calls = []
     with mock.patch.object(utils, "execute", return_value=("", "")) as ex:
         linux_net._set_device_mtu("fake-dev")
         ex.assert_has_calls(calls)
Exemplo n.º 14
0
Arquivo: vif.py Projeto: isyippee/nova
 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.create_tap_dev(dev, mac)
     linux_net._set_device_mtu(dev)