Fix RouterInterface properties validation
get_attr on a non-created resource returns an empty string (rather than None). We should pass validation in this case. Change-Id: I5a1d651cc7dc46162140210ebeacaa7519111c91 Closes-bug: 1451819
This commit is contained in:
parent
1ad9f9f186
commit
0fbb16e6fc
|
@ -328,7 +328,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