diff --git a/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py b/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py index 204ff76b85..ba09674482 100644 --- a/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py +++ b/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from distutils import version import eventlet import netaddr import random @@ -116,9 +117,8 @@ class EdgeManager(object): self._check_backup_edge_pools() def _get_per_edge_rp_filter_state(self): - version = self.nsxv_manager.vcns.get_version() - # TODO(kobis): should have better mapping of versions here for this - if version[:3] == '6.1': + ver = self.nsxv_manager.vcns.get_version() + if version.LooseVersion(ver) < version.LooseVersion('6.2.0'): return False return True diff --git a/vmware_nsx/plugins/nsx_v/vshield/vcns.py b/vmware_nsx/plugins/nsx_v/vshield/vcns.py index 53761b8b86..889b82f589 100644 --- a/vmware_nsx/plugins/nsx_v/vshield/vcns.py +++ b/vmware_nsx/plugins/nsx_v/vshield/vcns.py @@ -23,6 +23,7 @@ import retrying import six import xml.etree.ElementTree as et +from vmware_nsx._i18n import _LE from vmware_nsx.common import nsxv_constants from vmware_nsx.plugins.nsx_v.vshield.common import exceptions from vmware_nsx.plugins.nsx_v.vshield.common import VcnsApiClient @@ -793,16 +794,22 @@ class Vcns(object): return False return True - def get_version(self): - uri = '/api/1.0/appliance-management/summary/system' + def _get_version(self): + uri = '/api/2.0/services/vsmconfig' h, c = self.do_request(HTTP_GET, uri, decode=True) - version = '%s.%s.%s' % (c['versionInfo']['majorVersion'], - c['versionInfo']['minorVersion'], - c['versionInfo']['patchVersion']) - LOG.debug("NSX Version: %s, Build: %s", - version, c['versionInfo']['buildNumber']) + version = c['version'] + LOG.debug("NSX Version: %s", version) return version + def get_version(self): + try: + return self._get_version() + except Exception as e: + # Versions prior to 6.2.0 do not support the above API + LOG.error(_LE("Unable to get NSX version. Exception: %s"), e) + # Minimum supported version is 6.1 + return '6.1' + def get_tuning_configration(self): uri = '/api/4.0/edgePublish/tuningConfiguration' h, c = self.do_request(HTTP_GET, uri, decode=True)