Add common files for ONTAP and SOLIDFIRE unit tests (#48739)

* And unit test files

* Changes to netapp.py

* Matt's changed, and pep8 change for test_netapp.py
This commit is contained in:
Chris Archibald 2018-11-19 06:43:32 -08:00 committed by John R Barker
commit 50808ffa8f
4 changed files with 104 additions and 15 deletions

View file

@ -27,10 +27,8 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
try:
import json
except ImportError:
import simplejson as json
import json
import os
from ansible.module_utils.six.moves.urllib.error import HTTPError
from ansible.module_utils.urls import open_url
@ -40,17 +38,13 @@ try:
except ImportError:
ansible_version = 'unknown'
import os
import ssl
HAS_NETAPP_LIB = False
try:
from netapp_lib.api.zapi import zapi
from netapp_lib.api.zapi import errors as zapi_errors
HAS_NETAPP_LIB = True
except:
except ImportError:
HAS_NETAPP_LIB = False
import ssl
HAS_SF_SDK = False
SF_BYTE_MAP = dict(
@ -67,6 +61,20 @@ SF_BYTE_MAP = dict(
yb=1000 ** 8
)
POW2_BYTE_MAP = dict(
# Here, 1 kb = 1024
bytes=1,
b=1,
kb=1024,
mb=1024 ** 2,
gb=1024 ** 3,
tb=1024 ** 4,
pb=1024 ** 5,
eb=1024 ** 6,
zb=1024 ** 7,
yb=1024 ** 8
)
try:
from solidfire.factory import ElementFactory
from solidfire.custom.models import TimeIntervalFrequency
@ -93,7 +101,8 @@ def na_ontap_host_argument_spec():
password=dict(required=True, type='str', aliases=['pass'], no_log=True),
https=dict(required=False, type='bool', default=False),
validate_certs=dict(required=False, type='bool', default=True),
http_port=dict(required=False, type='int')
http_port=dict(required=False, type='int'),
ontapi=dict(required=False, type='int')
)
@ -128,6 +137,7 @@ def setup_na_ontap_zapi(module, vserver=None):
https = module.params['https']
validate_certs = module.params['validate_certs']
port = module.params['http_port']
version = module.params['ontapi']
if HAS_NETAPP_LIB:
# set up zapi
@ -136,8 +146,11 @@ def setup_na_ontap_zapi(module, vserver=None):
server.set_password(password)
if vserver:
server.set_vserver(vserver)
# Todo : Replace hard-coded values with configurable parameters.
server.set_api_version(major=1, minor=110)
if version:
minor = version
else:
minor = 110
server.set_api_version(major=1, minor=minor)
# default is HTTP
if https:
if port is None:

View file

@ -61,12 +61,17 @@ options:
description:
- Override the default port (80 or 443) with this port
type: int
ontapi:
description:
- The ontap api version to use
type: int
requirements:
- A physical or virtual clustered Data ONTAP system. The modules were developed with Clustered Data ONTAP 9.3
- A physical or virtual clustered Data ONTAP system. The modules support Data ONTAP 9.1 and onward
- Ansible 2.6
- netapp-lib (2017.10.30). Install using 'pip install netapp-lib'
- Python2 netapp-lib (2017.10.30) or later. Install using 'pip install netapp-lib'
- Python3 netapp-lib (2018.11.13) or later. Install using 'pip install netapp-lib'
- To enable http on the cluster you must run the following commands 'set -privilege advanced;' 'system services web modify -http-enabled true;'
notes: