NSX|V3+P: Do not set default Qos policy on external networks

Change-Id: I9cee1ac13f70268055eaa2598061a6e80b9c94cc
This commit is contained in:
asarfaty 2021-01-21 10:01:15 +02:00 committed by Adit Sarfaty
parent dcb586f893
commit 94bd8e335c
2 changed files with 14 additions and 7 deletions

View File

@ -1485,7 +1485,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
def _update_qos_on_created_network(self, context, net_data, new_net):
qos_policy_id = qos_com_utils.set_qos_policy_on_new_net(
context, net_data, new_net)
context, net_data, new_net, allow_external=True)
if qos_policy_id:
# update the QoS data on the backend

View File

@ -14,6 +14,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib.api.definitions import external_net
from neutron_lib.api import validators
from neutron_lib.exceptions import qos as qos_exc
from neutron_lib.objects import registry as obj_reg
from neutron_lib.services.qos import constants as qos_consts
@ -76,18 +78,23 @@ def get_network_policy_id(context, net_id):
return policy.id
def set_qos_policy_on_new_net(context, net_data, created_net):
def set_qos_policy_on_new_net(context, net_data, created_net,
allow_external=False):
"""Update the network with the assigned or default QoS policy
Update the network-qos binding table, and the new network structure
"""
qos_policy_id = net_data.get(qos_consts.QOS_POLICY_ID)
if not qos_policy_id:
# try and get the default one
qos_obj = obj_reg.load_class('QosPolicyDefault').get_object(
context, project_id=created_net['project_id'])
if qos_obj:
qos_policy_id = qos_obj.qos_policy_id
# try and get the default qos policy. If the plugin does not allow
# qos on external networks, check it.
external = net_data.get(external_net.EXTERNAL)
is_external_net = validators.is_attr_set(external) and external
if allow_external or not is_external_net:
qos_obj = obj_reg.load_class('QosPolicyDefault').get_object(
context, project_id=created_net['project_id'])
if qos_obj:
qos_policy_id = qos_obj.qos_policy_id
if qos_policy_id:
# attach the policy to the network in the neutron DB