예제 #1
0
def _parse_bandwidths(cms_options):
    for cms_option in cms_options:
        if ovn_const.RP_BANDWIDTHS in cms_option:
            bw_values = cms_option.split('=')[1]
            break
    else:
        return

    if bw_values:
        return placement_utils.parse_rp_bandwidths(bw_values.split(';'))
예제 #2
0
    def parse(self):
        """Parses device_mappings and exclude_devices.

        Parse and validate the consistency in both mappings
        """
        self.device_mappings = helpers.parse_mappings(
            cfg.CONF.SRIOV_NIC.physical_device_mappings, unique_keys=False)
        self.exclude_devices = config.parse_exclude_devices(
            cfg.CONF.SRIOV_NIC.exclude_devices)
        self.rp_bandwidths = place_utils.parse_rp_bandwidths(
            cfg.CONF.SRIOV_NIC.resource_provider_bandwidths)
        self.rp_inventory_defaults = place_utils.parse_rp_inventory_defaults(
            cfg.CONF.SRIOV_NIC.resource_provider_inventory_defaults)
        self._validate()
예제 #3
0
    def parse(self):
        """Parses device_mappings and exclude_devices.

        Parse and validate the consistency in both mappings
        """
        self.device_mappings = helpers.parse_mappings(
            cfg.CONF.SRIOV_NIC.physical_device_mappings, unique_keys=False)
        self.exclude_devices = config.parse_exclude_devices(
            cfg.CONF.SRIOV_NIC.exclude_devices)
        self.rp_bandwidths = place_utils.parse_rp_bandwidths(
            cfg.CONF.SRIOV_NIC.resource_provider_bandwidths)
        self.rp_inventory_defaults = place_utils.parse_rp_inventory_defaults(
            cfg.CONF.SRIOV_NIC.resource_provider_inventory_defaults)
        self._validate()
예제 #4
0
    def test_parse_rp_bandwidths(self):
        self.assertEqual(
            {},
            place_utils.parse_rp_bandwidths([]),
        )

        self.assertEqual(
            {'eth0': {'egress': None, 'ingress': None}},
            place_utils.parse_rp_bandwidths(['eth0']),
        )

        self.assertEqual(
            {'eth0': {'egress': None, 'ingress': None}},
            place_utils.parse_rp_bandwidths(['eth0::']),
        )

        self.assertRaises(
            ValueError,
            place_utils.parse_rp_bandwidths,
            ['eth0::', 'eth0::'],
        )

        self.assertRaises(
            ValueError,
            place_utils.parse_rp_bandwidths,
            ['eth0:not a number:not a number'],
        )

        self.assertEqual(
            {'eth0': {'egress': 1, 'ingress': None}},
            place_utils.parse_rp_bandwidths(['eth0:1:']),
        )

        self.assertEqual(
            {'eth0': {'egress': None, 'ingress': 1}},
            place_utils.parse_rp_bandwidths(['eth0::1']),
        )

        self.assertEqual(
            {'eth0': {'egress': 1, 'ingress': 1}},
            place_utils.parse_rp_bandwidths(['eth0:1:1']),
        )

        self.assertEqual(
            {'eth0': {'egress': 1, 'ingress': 1},
             'eth1': {'egress': 10, 'ingress': 10}},
            place_utils.parse_rp_bandwidths(['eth0:1:1', 'eth1:10:10']),
        )
예제 #5
0
def _parse_bandwidths(cms_options):
    bw_values = _parse_placement_option(n_const.RP_BANDWIDTHS, cms_options)
    if not bw_values:
        return {}

    return placement_utils.parse_rp_bandwidths(bw_values.split(';'))