diff --git a/nova/conf/__init__.py b/nova/conf/__init__.py index 309621c51696..377435add797 100644 --- a/nova/conf/__init__.py +++ b/nova/conf/__init__.py @@ -51,6 +51,7 @@ from nova.conf import osapi_v21 from nova.conf import paths from nova.conf import pci from nova.conf import placement +from nova.conf import powervm from nova.conf import quota from nova.conf import rdp from nova.conf import remote_debug @@ -103,6 +104,7 @@ osapi_v21.register_opts(CONF) paths.register_opts(CONF) pci.register_opts(CONF) placement.register_opts(CONF) +powervm.register_opts(CONF) quota.register_opts(CONF) rdp.register_opts(CONF) scheduler.register_opts(CONF) diff --git a/nova/conf/powervm.py b/nova/conf/powervm.py new file mode 100644 index 000000000000..f18e79c28f50 --- /dev/null +++ b/nova/conf/powervm.py @@ -0,0 +1,48 @@ +# Copyright 2018 IBM Corporation +# 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 + + +powervm_group = cfg.OptGroup( + name="powervm", + title="PowerVM Options", + help="""PowerVM options allow cloud administrators to configure how + OpenStack will work with the PowerVM hypervisor. + """ +) + +powervm_opts = [ + cfg.FloatOpt( + 'proc_units_factor', + default=0.1, + min=0.05, + max=1, + help="""Factor used to calculate the amount of physical processor + compute power given to each vCPU. E.g. A value of 1.0 means a + whole physical processor, whereas 0.05 means 1/20th of a physical + processor. + """ + ), +] + + +def register_opts(conf): + conf.register_group(powervm_group) + conf.register_opts(powervm_opts, group=powervm_group) + + +def list_opts(): + return {powervm_group: powervm_opts} diff --git a/nova/tests/unit/virt/powervm/test_vm.py b/nova/tests/unit/virt/powervm/test_vm.py index 73f55f54ced8..7f6155c94bb4 100644 --- a/nova/tests/unit/virt/powervm/test_vm.py +++ b/nova/tests/unit/virt/powervm/test_vm.py @@ -63,7 +63,7 @@ class TestVMBuilder(test.NoDBTestCase): name='lpar_name', uuid='lpar_uuid', flavor=mock.Mock(memory_mb='mem', vcpus='vcpus', extra_specs={})) vmb = vm.VMBuilder('host', 'adap') - mock_def_stdz.assert_called_once_with('host') + mock_def_stdz.assert_called_once_with('host', proc_units_factor=0.1) self.assertEqual(mock_lpar_bldr.return_value, vmb.lpar_builder(inst)) self.san_lpar_name.assert_called_once_with('lpar_name') @@ -75,6 +75,12 @@ class TestVMBuilder(test.NoDBTestCase): 'vcpu': 'vcpus', 'srr_capability': True}, mock_def_stdz.return_value) + # Assert non-default proc_units_factor. + mock_def_stdz.reset_mock() + self.flags(proc_units_factor=0.2, group='powervm') + vmb = vm.VMBuilder('host', 'adap') + mock_def_stdz.assert_called_once_with('host', proc_units_factor=0.2) + def test_format_flavor(self): """Perform tests against _format_flavor.""" # convert instance uuid to pypowervm uuid diff --git a/nova/virt/powervm/vm.py b/nova/virt/powervm/vm.py index eb52cfff9d66..fc4cbbffa60f 100644 --- a/nova/virt/powervm/vm.py +++ b/nova/virt/powervm/vm.py @@ -35,11 +35,13 @@ from pypowervm.wrappers import shared_proc_pool as pvm_spp import six from nova.compute import power_state +from nova import conf from nova import exception as exc from nova.i18n import _ from nova.virt import hardware +CONF = conf.CONF LOG = logging.getLogger(__name__) _POWERVM_STARTABLE_STATE = (pvm_bp.LPARState.NOT_ACTIVATED,) @@ -406,7 +408,8 @@ class VMBuilder(object): """ self.adapter = adapter self.host_w = host_w - self.stdz = lpar_bldr.DefaultStandardize(host_w) + kwargs = dict(proc_units_factor=CONF.powervm.proc_units_factor) + self.stdz = lpar_bldr.DefaultStandardize(host_w, **kwargs) def lpar_builder(self, inst): """Returns the pypowervm LPARBuilder for a given Nova flavor. diff --git a/releasenotes/notes/pvm_proc_units_factor-50d1e4ba079d7a6c.yaml b/releasenotes/notes/pvm_proc_units_factor-50d1e4ba079d7a6c.yaml new file mode 100644 index 000000000000..87c3842ada70 --- /dev/null +++ b/releasenotes/notes/pvm_proc_units_factor-50d1e4ba079d7a6c.yaml @@ -0,0 +1,12 @@ +--- +features: + - | + Introduces the ``powervm`` configuration group which contains the + ``proc_units_factor`` configuration option. This allows the operator to + specify the physical processing power to assign per vCPU. +upgrade: + - | + Previously the PowerVM driver would default to 0.5 physical processors per + vCPU, which is the default from the pypowervm library. The default will now + be 0.1 physical processors per vCPU, from the ``proc_units_factor`` + configuration option in the ``powervm`` configuration group.