From 1748e7cb4b6a3ce7f92d9e02e9b825294f3ddf3e Mon Sep 17 00:00:00 2001 From: asarfaty Date: Thu, 25 Feb 2021 10:31:29 +0200 Subject: [PATCH] V2T cmigration: Add validation on QoS limits Change-Id: Ie7ef79652c41d823c6882b2166b249f848c916b4 --- .../admin/plugins/nsxv/resources/migration.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/vmware_nsx/shell/admin/plugins/nsxv/resources/migration.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/migration.py index 44a1776b46..244460a659 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv/resources/migration.py +++ b/vmware_nsx/shell/admin/plugins/nsxv/resources/migration.py @@ -19,6 +19,7 @@ from oslo_config import cfg from oslo_log import log as logging from networking_l2gw.db.l2gateway import l2gateway_models +from neutron.services.qos import qos_plugin from neutron_lib.api.definitions import allowedaddresspairs as addr_apidef from neutron_lib.api.definitions import provider_net as pnet from neutron_lib.api import validators @@ -34,6 +35,7 @@ from vmware_nsx.plugins.nsx_v import availability_zones as nsx_az from vmware_nsx.services.lbaas.nsx_v import lbaas_common as lb_common from vmware_nsx.services.lbaas.nsx_v3.implementation import lb_utils from vmware_nsx.services.lbaas.octavia import constants as oct_const +from vmware_nsx.services.qos.nsx_v3 import pol_utils as qos_utils from vmware_nsx.shell.admin.plugins.common import constants from vmware_nsx.shell.admin.plugins.common import utils as admin_utils from vmware_nsx.shell.admin.plugins.nsxv.resources import utils @@ -317,6 +319,25 @@ def validate_config_for_migration(resource, event, trigger, **kwargs): "supported.", sg['id']) n_errors = n_errors + 1 + # Validate QoS limits + qos_plugin_inst = qos_plugin.QoSPlugin() + policies = qos_plugin_inst.get_policies(admin_context) + for policy in policies: + for rule in policy.get('rules', []): + if rule.get('type') == 'bandwidth_limit': + # Validate the limits + if rule.get('max_kbps') < qos_utils.MAX_KBPS_MIN_VALUE: + LOG.error("ERROR: QoS Policy %s has max_kbps below the " + "minimal value of %s. This is not supported.", + policy['id'], rule['max_kbps']) + n_errors = n_errors + 1 + if rule.get('max_burst_kbps') > qos_utils.MAX_BURST_MAX_VALUE: + LOG.error("ERROR: QoS Policy %s has max_burst_kbps above " + "the maximal value of %s. This is not " + "supported.", + policy['id'], rule['max_burst_kbps']) + n_errors = n_errors + 1 + # L2GW is not supported with the policy plugin l2gws = admin_context.session.query(l2gateway_models.L2Gateway).all() if len(l2gws):