Пример #1
0
def set_vf_interface_vlan(pci_addr, mac_addr, vlan=0):
    pf_ifname = pci_utils.get_ifname_by_pci_address(pci_addr,
                                                    pf_interface=True)
    vf_ifname = pci_utils.get_ifname_by_pci_address(pci_addr)
    vf_num = pci_utils.get_vf_num_by_pci_address(pci_addr)

    # Set the VF's mac address and vlan
    exit_code = [0, 2, 254]
    port_state = 'up' if vlan > 0 else 'down'
    utils.execute('ip',
                  'link',
                  'set',
                  pf_ifname,
                  'vf',
                  vf_num,
                  'mac',
                  mac_addr,
                  'vlan',
                  vlan,
                  run_as_root=True,
                  check_exit_code=exit_code)
    # Bring up/down the VF's interface
    # TODO(edand): The mac is assigned as a workaround for the following issue
    #              https://bugzilla.redhat.com/show_bug.cgi?id=1372944
    #              once resolved it will be removed
    utils.execute('ip',
                  'link',
                  'set',
                  vf_ifname,
                  'address',
                  mac_addr,
                  port_state,
                  run_as_root=True,
                  check_exit_code=exit_code)
Пример #2
0
def set_vf_interface_vlan(pci_addr, mac_addr, vlan=0):
    pf_ifname = pci_utils.get_ifname_by_pci_address(pci_addr,
                                                    pf_interface=True)
    vf_ifname = pci_utils.get_ifname_by_pci_address(pci_addr)
    vf_num = pci_utils.get_vf_num_by_pci_address(pci_addr)

    nova.privsep.linux_net.set_device_macaddr_and_vlan(
        pf_ifname, vf_num, mac_addr, vlan)

    # Bring up/down the VF's interface
    # TODO(edand): The mac is assigned as a workaround for the following issue
    #              https://bugzilla.redhat.com/show_bug.cgi?id=1372944
    #              once resolved it will be removed
    port_state = 'up' if vlan > 0 else 'down'
    nova.privsep.linux_net.set_device_macaddr(vf_ifname, mac_addr,
                                              port_state=port_state)
Пример #3
0
Файл: vif.py Проект: YLTiny/nova
def set_vf_trusted(pci_addr, trusted):
    """Configures the VF to be trusted or not

    :param pci_addr: PCI slot of the device
    :param trusted: Boolean value to indicate whether to
                    enable/disable 'trusted' capability
    """
    pf_ifname = pci_utils.get_ifname_by_pci_address(pci_addr,
                                                    pf_interface=True)
    vf_num = pci_utils.get_vf_num_by_pci_address(pci_addr)
    nova.privsep.linux_net.set_device_trust(pf_ifname, vf_num, trusted)
Пример #4
0
def set_vf_interface_vlan(pci_addr, mac_addr, vlan=0):
    pf_ifname = pci_utils.get_ifname_by_pci_address(pci_addr,
                                                    pf_interface=True)
    vf_ifname = pci_utils.get_ifname_by_pci_address(pci_addr)
    vf_num = pci_utils.get_vf_num_by_pci_address(pci_addr)

    # Set the VF's mac address and vlan
    utils.execute('ip', 'link', 'set', pf_ifname,
                  'vf', vf_num,
                  'mac', mac_addr,
                  'vlan', vlan,
                  run_as_root=True,
                  check_exit_code=[0, 2, 254])
    # Bring up/down the VF's interface
    # TODO(edand): The mac is assigned as a workaround for the following issue
    #              https://bugzilla.redhat.com/show_bug.cgi?id=1372944
    #              once resolved it will be removed
    port_state = 'up' if vlan > 0 else 'down'
    nova.privsep.linux_net.set_device_macaddr(vf_ifname, mac_addr,
                                              port_state=port_state)
Пример #5
0
def set_vif_host_backend_hw_veb(conf, net_type, devname, vlan, tapname=None):
    """Populate a LibvirtConfigGuestInterface instance
    with host backend details for an device that supports hardware
    virtual ethernet bridge.
    """

    conf.net_type = net_type
    if net_type == 'direct':
        conf.source_mode = 'passthrough'
        conf.source_dev = pci_utils.get_ifname_by_pci_address(devname)
        conf.driver_name = 'vhost'
    else:
        conf.source_dev = devname
        conf.model = None
        conf.vlan = vlan
    if tapname:
        conf.target_dev = tapname
Пример #6
0
def set_vif_host_backend_802qbh_config(conf, net_type, devname, profileid, tapname=None):
    """Populate a LibvirtConfigGuestInterface instance
    with host backend details for an 802.1qbh device.
    """

    conf.net_type = net_type
    if net_type == "direct":
        conf.source_mode = "passthrough"
        conf.source_dev = pci_utils.get_ifname_by_pci_address(devname)
        conf.driver_name = "vhost"
    else:
        conf.source_dev = devname
        conf.model = None
    conf.vporttype = "802.1Qbh"
    conf.add_vport_param("profileid", profileid)
    if tapname:
        conf.target_dev = tapname
Пример #7
0
def set_vif_host_backend_hw_veb(conf, net_type, devname, vlan, tapname=None):
    """Populate a LibvirtConfigGuestInterface instance
    with host backend details for an device that supports hardware
    virtual ethernet bridge.
    """

    conf.net_type = net_type
    if net_type == "direct":
        conf.source_mode = "passthrough"
        conf.source_dev = pci_utils.get_ifname_by_pci_address(devname)
        conf.driver_name = "vhost"
    else:
        conf.source_dev = devname
        conf.model = None
        conf.vlan = vlan
    if tapname:
        conf.target_dev = tapname
Пример #8
0
def set_vif_host_backend_802qbh_config(conf, net_type, devname, profileid,
                                       tapname=None):
    """Populate a LibvirtConfigGuestInterface instance
    with host backend details for an 802.1qbh device.
    """

    conf.net_type = net_type
    if net_type == 'direct':
        conf.source_mode = 'passthrough'
        conf.source_dev = pci_utils.get_ifname_by_pci_address(devname)
        conf.driver_name = 'vhost'
    else:
        conf.source_dev = devname
        conf.model = None
    conf.vporttype = "802.1Qbh"
    conf.add_vport_param("profileid", profileid)
    if tapname:
        conf.target_dev = tapname
Пример #9
0
 def test_virtual_function_inferface_name(self, mock_listdir):
     mock_listdir.return_value = ['foo', 'bar']
     ifname = utils.get_ifname_by_pci_address(
         self.pci_address, pf_interface=False)
     self.assertEqual(ifname, 'bar')
Пример #10
0
 def test_virtual_function_inferface_name(self, mock_listdir):
     mock_listdir.return_value = ['foo', 'bar']
     ifname = utils.get_ifname_by_pci_address(
         self.pci_address, pf_interface=False)
     self.assertEqual(ifname, 'bar')
Пример #11
0
 def test_physical_function_inferface_name(self, mock_listdir):
     mock_listdir.return_value = ["foo", "bar"]
     ifname = utils.get_ifname_by_pci_address(self.pci_address, pf_interface=True)
     self.assertEqual(ifname, "bar")