Merge "Add context to PartitionInstance"
This commit is contained in:
commit
6c83181d89
|
@ -243,6 +243,16 @@ class DPMDriverInstanceTestCase(TestCase):
|
|||
self.dpmdriver = driver.DPMDriver(None)
|
||||
self.dpmdriver._client = self.client
|
||||
|
||||
@mock.patch.object(driver.DPMDriver, '_get_partition_instance')
|
||||
def test_spawn_context(self, mocked_get_part_inst):
|
||||
"""Make sure that context is provided to the PartitionInstance"""
|
||||
mock_context = mock.Mock()
|
||||
mock_inst = mock.Mock()
|
||||
self.dpmdriver.spawn(mock_context, mock_inst, None, None, None, None,
|
||||
[])
|
||||
|
||||
mocked_get_part_inst.assert_called_once_with(mock_inst, mock_context)
|
||||
|
||||
@mock.patch.object(vm.PartitionInstance, 'get_partition')
|
||||
@mock.patch.object(vm.PartitionInstance, 'create')
|
||||
@mock.patch.object(vm.PartitionInstance, 'properties')
|
||||
|
|
|
@ -70,11 +70,11 @@ class DPMDriver(driver.ComputeDriver):
|
|||
|
||||
self.volume_drivers = self._get_volume_drivers()
|
||||
|
||||
def _get_partition_instance(self, instance):
|
||||
def _get_partition_instance(self, instance, context=None):
|
||||
if instance.image_ref != '':
|
||||
raise exceptions.BootFromImageNotSupported()
|
||||
else:
|
||||
return vm.PartitionInstance(instance, self._cpc)
|
||||
return vm.PartitionInstance(instance, self._cpc, context)
|
||||
|
||||
def init_host(self, host):
|
||||
"""Driver initialization of the hypervisor node"""
|
||||
|
@ -303,7 +303,7 @@ class DPMDriver(driver.ComputeDriver):
|
|||
admin_password, allocations, network_info=None,
|
||||
block_device_info=None):
|
||||
|
||||
inst = self._get_partition_instance(instance)
|
||||
inst = self._get_partition_instance(instance, context)
|
||||
|
||||
# The creation of NICs is limited in DPM by the partitions
|
||||
# boot-os-specific-parameters property. It is used to pass additional
|
||||
|
|
|
@ -119,10 +119,11 @@ def cpcsubset_partition_list(cpc):
|
|||
|
||||
|
||||
class PartitionInstance(object):
|
||||
def __init__(self, instance, cpc):
|
||||
def __init__(self, instance, cpc, context=None):
|
||||
self.instance = instance
|
||||
self.cpc = cpc
|
||||
self.partition = self.get_partition()
|
||||
self.context = context
|
||||
|
||||
@staticmethod
|
||||
def create_object(instance, cpc, flavor=None):
|
||||
|
|
Loading…
Reference in New Issue