示例#1
0
    def test_update_sriov_vf_map_exist_complete(self):
        vf_initial = [{'device_type': 'vf', 'name': 'eth1_2',
                       'device': {'name': 'eth1', 'vfid': 2},
                       'vlan_id': 10, 'qos': 5,
                       'spoofcheck': 'on', 'trust': 'on',
                       'state': 'enable',
                       'macaddr': 'AA:BB:CC:DD:EE:FF',
                       'promisc': 'off',
                       'pci_address': "0000:80:00.1"}]
        utils.write_yaml_config(sriov_config._SRIOV_CONFIG_FILE, vf_initial)

        utils.update_sriov_vf_map('eth1', 2, 'eth1_2', vlan_id=100, qos=15,
                                  spoofcheck="off", trust="off", state="auto",
                                  macaddr="BB:BB:CC:DD:EE:FF", promisc="on",
                                  pci_address="0000:80:00.1")
        vf_final = [{'device_type': 'vf', 'name': 'eth1_2',
                     'device': {'name': 'eth1', 'vfid': 2},
                     'vlan_id': 100, 'qos': 15,
                     'spoofcheck': 'off', 'trust': 'off',
                     'state': 'auto',
                     'macaddr': 'BB:BB:CC:DD:EE:FF',
                     'promisc': 'on',
                     'pci_address': '0000:80:00.1'}]
        contents = utils.get_file_data(sriov_config._SRIOV_CONFIG_FILE)

        vf_map = yaml.safe_load(contents) if contents else []
        self.assertEqual(1, len(vf_map))
        self.assertListEqual(vf_final, vf_map)
 def test_update_sriov_vf_map_complete_new(self):
     utils.update_sriov_vf_map('eth1',
                               2,
                               'eth1_2',
                               vlan_id=10,
                               qos=5,
                               spoofcheck="on",
                               trust="on",
                               state="enable",
                               macaddr="AA:BB:CC:DD:EE:FF",
                               promisc="off",
                               pci_address="0000:80:00.1")
     contents = utils.get_file_data(sriov_config._SRIOV_CONFIG_FILE)
     sriov_vf_map = yaml.safe_load(contents) if contents else []
     self.assertEqual(1, len(sriov_vf_map))
     test_sriov_vf_map = [{
         'device_type': 'vf',
         'name': 'eth1_2',
         'device': {
             'name': 'eth1',
             'vfid': 2
         },
         'vlan_id': 10,
         'qos': 5,
         'spoofcheck': 'on',
         'trust': 'on',
         'state': 'enable',
         'macaddr': 'AA:BB:CC:DD:EE:FF',
         'promisc': 'off',
         'pci_address': "0000:80:00.1"
     }]
     self.assertListEqual(test_sriov_vf_map, sriov_vf_map)
示例#3
0
    def test_udev_rule_for_sriov_vf(self):
        def get_numvfs_stub(pf_name):
            return 10
        self.stub_out('os_net_config.sriov_config.get_numvfs',
                      get_numvfs_stub)
        utils.update_sriov_pf_map('eth1', 10, False)
        utils.update_sriov_pf_map('eth2', 10, False)
        utils.update_sriov_vf_map('eth1', 2, 'eth1_2')
        contents = common.get_file_data(common.SRIOV_CONFIG_FILE)
        sriov_vf_map = yaml.safe_load(contents) if contents else []
        self.assertEqual(3, len(sriov_vf_map))

        test_sriov_vf_map = {'device': {'name': 'eth1', 'vfid': 2},
                             'device_type': 'vf', 'max_tx_rate': 0,
                             'min_tx_rate': 0, 'name': 'eth1_2'}
        udev_file = open(sriov_config._UDEV_LEGACY_RULE_FILE, "w")
        udev_file.write(udev_content)
        udev_file.close()

        # sriov_config.add_udev_rule_for_legacy_sriov_pf("eth1", 10)
        for dev in sriov_vf_map:
            if(dev.keys() == test_sriov_vf_map.keys()):
                self.assertEqual(test_sriov_vf_map, dev)

        expect = '# This file is autogenerated by os-net-config\n'\
                 'KERNEL=="eth2", RUN+="/bin/os-net-config-sriov -n %k:10"\n'
        utils.nicpart_udev_rules_check()
        f = open(sriov_config._UDEV_LEGACY_RULE_FILE, 'r')
        self.assertEqual(expect, f.read())
        f.close()
示例#4
0
    def test_update_sriov_vf_map_exist_complete(self):
        vf_initial = [{'device_type': 'vf', 'name': 'eth1_2',
                       'device': {'name': 'eth1', 'vfid': 2},
                       'vlan_id': 10, 'qos': 5,
                       'spoofcheck': 'on', 'trust': 'on',
                       'state': 'enable',
                       'macaddr': 'AA:BB:CC:DD:EE:FF',
                       'promisc': 'off',
                       'pci_address': "0000:80:00.1"}]
        utils.write_yaml_config(sriov_config._SRIOV_CONFIG_FILE, vf_initial)

        utils.update_sriov_vf_map('eth1', 2, 'eth1_2', vlan_id=100, qos=15,
                                  spoofcheck="off", trust="off", state="auto",
                                  macaddr="BB:BB:CC:DD:EE:FF", promisc="on",
                                  pci_address="0000:80:00.1")
        vf_final = [{'device_type': 'vf', 'name': 'eth1_2',
                     'device': {'name': 'eth1', 'vfid': 2},
                     'vlan_id': 100, 'qos': 15,
                     'spoofcheck': 'off', 'trust': 'off',
                     'state': 'auto',
                     'macaddr': 'BB:BB:CC:DD:EE:FF',
                     'promisc': 'on',
                     'pci_address': '0000:80:00.1'}]
        contents = utils.get_file_data(sriov_config._SRIOV_CONFIG_FILE)

        vf_map = yaml.safe_load(contents) if contents else []
        self.assertEqual(1, len(vf_map))
        self.assertListEqual(vf_final, vf_map)
示例#5
0
 def test_update_sriov_vf_map_minimal_new(self):
     utils.update_sriov_vf_map('eth1', 2, 'eth1_2')
     contents = utils.get_file_data(sriov_config._SRIOV_CONFIG_FILE)
     sriov_vf_map = yaml.safe_load(contents) if contents else []
     self.assertEqual(1, len(sriov_vf_map))
     test_sriov_vf_map = [{'device_type': 'vf', 'name': 'eth1_2',
                           'device': {"name": "eth1", "vfid": 2}}]
     self.assertListEqual(test_sriov_vf_map, sriov_vf_map)
示例#6
0
 def test_update_sriov_vf_map_minimal_new(self):
     utils.update_sriov_vf_map('eth1', 2, 'eth1_2')
     contents = utils.get_file_data(sriov_config._SRIOV_CONFIG_FILE)
     sriov_vf_map = yaml.safe_load(contents) if contents else []
     self.assertEqual(1, len(sriov_vf_map))
     test_sriov_vf_map = [{'device_type': 'vf', 'name': 'eth1_2',
                           'device': {"name": "eth1", "vfid": 2}}]
     self.assertListEqual(test_sriov_vf_map, sriov_vf_map)
示例#7
0
    def test_update_sriov_vf_map_exist(self):
        vf_initial = [{
            'device_type': 'vf',
            'name': 'eth1_2',
            'device': {
                "name": "eth1",
                "vfid": 2
            }
        }]
        utils.write_yaml_config(common.SRIOV_CONFIG_FILE, vf_initial)

        utils.update_sriov_vf_map('eth1',
                                  2,
                                  'eth1_2',
                                  vlan_id=10,
                                  qos=5,
                                  spoofcheck="on",
                                  trust="on",
                                  state="enable",
                                  macaddr="AA:BB:CC:DD:EE:FF",
                                  promisc="off",
                                  pci_address="0000:80:00.1",
                                  max_tx_rate=10)
        vf_final = [{
            'device_type': 'vf',
            'name': 'eth1_2',
            'device': {
                'name': 'eth1',
                'vfid': 2
            },
            'vlan_id': 10,
            'qos': 5,
            'min_tx_rate': 0,
            'max_tx_rate': 10,
            'spoofcheck': 'on',
            'trust': 'on',
            'state': 'enable',
            'macaddr': 'AA:BB:CC:DD:EE:FF',
            'promisc': 'off',
            'pci_address': '0000:80:00.1'
        }]
        contents = common.get_file_data(common.SRIOV_CONFIG_FILE)

        vf_map = yaml.safe_load(contents) if contents else []
        self.assertEqual(1, len(vf_map))
        self.assertListEqual(vf_final, vf_map)
示例#8
0
 def test_update_sriov_vf_map_complete_new(self):
     utils.update_sriov_vf_map('eth1', 2, 'eth1_2', vlan_id=10, qos=5,
                               spoofcheck="on", trust="on", state="enable",
                               macaddr="AA:BB:CC:DD:EE:FF", promisc="off",
                               pci_address="0000:80:00.1")
     contents = utils.get_file_data(sriov_config._SRIOV_CONFIG_FILE)
     sriov_vf_map = yaml.safe_load(contents) if contents else []
     self.assertEqual(1, len(sriov_vf_map))
     test_sriov_vf_map = [{'device_type': 'vf', 'name': 'eth1_2',
                           'device': {'name': 'eth1', 'vfid': 2},
                           'vlan_id': 10, 'qos': 5,
                           'spoofcheck': 'on', 'trust': 'on',
                           'state': 'enable',
                           'macaddr': 'AA:BB:CC:DD:EE:FF',
                           'promisc': 'off',
                           'pci_address': "0000:80:00.1"}]
     self.assertListEqual(test_sriov_vf_map, sriov_vf_map)
示例#9
0
    def test_ordered_active_nics_with_dpdk_mapping_of_vf(self):
        tmpdir = tempfile.mkdtemp()
        self.stub_out('os_net_config.common.SYS_CLASS_NET', tmpdir)
        tmp_pci_dir = tempfile.mkdtemp()
        self.stub_out('os_net_config.common._SYS_BUS_PCI_DEV', tmp_pci_dir)
        physfn_path = common._SYS_BUS_PCI_DEV + '/0000:05:01.1/physfn'
        os.makedirs(physfn_path)

        def test_is_available_nic(interface_name, check_active):
            return True
        self.stub_out('os_net_config.utils._is_available_nic',
                      test_is_available_nic)

        utils._update_dpdk_map('eth2_0', '0000:06:01.1', 'AA:02:03:04:05:FE',
                               'vfio-pci')
        utils.update_sriov_vf_map('eth2', 0, 'eth2_0')

        nics = utils.ordered_active_nics()

        self.assertEqual(len(nics), 0)

        shutil.rmtree(tmpdir)
        shutil.rmtree(tmp_pci_dir)