From bf72494d00dc5a05548d30fa0ac5bc3d06d035e6 Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Wed, 3 Aug 2016 23:12:29 -0700 Subject: [PATCH] Use neutron-lib add_validator for registration As per [1], neutron-lib 0.3.0 provides a public add/get API for local validator registration/access. This API is preferred over directly accessing the validators dict module-level attribute that's done today when adding a new validator and in fact direct access to the validators dict is deprecated. This patch changes all vmware-nsx's usage of the validators dict to use the public API. Related-Bug: #1584237 [1] https://review.openstack.org/#/c/324090/ Change-Id: Ifc403d41133eefb1dfbcd31952c7a88c436e9724 --- vmware_nsx/extensions/dns_search_domain.py | 2 +- vmware_nsx/extensions/networkgw.py | 4 ++-- vmware_nsx/plugins/nsx_v3/plugin.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vmware_nsx/extensions/dns_search_domain.py b/vmware_nsx/extensions/dns_search_domain.py index 090a999812..0ef741a575 100644 --- a/vmware_nsx/extensions/dns_search_domain.py +++ b/vmware_nsx/extensions/dns_search_domain.py @@ -64,7 +64,7 @@ def _validate_dns_search_domain(data, max_len=attributes.NAME_MAX_LEN): return msg -validators.validators['type:dns_search_domain'] = (_validate_dns_search_domain) +validators.add_validator('dns_search_domain', _validate_dns_search_domain) DNS_SEARCH_DOMAIN = 'dns_search_domain' diff --git a/vmware_nsx/extensions/networkgw.py b/vmware_nsx/extensions/networkgw.py index 01f42db741..e5b2e0a4c0 100644 --- a/vmware_nsx/extensions/networkgw.py +++ b/vmware_nsx/extensions/networkgw.py @@ -151,8 +151,8 @@ nw_gw_quota_opts = [ cfg.CONF.register_opts(nw_gw_quota_opts, 'QUOTAS') -validators.validators['type:device_list'] = _validate_device_list -validators.validators['type:connector_type'] = _validate_connector_type +validators.add_validator('device_list', _validate_device_list) +validators.add_validator('connector_type', _validate_connector_type) class Networkgw(extensions.ExtensionDescriptor): diff --git a/vmware_nsx/plugins/nsx_v3/plugin.py b/vmware_nsx/plugins/nsx_v3/plugin.py index 449bc894ff..92af31630d 100644 --- a/vmware_nsx/plugins/nsx_v3/plugin.py +++ b/vmware_nsx/plugins/nsx_v3/plugin.py @@ -2623,7 +2623,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, if cfg.CONF.api_replay_mode: def _pass(data, _dummy=None): pass - ext_sg.validators.validators['type:name_not_default'] = _pass + validators.add_validator('name_not_default', _pass) def get_security_groups(self, context, filters=None, fields=None, sorts=None, limit=None,