config options: Centralise PCI options

Add options from 'pci/whitelist'. These options are part of the
'DEFAULT' group but are included in the "nova.conf.pci" file in hope
that they can eventually be moved to a 'pci' group.

Change-Id: Ib28a16ef7dccd98425f39cffcec7652aa0f05fa8
Implements: blueprint centralize-config-options
This commit is contained in:
Stephen Finucane 2015-12-04 22:40:28 +00:00
parent deb1ee4409
commit 0a3d6e2af0
5 changed files with 57 additions and 35 deletions

View File

@ -57,6 +57,7 @@ from nova.conf import ironic
# from nova.conf import neutron
# from nova.conf import notification
# from nova.conf import osapi_v21
from nova.conf import pci
# from nova.conf import rdp
from nova.conf import scheduler
# from nova.conf import security
@ -115,6 +116,7 @@ ironic.register_opts(CONF)
# neutron.register_opts(CONF)
# notification.register_opts(CONF)
# osapi_v21.register_opts(CONF)
pci.register_opts(CONF)
# rdp.register_opts(CONF)
scheduler.register_opts(CONF)
# security.register_opts(CONF)

51
nova/conf/pci.py Normal file
View File

@ -0,0 +1,51 @@
# Copyright (c) 2013 Intel, Inc.
# Copyright (c) 2013 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
pci_alias_opt = cfg.MultiStrOpt(
'pci_alias',
default=[],
help='An alias for a PCI passthrough device requirement. This allows '
'users to specify the alias in the extra_spec for a flavor, '
'without needing to repeat all the PCI property requirements. For '
'example: pci_alias = { '
'"name": "QuickAssist", '
'"product_id": "0443", '
'"vendor_id": "8086", '
'"device_type": "type-PCI" '
'} defines an alias for the Intel QuickAssist card. (multi '
'valued).')
pci_passthrough_whitelist_opt = cfg.MultiStrOpt(
'pci_passthrough_whitelist',
default=[],
help='White list of PCI devices available to VMs. For example: '
'pci_passthrough_whitelist = '
'[{"vendor_id": "8086", "product_id": "0443"}]')
ALL_OPTS = [pci_alias_opt,
pci_passthrough_whitelist_opt]
def register_opts(conf):
conf.register_opts(ALL_OPTS)
def list_opts():
# TODO(sfinucan): This should be moved into the PCI group and
# oslo_config.cfg.OptGroup used
return {'DEFAULT': ALL_OPTS}

View File

@ -46,8 +46,6 @@ import nova.netconf
import nova.notifications
import nova.objects.network
import nova.paths
import nova.pci.request
import nova.pci.whitelist
import nova.quota
import nova.rdp
import nova.service
@ -89,8 +87,6 @@ def list_opts():
nova.notifications.notify_opts,
nova.objects.network.network_opts,
nova.paths.path_opts,
nova.pci.request.pci_alias_opts,
nova.pci.whitelist.pci_opts,
nova.quota.quota_opts,
nova.service.service_opts,
nova.utils.monkey_patch_opts,

View File

@ -39,37 +39,18 @@
import copy
import jsonschema
from oslo_config import cfg
from oslo_serialization import jsonutils
import six
import nova.conf
from nova import exception
from nova import objects
from nova.objects import fields as obj_fields
from nova.pci import utils
pci_alias_opts = [
cfg.MultiStrOpt('pci_alias',
default=[],
help='An alias for a PCI passthrough device requirement. '
'This allows users to specify the alias in the '
'extra_spec for a flavor, without needing to repeat '
'all the PCI property requirements. For example: '
'pci_alias = '
'{ "name": "QuickAssist", '
' "product_id": "0443", '
' "vendor_id": "8086", '
' "device_type": "type-PCI" '
'} '
'defines an alias for the Intel QuickAssist card. '
'(multi valued)'
)
]
PCI_NET_TAG = 'physical_network'
CONF = cfg.CONF
CONF.register_opts(pci_alias_opts)
CONF = nova.conf.CONF
_ALIAS_DEV_TYPE = [obj_fields.PciDeviceType.STANDARD,

View File

@ -14,22 +14,14 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from oslo_serialization import jsonutils
import nova.conf
from nova import exception
from nova.i18n import _
from nova.pci import devspec
pci_opts = [cfg.MultiStrOpt('pci_passthrough_whitelist',
default=[],
help='White list of PCI devices available to VMs. '
'For example: pci_passthrough_whitelist = '
'[{"vendor_id": "8086", "product_id": "0443"}]'
)
]
CONF = cfg.CONF
CONF.register_opts(pci_opts)
CONF = nova.conf.CONF
class Whitelist(object):