Instance delete always stops partition
Instance delete always stops partition even if partition ia already stoped. Work around is when it try to stop the partition which is already stopped, then catch exception and pass it. Closes-Bug: #1701506 Change-Id: I8ddb84de307bc58fa68136c503408a2d65ef629a Signed-off-by: Prabhat Ranjan <pranjank@in.ibm.com>
This commit is contained in:
parent
dcf6bb6954
commit
4c23e0b0bc
|
@ -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