Update is_default field only when specified in the request
Closes-bug: 1670524 Change-Id: Ie46fe7126693bcf6732332a479f4b2609c402c5d
This commit is contained in:
parent
0e0135c312
commit
ea27e1aa1e
|
@ -53,7 +53,7 @@ def _extend_external_network_default(core_plugin, net_res, net_db):
|
|||
def _ensure_external_network_default_value_callback(
|
||||
resource, event, trigger, context, request, network):
|
||||
"""Ensure the is_default db field matches the create/update request."""
|
||||
is_default = request.get(IS_DEFAULT, False)
|
||||
is_default = request.get(IS_DEFAULT)
|
||||
if event in (events.BEFORE_CREATE, events.BEFORE_UPDATE) and is_default:
|
||||
# ensure there is only one default external network at any given time
|
||||
pager = base_obj.Pager(limit=1)
|
||||
|
@ -65,11 +65,12 @@ def _ensure_external_network_default_value_callback(
|
|||
net_id=objs[0].network_id)
|
||||
|
||||
# Reflect the status of the is_default on the create/update request
|
||||
obj = net_obj.ExternalNetwork.get_object(context,
|
||||
network_id=network['id'])
|
||||
if obj:
|
||||
obj.is_default = is_default
|
||||
obj.update()
|
||||
if is_default is not None:
|
||||
obj = net_obj.ExternalNetwork.get_object(context,
|
||||
network_id=network['id'])
|
||||
if obj:
|
||||
obj.is_default = is_default
|
||||
obj.update()
|
||||
|
||||
|
||||
class AutoAllocatedTopologyMixin(common_db_mixin.CommonDbMixin):
|
||||
|
|
|
@ -54,6 +54,9 @@ class TestAutoAllocatedTopology(base.BaseAdminNetworkTest):
|
|||
# Ensure the public external network is the default external network
|
||||
public_net_id = cfg.CONF.network.public_network_id
|
||||
cls.admin_client.update_network(public_net_id, is_default=True)
|
||||
# Ensure that is_default does not accidentally flip back to False
|
||||
# because of network_update requests that do not contain is_default.
|
||||
cls.admin_client.update_network(public_net_id, description="gman")
|
||||
|
||||
def _count_topology_resources(self):
|
||||
'''Count the resources whose names begin with 'auto_allocated_'.'''
|
||||
|
|
Loading…
Reference in New Issue