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
This commit is contained in:
parent
c85642f6e2
commit
8eb9098418
@ -15,6 +15,7 @@
|
||||
|
||||
import base64
|
||||
import socket
|
||||
import ssl
|
||||
import struct
|
||||
import textwrap
|
||||
|
||||
@ -236,7 +237,11 @@ def shelve_server(servers_client, server_id, force_shelve_offload=False):
|
||||
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user