Call pypowervm LPAR Wrapper validation on deploy

The additional validation in pypowervm will catch and raise
deployment violations that the PowerVM management interface will raise.
This is done to avoid issuing failing calls to the management interface.

There is still several validation checks needed in pypowervm.
Currently the validation will check that the LPAR desired processors
will not exceed what's available on the host.

Additional validation checks to be implemented in pypowervm:
1. Memory validation
2. Deploy vs resize validation

Change-Id: I3db3ada41e43da52072eaaf4eef3592668e05c8f
This commit is contained in:
Matt Rabe 2015-08-17 18:11:25 +02:00
parent 94bfbe53b6
commit 108b836155
2 changed files with 7 additions and 2 deletions

View File

@ -245,7 +245,8 @@ class TestVM(test.TestCase):
@mock.patch('pypowervm.utils.lpar_builder.DefaultStandardize')
@mock.patch('pypowervm.utils.lpar_builder.LPARBuilder.build')
def test_crt_lpar(self, mock_bld, mock_stdz):
@mock.patch('pypowervm.utils.validation.LPARWrapperValidator.validate_all')
def test_crt_lpar(self, mock_vld_all, mock_bld, mock_stdz):
instance = objects.Instance(**powervm.TEST_INSTANCE)
flavor = instance.get_flavor()
flavor.extra_specs = {'powervm:dedicated_proc': 'true'}
@ -256,6 +257,7 @@ class TestVM(test.TestCase):
self.apt.create.return_value = lparw.entry
vm.crt_lpar(self.apt, host_wrapper, instance, flavor)
self.assertTrue(self.apt.create.called)
self.assertTrue(mock_vld_all.called)
flavor.extra_specs = {'powervm:BADATTR': 'true'}
host_wrapper = mock.Mock()

View File

@ -29,6 +29,7 @@ from pypowervm.tasks import power
from pypowervm.tasks import vterm
from pypowervm.utils import lpar_builder as lpar_bldr
from pypowervm.utils import uuid as pvm_uuid
from pypowervm.utils import validation as vldn
from pypowervm.wrappers import base_partition as pvm_bp
from pypowervm.wrappers import logical_partition as pvm_lpar
from pypowervm.wrappers import managed_system as pvm_ms
@ -446,7 +447,9 @@ def crt_lpar(adapter, host_wrapper, instance, flavor):
:return: The LPAR response from the API.
"""
lpar_b = VMBuilder(host_wrapper, adapter).lpar_builder(instance, flavor)
lpar_w = lpar_b.build().create(parent_type=pvm_ms.System,
pending_lpar_w = lpar_b.build()
vldn.LPARWrapperValidator(pending_lpar_w, host_wrapper).validate_all()
lpar_w = pending_lpar_w.create(parent_type=pvm_ms.System,
parent_uuid=host_wrapper.uuid)
return lpar_w