Merge "If HMC is up and CPC is down"
This commit is contained in:
commit
2b53cd3f33
|
@ -83,3 +83,44 @@ class HostTestCase(TestCase):
|
|||
self.assertRaises(
|
||||
exceptions.CpcDpmModeNotEnabledException,
|
||||
utils.validate_host_conf, cpc)
|
||||
|
||||
def test_if_cpc_is_down(self):
|
||||
session = zhmcclient_mock.FakedSession(
|
||||
'fake-host', 'fake-hmc', '2.13.1', '1.8')
|
||||
|
||||
session.hmc.cpcs.add({
|
||||
'name': 'cpc_1',
|
||||
'description': 'CPC #1',
|
||||
'status': 'no-power',
|
||||
'dpm-enabled': True,
|
||||
'processor-count-ifl': 10,
|
||||
'storage-customer': 2048,
|
||||
})
|
||||
client = zhmcclient.Client(session)
|
||||
cpc = client.cpcs.find(**{"name": "cpc_1"})
|
||||
self.flags(host='foo')
|
||||
self.flags(group="dpm", max_processors=3)
|
||||
self.flags(group="dpm", max_memory=1024)
|
||||
|
||||
self.assertRaises(
|
||||
exceptions.CpcDownError,
|
||||
utils.validate_host_conf, cpc)
|
||||
|
||||
def test_if_cpc_is_not_down(self):
|
||||
session = zhmcclient_mock.FakedSession(
|
||||
'fake-host', 'fake-hmc', '2.13.1', '1.8')
|
||||
|
||||
session.hmc.cpcs.add({
|
||||
'name': 'cpc_1',
|
||||
'description': 'CPC #1',
|
||||
'status': 'service-required',
|
||||
'dpm-enabled': True,
|
||||
'processor-count-ifl': 10,
|
||||
'storage-customer': 2048,
|
||||
})
|
||||
client = zhmcclient.Client(session)
|
||||
cpc = client.cpcs.find(**{"name": "cpc_1"})
|
||||
self.flags(host='foo')
|
||||
self.flags(group="dpm", max_processors=3)
|
||||
self.flags(group="dpm", max_memory=1024)
|
||||
utils.validate_host_conf(cpc)
|
||||
|
|
|
@ -57,3 +57,7 @@ class MaxMemoryExceededError(NovaException):
|
|||
|
||||
class CpcDpmModeNotEnabledException(NovaException):
|
||||
msg_fmt = _("DPM mode on CPC %(cpc_name)s not enabled.")
|
||||
|
||||
|
||||
class CpcDownError(NovaException):
|
||||
msg_fmt = _("CPC is Down")
|
||||
|
|
|
@ -13,12 +13,14 @@
|
|||
# limitations under the License.
|
||||
|
||||
import nova_dpm.conf
|
||||
from zhmcclient import HTTPError
|
||||
|
||||
from nova_dpm.virt.dpm import exceptions
|
||||
from oslo_log import log as logging
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONF = nova_dpm.conf.CONF
|
||||
CPC_UP_STATUS = ("active", "service-required", "degraded", "exceptions")
|
||||
|
||||
|
||||
def validate_host_conf(cpc):
|
||||
|
@ -27,6 +29,15 @@ def validate_host_conf(cpc):
|
|||
raise exceptions.CpcDpmModeNotEnabledException(
|
||||
cpc_name=cpc.get_property('name'))
|
||||
|
||||
try:
|
||||
if cpc.get_property('status') not in CPC_UP_STATUS:
|
||||
raise exceptions.CpcDownError()
|
||||
except HTTPError as http_error:
|
||||
if http_error.http_status == 409:
|
||||
raise exceptions.CpcDownError()
|
||||
else:
|
||||
raise http_error
|
||||
|
||||
if (CONF.dpm.max_processors > cpc.get_property('processor-count-ifl')):
|
||||
raise exceptions.MaxProcessorExceededError(
|
||||
config_proc=CONF.dpm.max_processors,
|
||||
|
|
Loading…
Reference in New Issue