Skip to content

Commit 1859648

Browse files
authored
Merge pull request #588 from sdodsley/disable_warnings
Add disable_warnings parameter
2 parents c1403a7 + a3f3e9e commit 1859648

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The Pure Storage FlashArray collection consists of the latest versions of the Fl
2525
- pycountry
2626
- packaging
2727
- pyz
28+
- urllib3
2829

2930
## Installation
3031

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minor_changes:
2+
- all - add ``disable_warnings`` parameters

plugins/doc_fragments/purestorage.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ class ModuleDocFragment(object):
3030
description:
3131
- FlashArray API token for admin privileged user.
3232
type: str
33+
disable_warnings:
34+
description:
35+
- Disable insecure certificate warnings in debug logs
36+
type: bool
37+
default: false
38+
version_added: '1.29.0'
3339
notes:
3440
- This module requires the C(purestorage) and C(py-pure-client) Python libraries
3541
- Additional Python librarues may be required for specific modules.
@@ -42,4 +48,5 @@ class ModuleDocFragment(object):
4248
- netaddr
4349
- requests
4450
- pycountry
51+
- urllib3
4552
"""

plugins/module_utils/purefa.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232

3333
__metaclass__ = type
3434

35+
HAS_URLLIB3 = True
36+
try:
37+
import urllib3
38+
except ImportError:
39+
HAS_URLLIB3 = False
40+
3541
HAS_DISTRO = True
3642
try:
3743
import distro
@@ -59,6 +65,8 @@
5965

6066
def get_system(module):
6167
"""Return System Object or Fail"""
68+
if HAS_URLLIB3 and module.params["disable_warnings"]:
69+
urllib3.disable_warnings()
6270
if HAS_DISTRO:
6371
user_agent = "%(base)s %(class)s/%(version)s (%(platform)s)" % {
6472
"base": USER_AGENT_BASE,
@@ -105,6 +113,8 @@ def get_system(module):
105113

106114
def get_array(module):
107115
"""Return System Object or Fail"""
116+
if HAS_URLLIB3 and module.params["disable_warnings"]:
117+
urllib3.disable_warnings()
108118
if HAS_DISTRO:
109119
user_agent = "%(base)s %(class)s/%(version)s (%(platform)s)" % {
110120
"base": USER_AGENT_BASE,
@@ -156,4 +166,5 @@ def purefa_argument_spec():
156166
return dict(
157167
fa_url=dict(),
158168
api_token=dict(no_log=True),
169+
disable_warnings=dict(type="bool", default=False),
159170
)

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ netaddr
66
requests
77
pycountry
88
pytz
9+
urllib3

0 commit comments

Comments
 (0)