Merge "Instance delete always stops partition"
This commit is contained in:
commit
8c7c087574
|
@ -20,6 +20,8 @@ from nova.objects import instance as instance_obj
|
|||
from nova.test import TestCase
|
||||
from nova_dpm.virt.dpm import exceptions
|
||||
from nova_dpm.virt.dpm import vm
|
||||
|
||||
import mock
|
||||
import zhmcclient
|
||||
import zhmcclient_mock
|
||||
|
||||
|
@ -43,6 +45,14 @@ def fake_session():
|
|||
'maximum-memory': 512,
|
||||
'ifl-processors': 3
|
||||
})
|
||||
cpc1.partitions.add({
|
||||
'name': 'OpenStack-foo-6511ee0f-0d64-4392-aaaa-bbbbbbbbbbbb',
|
||||
'description': 'OpenStack CPCSubset=foo',
|
||||
'initial-memory': 512,
|
||||
'status': 'stopped',
|
||||
'maximum-memory': 512,
|
||||
'ifl-processors': 3
|
||||
})
|
||||
adapter1 = cpc1.adapters.add({
|
||||
'object-id': '6511ee0f-0d64-4392-b9e0-cdbea10a17c3',
|
||||
'name': 'fcp_1',
|
||||
|
@ -271,6 +281,13 @@ class VmPartitionInstanceTestCase(TestCase):
|
|||
'object-uri') + '/hbas/1',
|
||||
self.partition_inst.get_boot_hba_uri())
|
||||
|
||||
def test_destroy_stopped_partition(self):
|
||||
instance = instance_obj.Instance()
|
||||
instance.save = mock.Mock()
|
||||
instance.uuid = '6511ee0f-0d64-4392-aaaa-bbbbbbbbbbbb'
|
||||
partition_inst = vm.PartitionInstance(instance, self.cpc)
|
||||
partition_inst.destroy()
|
||||
|
||||
|
||||
class PhysicalAdapterModelTestCase(TestCase):
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ from nova_dpm.virt.dpm import exceptions
|
|||
from nova_dpm.virt.dpm import utils
|
||||
from oslo_log import log as logging
|
||||
from zhmcclient._exceptions import NotFound
|
||||
from zhmcclient import HTTPError
|
||||
|
||||
CONF = conf.CONF
|
||||
OPENSTACK_PREFIX = 'OpenStack'
|
||||
|
@ -289,7 +290,18 @@ class PartitionInstance(object):
|
|||
def destroy(self):
|
||||
LOG.debug('Partition Destroy triggered')
|
||||
if self.partition:
|
||||
self.partition.stop(True)
|
||||
try:
|
||||
self.partition.stop(True)
|
||||
except HTTPError as http_error:
|
||||
# (http_status == 409 and reason == 1) means
|
||||
# Partition status is not valid to perform the operation.
|
||||
# e.g - If partition is already stop then stop operation
|
||||
# is not a valid operation on partition.
|
||||
if http_error.http_status == 409 and http_error.reason == 1:
|
||||
pass
|
||||
else:
|
||||
raise http_error
|
||||
|
||||
# TODO(preethipy): The below method to be removed once the bug
|
||||
# on DPM is fixed to return correct status on API return
|
||||
self._loop_status_update(5, 'stopped')
|
||||
|
|
Loading…
Reference in New Issue