Exemplo n.º 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)
Exemplo n.º 2
0
Arquivo: vif.py Projeto: 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)
Exemplo n.º 3
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)
Exemplo n.º 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)
Exemplo n.º 5
0
 def test_vf_number_found(self, mock_iglob, mock_readlink):
     mock_iglob.return_value = self.paths
     mock_readlink.return_value = '../../0000:00:00.1'
     vf_num = utils.get_vf_num_by_pci_address(self.pci_address)
     self.assertEqual(vf_num, '3')
Exemplo n.º 6
0
 def test_vf_number_found(self, mock_iglob, mock_readlink):
     mock_iglob.return_value = self.paths
     mock_readlink.return_value = '../../0000:00:00.1'
     vf_num = utils.get_vf_num_by_pci_address(self.pci_address)
     self.assertEqual(vf_num, '3')