Merge "force_config_drive: StrOpt -> BoolOpt"
This commit is contained in:
commit
f0882bf2ec
@ -12,36 +12,14 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo_utils import strutils
|
|
||||||
|
|
||||||
from nova import objects
|
from nova import objects
|
||||||
from nova import test
|
from nova import test
|
||||||
from nova.virt import configdrive
|
from nova.virt import configdrive
|
||||||
|
|
||||||
|
|
||||||
class ConfigDriveTestCase(test.NoDBTestCase):
|
class ConfigDriveTestCase(test.NoDBTestCase):
|
||||||
def test_valid_string_values(self):
|
|
||||||
instance = objects.Instance(
|
|
||||||
config_drive=None,
|
|
||||||
system_metadata={}
|
|
||||||
)
|
|
||||||
|
|
||||||
for value in (strutils.TRUE_STRINGS + ('always',)):
|
|
||||||
self.flags(force_config_drive=value)
|
|
||||||
self.assertTrue(configdrive.required_by(instance))
|
|
||||||
|
|
||||||
def test_invalid_string_values(self):
|
|
||||||
instance = objects.Instance(
|
|
||||||
config_drive=None,
|
|
||||||
system_metadata={}
|
|
||||||
)
|
|
||||||
|
|
||||||
for value in (strutils.FALSE_STRINGS + ('foo',)):
|
|
||||||
self.flags(force_config_drive=value)
|
|
||||||
self.assertFalse(configdrive.required_by(instance))
|
|
||||||
|
|
||||||
def test_instance_force(self):
|
def test_instance_force(self):
|
||||||
self.flags(force_config_drive="no")
|
self.flags(force_config_drive=False)
|
||||||
|
|
||||||
instance = objects.Instance(
|
instance = objects.Instance(
|
||||||
config_drive="yes",
|
config_drive="yes",
|
||||||
@ -53,7 +31,7 @@ class ConfigDriveTestCase(test.NoDBTestCase):
|
|||||||
self.assertTrue(configdrive.required_by(instance))
|
self.assertTrue(configdrive.required_by(instance))
|
||||||
|
|
||||||
def test_image_meta_force(self):
|
def test_image_meta_force(self):
|
||||||
self.flags(force_config_drive="no")
|
self.flags(force_config_drive=False)
|
||||||
|
|
||||||
instance = objects.Instance(
|
instance = objects.Instance(
|
||||||
config_drive=None,
|
config_drive=None,
|
||||||
@ -64,8 +42,20 @@ class ConfigDriveTestCase(test.NoDBTestCase):
|
|||||||
|
|
||||||
self.assertTrue(configdrive.required_by(instance))
|
self.assertTrue(configdrive.required_by(instance))
|
||||||
|
|
||||||
def test_image_meta_opt(self):
|
def test_config_flag_force(self):
|
||||||
self.flags(force_config_drive="no")
|
self.flags(force_config_drive=True)
|
||||||
|
|
||||||
|
instance = objects.Instance(
|
||||||
|
config_drive=None,
|
||||||
|
system_metadata={
|
||||||
|
"image_img_config_drive": "optional",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertTrue(configdrive.required_by(instance))
|
||||||
|
|
||||||
|
def test_no_config_drive(self):
|
||||||
|
self.flags(force_config_drive=False)
|
||||||
|
|
||||||
instance = objects.Instance(
|
instance = objects.Instance(
|
||||||
config_drive=None,
|
config_drive=None,
|
||||||
|
@ -21,11 +21,9 @@ import shutil
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import fileutils
|
from oslo_utils import fileutils
|
||||||
from oslo_utils import strutils
|
|
||||||
from oslo_utils import units
|
from oslo_utils import units
|
||||||
|
|
||||||
from nova import exception
|
from nova import exception
|
||||||
from nova.i18n import _LW
|
|
||||||
from nova import objects
|
from nova import objects
|
||||||
from nova.objects import fields
|
from nova.objects import fields
|
||||||
from nova import utils
|
from nova import utils
|
||||||
@ -38,13 +36,9 @@ configdrive_opts = [
|
|||||||
default='iso9660',
|
default='iso9660',
|
||||||
choices=('iso9660', 'vfat'),
|
choices=('iso9660', 'vfat'),
|
||||||
help='Config drive format.'),
|
help='Config drive format.'),
|
||||||
# force_config_drive is a string option, to allow for future behaviors
|
cfg.BoolOpt('force_config_drive',
|
||||||
# (e.g. use config_drive based on image properties)
|
help='Force injection to take place on a config drive',
|
||||||
cfg.StrOpt('force_config_drive',
|
default=False),
|
||||||
choices=('always', 'True', 'False'),
|
|
||||||
help='Set to "always" to force injection to take place on a '
|
|
||||||
'config drive. NOTE: The "always" will be deprecated in '
|
|
||||||
'the Liberty release cycle.'),
|
|
||||||
cfg.StrOpt('mkisofs_cmd',
|
cfg.StrOpt('mkisofs_cmd',
|
||||||
default='genisoimage',
|
default='genisoimage',
|
||||||
help='Name and optionally path of the tool used for '
|
help='Name and optionally path of the tool used for '
|
||||||
@ -62,9 +56,6 @@ class ConfigDriveBuilder(object):
|
|||||||
"""Build config drives, optionally as a context manager."""
|
"""Build config drives, optionally as a context manager."""
|
||||||
|
|
||||||
def __init__(self, instance_md=None):
|
def __init__(self, instance_md=None):
|
||||||
if CONF.force_config_drive == 'always':
|
|
||||||
LOG.warning(_LW('The setting "always" will be deprecated in the '
|
|
||||||
'Liberty version. Please use "True" instead'))
|
|
||||||
self.imagefile = None
|
self.imagefile = None
|
||||||
self.mdfiles = []
|
self.mdfiles = []
|
||||||
|
|
||||||
@ -186,8 +177,7 @@ def required_by(instance):
|
|||||||
fields.ConfigDrivePolicy.OPTIONAL)
|
fields.ConfigDrivePolicy.OPTIONAL)
|
||||||
|
|
||||||
return (instance.config_drive or
|
return (instance.config_drive or
|
||||||
'always' == CONF.force_config_drive or
|
CONF.force_config_drive or
|
||||||
strutils.bool_from_string(CONF.force_config_drive) or
|
|
||||||
image_prop == fields.ConfigDrivePolicy.MANDATORY
|
image_prop == fields.ConfigDrivePolicy.MANDATORY
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user