PowerVM: Add proc_units_factor conf option

This introduces a new PowerVM conf option, proc_units_factor, which can
range from 0.05 to 1.0 and will default to 0.1. It is used to calculate
the physical processing power to assign per vCPU, where 1.0 is a whole
physical processor and 0.05 is 1/20th of a physical processor.

Change-Id: I67bfe2a6eff86f1947ada7661fc7c3fed81ed28f
This commit is contained in:
esberglu 2018-03-20 15:12:50 -05:00
parent e4a34856d7
commit 8a67fcd1c2
5 changed files with 73 additions and 2 deletions

View File

@ -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)

48
nova/conf/powervm.py Normal file
View File

@ -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}

View File

@ -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

View File

@ -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.

View File

@ -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.