Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
Updated ImageStreamer client to also accept a ca cert file
Browse files Browse the repository at this point in the history
- Updated README to include using a certificate file on Image Streamer
- Updated config-rename.json example
  • Loading branch information
fgbulsoni committed Nov 27, 2017
1 parent 2fcbf2c commit ed79be8
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 15 deletions.
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,28 @@ oneview_client = OneViewClient(config)

To enable the SDK to establish a SSL connection to the HPE OneView server, it is necessary to generate a CA Cert file containing the server credentials.

1. Fetch the HPE OneView Appliance CA certificate

Example:

1. Fetch the HPE OneView Appliance CA certificate.
```bash
$ openssl s_client -showcerts -host <host> -port 443
```

Copy the server certificate content from `-----BEGIN CERTIFICATE-----` to `-----END CERTIFICATE-----` (inclusive) into a `<file_name>.crt` file.

2. Declare the CA Certificate location when creating a `config` dictionary
2. Copy the server certificate wrapped with a header line and a footer line into a `<file_name>.crt` file.
```
-----BEGIN CERTIFICATE-----
... (HPE OneView Appliance certificate in base64 PEM encoding) ...
-----END CERTIFICATE-----
```
When using HPE Image Streamer, the server certificate for the HPE Image Streamer should also be added to the certificates file. Example:
```
-----BEGIN CERTIFICATE-----
... (HPE OneView Appliance certificate in base64 PEM encoding) ...
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
... (HPE Image Streamer Appliance 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",
Expand Down
3 changes: 2 additions & 1 deletion examples/config-rename.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"ip": "172.16.102.59",
"image_streamer_ip": "172.16.102.60",
"api_version": 300,
"api_version": 500,
"ssl_certificate": "",
"credentials": {
"userName": "administrator",
"authLoginDomain": "",
Expand Down
4 changes: 2 additions & 2 deletions hpOneView/connection.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*

###
# (C) Copyright (2012-2017) Hewlett Packard Enterprise Development LP
#
Expand Down Expand Up @@ -68,6 +67,7 @@ def __init__(self, applianceIp, api_version=300, sslBundle=False):
self._proxyPort = None
self._doProxy = False
self._sslTrustAll = True
self._sslBundle = sslBundle
self._sslTrustedBundle = self.set_trusted_ssl_bundle(sslBundle)
self._nextPage = None
self._prevPage = None
Expand All @@ -91,7 +91,7 @@ def set_proxy(self, proxyHost, proxyPort):
self._doProxy = True

def set_trusted_ssl_bundle(self, sslBundle):
if sslBundle is not False:
if sslBundle:
self._sslTrustAll = False
return sslBundle

Expand Down
4 changes: 2 additions & 2 deletions hpOneView/image_streamer/image_streamer_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@


class ImageStreamerClient(object):
def __init__(self, ip, session_id, api_version):
self.__connection = connection(ip, api_version)
def __init__(self, ip, session_id, api_version, sslBundle=False):
self.__connection = connection(ip, api_version, sslBundle)
self.__connection.set_session_id(session_id)
self.__golden_images = None
self.__plan_scripts = None
Expand Down
3 changes: 2 additions & 1 deletion hpOneView/oneview_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ def create_image_streamer_client(self):
"""
image_streamer = ImageStreamerClient(self.__image_streamer_ip,
self.__connection.get_session_id(),
self.__connection._apiVersion)
self.__connection._apiVersion,
self.__connection._sslBundle)

return image_streamer

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ def test_get_connection_ssl_trust_all_with_proxy(self):
def test_get_connection_trusted_ssl_bundle_with_proxy(self, mock_lvl):

self.connection.set_proxy('10.0.0.1', 3128)
self.connection.set_trusted_ssl_bundle(None)
self.connection.set_trusted_ssl_bundle('/test')

conn = self.connection.get_connection()

Expand All @@ -995,7 +995,7 @@ def test_get_connection_trusted_ssl_bundle_with_proxy(self, mock_lvl):
@patch.object(ssl.SSLContext, 'load_verify_locations')
def test_get_connection_trusted_ssl_bundle(self, mock_lvl):

self.connection.set_trusted_ssl_bundle(None)
self.connection.set_trusted_ssl_bundle('/test')

conn = self.connection.get_connection()

Expand Down

0 comments on commit ed79be8

Please sign in to comment.