Skip to content

Commit 0302750

Browse files
authored
vmware: Add support for VMware 7 (#4300)
1 parent 8fec222 commit 0302750

File tree

16 files changed

+506
-39
lines changed

16 files changed

+506
-39
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
package com.cloud.agent.api;
20+
21+
public class GetVmVncTicketAnswer extends Answer {
22+
23+
private String ticket;
24+
25+
public GetVmVncTicketAnswer(String ticket, boolean result, String details) {
26+
this.ticket = ticket;
27+
this.result = result;
28+
this.details = details;
29+
}
30+
31+
public String getTicket() {
32+
return ticket;
33+
}
34+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
package com.cloud.agent.api;
20+
21+
public class GetVmVncTicketCommand extends Command {
22+
23+
private String vmInternalName;
24+
25+
public GetVmVncTicketCommand(String vmInternalName) {
26+
this.vmInternalName = vmInternalName;
27+
}
28+
29+
public String getVmInternalName() {
30+
return this.vmInternalName;
31+
}
32+
33+
@Override
34+
public boolean executeInSequence() {
35+
return false;
36+
}
37+
}

engine/schema/src/main/resources/META-INF/db/schema-41500to41510.sql

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
--;
1919
-- Schema upgrade from 4.15.0.0 to 4.15.1.0
2020
--;
21-
2221
-- Correct guest OS names
2322
UPDATE `cloud`.`guest_os` SET display_name='Fedora Linux (32 bit)' WHERE id=320;
2423
UPDATE `cloud`.`guest_os` SET display_name='Mandriva Linux (32 bit)' WHERE id=323;
@@ -56,3 +55,80 @@ INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervis
5655
-- Add support for Ubuntu Focal Fossa 20.04 for Xenserver 8.2.0
5756
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (335, UUID(), 10, 'Ubuntu 20.04 LTS', now());
5857
INSERT INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'Xenserver', '8.2.0', 'Ubuntu Focal Fossa 20.04', 330, now(), 0);
58+
59+
-------------------------------------------------------------------------------------------------------------
60+
61+
-- Add support for VMware 7.0
62+
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities` (uuid, hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_data_volumes_limit, max_hosts_per_cluster, storage_motion_supported, vm_snapshot_enabled) values (UUID(), 'VMware', '7.0', 1024, 0, 59, 64, 1, 1);
63+
INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) SELECT UUID(),'VMware', '7.0', guest_os_name, guest_os_id, utc_timestamp(), 0 FROM `cloud`.`guest_os_hypervisor` WHERE hypervisor_type='VMware' AND hypervisor_version='6.7';
64+
65+
-- Add support for darwin19_64Guest from VMware 7.0
66+
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (336, UUID(), 7, 'macOS 10.15 (64 bit)', now());
67+
INSERT INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '7.0', 'darwin19_64Guest', 336, now(), 0);
68+
69+
-- Add support for debian11_64Guest from VMware 7.0
70+
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (337, UUID(), 2, 'Debian GNU/Linux 11 (64-bit)', now());
71+
INSERT INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '7.0', 'debian11_64Guest', 337, now(), 0);
72+
73+
-- Add support for debian11Guest from VMware 7.0
74+
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (338, UUID(), 2, 'Debian GNU/Linux 11 (32-bit)', now());
75+
INSERT INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '7.0', 'debian11Guest', 338, now(), 0);
76+
77+
-- Add support for windows2019srv_64Guest from VMware 7.0
78+
INSERT INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '7.0', 'windows2019srv_64Guest', 276, now(), 0);
79+
80+
81+
-- Add support for VMware 7.0.1.0
82+
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities` (uuid, hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_data_volumes_limit, max_hosts_per_cluster, storage_motion_supported, vm_snapshot_enabled) values (UUID(), 'VMware', '7.0.1.0', 1024, 0, 59, 64, 1, 1);
83+
INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) SELECT UUID(),'VMware', '7.0.1.0', guest_os_name, guest_os_id, utc_timestamp(), 0 FROM `cloud`.`guest_os_hypervisor` WHERE hypervisor_type='VMware' AND hypervisor_version='7.0';
84+
85+
-- Add support for amazonlinux3_64Guest from VMware 7.0.1.0
86+
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (339, UUID(), 7, 'Amazon Linux 3 (64 bit)', now());
87+
INSERT INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '7.0.1.0', 'amazonlinux3_64Guest', 339, now(), 0);
88+
89+
-- Add support for asianux9_64Guest from VMware 7.0.1.0
90+
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (340, UUID(), 7, 'Asianux Server 9 (64 bit)', now());
91+
INSERT INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '7.0.1.0', 'asianux9_64Guest', 340, now(), 0);
92+
93+
-- Add support for centos9_64Guest from VMware 7.0.1.0
94+
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (341, UUID(), 1, 'CentOS 9', now());
95+
INSERT INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '7.0.1.0', 'centos9_64Guest', 341, now(), 0);
96+
97+
-- Add support for darwin20_64Guest from VMware 7.0.1.0
98+
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (342, UUID(), 7, 'macOS 11 (64 bit)', now());
99+
INSERT INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '7.0.1.0', 'darwin20_64Guest', 342, now(), 0);
100+
101+
-- Add support for darwin21_64Guest from VMware 7.0.1.0
102+
INSERT INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '7.0.1.0', 'darwin21_64Guest', 342, now(), 0);
103+
104+
-- Add support for freebsd13_64Guest from VMware 7.0.1.0
105+
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (343, UUID(), 9, 'FreeBSD 13 (64-bit)', now());
106+
INSERT INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '7.0.1.0', 'freebsd13_64Guest', 343, now(), 0);
107+
108+
-- Add support for freebsd13Guest from VMware 7.0.1.0
109+
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (344, UUID(), 9, 'FreeBSD 13 (32-bit)', now());
110+
INSERT INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '7.0.1.0', 'freebsd13Guest', 344, now(), 0);
111+
112+
-- Add support for oracleLinux9_64Guest from VMware 7.0.1.0
113+
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (345, UUID(), 3, 'Oracle Linux 9', now());
114+
INSERT INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '7.0.1.0', 'oracleLinux9_64Guest', 345, now(), 0);
115+
116+
-- Add support for other5xLinux64Guest from VMware 7.0.1.0
117+
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (346, UUID(), 2, 'Linux 5.x Kernel (64-bit)', now());
118+
INSERT INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '7.0.1.0', 'other5xLinux64Guest', 346, now(), 0);
119+
120+
-- Add support for other5xLinuxGuest from VMware 7.0.1.0
121+
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (347, UUID(), 2, 'Linux 5.x Kernel (32-bit)', now());
122+
INSERT INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '7.0.1.0', 'other5xLinuxGuest', 347, now(), 0);
123+
124+
-- Add support for rhel9_64Guest from VMware 7.0.1.0
125+
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (348, UUID(), 4, 'Red Hat Enterprise Linux 9.0', now());
126+
INSERT INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '7.0.1.0', 'rhel9_64Guest', 348, now(), 0);
127+
128+
-- Add support for sles16_64Guest from VMware 7.0.1.0
129+
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (349, UUID(), 5, 'SUSE Linux Enterprise Server 16 (64-bit)', now());
130+
INSERT INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '7.0.1.0', 'sles16_64Guest', 349, now(), 0);
131+
132+
-- Add support for windows2019srvNext_64Guest from VMware 7.0.1.0
133+
INSERT INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '7.0.1.0', 'windows2019srvNext_64Guest', 276, now(), 0);
134+

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@
101101
import com.cloud.agent.api.GetVmDiskStatsAnswer;
102102
import com.cloud.agent.api.GetVmDiskStatsCommand;
103103
import com.cloud.agent.api.GetVmIpAddressCommand;
104+
import com.cloud.agent.api.GetVmVncTicketCommand;
105+
import com.cloud.agent.api.GetVmVncTicketAnswer;
104106
import com.cloud.agent.api.GetVmNetworkStatsAnswer;
105107
import com.cloud.agent.api.GetVmNetworkStatsCommand;
106108
import com.cloud.agent.api.GetVmStatsAnswer;
@@ -578,6 +580,8 @@ public Answer executeRequest(Command cmd) {
578580
answer = execute((PrepareUnmanageVMInstanceCommand) cmd);
579581
} else if (clz == ValidateVcenterDetailsCommand.class) {
580582
answer = execute((ValidateVcenterDetailsCommand) cmd);
583+
} else if (clz == GetVmVncTicketCommand.class) {
584+
answer = execute((GetVmVncTicketCommand) cmd);
581585
} else {
582586
answer = Answer.createUnsupportedCommandAnswer(cmd);
583587
}
@@ -7562,4 +7566,25 @@ private Answer execute(ValidateVcenterDetailsCommand cmd) {
75627566
return new Answer(cmd, false, "Provided vCenter server address is invalid");
75637567
}
75647568
}
7569+
7570+
public String acquireVirtualMachineVncTicket(String vmInternalCSName) throws Exception {
7571+
VmwareContext context = getServiceContext();
7572+
VmwareHypervisorHost hyperHost = getHyperHost(context);
7573+
DatacenterMO dcMo = new DatacenterMO(hyperHost.getContext(), hyperHost.getHyperHostDatacenter());
7574+
VirtualMachineMO vmMo = dcMo.findVm(vmInternalCSName);
7575+
return vmMo.acquireVncTicket();
7576+
}
7577+
7578+
private GetVmVncTicketAnswer execute(GetVmVncTicketCommand cmd) {
7579+
String vmInternalName = cmd.getVmInternalName();
7580+
s_logger.info("Getting VNC ticket for VM " + vmInternalName);
7581+
try {
7582+
String ticket = acquireVirtualMachineVncTicket(vmInternalName);
7583+
boolean result = StringUtils.isNotBlank(ticket);
7584+
return new GetVmVncTicketAnswer(ticket, result, result ? "" : "Empty ticket obtained");
7585+
} catch (Exception e) {
7586+
s_logger.error("Error getting VNC ticket for VM " + vmInternalName, e);
7587+
return new GetVmVncTicketAnswer(null, false, e.getLocalizedMessage());
7588+
}
7589+
}
75657590
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
<cs.servlet.version>4.0.1</cs.servlet.version>
167167
<cs.tomcat-embed-core.version>8.5.61</cs.tomcat-embed-core.version>
168168
<cs.trilead.version>build-217-jenkins-27</cs.trilead.version>
169-
<cs.vmware.api.version>6.7</cs.vmware.api.version>
169+
<cs.vmware.api.version>7.0</cs.vmware.api.version>
170170
<cs.winrm4j.version>0.5.0</cs.winrm4j.version>
171171
<cs.xapi.version>6.2.0-3.1</cs.xapi.version>
172172
<cs.xmlrpc.version>3.1.3</cs.xmlrpc.version>

server/src/main/java/com/cloud/servlet/ConsoleProxyClientParam.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class ConsoleProxyClientParam {
3434
private String password;
3535

3636
private String sourceIP;
37+
private String websocketUrl;
3738

3839
public ConsoleProxyClientParam() {
3940
clientHostPort = 0;
@@ -150,4 +151,12 @@ public String getSourceIP() {
150151
public void setSourceIP(String sourceIP) {
151152
this.sourceIP = sourceIP;
152153
}
154+
155+
public String getWebsocketUrl() {
156+
return websocketUrl;
157+
}
158+
159+
public void setWebsocketUrl(String websocketUrl) {
160+
this.websocketUrl = websocketUrl;
161+
}
153162
}

server/src/main/java/com/cloud/servlet/ConsoleProxyServlet.java

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@
3737
import javax.servlet.http.HttpServletResponse;
3838
import javax.servlet.http.HttpSession;
3939

40+
import com.cloud.agent.AgentManager;
41+
import com.cloud.agent.api.Answer;
42+
import com.cloud.agent.api.GetVmVncTicketAnswer;
43+
import com.cloud.agent.api.GetVmVncTicketCommand;
44+
import com.cloud.exception.AgentUnavailableException;
45+
import com.cloud.exception.OperationTimedoutException;
46+
import com.cloud.utils.StringUtils;
4047
import org.apache.cloudstack.framework.security.keys.KeysManager;
4148
import org.apache.commons.codec.binary.Base64;
4249
import org.apache.log4j.Logger;
@@ -94,6 +101,8 @@ public class ConsoleProxyServlet extends HttpServlet {
94101
UserVmDetailsDao _userVmDetailsDao;
95102
@Inject
96103
KeysManager _keysMgr;
104+
@Inject
105+
AgentManager agentManager;
97106

98107
static KeysManager s_keysMgr;
99108

@@ -427,6 +436,47 @@ private String composeThumbnailUrl(String rootUrl, VirtualMachine vm, HostVO hos
427436
return sb.toString();
428437
}
429438

439+
/**
440+
* Sets the URL to establish a VNC over websocket connection
441+
*/
442+
private void setWebsocketUrl(VirtualMachine vm, ConsoleProxyClientParam param) {
443+
String ticket = acquireVncTicketForVmwareVm(vm);
444+
if (StringUtils.isBlank(ticket)) {
445+
s_logger.error("Could not obtain VNC ticket for VM " + vm.getInstanceName());
446+
return;
447+
}
448+
String wsUrl = composeWebsocketUrlForVmwareVm(ticket, param);
449+
param.setWebsocketUrl(wsUrl);
450+
}
451+
452+
/**
453+
* Format expected: wss://<ESXi_HOST_IP>:443/ticket/<TICKET_ID>
454+
*/
455+
private String composeWebsocketUrlForVmwareVm(String ticket, ConsoleProxyClientParam param) {
456+
param.setClientHostPort(443);
457+
return String.format("wss://%s:%s/ticket/%s", param.getClientHostAddress(), param.getClientHostPort(), ticket);
458+
}
459+
460+
/**
461+
* Acquires a ticket to be used for console proxy as described in 'Removal of VNC Server from ESXi' on:
462+
* https://docs.vmware.com/en/VMware-vSphere/7.0/rn/vsphere-esxi-vcenter-server-70-release-notes.html
463+
*/
464+
private String acquireVncTicketForVmwareVm(VirtualMachine vm) {
465+
try {
466+
s_logger.info("Acquiring VNC ticket for VM = " + vm.getHostName());
467+
GetVmVncTicketCommand cmd = new GetVmVncTicketCommand(vm.getInstanceName());
468+
Answer answer = agentManager.send(vm.getHostId(), cmd);
469+
GetVmVncTicketAnswer ans = (GetVmVncTicketAnswer) answer;
470+
if (!ans.getResult()) {
471+
s_logger.info("VNC ticket could not be acquired correctly: " + ans.getDetails());
472+
}
473+
return ans.getTicket();
474+
} catch (AgentUnavailableException | OperationTimedoutException e) {
475+
s_logger.error("Error acquiring ticket", e);
476+
return null;
477+
}
478+
}
479+
430480
private String composeConsoleAccessUrl(String rootUrl, VirtualMachine vm, HostVO hostVo, InetAddress addr) {
431481
StringBuffer sb = new StringBuffer(rootUrl);
432482
String host = hostVo.getPrivateIpAddress();
@@ -477,6 +527,10 @@ private String composeConsoleAccessUrl(String rootUrl, VirtualMachine vm, HostVO
477527
param.setTicket(ticket);
478528
param.setSourceIP(addr != null ? addr.getHostAddress(): null);
479529

530+
if (requiresVncOverWebSocketConnection(vm, hostVo)) {
531+
setWebsocketUrl(vm, param);
532+
}
533+
480534
if (details != null) {
481535
param.setLocale(details.getValue());
482536
}
@@ -513,6 +567,14 @@ private String composeConsoleAccessUrl(String rootUrl, VirtualMachine vm, HostVO
513567
return sb.toString();
514568
}
515569

570+
/**
571+
* Since VMware 7.0 VNC servers are deprecated, it uses a ticket to create a VNC over websocket connection
572+
* Check: https://docs.vmware.com/en/VMware-vSphere/7.0/rn/vsphere-esxi-vcenter-server-70-release-notes.html
573+
*/
574+
private boolean requiresVncOverWebSocketConnection(VirtualMachine vm, HostVO hostVo) {
575+
return vm.getHypervisorType() == Hypervisor.HypervisorType.VMware && hostVo.getHypervisorVersion().compareTo("7.0") >= 0;
576+
}
577+
516578
public static String genAccessTicket(String host, String port, String sid, String tag) {
517579
return genAccessTicket(host, port, sid, tag, new Date());
518580
}

services/console-proxy/server/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@
6565
<artifactId>websocket-server</artifactId>
6666
<version>${cs.jetty.version}</version>
6767
</dependency>
68+
<dependency>
69+
<groupId>org.java-websocket</groupId>
70+
<artifactId>Java-WebSocket</artifactId>
71+
<version>1.5.1</version>
72+
</dependency>
6873
</dependencies>
6974
<build>
7075
<resources>

services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxy.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.Properties;
3232
import java.util.concurrent.Executor;
3333

34+
import com.cloud.utils.StringUtils;
3435
import org.apache.log4j.xml.DOMConfigurator;
3536
import org.eclipse.jetty.websocket.api.Session;
3637

@@ -172,6 +173,11 @@ public static ConsoleProxyAuthenticationResult authenticateConsoleAccess(Console
172173
authResult.setHost(param.getClientHostAddress());
173174
authResult.setPort(param.getClientHostPort());
174175

176+
String websocketUrl = param.getWebsocketUrl();
177+
if (StringUtils.isNotBlank(websocketUrl)) {
178+
return authResult;
179+
}
180+
175181
if (standaloneStart) {
176182
return authResult;
177183
}

services/console-proxy/server/src/main/java/com/cloud/consoleproxy/ConsoleProxyClientParam.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class ConsoleProxyClientParam {
3636
private String hypervHost;
3737
private String username;
3838
private String password;
39+
private String websocketUrl;
3940

4041
private String sourceIP;
4142

@@ -153,4 +154,12 @@ public String getSourceIP() {
153154
public void setSourceIP(String sourceIP) {
154155
this.sourceIP = sourceIP;
155156
}
157+
158+
public String getWebsocketUrl() {
159+
return websocketUrl;
160+
}
161+
162+
public void setWebsocketUrl(String websocketUrl) {
163+
this.websocketUrl = websocketUrl;
164+
}
156165
}

0 commit comments

Comments
 (0)