Add allow-overwrite default header by config
This flag is needed for the devstack cleanup script to delete all backend objects. Change-Id: I0ec8fab48dd58861d87119b8e8b7ff4391940780
This commit is contained in:
parent
5467ac673a
commit
ec3007872a
|
@ -197,14 +197,15 @@ class NSXRequestsHTTPProvider(AbstractHTTPProvider):
|
|||
session.mount('http://', adapter)
|
||||
session.mount('https://', adapter)
|
||||
|
||||
self.get_default_headers(session, provider)
|
||||
self.get_default_headers(session, provider,
|
||||
config.allow_overwrite_header)
|
||||
|
||||
return session
|
||||
|
||||
def is_connection_exception(self, exception):
|
||||
return isinstance(exception, requests_exceptions.ConnectionError)
|
||||
|
||||
def get_default_headers(self, session, provider):
|
||||
def get_default_headers(self, session, provider, allow_overwrite_header):
|
||||
"""Get the default headers that should be added to future requests"""
|
||||
session.default_headers = {}
|
||||
|
||||
|
@ -236,6 +237,10 @@ class NSXRequestsHTTPProvider(AbstractHTTPProvider):
|
|||
"headers %(hdr)s",
|
||||
{'url': provider.url, 'hdr': session.default_headers})
|
||||
|
||||
# Add allow-overwrite if configured
|
||||
if allow_overwrite_header:
|
||||
session.default_headers['X-Allow-Overwrite'] = 'true'
|
||||
|
||||
|
||||
class ClusterHealth(object):
|
||||
"""Indicator of overall cluster health.
|
||||
|
|
|
@ -68,7 +68,10 @@ class NsxLibConfig(object):
|
|||
:param dns_domain: Domain to use for building the hostnames.
|
||||
:param dhcp_profile_uuid: Currently unused and deprecated.
|
||||
Kept for backward compatibility.
|
||||
|
||||
:param allow_overwrite_header: If True, a default header of
|
||||
X-Allow-Overwrite:true will be added to all
|
||||
the requests, to allow admin user to update/
|
||||
delete all entries.
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
|
@ -90,7 +93,8 @@ class NsxLibConfig(object):
|
|||
plugin_ver=None,
|
||||
dns_nameservers=None,
|
||||
dns_domain='openstacklocal',
|
||||
dhcp_profile_uuid=None):
|
||||
dhcp_profile_uuid=None,
|
||||
allow_overwrite_header=False):
|
||||
|
||||
self.nsx_api_managers = nsx_api_managers
|
||||
self._username = username
|
||||
|
@ -110,6 +114,7 @@ class NsxLibConfig(object):
|
|||
self.plugin_ver = plugin_ver
|
||||
self.dns_nameservers = dns_nameservers or []
|
||||
self.dns_domain = dns_domain
|
||||
self.allow_overwrite_header = allow_overwrite_header
|
||||
|
||||
if dhcp_profile_uuid:
|
||||
# this is deprecated, and never used.
|
||||
|
|
Loading…
Reference in New Issue