-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
4,630 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
*.py[cod] | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Local Certificates | ||
*.pem | ||
|
||
# Packages | ||
*.egg | ||
*.egg-info | ||
dist | ||
build/* | ||
eggs | ||
parts | ||
bin | ||
var | ||
sdist | ||
develop-eggs | ||
.installed.cfg | ||
lib | ||
lib64 | ||
__pycache__ | ||
|
||
# Rope | ||
.ropeproject/ | ||
|
||
|
||
# Installer logs | ||
pip-log.txt | ||
|
||
# Unit test / coverage reports | ||
.coverage | ||
.tox | ||
nosetests.xml | ||
htmlcov | ||
|
||
# Translations | ||
*.mo | ||
|
||
# Mr Developer | ||
.mr.developer.cfg | ||
.project | ||
.pydevproject | ||
|
||
#coverage | ||
coverage.xml | ||
.coverage | ||
htmlcov | ||
|
||
#virtualenv | ||
env | ||
|
||
#pycharm | ||
.idea | ||
.idea/ | ||
|
||
#Global configuration to run examples | ||
examples/config.json | ||
|
||
#sphinx generated files | ||
docs/build/* | ||
docs/source/* | ||
!docs/source/conf.py | ||
!docs/source/index.rst | ||
.vscode | ||
|
||
#certificate files | ||
*.crt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# v1.0.0 | ||
#### Notes | ||
This is the first release of the SimpliVity Python SDK and it adds support for the below features. | ||
|
||
#### Features supported | ||
- Backup | ||
- Datastore | ||
- Host | ||
- OmniStack cluster | ||
- Policy | ||
- Virtual machine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Contribution Guide | ||
|
||
We welcome and encourage community contributions to simplivity-python. | ||
|
||
## Contributing | ||
|
||
The best way to directly collaborate with the project contributors is through GitHub: <https://github.com/HewlettPackard/simplivity-python> | ||
|
||
* If you want to contribute to our code by either fixing a problem or creating a new feature, please open a GitHub pull request. | ||
* If you want to raise an issue such as a defect, an enhancement request or a general issue, please open a GitHub issue. | ||
|
||
Before you start to code, we recommend discussing your plans through a GitHub issue, especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing. | ||
|
||
Note that all patches from all contributors get reviewed. | ||
After a pull request is made, other contributors will offer feedback. If the patch passes review, a maintainer will accept it with a comment. | ||
When a pull request fails review, the author is expected to update the pull request to address the issue until it passes review and the pull request merges successfully. | ||
|
||
At least one review from a maintainer is required for all patches. | ||
|
||
### Developer's Certificate of Origin | ||
|
||
All contributions must include acceptance of the DCO: | ||
|
||
> Developer Certificate of Origin Version 1.1 | ||
> | ||
> Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 660 | ||
> York Street, Suite 102, San Francisco, CA 94110 USA | ||
> | ||
> Everyone is permitted to copy and distribute verbatim copies of this | ||
> license document, but changing it is not allowed. | ||
> | ||
> Developer's Certificate of Origin 1.1 | ||
> | ||
> By making a contribution to this project, I certify that: | ||
> | ||
> \(a) The contribution was created in whole or in part by me and I have | ||
> the right to submit it under the open source license indicated in the | ||
> file; or | ||
> | ||
> \(b) The contribution is based upon previous work that, to the best of my | ||
> knowledge, is covered under an appropriate open source license and I | ||
> have the right under that license to submit that work with | ||
> modifications, whether created in whole or in part by me, under the same | ||
> open source license (unless I am permitted to submit under a different | ||
> license), as indicated in the file; or | ||
> | ||
> \(c) The contribution was provided directly to me by some other person | ||
> who certified (a), (b) or (c) and I have not modified it. | ||
> | ||
> \(d) I understand and agree that this project and the contribution are | ||
> public and that a record of the contribution (including all personal | ||
> information I submit with it, including my sign-off) is maintained | ||
> indefinitely and may be redistributed consistent with this project or | ||
> the open source license(s) involved. | ||
### Sign your work | ||
|
||
To accept the DCO, simply add this line to each commit message with your | ||
name and email address (git commit -s will do this for you): | ||
|
||
Signed-off-by: Jane Example <[email protected]> | ||
|
||
For legal reasons, no anonymous or pseudonymous contributions are | ||
accepted. | ||
|
||
## Submitting Code Pull Requests | ||
|
||
We encourage and support contributions from the community. No fix is too | ||
small. We strive to process all pull requests as soon as possible and | ||
with constructive feedback. If your pull request is not accepted at | ||
first, please try again after addressing the feedback you received. | ||
|
||
To make a pull request you will need a GitHub account. For help, see | ||
GitHub's documentation on forking and pull requests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
# HPE SimpliVity SDK for Python | ||
|
||
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. | ||
|
||
## Installation | ||
|
||
### From source | ||
|
||
Either: | ||
|
||
```bash | ||
$ 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: | ||
|
||
```bash | ||
$ 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! | ||
|
||
### From Pypi | ||
|
||
```bash | ||
$ pip install simplivity | ||
``` | ||
|
||
|
||
## API Implementation | ||
|
||
Status of the HPE SimpliVity REST interfaces that have been implemented in this Python library can be found in the [Wiki section](https://github.com/HewlettPackard/simplivity-python/blob/master/endpoints-support.md). | ||
|
||
|
||
## SDK Documentation | ||
|
||
The latest version of the SDK documentation can be found in the [SDK Documentation section](https://hewlettpackard.github.io/simplivity-python/index.html). | ||
|
||
## Configuration | ||
|
||
### JSON | ||
|
||
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](examples/config-rename.json). | ||
|
||
Once you have created the JSON file, you can initialize the OVC client: | ||
|
||
```python | ||
ovc_client = OVC.from_json_file('/path/config.json') | ||
``` | ||
|
||
:lock: Tip: Check the file permissions because the password is stored in clear-text. | ||
|
||
### Environment Variables | ||
|
||
Configuration can also be stored in environment variables: | ||
|
||
```bash | ||
# 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>' | ||
``` | ||
|
||
:lock: 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: | ||
|
||
```python | ||
ovc_client = OVC.from_environment_variables() | ||
``` | ||
|
||
### Dictionary | ||
|
||
You can also set the configuration using a dictionary. As described above, for authentication you can use username/password: | ||
|
||
|
||
```python | ||
config = { | ||
"ip": "10.30.4.45", | ||
"credentials": { | ||
"username": "admin", | ||
"password": "secret" | ||
} | ||
} | ||
|
||
ovc_client_client = OVC(config) | ||
``` | ||
|
||
:lock: Tip: Check the file permissions because the password is stored in clear-text. | ||
|
||
|
||
### SSL Server Certificate | ||
|
||
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. | ||
|
||
1. Fetch the SimpliVity OVC CA certificate. | ||
```bash | ||
$ openssl s_client -showcerts -host <ovc_ip> -port 443 | ||
``` | ||
|
||
2. 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----- | ||
``` | ||
|
||
3. Declare the CA Certificate location when creating a `config` dictionary. | ||
```python | ||
config = { | ||
"ip": "172.16.102.82", | ||
"credentials": { | ||
"username": "admin", | ||
"password": "secret" | ||
}, | ||
"ssl_certificate": "/path/ovc_certificate.crt" | ||
} | ||
``` | ||
|
||
### SimpliVity Connection Timeout | ||
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: | ||
|
||
1. Setting the appropriate environment variable: | ||
```bash | ||
export SIMPLIVITYSDK_CONNECTION_TIMEOUT='<connection time-out in seconds>' | ||
``` | ||
|
||
2. Setting the time-out in the JSON configuration file using the following syntax: | ||
```json | ||
"timeout": <timeout in seconds> | ||
``` | ||
|
||
## Contributing and feature requests | ||
Contribution guide can be found at: [CONTRIBUTION GUIDE](CONTRIBUTING.md). | ||
|
||
#### Testing | ||
|
||
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](https://docs.python.org/3/library/unittest.mock.html) 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](tests) folder. | ||
|
||
## License | ||
|
||
This project is licensed under the Apache license. Please see [LICENSE](LICENSE) for more information. | ||
|
||
## Version and changes | ||
|
||
To view history and notes for this version, view the [Changelog](CHANGELOG.md). |
Oops, something went wrong.