Support testing nova-novncproxy on SSL
When the VNC url is https, wrap the socket client with SSL.
If the VNC url is of http, use a regular socket client.
Change-Id: I7e5d6ccb65293b89540f528cc84da6c0d8699fee
Closes-Bug: #1677142
diff --git a/tempest/common/compute.py b/tempest/common/compute.py
index 38daffe..63e7d31 100644
--- a/tempest/common/compute.py
+++ b/tempest/common/compute.py
@@ -15,6 +15,7 @@
import base64
import socket
+import ssl
import struct
import textwrap
@@ -236,7 +237,11 @@
def create_websocket(url):
url = urlparse.urlparse(url)
- client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ if url.scheme == 'https':
+ client_socket = ssl.wrap_socket(socket.socket(socket.AF_INET,
+ socket.SOCK_STREAM))
+ else:
+ client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
client_socket.connect((url.hostname, url.port))
# Turn the Socket into a WebSocket to do the communication