Handles exception in init_host() if CPC is not found
This code writes an error log in the nova log if the CPC is not found in the init_host() method of the DPMDriver. This will help to debug problems. The error message contains information about the HMC host, HMC userid and CPC UUID that were used. Closes-Bug: #1659037 Change-Id: I4606cefc9943c0a1a3a0db0c496dcce5c468407f Signed-off-by: Juergen Leopold <leopoldj@de.ibm.com>
This commit is contained in:
parent
e525fb3c54
commit
ff1b77f71a
|
@ -80,6 +80,11 @@ class DPMdriverInitHostTestCase(TestCase):
|
|||
self.flags(group="dpm", max_memory=512)
|
||||
self.dpmdriver.init_host(None)
|
||||
|
||||
def test_cpc_not_exists(self):
|
||||
self.flags(group="dpm", cpc_object_id="abc")
|
||||
self.assertRaises(SystemExit,
|
||||
self.dpmdriver.init_host, None)
|
||||
|
||||
def test_get_available_resource(self):
|
||||
host_properties = self.dpmdriver.get_available_resource(None)
|
||||
self.assertEqual('cpc_1', host_properties['cpc_name'])
|
||||
|
|
|
@ -33,6 +33,9 @@ from nova_dpm.virt.dpm import utils
|
|||
from nova_dpm.virt.dpm import vm
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
import sys
|
||||
import zhmcclient
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONF = nova_dpm.conf.CONF
|
||||
|
@ -71,9 +74,15 @@ class DPMDriver(driver.ComputeDriver):
|
|||
def init_host(self, host):
|
||||
"""Driver initialization of the hypervisor node"""
|
||||
LOG.debug("init_host")
|
||||
|
||||
self._cpc = self._client.cpcs.find(**{
|
||||
"object-id": CONF.dpm.cpc_object_id})
|
||||
try:
|
||||
self._cpc = self._client.cpcs.find(**{
|
||||
"object-id": CONF.dpm.cpc_object_id})
|
||||
except zhmcclient.NotFound:
|
||||
LOG.error("Matching hypervisor %s not found for object-id %s "
|
||||
"and username %s on HMC %s",
|
||||
CONF.host, CONF.dpm.cpc_object_id,
|
||||
CONF.dpm.hmc_username, CONF.dpm.hmc)
|
||||
sys.exit(1)
|
||||
LOG.debug("Matching hypervisor found %s for object-id %s and CPC %s",
|
||||
CONF.host, CONF.dpm.cpc_object_id,
|
||||
self._cpc.properties['name'])
|
||||
|
|
Loading…
Reference in New Issue