コード例 #1
0
ファイル: test_utils.py プロジェクト: openstack/os-net-config
    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()
コード例 #2
0
    def test_update_sriov_pf_map_exist_with_promisc(self):
        def get_numvfs_stub(pf_name):
            return 10

        self.stub_out('os_net_config.sriov_config.get_numvfs', get_numvfs_stub)
        pf_initial = [{
            'device_type': 'pf',
            'link_mode': 'legacy',
            'name': 'eth1',
            'numvfs': 10,
            'promisc': 'on'
        }]
        utils.write_yaml_config(sriov_config._SRIOV_CONFIG_FILE, pf_initial)

        utils.update_sriov_pf_map('eth1', 10, False, promisc='off')
        pf_final = [{
            'device_type': 'pf',
            'link_mode': 'legacy',
            'name': 'eth1',
            'numvfs': 10,
            'promisc': 'off'
        }]
        contents = utils.get_file_data(sriov_config._SRIOV_CONFIG_FILE)

        pf_map = yaml.safe_load(contents) if contents else []
        self.assertEqual(1, len(pf_map))
        self.assertListEqual(pf_final, pf_map)
コード例 #3
0
 def test_update_sriov_pf_map_new(self):
     utils.update_sriov_pf_map('eth1', 10, False)
     contents = utils.get_file_data(utils._SRIOV_PF_CONFIG_FILE)
     sriov_pf_map = yaml.load(contents) if contents else []
     self.assertEqual(1, len(sriov_pf_map))
     test_sriov_pf_map = [{'name': 'eth1', 'numvfs': 10}]
     self.assertListEqual(test_sriov_pf_map, sriov_pf_map)
コード例 #4
0
ファイル: test_utils.py プロジェクト: openstack/os-net-config
 def test_update_sriov_pf_map_new_with_promisc(self):
     utils.update_sriov_pf_map('eth1', 10, False, promisc='off')
     contents = utils.get_file_data(sriov_config._SRIOV_CONFIG_FILE)
     sriov_pf_map = yaml.safe_load(contents) if contents else []
     self.assertEqual(1, len(sriov_pf_map))
     test_sriov_pf_map = [{'device_type': 'pf', 'link_mode': 'legacy',
                           'name': 'eth1', 'numvfs': 10, 'promisc': 'off'}]
     self.assertListEqual(test_sriov_pf_map, sriov_pf_map)
コード例 #5
0
    def test_update_sriov_pf_map_exist(self):
        pf_initial = [{'name': 'eth1', 'numvfs': 10}]
        utils.write_yaml_config(utils._SRIOV_PF_CONFIG_FILE, pf_initial)

        utils.update_sriov_pf_map('eth1', 20, False)
        pf_final = [{'name': 'eth1', 'numvfs': 20}]
        contents = utils.get_file_data(utils._SRIOV_PF_CONFIG_FILE)

        pf_map = yaml.load(contents) if contents else []
        self.assertEqual(1, len(pf_map))
        self.assertListEqual(pf_final, pf_map)
コード例 #6
0
 def test_update_sriov_pf_map_new(self):
     utils.update_sriov_pf_map('eth1', 10, False)
     contents = utils.get_file_data(sriov_config._SRIOV_CONFIG_FILE)
     sriov_pf_map = yaml.safe_load(contents) if contents else []
     self.assertEqual(1, len(sriov_pf_map))
     test_sriov_pf_map = [{
         'device_type': 'pf',
         'link_mode': 'legacy',
         'name': 'eth1',
         'numvfs': 10
     }]
     self.assertListEqual(test_sriov_pf_map, sriov_pf_map)
コード例 #7
0
ファイル: test_utils.py プロジェクト: zeus-iiit/os-net-config
 def test_update_sriov_pf_map_new_with_promisc(self):
     def get_numvfs_stub(pf_name):
         return 0
     self.stub_out('os_net_config.sriov_config.get_numvfs',
                   get_numvfs_stub)
     utils.update_sriov_pf_map('eth1', 10, False, promisc='off')
     contents = utils.get_file_data(sriov_config._SRIOV_CONFIG_FILE)
     sriov_pf_map = yaml.safe_load(contents) if contents else []
     self.assertEqual(1, len(sriov_pf_map))
     test_sriov_pf_map = [{'device_type': 'pf', 'link_mode': 'legacy',
                           'name': 'eth1', 'numvfs': 10, 'promisc': 'off'}]
     self.assertListEqual(test_sriov_pf_map, sriov_pf_map)
コード例 #8
0
ファイル: test_utils.py プロジェクト: mk1234567/os-net-config
 def test_update_sriov_pf_map_new_with_promisc(self):
     utils.update_sriov_pf_map('eth1', 10, False, promisc='off')
     contents = utils.get_file_data(sriov_config._SRIOV_CONFIG_FILE)
     sriov_pf_map = yaml.load(contents) if contents else []
     self.assertEqual(1, len(sriov_pf_map))
     test_sriov_pf_map = [{
         'device_type': 'pf',
         'name': 'eth1',
         'numvfs': 10,
         'promisc': 'off'
     }]
     self.assertListEqual(test_sriov_pf_map, sriov_pf_map)
コード例 #9
0
ファイル: test_utils.py プロジェクト: openstack/os-net-config
 def test_update_sriov_pf_map_with_same_numvfs(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)
     contents = common.get_file_data(common.SRIOV_CONFIG_FILE)
     sriov_pf_map = yaml.safe_load(contents) if contents else []
     self.assertEqual(1, len(sriov_pf_map))
     test_sriov_pf_map = [{'device_type': 'pf', 'link_mode': 'legacy',
                           'name': 'eth1', 'numvfs': 10, 'vdpa': False}]
     self.assertListEqual(test_sriov_pf_map, sriov_pf_map)
コード例 #10
0
ファイル: test_utils.py プロジェクト: openstack/os-net-config
    def test_update_sriov_pf_map_exist_with_promisc(self):
        pf_initial = [{'device_type': 'pf', 'link_mode': 'legacy',
                       'name': 'eth1', 'numvfs': 10, 'promisc': 'on'}]
        utils.write_yaml_config(sriov_config._SRIOV_CONFIG_FILE, pf_initial)

        utils.update_sriov_pf_map('eth1', 20, False)
        pf_final = [{'device_type': 'pf', 'link_mode': 'legacy',
                     'name': 'eth1', 'numvfs': 20, 'promisc': 'on'}]
        contents = utils.get_file_data(sriov_config._SRIOV_CONFIG_FILE)

        pf_map = yaml.safe_load(contents) if contents else []
        self.assertEqual(1, len(pf_map))
        self.assertListEqual(pf_final, pf_map)
コード例 #11
0
    def test_update_sriov_pf_map_exist(self):
        pf_initial = [{
            'device_type': 'pf',
            'link_mode': 'legacy',
            'name': 'eth1',
            'numvfs': 10
        }]
        utils.write_yaml_config(sriov_config._SRIOV_CONFIG_FILE, pf_initial)

        utils.update_sriov_pf_map('eth1', 20, False)
        pf_final = [{
            'device_type': 'pf',
            'link_mode': 'legacy',
            'name': 'eth1',
            'numvfs': 20
        }]
        contents = utils.get_file_data(sriov_config._SRIOV_CONFIG_FILE)

        pf_map = yaml.safe_load(contents) if contents else []
        self.assertEqual(1, len(pf_map))
        self.assertListEqual(pf_final, pf_map)