Merge "Default proc weight added to create lpar"

This commit is contained in:
Drew Thorstensen 2015-01-12 14:24:10 -06:00 committed by Gerrit Code Review
commit 954d14f008
3 changed files with 43 additions and 2 deletions

View File

@ -162,8 +162,41 @@ class TestVM(test.TestCase):
self.assertEqual(len(lpar_list), 21)
@mock.patch('pypowervm.adapter.Adapter')
def test_crt_lpar(self, mock_adr):
@mock.patch('pypowervm.wrappers.logical_partition.crt_shared_procs')
@mock.patch('pypowervm.wrappers.logical_partition.crt_lpar')
def test_crt_lpar(self, mock_crt_lpar, mock_crt_sp, mock_adr):
instance = FakeInstance()
instance.name = 'Fake'
flavor = FakeFlavor()
flavor.memory_mb = 100
# Create a side effect that can validate the input into the create
# call.
def validate_of_create_sp(*kargs, **kwargs):
self.assertEqual(64, kwargs.get('uncapped_weight'))
proc_units = kargs[0]
self.assertEqual('0.10', proc_units)
vcpus = kargs[1]
self.assertEqual('1', vcpus)
mock_crt_sp.side_effect = validate_of_create_sp
def validate_of_create_lpar(*kargs, **kwargs):
instance_name = kargs[0]
self.assertEqual('Fake', instance_name)
_type = kargs[1]
self.assertEqual('AIX/Linux', _type)
# sprocs = kargs[2]
mem = kargs[3]
self.assertEqual('100', mem)
self.assertEqual('100', kwargs.get('min_mem'))
self.assertEqual('100', kwargs.get('max_mem'))
self.assertEqual('64', kwargs.get('max_io_slots'))
mock_crt_lpar.side_effect = validate_of_create_lpar
vm.crt_lpar(mock_adr, 'host_uuid', instance, flavor)
self.assertTrue(mock_adr.create.called)
self.assertTrue(mock_crt_sp.called)

View File

@ -21,6 +21,12 @@ hmc_opts = [
default=0.1,
help='Factor used to calculate the processor units per vcpu.'
' Valid values are: 0.05 - 1.0'),
cfg.IntOpt('uncapped_proc_weight',
default=64,
help='The processor weight to assign to newly created VMs. '
'Value should be between 1 and 255. Represents how '
'aggressively LPARs grab CPU when unused cycles are '
'available.'),
# TODO(kyleh) Temporary - Only needed since we're using an HMC
cfg.StrOpt('hmc_host_id',
default='',

View File

@ -208,8 +208,10 @@ def crt_lpar(adapter, host_uuid, instance, flavor):
mem = str(flavor.memory_mb)
vcpus = str(flavor.vcpus)
proc_units = '%.2f' % calc_proc_units(flavor.vcpus)
proc_weight = CONF.uncapped_proc_weight
sprocs = pvm_lpar.crt_shared_procs(proc_units, vcpus)
sprocs = pvm_lpar.crt_shared_procs(proc_units, vcpus,
uncapped_weight=proc_weight)
lpar_elem = pvm_lpar.crt_lpar(instance.name,
pvm_lpar.LPAR_TYPE_AIXLINUX,
sprocs,