From dbe45cf03fa32635090c07c3df6112ca4177b0d9 Mon Sep 17 00:00:00 2001 From: sreeteja Date: Wed, 26 Apr 2017 17:04:08 +0530 Subject: [PATCH] Added default value to the max_instances parameter of dpm.py The default value is set to -1, which means that there is no artificial upper bound for the number of instances on this CPC. The number of instances is only limited by the number of (free) partitions on this CPC. closes-Bug: 1683318 Change-Id: I80f8b36fa21cef313e0b5a821a26877afd1af980 --- nova_dpm/conf/dpm.py | 9 ++++-- nova_dpm/tests/unit/conf/test_dpm.py | 32 +++++++++++++++++++ ...tances-default-value-7e530d2ae32c4c44.yaml | 7 ++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 nova_dpm/tests/unit/conf/test_dpm.py create mode 100644 releasenotes/notes/config-max_instances-default-value-7e530d2ae32c4c44.yaml diff --git a/nova_dpm/conf/dpm.py b/nova_dpm/conf/dpm.py index db562c7..637dcd6 100644 --- a/nova_dpm/conf/dpm.py +++ b/nova_dpm/conf/dpm.py @@ -34,9 +34,14 @@ ALL_DPM_OPTS = [ cfg.IntOpt('max_memory', help=""" Maximum amount of memory (in MiB) on the target CPC that can be used for this OpenStack hypervisor host"""), - cfg.IntOpt('max_instances', help=""" + cfg.IntOpt('max_instances', default=-1, min=-1, help=""" Maximum number of instances (partitions) that can be created for this - OpenStack hypervisor host"""), + OpenStack hypervisor host. Valid values are: + -1: The number of instances is only limited by the + number of free partitions on this CPC + 0: A technically valid upper bound but useless. + >0: If this value is reached, + this host won't be able to spawn new instances."""), MultiStorageAdapterMappingOpt('physical_storage_adapter_mappings', help=""" Physical storage adapter with port details for hba creation"""), cfg.ListOpt('target_wwpn_ignore_list', default='', help=""" diff --git a/nova_dpm/tests/unit/conf/test_dpm.py b/nova_dpm/tests/unit/conf/test_dpm.py new file mode 100644 index 0000000..d486847 --- /dev/null +++ b/nova_dpm/tests/unit/conf/test_dpm.py @@ -0,0 +1,32 @@ +# Copyright 2017 IBM Corp. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import nova_dpm.conf + +from nova.test import TestCase + + +class TestConfigParameters(TestCase): + + def setUp(self): + super(TestConfigParameters, self).setUp() + self.CONF = nova_dpm.conf.CONF + + def test_default_value(self): + max_instance = self.CONF.dpm.max_instances + self.assertEqual(-1, max_instance) + + def test_min_value(self): + self.assertRaises(ValueError, self.CONF.set_override, "max_instances", + -2, group="dpm") diff --git a/releasenotes/notes/config-max_instances-default-value-7e530d2ae32c4c44.yaml b/releasenotes/notes/config-max_instances-default-value-7e530d2ae32c4c44.yaml new file mode 100644 index 0000000..8540212 --- /dev/null +++ b/releasenotes/notes/config-max_instances-default-value-7e530d2ae32c4c44.yaml @@ -0,0 +1,7 @@ +--- +upgrade: + - | + Default value of -1 has been set for the configuration option + ``max_instances``. This means that by default, there is no upper + limit set on the maximum number of instances that can be created for + this host.