Merge "Persist existing LPAR wrapper attributes in DefaultStandardize on resize" into stable/pike

This commit is contained in:
Zuul
2017-11-08 21:58:54 +00:00
committed by Gerrit Code Review
2 changed files with 42 additions and 3 deletions

View File

@@ -67,6 +67,33 @@ 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'
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)
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'
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

@@ -263,21 +263,32 @@ 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
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):
@@ -578,7 +589,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.