diff --git a/reddwarf/common/cfg.py b/reddwarf/common/cfg.py index e7616d755a..12b8582db7 100644 --- a/reddwarf/common/cfg.py +++ b/reddwarf/common/cfg.py @@ -36,7 +36,6 @@ common_opts = [ cfg.BoolOpt('reddwarf_volume_support', default=False, help='File name for the paste.deploy config for reddwarf-api'), - cfg.BoolOpt('reddwarf_must_use_volume', default=False), cfg.ListOpt('admin_roles', default=[]), cfg.StrOpt('remote_implementation', default="real", diff --git a/reddwarf/instance/service.py b/reddwarf/instance/service.py index be713dd947..9df528e27b 100644 --- a/reddwarf/instance/service.py +++ b/reddwarf/instance/service.py @@ -272,15 +272,14 @@ class InstanceController(wsgi.Controller): if not name: raise exception.MissingKey(key='name') vol_enabled = CONF.reddwarf_volume_support - must_have_vol = CONF.reddwarf_must_use_volume if vol_enabled: if body['instance'].get('volume', None): if body['instance']['volume'].get('size', None): volume_size = body['instance']['volume']['size'] InstanceController._validate_volume_size(volume_size) - elif must_have_vol: + else: raise exception.MissingKey(key="size") - elif must_have_vol: + else: raise exception.MissingKey(key="volume") except KeyError as e: diff --git a/reddwarf/tests/api/instances.py b/reddwarf/tests/api/instances.py index 4cd68ebf02..821dc4c226 100644 --- a/reddwarf/tests/api/instances.py +++ b/reddwarf/tests/api/instances.py @@ -235,7 +235,7 @@ class CreateInstance(unittest.TestCase): """ def test_instance_size_too_big(self): - vol_ok = CONFIG.get('reddwarf_can_have_volume', False) + vol_ok = CONFIG.get('reddwarf_volume_support', False) if 'reddwarf_max_accepted_volume_size' in CONFIG.values and vol_ok: too_big = CONFIG.values['reddwarf_max_accepted_volume_size'] assert_raises(exceptions.OverLimit, dbaas.instances.create, @@ -253,7 +253,7 @@ class CreateInstance(unittest.TestCase): users.append({"name": "lite", "password": "litepass", "databases": [{"name": "firstdb"}]}) instance_info.users = users - if CONFIG.values['reddwarf_main_instance_has_volume']: + if CONFIG.values['reddwarf_volume_support']: instance_info.volume = {'size': 1} else: instance_info.volume = None @@ -290,7 +290,7 @@ class CreateInstance(unittest.TestCase): # Check these attrs only are returned in create response expected_attrs = ['created', 'flavor', 'addresses', 'id', 'links', 'name', 'status', 'updated'] - if CONFIG.values['reddwarf_can_have_volume']: + if CONFIG.values['reddwarf_volume_support']: expected_attrs.append('volume') if CONFIG.values['reddwarf_dns_support']: expected_attrs.append('hostname') @@ -302,11 +302,11 @@ class CreateInstance(unittest.TestCase): # Don't CheckInstance if the instance already exists. check.flavor() check.links(result._info['links']) - if CONFIG.values['reddwarf_can_have_volume']: + if CONFIG.values['reddwarf_volume_support']: check.volume() def test_create_failure_with_empty_volume(self): - if CONFIG.values['reddwarf_must_have_volume']: + if CONFIG.values['reddwarf_volume_support']: instance_name = "instance-failure-with-no-volume-size" databases = [] volume = {} @@ -316,7 +316,7 @@ class CreateInstance(unittest.TestCase): assert_equal(400, dbaas.last_http_code) def test_create_failure_with_no_volume_size(self): - if CONFIG.values['reddwarf_must_have_volume']: + if CONFIG.values['reddwarf_volume_support']: instance_name = "instance-failure-with-no-volume-size" databases = [] volume = {'size': None} @@ -326,7 +326,7 @@ class CreateInstance(unittest.TestCase): assert_equal(400, dbaas.last_http_code) def test_create_failure_with_no_name(self): - if CONFIG.values['reddwarf_main_instance_has_volume']: + if CONFIG.values['reddwarf_volume_support']: volume = {'size': 1} else: volume = None @@ -338,7 +338,7 @@ class CreateInstance(unittest.TestCase): assert_equal(400, dbaas.last_http_code) def test_create_failure_with_spaces_for_name(self): - if CONFIG.values['reddwarf_main_instance_has_volume']: + if CONFIG.values['reddwarf_volume_support']: volume = {'size': 1} else: volume = None @@ -650,7 +650,7 @@ class TestInstanceListing(object): def test_get_legacy_status_notfound(self): assert_raises(exceptions.NotFound, dbaas.instances.get, -2) - @test(enabled=CONFIG.values["reddwarf_main_instance_has_volume"]) + @test(enabled=CONFIG.values["reddwarf_volume_support"]) def test_volume_found(self): instance = dbaas.instances.get(instance_info.id) if create_new_instance(): @@ -756,7 +756,7 @@ class DeleteInstance(object): "time: %s" % (str(instance_info.id), attempts, str(ex))) @time_out(30) - @test(enabled=CONFIG.values["reddwarf_can_have_volume"], + @test(enabled=CONFIG.values["reddwarf_volume_support"], depends_on=[test_delete]) def test_volume_is_deleted(self): raise SkipTest("Cannot test volume is deleted from db.") @@ -881,14 +881,14 @@ class CheckInstance(AttrCheck): self.links(self.instance['flavor']['links']) def volume_key_exists(self): - if CONFIG.values['reddwarf_main_instance_has_volume']: + if CONFIG.values['reddwarf_volume_support']: if 'volume' not in self.instance: self.fail("'volume' not found in instance.") return False return True def volume(self): - if not CONFIG.values["reddwarf_can_have_volume"]: + if not CONFIG.values["reddwarf_volume_support"]: return if self.volume_key_exists(): expected_attrs = ['size'] @@ -898,7 +898,7 @@ class CheckInstance(AttrCheck): msg="Volumes") def used_volume(self): - if not CONFIG.values["reddwarf_can_have_volume"]: + if not CONFIG.values["reddwarf_volume_support"]: return if self.volume_key_exists(): expected_attrs = ['size', 'used'] diff --git a/reddwarf/tests/api/instances_actions.py b/reddwarf/tests/api/instances_actions.py index 47227c59f5..5a7c0bb562 100644 --- a/reddwarf/tests/api/instances_actions.py +++ b/reddwarf/tests/api/instances_actions.py @@ -314,7 +314,7 @@ class StopTests(RebootTestBase): Confirms the get call behaves appropriately while an instance is down. """ - if not CONFIG.reddwarf_main_instance_has_volume: + if not CONFIG.reddwarf_volume_support: raise SkipTest("Not testing volumes.") instance = self.dbaas.instances.get(self.instance_id) with TypeCheck("instance", instance) as check: @@ -489,7 +489,7 @@ def resize_should_not_delete_users(): @test(depends_on_classes=[ResizeInstanceTest], depends_on=[create_user], groups=[GROUP, tests.INSTANCES], - enabled=CONFIG.reddwarf_main_instance_has_volume) + enabled=CONFIG.reddwarf_volume_support) class ResizeInstanceVolume(object): """ Resize the volume of the instance """ diff --git a/reddwarf/tests/api/mgmt/instances.py b/reddwarf/tests/api/mgmt/instances.py index 5fca072696..319c68f427 100644 --- a/reddwarf/tests/api/mgmt/instances.py +++ b/reddwarf/tests/api/mgmt/instances.py @@ -95,7 +95,7 @@ def mgmt_instance_get(): instance.has_field('tenant_id', basestring) instance.has_field('updated', basestring) # Can be None if no volume is given on this instance. - if CONFIG.reddwarf_main_instance_has_volume: + if CONFIG.reddwarf_volume_support: instance.has_field('volume', dict, volume_check) else: instance.has_field('volume', None) diff --git a/reddwarf/tests/config.py b/reddwarf/tests/config.py index cc9d329a5c..94b18ee217 100644 --- a/reddwarf/tests/config.py +++ b/reddwarf/tests/config.py @@ -79,6 +79,7 @@ class TestConfig(object): "report_directory": os.environ.get("REPORT_DIRECTORY", None), "sleep_mode": "simulated", "simulate_events": False, + "reddwarf_volume_support": True, } self._frozen_values = FrozenDict(self._values) self._users = None