Persist existing LPAR wrapper attributes in DefaultStandardize on resize

The DefaultStandardize object in pypowervm defaults the proc units
factor, max virtio slots, uncapped weight, spp, availability
priority, srr, proc compat, and lpar metric values. nova-powervm
does not pass in these parameters when resizing.

This results in these attributes being set to the default defined
by the DefaultStandardize object for every resize operation. This
change passes those parameters into the DefaultStandardize object.

Note that if the attributes were passed in as part of the flavor
then the flavor's values would be set later in the DefaultStandardize
object by the LPARBuilder.

Closes-Bug: #1722923
Change-Id: I0e9ad0dbbc35658e096636a454ad493492025420
This commit is contained in:
mdrabe 2017-10-11 16:03:36 -05:00
parent a584585074
commit 4bad1ec165
2 changed files with 47 additions and 3 deletions

View File

@ -67,6 +67,36 @@ class TestVMBuilder(test.TestCase):
'pypowervm.util.sanitize_partition_name_for_api')).mock
self.san_lpar_name.side_effect = lambda name: name
def test_resize_attributes_maintained(self):
lpar_w = mock.MagicMock()
lpar_w.io_config.max_virtual_slots = 200
lpar_w.proc_config.shared_proc_cfg.pool_id = 56
lpar_w.avail_priority = 129
lpar_w.srr_enabled = False
lpar_w.proc_compat_mode = 'POWER7'
lpar_w.allow_perf_data_collection = True
vm_bldr = vm.VMBuilder(self.host_w, self.adpt, cur_lpar_w=lpar_w)
self.assertEqual(200, vm_bldr.stdz.max_slots)
self.assertEqual(56, vm_bldr.stdz.spp)
self.assertEqual(129, vm_bldr.stdz.avail_priority)
self.assertFalse(vm_bldr.stdz.srr)
self.assertEqual('POWER7', vm_bldr.stdz.proc_compat)
self.assertTrue(vm_bldr.stdz.enable_lpar_metric)
def test_max_vslots_is_the_greater(self):
lpar_w = mock.MagicMock()
lpar_w.io_config.max_virtual_slots = 64
lpar_w.proc_config.shared_proc_cfg.pool_id = 56
lpar_w.avail_priority = 129
lpar_w.srr_enabled = False
lpar_w.proc_compat_mode = 'POWER7'
lpar_w.allow_perf_data_collection = True
slot_mgr = mock.MagicMock()
slot_mgr.build_map.get_max_vslots.return_value = 128
vm_bldr = vm.VMBuilder(
self.host_w, self.adpt, slot_mgr=slot_mgr, cur_lpar_w=lpar_w)
self.assertEqual(128, vm_bldr.stdz.max_slots)
def test_conf_values(self):
# Test driver CONF values are passed to the standardizer
self.flags(uncapped_proc_weight=75, proc_units_factor=.25,

View File

@ -267,21 +267,34 @@ class VMBuilder(object):
pvm_bp.DedicatedSharingMode.SHARE_IDLE_PROCS_ALWAYS
}
def __init__(self, host_w, adapter, slot_mgr=None):
def __init__(self, host_w, adapter, slot_mgr=None, cur_lpar_w=None):
"""Initialize the converter.
:param host_w: The host system wrapper.
:param adapter: The pypowervm.adapter.Adapter for the PowerVM REST API.
:param slot_mgr: NovaSlotManager for setting/saving the maximum number
of virtual slots on the VM.
:param cur_lpar_w: The LPAR wrapper of the instance. Passing in this
parameter signifies a resize operation.
"""
self.adapter = adapter
self.host_w = host_w
kwargs = dict(uncapped_weight=CONF.powervm.uncapped_proc_weight,
proc_units_factor=CONF.powervm.proc_units_factor)
if cur_lpar_w:
# Maintain the existing attributes in DefaultStandardize
kwargs['max_slots'] = cur_lpar_w.io_config.max_virtual_slots
kwargs['spp'] = cur_lpar_w.proc_config.shared_proc_cfg.pool_id
kwargs['avail_priority'] = cur_lpar_w.avail_priority
kwargs['srr'] = cur_lpar_w.srr_enabled
kwargs['proc_compat'] = cur_lpar_w.proc_compat_mode
kwargs['enable_lpar_metric'] = (
cur_lpar_w.allow_perf_data_collection)
if slot_mgr is not None:
# This will already default if not set
kwargs['max_slots'] = slot_mgr.build_map.get_max_vslots()
max_vslots = slot_mgr.build_map.get_max_vslots()
if max_vslots > kwargs.get('max_slots', 0):
kwargs['max_slots'] = max_vslots
self.stdz = lpar_bldr.DefaultStandardize(self.host_w, **kwargs)
def lpar_builder(self, instance):
@ -586,7 +599,8 @@ def update(adapter, host_wrapper, instance, entry=None, name=None):
if not entry:
entry = get_instance_wrapper(adapter, instance)
lpar_b = VMBuilder(host_wrapper, adapter).lpar_builder(instance)
lpar_b = VMBuilder(host_wrapper, adapter, cur_lpar_w=entry).lpar_builder(
instance)
lpar_b.rebuild(entry)
# Set the new name if the instance name is not desired.