Merge "Apply neutron router constraint"

This commit is contained in:
Jenkins 2015-03-13 07:28:55 +00:00 committed by Gerrit Code Review
commit 115d35f930
7 changed files with 36 additions and 4 deletions

View File

@ -14,6 +14,7 @@
from heat.common import exception
from heat.common.i18n import _
from heat.engine import constraints
from heat.engine import properties
from heat.engine.resources.openstack.neutron import neutron
@ -30,7 +31,11 @@ class ExtraRoute(neutron.NeutronResource):
ROUTER_ID: properties.Schema(
properties.Schema.STRING,
description=_('The router id.'),
required=True),
required=True,
constraints=[
constraints.CustomConstraint('neutron.router')
]
),
DESTINATION: properties.Schema(
properties.Schema.STRING,
description=_('Network in CIDR notation.'),

View File

@ -74,6 +74,7 @@ class NeutronExtraRouteTest(common.HeatTestCase):
return rsrc
def test_extraroute(self):
self.stub_RouterConstraint_validate()
# add first route
neutronclient.Client.show_router(
'3e46229d-8fce-4733-819a-b5fe630550f8'

View File

@ -263,14 +263,20 @@ class RouterInterface(neutron.NeutronResource):
properties_schema = {
ROUTER: properties.Schema(
properties.Schema.STRING,
_('The router.')
_('The router.'),
constraints=[
constraints.CustomConstraint('neutron.router')
],
),
ROUTER_ID: properties.Schema(
properties.Schema.STRING,
_('ID of the router.'),
support_status=support.SupportStatus(
support.DEPRECATED,
_('Use property %s.') % ROUTER)
_('Use property %s.') % ROUTER),
constraints=[
constraints.CustomConstraint('neutron.router')
],
),
SUBNET_ID: properties.Schema(
properties.Schema.STRING,
@ -393,7 +399,10 @@ class RouterGateway(neutron.NeutronResource):
ROUTER_ID: properties.Schema(
properties.Schema.STRING,
_('ID of the router.'),
required=True
required=True,
constraints=[
constraints.CustomConstraint('neutron.router')
]
),
NETWORK_ID: properties.Schema(
properties.Schema.STRING,

View File

@ -83,10 +83,16 @@ class VPNService(neutron.NeutronResource):
support_status=support.SupportStatus(
support.DEPRECATED,
_('Use property %s') % ROUTER),
constraints=[
constraints.CustomConstraint('neutron.router')
]
),
ROUTER: properties.Schema(
properties.Schema.STRING,
_('The router to which the vpn service will be inserted.'),
constraints=[
constraints.CustomConstraint('neutron.router')
]
)
}

View File

@ -200,3 +200,7 @@ class HeatTestCase(testscenarios.WithScenarios,
def stub_SubnetConstraint_validate(self):
validate = self.patchobject(neutron.SubnetConstraint, 'validate')
validate.return_value = True
def stub_RouterConstraint_validate(self):
validate = self.patchobject(neutron.RouterConstraint, 'validate')
validate.return_value = True

View File

@ -1784,6 +1784,7 @@ class NeutronRouterTest(common.HeatTestCase):
subnet_key = 'subnet_id'
router_key = 'router_id'
self.stub_SubnetConstraint_validate()
self.stub_RouterConstraint_validate()
if resolve_router:
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
@ -1812,6 +1813,7 @@ class NeutronRouterTest(common.HeatTestCase):
def test_router_interface_with_old_data(self):
self.stub_SubnetConstraint_validate()
self.stub_RouterConstraint_validate()
neutronclient.Client.add_interface_router(
'3e46229d-8fce-4733-819a-b5fe630550f8',
{'subnet_id': '91e47a57-7508-46fe-afc9-fc454e8580e1'}
@ -1876,6 +1878,7 @@ class NeutronRouterTest(common.HeatTestCase):
{'port_id': '9577cafd-8e98-4059-a2e6-8a771b4d318e'}
).AndRaise(qe.NeutronClientException(status_code=404))
self.stub_PortConstraint_validate()
self.stub_RouterConstraint_validate()
self.m.ReplayAll()
t = template_format.parse(neutron_template)
@ -1951,6 +1954,8 @@ class NeutronRouterTest(common.HeatTestCase):
neutronclient.Client.remove_gateway_router(
'3e46229d-8fce-4733-819a-b5fe630550f8'
).AndRaise(qe.NeutronClientException(status_code=404))
self.stub_RouterConstraint_validate()
self.m.ReplayAll()
t = template_format.parse(neutron_template)
stack = utils.parse_stack(t)

View File

@ -175,6 +175,7 @@ class VPNServiceTest(common.HeatTestCase):
def create_vpnservice(self, resolve_neutron=True, resolve_router=True):
self.stub_SubnetConstraint_validate()
self.stub_RouterConstraint_validate()
if resolve_neutron:
neutronV20.find_resourceid_by_name_or_id(
mox.IsA(neutronclient.Client),
@ -224,6 +225,7 @@ class VPNServiceTest(common.HeatTestCase):
'subnet',
'sub123'
).MultipleTimes().AndReturn('sub123')
self.stub_RouterConstraint_validate()
neutronclient.Client.create_vpnservice(self.VPN_SERVICE_CONF).AndRaise(
exceptions.NeutronClientException())