from cinder import exception
from cinder import flags
from cinder.openstack.common import log as logging
+from cinder.openstack.common import strutils
from cinder import utils
from cinder import volume
msg = _("Invalid value '%s' for force. ") % force
raise exception.InvalidParameterValue(err=msg)
- if utils.bool_from_str(force):
+ if strutils.bool_from_string(force):
new_snapshot = self.volume_api.create_snapshot_force(
context,
volume,
from cinder import exception
from cinder import flags
from cinder.openstack.common import log as logging
+from cinder.openstack.common import strutils
from cinder import utils
from cinder import volume
msg = _("Invalid value '%s' for force. ") % force
raise exception.InvalidParameterValue(err=msg)
- if utils.bool_from_str(force):
+ if strutils.bool_from_string(force):
new_snapshot = self.volume_api.create_snapshot_force(
context,
volume,
import cinder
from cinder import exception
from cinder import flags
+from cinder.openstack.common import strutils
from cinder.openstack.common import timeutils
from cinder import test
from cinder import utils
hostname = "<}\x1fh\x10e\x08l\x02l\x05o\x12!{>"
self.assertEqual("hello", utils.sanitize_hostname(hostname))
- def test_bool_from_str(self):
- self.assertTrue(utils.bool_from_str('1'))
- self.assertTrue(utils.bool_from_str('2'))
- self.assertTrue(utils.bool_from_str('-1'))
- self.assertTrue(utils.bool_from_str('true'))
- self.assertTrue(utils.bool_from_str('True'))
- self.assertTrue(utils.bool_from_str('tRuE'))
- self.assertFalse(utils.bool_from_str('False'))
- self.assertFalse(utils.bool_from_str('false'))
- self.assertFalse(utils.bool_from_str('0'))
- self.assertFalse(utils.bool_from_str(None))
- self.assertFalse(utils.bool_from_str('junk'))
-
def test_generate_glance_url(self):
generated_url = utils.generate_glance_url()
actual_url = "http://%s:%d" % (FLAGS.glance_host, FLAGS.glance_port)
return cls() # Ugly PyLint hack
-def bool_from_str(val):
- """Convert a string representation of a bool into a bool value"""
-
- if not val:
- return False
- try:
- return True if int(val) else False
- except ValueError:
- return val.lower() == 'true'
-
-
def is_valid_boolstr(val):
"""Check if the provided string is a valid bool string or not. """
val = str(val).lower()