Add checkbox to enable SSL connection for SPICE

If in OpenNebula not enabled TLS for SPICE protocol, when
cannot connect to OpenNebula with generated virt-viewer connection
config file, because "secure-channel" options successfully work
over TLS only.
This changes allow enable or disable TLS on UDS site.
This commit is contained in:
Alexander Burmatov 2023-01-27 18:21:09 +03:00
parent 879ae4b74a
commit 6240c4cbff
3 changed files with 11 additions and 1 deletions

View File

@ -65,6 +65,7 @@ class RemoteViewerFile:
usb_auto_share: bool = True
new_usb_auto_share: bool = False
delete_file: bool = True
ssl_connection: bool = False
def __init__(
self,
@ -101,6 +102,7 @@ class RemoteViewerFile:
delete_file = '01'[self.delete_file]
usb_auto_share = '01'[self.usb_auto_share]
new_usb_auto_share = '01'[self.new_usb_auto_share]
ssl_connection = '01'[self.ssl_connection]
ca = self.ca.strip().replace(
'\n', '\\n'
@ -121,6 +123,6 @@ class RemoteViewerFile:
host_subject=self.host_subject if tls_port != '-1' else '',
ca=ca if tls_port != '-1' else '',
secure_channel='secure-channels=main;inputs;cursor;playback;record;display;usbredir;smartcard'
if tls_port != '-1'
if ssl_connection and tls_port != '-1'
else '',
)

View File

@ -64,6 +64,7 @@ class SPICETransport(BaseSpiceTransport):
usbShare = BaseSpiceTransport.usbShare
autoNewUsbShare = BaseSpiceTransport.autoNewUsbShare
smartCardRedirect = BaseSpiceTransport.smartCardRedirect
sslConnection = BaseSpiceTransport.SSLConnection
def getUDSTransportScript(
self,
@ -98,6 +99,7 @@ class SPICETransport(BaseSpiceTransport):
r.usb_auto_share = self.usbShare.isTrue()
r.new_usb_auto_share = self.autoNewUsbShare.isTrue()
r.smartcard = self.smartCardRedirect.isTrue()
r.ssl = self.sslConnection.isTrue()
osName = {
OsDetector.KnownOS.Windows: 'windows',

View File

@ -113,6 +113,12 @@ class BaseSpiceTransport(transports.Transport):
defvalue=gui.FALSE,
tab=gui.ADVANCED_TAB,
)
SSLConnection = gui.CheckBoxField(
order=9,
label=_('SSL Connection'),
tooltip=_('If checked, SPICE protocol will required SSL connection.'),
defvalue=gui.FALSE,
)
def isAvailableFor(self, userService: 'models.UserService', ip: str) -> bool:
"""