Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from djtaylor/release-0.1.3
Browse files Browse the repository at this point in the history
Release 0.1.3
  • Loading branch information
djtaylor authored Feb 22, 2019
2 parents bd09a62 + fd49f50 commit bdf80fe
Show file tree
Hide file tree
Showing 24 changed files with 394 additions and 90 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ __pycache__
.eggs
venv
debug.py
debug.sh
35 changes: 25 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,34 @@
# NetApp OnCommand Unified Manager (OCUM)
This module is designed to read information from the NetApp OCUM to gather information about your storage infrastructure.

### Python3
The initial release is targeting support for Python 3. Python 2 support is not planned.
### Python3 / Installation
The initial release is targeting support for Python 3. Python 2 support is not planned. To install this module:

### Caveats
The first release of this module may not have full support for Namespaces and LUNs. We are not using either of those object types in our infrastructure, so I have no way to initially test or get example API responses.
```
$ pip3 install netapp-ocum
# Or to install from source
$ git clone https://github.com/djtaylor/python-netapp-ocum
$ cd python-netapp-ocum
$ python3 setup.py install
```

### Getting Started
This repository includes an [example scripts](examples/README.md) directory to help you get started.

### Supported OCUM Versions
As of the initial release, functional testing has been done against the following versions of OCUM:

- 9.3P9

Other versions may work, but have not been tested.

### OCUM API Documentation
You can view Swagger API documentation for NetApp OCUM by going to the following URL:

**NOTE**: This module only supports Python 3
**NOTE**: LUNs and Namespaces are not functionally tested since we don't have any in our infrastructure
**NOTE**: To see full API docs for UOM, visit: https://myuom.domain.com/apidocs
**NOTE**: Currently this is only tested against UOM 9.3
- https://my-uom.domain.com/apidocs

### Example Usage
This module includes example scripts [example scripts](examples/README.md) to help you get started.
This page lets you test HTTP queries, view available parameters, and return data for the request.

### Tests
Testing is done with `unittest` and `nose` for discovery.
Expand Down
6 changes: 6 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# NetApp OCUM Example Scripts
This directory contains example scripts that show how to use this module:

- [Filtered client requests](filtered_client.py)
- [Get volumes](get_volumes.py)
- [Get performance metrics](get_metrics.py)
13 changes: 13 additions & 0 deletions examples/get_metrics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env python3
import json
from netapp_ocum.client import NetApp_OCUM_Client

# Create a new client
ocum_client = NetApp_OCUM_Client('hostname', 'username', 'password')

# Get performance metrics for volumes and aggregates
aggregate_metrics = ocum_client.get_aggregate_metrics(params={'limit': 5})
volume_metrics = ocum_client.get_volume_metrics(params={'limit': 10})

print(json.dumps(aggregate_metrics.json, indent=2))
print(json.dumps(volume_metrics.json, indent=2))
2 changes: 1 addition & 1 deletion netapp_ocum/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
__version__ = '0.1.2'
__version__ = '0.1.3'
name = 'netapp_ocum'
54 changes: 23 additions & 31 deletions netapp_ocum/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, api_host, api_user, api_password,
# Request handler
self.request = NetApp_OCUM_HTTP(self.settings)

def set_params(self, params):
def _set_params(self, params):
"""
Set query parameters for the request, merge any filters defined at the
class level. Parameters passed to the method via `params` argument
Expand All @@ -44,78 +44,70 @@ def get_clusters(self, params={}):
"""
Return a list of clusters from the OCUM.
"""
return NetApp_OCUM_Collection(
self.request.GET('clusters', params=self.set_params(params)), 'cluster'
)
return NetApp_OCUM_Collection(self.request, 'clusters', self._set_params(params))

def get_svms(self, params={}):
"""
Return a list of SVMs from the OCUM.
"""
return NetApp_OCUM_Collection(
self.request.GET('svms', params=self.set_params(params)), 'svm'
)
return NetApp_OCUM_Collection(self.request, 'svms', self._set_params(params))

def get_nodes(self, params={}):
"""
Return a list of nodes from the OCUM.
"""
return NetApp_OCUM_Collection(
self.request.GET('nodes', params=self.set_params(params)), 'node'
)
return NetApp_OCUM_Collection(self.request, 'nodes', self._set_params(params))

def get_aggregates(self, params={}):
"""
Return a list of aggregates from the OCUM.
"""
return NetApp_OCUM_Collection(
self.request.GET('aggregates', params=self.set_params(params)), 'aggregate'
)
return NetApp_OCUM_Collection(self.request, 'aggregates', self._set_params(params))

def get_aggregate_metrics(self, params={}):
"""
Get aggregate metrics from the `aggregates/capacity-utilization` endpoint.
"""
return NetApp_OCUM_Collection(self.request, 'aggregates/capacity-utilization', self._set_params(params))

def get_volumes(self, params={}):
"""
Return a list of volumes from the OCUM.
"""
return NetApp_OCUM_Collection(
self.request.GET('volumes', params=self.set_params(params)), 'volume'
)
return NetApp_OCUM_Collection(self.request, 'volumes', self._set_params(params))

def get_volume_metrics(self, params={}):
"""
Get volume metrics from the `volumes/capacity-utilization` endpoint.
"""
return NetApp_OCUM_Collection(self.request, 'volumes/capacity-utilization', self._set_params(params))

def get_ports(self, params={}):
"""
Return a list of ports from the OCUM.
"""
return NetApp_OCUM_Collection(
self.request.GET('ports', params=self.set_params(params)), 'port'
)
return NetApp_OCUM_Collection(self.request, 'ports', self._set_params(params))

def get_events(self, params={}):
"""
Return a list of events from the OCUM.
"""
return NetApp_OCUM_Collection(
self.request.GET('events', params=self.set_params(params)), 'event'
)
return NetApp_OCUM_Collection(self.request, 'events', self._set_params(params))

def get_lifs(self, params={}):
"""
Return a list of LIFs from the OCUM.
"""
return NetApp_OCUM_Collection(
self.request.GET('lifs', params=self.set_params(params)), 'lif'
)
return NetApp_OCUM_Collection(self.request, 'lifs', self._set_params(params))

def get_luns(self, params={}):
"""
Return a list of LUNs from the OCUM.
"""
return NetApp_OCUM_Collection(
self.request.GET('luns', params=self.set_params(params)), 'lun'
)
return NetApp_OCUM_Collection(self.request, 'luns', self._set_params(params))

def get_namespaces(self, params={}):
"""
Return a list of namespaces from the OCUM.
"""
return NetApp_OCUM_Collection(
self.request.GET('namespaces', params=self.set_params(params)), 'namespace'
)
return NetApp_OCUM_Collection(self.request, 'namespaces', self._set_params(params))
23 changes: 22 additions & 1 deletion netapp_ocum/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_client_set_params(self):
""" Test the `set_params` method in the client. """
client = mock_client()
test_params = {'one': 'value_one', 'two': 'value_two'}
params_retval = client.set_params(test_params)
params_retval = client._set_params(test_params)
self.assertIsInstance(params_retval, dict)

@mock.patch('requests.get', side_effect=mock_get_request)
Expand Down Expand Up @@ -78,6 +78,27 @@ def test_get_aggregates(self, mock_get):
response = client.get_aggregates()
self.assertIsInstance(response, NetApp_OCUM_Collection)

@mock.patch('requests.get', side_effect=mock_get_request)
def test_get_aggregate_metrics(self, mock_get):
""" Test the `get_aggregate_metrics` method. """
client = mock_client()
response = client.get_aggregate_metrics()
self.assertIsInstance(response, NetApp_OCUM_Collection)

@mock.patch('requests.get', side_effect=mock_get_request)
def test_get_volumes(self, mock_get):
""" Test the `get_volumes` method. """
client = mock_client()
response = client.get_volumes()
self.assertIsInstance(response, NetApp_OCUM_Collection)

@mock.patch('requests.get', side_effect=mock_get_request)
def test_get_volume_metrics(self, mock_get):
""" Test the `get_volume_metrics` method. """
client = mock_client()
response = client.get_volume_metrics()
self.assertIsInstance(response, NetApp_OCUM_Collection)

@mock.patch('requests.get', side_effect=mock_get_request)
def test_get_svms(self, mock_get):
""" Test the `get_svms` method. """
Expand Down
Loading

0 comments on commit bdf80fe

Please sign in to comment.