Beispiel #1
0
def _preserve_iface_state(dev):
    dev_was_up = iface.is_up(dev)
    try:
        yield
    finally:
        if dev_was_up and not iface.is_up(dev):
            iface.up(dev)
Beispiel #2
0
def dummy_device(prefix='dummy_', max_length=11):
    dummy_interface = Dummy(prefix, max_length)
    dummy_name = dummy_interface.create()
    try:
        linkiface.up(dummy_name)
        yield dummy_name
    finally:
        dummy_interface.remove()
Beispiel #3
0
def dummy_device(prefix='dummy_', max_length=11):
    dummy_interface = Dummy(prefix, max_length)
    dummy_name = dummy_interface.create()
    try:
        linkiface.up(dummy_name)
        yield dummy_name
    finally:
        dummy_interface.remove()
Beispiel #4
0
def change_numvfs(pci_path, numvfs, net_name):
    """Change number of virtual functions of a device.

    The persistence is stored in the same place as other network persistence is
    stored. A call to setSafeNetworkConfig() will persist it across reboots.
    """
    # TODO: net_name is here only because it is hard to call pf_to_net_name
    # TODO: from here. once all our code will be under lib/vdsm this should be
    # TODO: removed.
    logging.info('Changing number of vfs on device %s -> %s.', pci_path,
                 numvfs)
    sriov.update_numvfs(pci_path, numvfs)
    sriov.persist_numvfs(pci_path, numvfs)

    link_iface.up(net_name)
Beispiel #5
0
Datei: api.py Projekt: EdDev/vdsm
def change_numvfs(pci_path, numvfs, net_name):
    """Change number of virtual functions of a device.

    The persistence is stored in the same place as other network persistence is
    stored. A call to setSafeNetworkConfig() will persist it across reboots.
    """
    # TODO: net_name is here only because it is hard to call pf_to_net_name
    # TODO: from here. once all our code will be under lib/vdsm this should be
    # TODO: removed.
    logging.info('Changing number of vfs on device %s -> %s.',
                 pci_path, numvfs)
    sriov.update_numvfs(pci_path, numvfs)
    sriov.persist_numvfs(pci_path, numvfs)

    link_iface.up(net_name)
Beispiel #6
0
    def test_get_lldp_tlvs(self):
        with veth_pair() as (nic1, nic2):
            iface.up(nic1)
            iface.up(nic2)
            with enable_lldp_on_ifaces((nic1, nic2), rx_only=False):
                self.assertTrue(lldptool.is_lldp_enabled_on_iface(nic1))
                self.assertTrue(lldptool.is_lldp_enabled_on_iface(nic2))
                tlvs = lldptool.get_tlvs(nic1)
                self.assertEqual(3, len(tlvs))
                expected_ttl_tlv = {
                    'type': 3,
                    'name': 'Time to Live',
                    'properties': {
                        'time to live': '120'
                    }
                }
                self.assertEqual(expected_ttl_tlv, tlvs[-1])

                tlvs = lldptool.get_tlvs(nic2)
                self.assertEqual(3, len(tlvs))
Beispiel #7
0
def set_ovs_links_up(nets2add, bonds2add, bonds2edit):
    # TODO: Make this universal for legacy and ovs.
    for dev in _gather_ovs_ifaces(nets2add, bonds2add, bonds2edit):
        iface.up(dev)
Beispiel #8
0
 def test_iface_notpromisc(self):
     with dummy_device() as nic:
         iface.up(nic)
         self.assertFalse(iface.is_promisc(nic))
Beispiel #9
0
 def test_iface_down(self):
     with dummy_device() as nic:
         iface.up(nic)
         iface.down(nic)
         self.assertFalse(iface.is_up(nic))
Beispiel #10
0
 def test_iface_up(self):
     with dummy_device() as nic:
         iface.up(nic)
         self.assertTrue(iface.is_up(nic))
Beispiel #11
0
 def test_iface_notpromisc(self):
     with dummy_device() as nic:
         iface.up(nic)
         self.assertFalse(iface.is_promisc(nic))
Beispiel #12
0
 def test_iface_down(self):
     with dummy_device() as nic:
         iface.up(nic)
         iface.down(nic)
         self.assertFalse(iface.is_up(nic))
Beispiel #13
0
 def test_iface_up(self):
     with dummy_device() as nic:
         iface.up(nic)
         self.assertTrue(iface.is_up(nic))
Beispiel #14
0
def set_ovs_links_up(nets2add, bonds2add, bonds2edit):
    # TODO: Make this universal for legacy and ovs.
    for dev in _gather_ovs_ifaces(nets2add, bonds2add, bonds2edit):
        iface.up(dev)