Add subnets as a dependency for router
Because router's external gateway depends on at least one external subnet, so add subnets as an implicit dependency for the router. Change-Id: Ib34636b440b3eee3993cd1030dab23312824510d Closes-Bug:1279645
This commit is contained in:
parent
59855364b3
commit
1ed544eb80
|
@ -100,6 +100,17 @@ class Router(neutron.NeutronResource):
|
|||
|
||||
update_allowed_keys = ('Properties',)
|
||||
|
||||
def add_dependencies(self, deps):
|
||||
super(Router, self).add_dependencies(deps)
|
||||
external_gw = self.properties.get(self.EXTERNAL_GATEWAY)
|
||||
if external_gw:
|
||||
external_gw_net = external_gw.get(self.EXTERNAL_GATEWAY_NETWORK)
|
||||
for res in self.stack.itervalues():
|
||||
if res.has_interface('OS::Neutron::Subnet'):
|
||||
subnet_net = res.properties.get(subnet.Subnet.NETWORK_ID)
|
||||
if subnet_net == external_gw_net:
|
||||
deps += (self, res)
|
||||
|
||||
def prepare_properties(self, properties, name):
|
||||
props = super(Router, self).prepare_properties(properties, name)
|
||||
gateway = props.get(self.EXTERNAL_GATEWAY)
|
||||
|
|
|
@ -253,6 +253,50 @@ neutron_port_with_address_pair_template = '''
|
|||
}
|
||||
'''
|
||||
|
||||
neutron_subnet_and_external_gateway_template = '''
|
||||
{
|
||||
"AWSTemplateFormatVersion": "2010-09-09",
|
||||
"Resources": {
|
||||
"net_external": {
|
||||
"Type": "OS::Neutron::Net",
|
||||
"Properties": {
|
||||
"name": "net_external",
|
||||
"admin_state_up": true,
|
||||
"value_specs": {
|
||||
"provider:network_type": "flat",
|
||||
"provider:physical_network": "default",
|
||||
"router:external": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"subnet_external": {
|
||||
"Type": "OS::Neutron::Subnet",
|
||||
"Properties": {
|
||||
"name": "subnet_external",
|
||||
"network_id": {
|
||||
"Ref": "net_external"
|
||||
},
|
||||
"ip_version": 4,
|
||||
"cidr": "192.168.10.0/24",
|
||||
"gateway_ip": "192.168.10.11",
|
||||
"enable_dhcp": false
|
||||
}
|
||||
},
|
||||
"router": {
|
||||
"Type": "OS::Neutron::Router",
|
||||
"Properties": {
|
||||
"name": "router_heat",
|
||||
"external_gateway_info": {
|
||||
"network": {
|
||||
"Ref": "net_external"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
'''
|
||||
|
||||
stpna = {
|
||||
"network": {
|
||||
"status": "ACTIVE",
|
||||
|
@ -1206,6 +1250,15 @@ class NeutronRouterTest(HeatTestCase):
|
|||
self.assertIsNone(scheduler.TaskRunner(rsrc.delete)())
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_router_dependence(self):
|
||||
# assert the implicit dependency between the router
|
||||
# and subnet
|
||||
t = template_format.parse(
|
||||
neutron_subnet_and_external_gateway_template)
|
||||
stack = utils.parse_stack(t)
|
||||
deps = stack.dependencies[stack['subnet_external']]
|
||||
self.assertIn(stack['router'], deps)
|
||||
|
||||
def test_router_interface(self):
|
||||
clients.OpenStackClients.keystone().AndReturn(
|
||||
fakes.FakeKeystoneClient())
|
||||
|
|
Loading…
Reference in New Issue