mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fixed all findbugs in hyperv plugin code
This commit is contained in:
parent
4523f5d8de
commit
6a4927f660
@ -45,9 +45,9 @@ public class HypervInvestigator extends AdapterBase implements Investigator {
|
||||
public Boolean isVmAlive(com.cloud.vm.VirtualMachine vm, Host host) {
|
||||
Status status = isAgentAlive(host);
|
||||
if (status == null) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
return status == Status.Up ? true : null;
|
||||
return status == Status.Up ? true : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -19,6 +19,7 @@ package com.cloud.hypervisor.hyperv.discoverer;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URI;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -254,7 +255,7 @@ public class HypervServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
// pool in the database
|
||||
// This GUID may change.
|
||||
if (cluster.getGuid() == null) {
|
||||
cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString());
|
||||
cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes(Charset.forName("UTF-8"))).toString());
|
||||
_clusterDao.update(clusterId, cluster);
|
||||
}
|
||||
|
||||
@ -318,7 +319,7 @@ public class HypervServerDiscoverer extends DiscovererBase implements Discoverer
|
||||
* @return GUID in form of a string.
|
||||
*/
|
||||
public static String calcServerResourceGuid(final String uuidSeed) {
|
||||
String guid = UUID.nameUUIDFromBytes(uuidSeed.getBytes()).toString();
|
||||
String guid = UUID.nameUUIDFromBytes(uuidSeed.getBytes(Charset.forName("UTF-8"))).toString();
|
||||
return guid;
|
||||
}
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.nio.charset.Charset;
|
||||
import java.rmi.RemoteException;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStoreException;
|
||||
@ -597,7 +598,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
public ExecutionResult createFileInVR(String routerIp, String filePath, String fileName, String content) {
|
||||
File keyFile = getSystemVMKeyFile();
|
||||
try {
|
||||
SshHelper.scpTo(routerIp, 3922, "root", keyFile, null, filePath, content.getBytes(), fileName, null);
|
||||
SshHelper.scpTo(routerIp, 3922, "root", keyFile, null, filePath, content.getBytes(Charset.forName("UTF-8")), fileName, null);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Fail to create file " + filePath + fileName + " in VR " + routerIp, e);
|
||||
return new ExecutionResult(false, e.getMessage());
|
||||
@ -1262,7 +1263,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
}
|
||||
|
||||
try {
|
||||
SshHelper.scpTo(controlIp, DEFAULT_DOMR_SSHPORT, "root", keyFile, null, "/tmp/", tmpCfgFileContents.toString().getBytes(), routerIp.replace('.', '_') +
|
||||
SshHelper.scpTo(controlIp, DEFAULT_DOMR_SSHPORT, "root", keyFile, null, "/tmp/", tmpCfgFileContents.toString().getBytes(Charset.forName("UTF-8")), routerIp.replace('.', '_') +
|
||||
".cfg", null);
|
||||
|
||||
try {
|
||||
@ -1459,7 +1460,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
||||
String json = new Gson().toJson(data);
|
||||
s_logger.debug("VM data JSON IS:" + json);
|
||||
|
||||
json = Base64.encodeBase64String(json.getBytes());
|
||||
json = Base64.encodeBase64String(json.getBytes(Charset.forName("UTF-8")));
|
||||
|
||||
String args = "-d " + json;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user