Just force the network backref always

This commit is contained in:
Matt Dietz
2013-07-26 21:10:14 +00:00
parent 46cefbd230
commit f175af3f4b
2 changed files with 4 additions and 15 deletions

View File

@@ -95,6 +95,7 @@ def create_subnet(context, subnet):
dns_ips = utils.pop_param(sub_attrs, "dns_nameservers", [])
host_routes = utils.pop_param(sub_attrs, "host_routes", [])
allocation_pools = utils.pop_param(sub_attrs, "allocation_pools", [])
sub_attrs["network"] = net
new_subnet = db_api.subnet_create(context, **sub_attrs)
@@ -122,9 +123,6 @@ def create_subnet(context, subnet):
exclude = exclude - x
new_subnet["ip_policy"] = db_api.ip_policy_create(context,
exclude=exclude)
# HACK(amir): force backref for ip_policy
if not new_subnet["network"]:
new_subnet["network"] = net
subnet_dict = v._make_subnet_dict(new_subnet,
default_route=routes.DEFAULT_ROUTE)
subnet_dict["gateway_ip"] = gateway_ip

View File

@@ -225,8 +225,7 @@ class TestQuarkCreateSubnetAllocationPools(test_quark_plugin.TestQuarkPlugin):
# * workaround is also in place for lame ATTR_NOT_SPECIFIED object()
class TestQuarkCreateSubnet(test_quark_plugin.TestQuarkPlugin):
@contextlib.contextmanager
def _stubs(self, subnet=None, network=None, routes=None, dns=None,
no_net_on_subnet_create=False):
def _stubs(self, subnet=None, network=None, routes=None, dns=None):
if network:
net = models.Network()
@@ -237,10 +236,6 @@ class TestQuarkCreateSubnet(test_quark_plugin.TestQuarkPlugin):
host_routes = subnet.pop("host_routes", [])
subnet_mod.update(subnet)
#FIXME(anyone): coverage support for subnet->network backref hack
if no_net_on_subnet_create:
no_net_sub = models.Subnet()
no_net_sub.update(subnet)
subnet["dns_nameservers"] = dns_ips
subnet["host_routes"] = host_routes
routes = routes or []
@@ -254,10 +249,7 @@ class TestQuarkCreateSubnet(test_quark_plugin.TestQuarkPlugin):
mock.patch("quark.db.api.dns_create"),
mock.patch("quark.db.api.route_create"),
) as (subnet_create, net_find, dns_create, route_create):
if no_net_on_subnet_create:
subnet_create.return_value = no_net_sub
else:
subnet_create.return_value = subnet_mod
subnet_create.return_value = subnet_mod
net_find.return_value = network
route_create.side_effect = route_models
dns_create.side_effect = dns_models
@@ -377,8 +369,7 @@ class TestQuarkCreateSubnet(test_quark_plugin.TestQuarkPlugin):
with self._stubs(
subnet=subnet["subnet"],
network=network,
routes=routes,
no_net_on_subnet_create=True
routes=routes
) as (subnet_create, dns_create, route_create):
dns_nameservers = subnet["subnet"].pop("dns_nameservers")
subnet_request = copy.deepcopy(subnet)