From ffd5bbaeda4d44b667524897a25bec647a1a0e6e Mon Sep 17 00:00:00 2001
From: Adit Sarfaty <asarfaty@vmware.com>
Date: Tue, 16 Jan 2018 13:47:06 +0200
Subject: [PATCH] NSX-v| Do not allow setting qos policy on port

The nsx-v plugin supports qos on a netwrok level only.

Change-Id: I0fbe56f02cf5f95445af59ac673131d10cd17a70
---
 vmware_nsx/plugins/nsx_v/plugin.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/vmware_nsx/plugins/nsx_v/plugin.py b/vmware_nsx/plugins/nsx_v/plugin.py
index 02679825f7..a7a8f6d5c6 100644
--- a/vmware_nsx/plugins/nsx_v/plugin.py
+++ b/vmware_nsx/plugins/nsx_v/plugin.py
@@ -1816,12 +1816,18 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
                     LOG.error(msg)
                     raise n_exc.InvalidInput(error_message=msg)
 
+    def _validate_port_qos(self, port):
+        if validators.is_attr_set(port.get(qos_consts.QOS_POLICY_ID)):
+            err_msg = (_("Cannot configure QOS directly on ports"))
+            raise n_exc.InvalidInput(error_message=err_msg)
+
     def create_port(self, context, port):
         port_data = port['port']
         dhcp_opts = port_data.get(ext_edo.EXTRADHCPOPTS)
         self._validate_extra_dhcp_options(dhcp_opts)
         self._validate_max_ips_per_port(port_data.get('fixed_ips', []),
                                         port_data.get('device_owner'))
+        self._validate_port_qos(port_data)
         direct_vnic_type = self._validate_port_vnic_type(
             context, port_data, port_data['network_id'])
 
@@ -2077,6 +2083,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
         port_data = port['port']
         dhcp_opts = port_data.get(ext_edo.EXTRADHCPOPTS)
         self._validate_extra_dhcp_options(dhcp_opts)
+        self._validate_port_qos(port_data)
         if addr_apidef.ADDRESS_PAIRS in attrs:
             self._validate_address_pairs(attrs, original_port)
         self._validate_max_ips_per_port(