Merge "Fix RouterInterface properties validation"
This commit is contained in:
commit
af1c47a595
|
@ -334,7 +334,7 @@ class RouterInterface(neutron.NeutronResource):
|
||||||
if value and deprecated_value:
|
if value and deprecated_value:
|
||||||
raise exception.ResourcePropertyConflict(key,
|
raise exception.ResourcePropertyConflict(key,
|
||||||
deprecated_key)
|
deprecated_key)
|
||||||
if not value and not deprecated_value:
|
if value is None and deprecated_value is None:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import six
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common import template_format
|
from heat.common import template_format
|
||||||
|
from heat.engine import properties
|
||||||
from heat.engine.resources.openstack.neutron import router
|
from heat.engine.resources.openstack.neutron import router
|
||||||
from heat.engine import rsrc_defn
|
from heat.engine import rsrc_defn
|
||||||
from heat.engine import scheduler
|
from heat.engine import scheduler
|
||||||
|
@ -864,3 +865,30 @@ class NeutronRouterTest(common.HeatTestCase):
|
||||||
rsrc = self.create_router(t, stack, 'router')
|
rsrc = self.create_router(t, stack, 'router')
|
||||||
self.assertIsNone(scheduler.TaskRunner(rsrc.delete)())
|
self.assertIsNone(scheduler.TaskRunner(rsrc.delete)())
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
|
def test_validate_depr_keys_required_both(self):
|
||||||
|
data = {'router_id': '1234',
|
||||||
|
'router': 'abc'}
|
||||||
|
p = properties.Properties(router.RouterInterface.properties_schema,
|
||||||
|
data)
|
||||||
|
self.assertRaises(
|
||||||
|
exception.ResourcePropertyConflict,
|
||||||
|
router.RouterInterface._validate_deprecated_keys,
|
||||||
|
p, 'router', 'router_id')
|
||||||
|
|
||||||
|
def test_validate_depr_keys_required_neither(self):
|
||||||
|
data = {}
|
||||||
|
p = properties.Properties(router.RouterInterface.properties_schema,
|
||||||
|
data)
|
||||||
|
|
||||||
|
res = router.RouterInterface._validate_deprecated_keys(
|
||||||
|
p, 'router', 'router_id')
|
||||||
|
self.assertFalse(res)
|
||||||
|
|
||||||
|
def test_validate_depr_keys_required_one(self):
|
||||||
|
data = {'router_id': ''}
|
||||||
|
p = properties.Properties(router.RouterInterface.properties_schema,
|
||||||
|
data)
|
||||||
|
res = router.RouterInterface._validate_deprecated_keys(
|
||||||
|
p, 'router', 'router_id')
|
||||||
|
self.assertTrue(res)
|
||||||
|
|
Loading…
Reference in New Issue