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

Commit ed79be8

Browse files
committed
Updated ImageStreamer client to also accept a ca cert file
- Updated README to include using a certificate file on Image Streamer - Updated config-rename.json example
1 parent 2fcbf2c commit ed79be8

File tree

6 files changed

+27
-15
lines changed

6 files changed

+27
-15
lines changed

README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,18 +145,28 @@ oneview_client = OneViewClient(config)
145145

146146
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.
147147

148-
1. Fetch the HPE OneView Appliance CA certificate
149-
150-
Example:
151-
148+
1. Fetch the HPE OneView Appliance CA certificate.
152149
```bash
153150
$ openssl s_client -showcerts -host <host> -port 443
154151
```
155152

156-
Copy the server certificate content from `-----BEGIN CERTIFICATE-----` to `-----END CERTIFICATE-----` (inclusive) into a `<file_name>.crt` file.
157-
158-
2. Declare the CA Certificate location when creating a `config` dictionary
153+
2. Copy the server certificate wrapped with a header line and a footer line into a `<file_name>.crt` file.
154+
```
155+
-----BEGIN CERTIFICATE-----
156+
... (HPE OneView Appliance certificate in base64 PEM encoding) ...
157+
-----END CERTIFICATE-----
158+
```
159+
When using HPE Image Streamer, the server certificate for the HPE Image Streamer should also be added to the certificates file. Example:
160+
```
161+
-----BEGIN CERTIFICATE-----
162+
... (HPE OneView Appliance certificate in base64 PEM encoding) ...
163+
-----END CERTIFICATE-----
164+
-----BEGIN CERTIFICATE-----
165+
... (HPE Image Streamer Appliance certificate in base64 PEM encoding) ...
166+
-----END CERTIFICATE-----
167+
```
159168

169+
3. Declare the CA Certificate location when creating a `config` dictionary.
160170
```python
161171
config = {
162172
"ip": "172.16.102.82",

examples/config-rename.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"ip": "172.16.102.59",
33
"image_streamer_ip": "172.16.102.60",
4-
"api_version": 300,
4+
"api_version": 500,
5+
"ssl_certificate": "",
56
"credentials": {
67
"userName": "administrator",
78
"authLoginDomain": "",

hpOneView/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# -*- coding: utf-8 -*
2-
32
###
43
# (C) Copyright (2012-2017) Hewlett Packard Enterprise Development LP
54
#
@@ -68,6 +67,7 @@ def __init__(self, applianceIp, api_version=300, sslBundle=False):
6867
self._proxyPort = None
6968
self._doProxy = False
7069
self._sslTrustAll = True
70+
self._sslBundle = sslBundle
7171
self._sslTrustedBundle = self.set_trusted_ssl_bundle(sslBundle)
7272
self._nextPage = None
7373
self._prevPage = None
@@ -91,7 +91,7 @@ def set_proxy(self, proxyHost, proxyPort):
9191
self._doProxy = True
9292

9393
def set_trusted_ssl_bundle(self, sslBundle):
94-
if sslBundle is not False:
94+
if sslBundle:
9595
self._sslTrustAll = False
9696
return sslBundle
9797

hpOneView/image_streamer/image_streamer_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444

4545

4646
class ImageStreamerClient(object):
47-
def __init__(self, ip, session_id, api_version):
48-
self.__connection = connection(ip, api_version)
47+
def __init__(self, ip, session_id, api_version, sslBundle=False):
48+
self.__connection = connection(ip, api_version, sslBundle)
4949
self.__connection.set_session_id(session_id)
5050
self.__golden_images = None
5151
self.__plan_scripts = None

hpOneView/oneview_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ def create_image_streamer_client(self):
286286
"""
287287
image_streamer = ImageStreamerClient(self.__image_streamer_ip,
288288
self.__connection.get_session_id(),
289-
self.__connection._apiVersion)
289+
self.__connection._apiVersion,
290+
self.__connection._sslBundle)
290291

291292
return image_streamer
292293

tests/unit/test_connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ def test_get_connection_ssl_trust_all_with_proxy(self):
984984
def test_get_connection_trusted_ssl_bundle_with_proxy(self, mock_lvl):
985985

986986
self.connection.set_proxy('10.0.0.1', 3128)
987-
self.connection.set_trusted_ssl_bundle(None)
987+
self.connection.set_trusted_ssl_bundle('/test')
988988

989989
conn = self.connection.get_connection()
990990

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

998-
self.connection.set_trusted_ssl_bundle(None)
998+
self.connection.set_trusted_ssl_bundle('/test')
999999

10001000
conn = self.connection.get_connection()
10011001

0 commit comments

Comments
 (0)