1 # Copyright 2014 Mellanox Technologies, Ltd
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 from oslo_config import cfg
19 from neutron._i18n import _
20 from neutron.agent.common import config
23 def parse_exclude_devices(exclude_list):
24 """Parse Exclude devices list
26 parses excluded device list in the form:
27 dev_name:pci_dev_1;pci_dev_2
28 @param exclude list: list of string pairs in "key:value" format
29 the key part represents the network device name
30 the value part is a list of PCI slots separated by ";"
33 for dev_mapping in exclude_list:
35 dev_name, exclude_devices = dev_mapping.split(":", 1)
37 raise ValueError(_("Invalid mapping: '%s'") % dev_mapping)
38 dev_name = dev_name.strip()
40 raise ValueError(_("Missing key in mapping: '%s'") % dev_mapping)
41 if dev_name in exclude_mapping:
42 raise ValueError(_("Device %(dev_name)s in mapping: %(mapping)s "
43 "not unique") % {'dev_name': dev_name,
44 'mapping': dev_mapping})
45 exclude_devices_list = exclude_devices.split(";")
46 exclude_devices_set = set()
47 for dev in exclude_devices_list:
50 exclude_devices_set.add(dev)
51 exclude_mapping[dev_name] = exclude_devices_set
52 return exclude_mapping
54 DEFAULT_DEVICE_MAPPINGS = []
55 DEFAULT_EXCLUDE_DEVICES = []
58 cfg.IntOpt('polling_interval', default=2,
59 help=_("The number of seconds the agent will wait between "
60 "polling for local device changes.")),
64 cfg.ListOpt('physical_device_mappings',
65 default=DEFAULT_DEVICE_MAPPINGS,
66 help=_("Comma-separated list of "
67 "<physical_network>:<network_device> tuples mapping "
68 "physical network names to the agent's node-specific "
69 "physical network device interfaces of SR-IOV physical "
70 "function to be used for VLAN networks. All physical "
71 "networks listed in network_vlan_ranges on the server "
72 "should have mappings to appropriate interfaces on "
74 cfg.ListOpt('exclude_devices',
75 default=DEFAULT_EXCLUDE_DEVICES,
76 help=_("Comma-separated list of "
77 "<network_device>:<vfs_to_exclude> tuples, mapping "
78 "network_device to the agent's node-specific list of "
79 "virtual functions that should not be used for virtual "
80 "networking. vfs_to_exclude is a semicolon-separated "
81 "list of virtual functions to exclude from "
82 "network_device. The network_device in the mapping "
83 "should appear in the physical_device_mappings "
88 cfg.CONF.register_opts(agent_opts, 'AGENT')
89 cfg.CONF.register_opts(sriov_nic_opts, 'SRIOV_NIC')
90 config.register_agent_state_opts_helper(cfg.CONF)