This library provides a Python interface to the HPE SimpliVity REST APIs.
HPE SimpliVity is an intelligent hyperconverged platform that speeds application performance, improves efficiency and resiliency, and backs up and restores VMs in seconds.
Either:
$ git clone https://github.com/HewlettPackard/simplivity-python.git
$ cd simplivity-python
$ python setup.py install --user # to install in the user directory (~/.local)
$ sudo python setup.py install # to install globally
Or if using PIP:
$ git clone https://github.com/HewlettPackard/simplivity-python.git
$ cd simplivity-python
$ pip install .
Both installation methods work if you are using virtualenv, which you should be!
$ pip install simplivity
Status of the HPE SimpliVity REST interfaces that have been implemented in this Python library can be found in the Wiki section.
The latest version of the SDK documentation can be found in the SDK Documentation section.
Connection properties for accessing the OVC can be set in a JSON file.
Before running the samples or your own scripts, you must create the JSON file. An example can be found at: configuration sample.
Once you have created the JSON file, you can initialize the OVC client:
ovc_client = OVC.from_json_file('/path/config.json')
🔒 Tip: Check the file permissions because the password is stored in clear-text.
Configuration can also be stored in environment variables:
# Required
export SIMPLIVITYSDK_OVC_IP='10.30.4.45'
export SIMPLIVITYSDK_USERNAME='admin'
export SIMPLIVITYSDK_PASSWORD='secret'
# Optional
export SIMPLIVITYSDK_SSL_CERTIFICATE='<path_to_cert.crt_file>'
export SIMPLIVITYSDK_CONNECTION_TIMEOUT='<connection time-out in seconds>'
🔒 Tip: Make sure no unauthorized person has access to the environment variables, since the password is stored in clear-text.
Once you have defined the environment variables, you can initialize the OVC client using the following code snippet:
ovc_client = OVC.from_environment_variables()
You can also set the configuration using a dictionary. As described above, for authentication you can use username/password:
config = {
"ip": "10.30.4.45",
"credentials": {
"username": "admin",
"password": "secret"
}
}
ovc_client_client = OVC(config)
🔒 Tip: Check the file permissions because the password is stored in clear-text.
To enable the SDK to establish a SSL connection to the SimpliVity OVC, it is necessary to generate a CA certificate file containing the OVC credentials.
- Fetch the SimpliVity OVC CA certificate.
$ openssl s_client -showcerts -host <ovc_ip> -port 443
- Copy the OVC certificate wrapped with a header line and a footer line into a
<file_name>.crt
file.
-----BEGIN CERTIFICATE-----
... (OVC certificate in base64 PEM encoding) ...
-----END CERTIFICATE-----
- Declare the CA Certificate location when creating a
config
dictionary.
config = {
"ip": "172.16.102.82",
"credentials": {
"username": "admin",
"password": "secret"
},
"ssl_certificate": "/path/ovc_certificate.crt"
}
By default the system timeout is used when connecting to OVC. If you want to change this, then the timeout can be set by either:
- Setting the appropriate environment variable:
export SIMPLIVITYSDK_CONNECTION_TIMEOUT='<connection time-out in seconds>'
- Setting the time-out in the JSON configuration file using the following syntax:
"timeout": <timeout in seconds>
Contributing: We welcome your contributions to the Python SDK for HPE SimpliVity. See CONTRIBUTING.md for more details.
Feature Requests: If you have a need that is not met by the current implementation, please let us know (via a new issue). This feedback is crucial for us to deliver a useful product. Do not assume that we have already thought of everything, because we assure you that is not the case.
When contributing code to this project, we require tests to accompany the code being delivered. That ensures a higher standing of quality, and also helps to avoid minor mistakes and future regressions.
When writing the unit tests, the standard approach we follow is to use the python library unittest.mock to patch all calls that would be made to the OVC and return mocked values.
We have packaged everything required to verify if the code is passing the tests in a tox file. The tox call runs all unit tests against Python 3, runs a flake8 validation, and generates the test coverage report.
To run it, use the following command:
$ tox
You can also check out examples of tests for different resources in the tests folder.
This project is licensed under the Apache license. Please see LICENSE for more information.
To view history and notes for this version, view the Changelog.