Destroy flow fixed for partition none case
Destroy flow currenly fails as the partition object is None and logging is trying to reference. The fix uses instance variables when partition is None Closes bug: 1662485 Change-Id: I8edfbebb3e986f42b57b799f72d505ede4adc385
This commit is contained in:
parent
eb2bc80389
commit
2e76bfa2aa
|
@ -15,6 +15,7 @@
|
|||
import mock
|
||||
|
||||
from nova.compute import manager as compute_manager
|
||||
from nova import exception
|
||||
from nova.test import TestCase
|
||||
from nova_dpm.tests.unit.virt.dpm import fakeutils
|
||||
from nova_dpm.tests.unit.virt.dpm import fakezhmcclient
|
||||
|
@ -57,6 +58,17 @@ class VmFunctionTestCase(TestCase):
|
|||
self.assertEqual(list[i].get_property('name'),
|
||||
partition_list[i].get_property('name'))
|
||||
|
||||
@mock.patch.object(vm.PartitionInstance, 'get_partition',
|
||||
return_value=None)
|
||||
def test_partition_destroy_partition_none(self, mock_get_part):
|
||||
mock_nova_inst = mock.Mock()
|
||||
mock_nova_inst.hostname = 'foo'
|
||||
mock_nova_inst.uuid = 'foo-id'
|
||||
inst = vm.PartitionInstance(
|
||||
mock_nova_inst, mock.Mock(), mock.Mock())
|
||||
self.assertRaises(exception.InstanceNotFound,
|
||||
inst.destroy)
|
||||
|
||||
|
||||
class InstancePropertiesTestCase(TestCase):
|
||||
def setUp(self):
|
||||
|
|
|
@ -299,8 +299,11 @@ class PartitionInstance(object):
|
|||
'status': self.partition.properties['status']})
|
||||
raise exception.InstanceInvalidState(errormsg)
|
||||
else:
|
||||
errormsg = (_("Partition - %(partition)s does not exist") %
|
||||
{'partition': self.partition.properties['name']})
|
||||
errormsg = (_("Partition corresponding to the instance "
|
||||
"%(instance)s and instance uuid %(uuid)s "
|
||||
"does not exist") %
|
||||
{'instance': self.instance.hostname,
|
||||
'uuid': self.instance.uuid})
|
||||
raise exception.InstanceNotFound(errormsg)
|
||||
|
||||
def power_on_vm(self):
|
||||
|
|
Loading…
Reference in New Issue