Skip to content

Commit 04eba00

Browse files
authored
Merge pull request #53 from shapeblue/FR590-vmware7
FR590 vmware7 on kddi-release-4113
2 parents 0cc9d82 + 574c3af commit 04eba00

File tree

145 files changed

+21696
-168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+21696
-168
lines changed

agent/src/com/cloud/agent/resource/consoleproxy/ConsoleProxyResource.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public Answer executeRequest(final Command cmd) {
114114

115115
private Answer execute(StartConsoleProxyAgentHttpHandlerCommand cmd) {
116116
s_logger.info("Invoke launchConsoleProxy() in responding to StartConsoleProxyAgentHttpHandlerCommand");
117-
launchConsoleProxy(cmd.getKeystoreBits(), cmd.getKeystorePassword(), cmd.getEncryptorPassword());
117+
launchConsoleProxy(cmd.getKeystoreBits(), cmd.getKeystorePassword(), cmd.getEncryptorPassword(), cmd.isSourceIpCheckEnabled());
118118
return new Answer(cmd);
119119
}
120120

@@ -314,7 +314,7 @@ public String getName() {
314314
return _name;
315315
}
316316

317-
private void launchConsoleProxy(final byte[] ksBits, final String ksPassword, final String encryptorPassword) {
317+
private void launchConsoleProxy(final byte[] ksBits, final String ksPassword, final String encryptorPassword, final Boolean isSourceIpCheckEnabled) {
318318
final Object resource = this;
319319
s_logger.info("Building class loader for com.cloud.consoleproxy.ConsoleProxy");
320320
final ClassLoader loader = ReflectUtil.getClassLoaderForName("console-proxy");
@@ -327,8 +327,8 @@ protected void runInContext() {
327327
Class<?> consoleProxyClazz = loader.loadClass("com.cloud.consoleproxy.ConsoleProxy");
328328
try {
329329
s_logger.info("Invoke startWithContext()");
330-
Method method = consoleProxyClazz.getMethod("startWithContext", Properties.class, Object.class, byte[].class, String.class, String.class);
331-
method.invoke(null, _properties, resource, ksBits, ksPassword, encryptorPassword);
330+
Method method = consoleProxyClazz.getMethod("startWithContext", Properties.class, Object.class, byte[].class, String.class, String.class, Boolean.class);
331+
method.invoke(null, _properties, resource, ksBits, ksPassword, encryptorPassword, isSourceIpCheckEnabled);
332332
} catch (SecurityException e) {
333333
s_logger.error("Unable to launch console proxy due to SecurityException", e);
334334
System.exit(ExitStatus.Error.value());
@@ -360,6 +360,8 @@ protected void runInContext() {
360360
Class<?> consoleProxyClazz = loader.loadClass("com.cloud.consoleproxy.ConsoleProxy");
361361
Method methodSetup = consoleProxyClazz.getMethod("setEncryptorPassword", String.class);
362362
methodSetup.invoke(null, encryptorPassword);
363+
methodSetup = consoleProxyClazz.getMethod("setIsSourceIpCheckEnabled", Boolean.class);
364+
methodSetup.invoke(null, isSourceIpCheckEnabled);
363365
} catch (SecurityException e) {
364366
s_logger.error("Unable to launch console proxy due to SecurityException", e);
365367
System.exit(ExitStatus.Error.value());
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+
}

core/src/com/cloud/agent/api/proxy/StartConsoleProxyAgentHttpHandlerCommand.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public class StartConsoleProxyAgentHttpHandlerCommand extends Command {
3131
@LogLevel(Log4jLevel.Off)
3232
private String encryptorPassword;
3333

34+
private Boolean isSourceIpCheckEnabled;
35+
3436
public StartConsoleProxyAgentHttpHandlerCommand() {
3537
super();
3638
}
@@ -68,4 +70,12 @@ public String getEncryptorPassword() {
6870
public void setEncryptorPassword(String encryptorPassword) {
6971
this.encryptorPassword = encryptorPassword;
7072
}
73+
74+
public Boolean isSourceIpCheckEnabled() {
75+
return isSourceIpCheckEnabled;
76+
}
77+
78+
public void setIsSourceIpCheckEnabled(Boolean isSourceIpCheckEnabled) {
79+
this.isSourceIpCheckEnabled = isSourceIpCheckEnabled;
80+
}
7181
}

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
import com.cloud.agent.api.GetVmDiskStatsAnswer;
9292
import com.cloud.agent.api.GetVmDiskStatsCommand;
9393
import com.cloud.agent.api.GetVmIpAddressCommand;
94+
import com.cloud.agent.api.GetVmVncTicketCommand;
95+
import com.cloud.agent.api.GetVmVncTicketAnswer;
9496
import com.cloud.agent.api.GetVmNetworkStatsAnswer;
9597
import com.cloud.agent.api.GetVmNetworkStatsCommand;
9698
import com.cloud.agent.api.GetVmStatsAnswer;
@@ -529,7 +531,9 @@ public Answer executeRequest(Command cmd) {
529531
} else if (clz == GetVmIpAddressCommand.class) {
530532
return execute((GetVmIpAddressCommand)cmd);
531533
} else if (clz == UnregisterNicCommand.class) {
532-
answer = execute((UnregisterNicCommand)cmd);
534+
answer = execute((UnregisterNicCommand) cmd);
535+
} else if (clz == GetVmVncTicketCommand.class) {
536+
answer = execute((GetVmVncTicketCommand) cmd);
533537
} else {
534538
answer = Answer.createUnsupportedCommandAnswer(cmd);
535539
}
@@ -6542,4 +6546,25 @@ private String getMountedDatastoreName(VmwareHypervisorHost sourceHyperHost, Str
65426546
}
65436547
return mountedDatastoreName;
65446548
}
6549+
6550+
public String acquireVirtualMachineVncTicket(String vmInternalCSName) throws Exception {
6551+
VmwareContext context = getServiceContext();
6552+
VmwareHypervisorHost hyperHost = getHyperHost(context);
6553+
DatacenterMO dcMo = new DatacenterMO(hyperHost.getContext(), hyperHost.getHyperHostDatacenter());
6554+
VirtualMachineMO vmMo = dcMo.findVm(vmInternalCSName);
6555+
return vmMo.acquireVncTicket();
6556+
}
6557+
6558+
private GetVmVncTicketAnswer execute(GetVmVncTicketCommand cmd) {
6559+
String vmInternalName = cmd.getVmInternalName();
6560+
s_logger.info("Getting VNC ticket for VM " + vmInternalName);
6561+
try {
6562+
String ticket = acquireVirtualMachineVncTicket(vmInternalName);
6563+
boolean result = StringUtils.isNotBlank(ticket);
6564+
return new GetVmVncTicketAnswer(ticket, result, result ? "" : "Empty ticket obtained");
6565+
} catch (Exception e) {
6566+
s_logger.error("Error getting VNC ticket for VM " + vmInternalName, e);
6567+
return new GetVmVncTicketAnswer(null, false, e.getLocalizedMessage());
6568+
}
6569+
}
65456570
}

0 commit comments

Comments
 (0)