Fixed all findbugs in hyperv plugin code

This commit is contained in:
Rajesh Battala 2014-03-12 11:32:44 +05:30
parent 4523f5d8de
commit 6a4927f660
3 changed files with 9 additions and 7 deletions

View File

@ -45,9 +45,9 @@ public class HypervInvestigator extends AdapterBase implements Investigator {
public Boolean isVmAlive(com.cloud.vm.VirtualMachine vm, Host host) { public Boolean isVmAlive(com.cloud.vm.VirtualMachine vm, Host host) {
Status status = isAgentAlive(host); Status status = isAgentAlive(host);
if (status == null) { if (status == null) {
return null; return false;
} }
return status == Status.Up ? true : null; return status == Status.Up ? true : false;
} }
@Override @Override

View File

@ -19,6 +19,7 @@ package com.cloud.hypervisor.hyperv.discoverer;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.URI; import java.net.URI;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.nio.charset.Charset;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -254,7 +255,7 @@ public class HypervServerDiscoverer extends DiscovererBase implements Discoverer
// pool in the database // pool in the database
// This GUID may change. // This GUID may change.
if (cluster.getGuid() == null) { 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); _clusterDao.update(clusterId, cluster);
} }
@ -318,7 +319,7 @@ public class HypervServerDiscoverer extends DiscovererBase implements Discoverer
* @return GUID in form of a string. * @return GUID in form of a string.
*/ */
public static String calcServerResourceGuid(final String uuidSeed) { 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; return guid;
} }

View File

@ -24,6 +24,7 @@ import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.nio.channels.SocketChannel; import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.security.KeyManagementException; import java.security.KeyManagementException;
import java.security.KeyStoreException; 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) { public ExecutionResult createFileInVR(String routerIp, String filePath, String fileName, String content) {
File keyFile = getSystemVMKeyFile(); File keyFile = getSystemVMKeyFile();
try { 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) { } catch (Exception e) {
s_logger.warn("Fail to create file " + filePath + fileName + " in VR " + routerIp, e); s_logger.warn("Fail to create file " + filePath + fileName + " in VR " + routerIp, e);
return new ExecutionResult(false, e.getMessage()); return new ExecutionResult(false, e.getMessage());
@ -1262,7 +1263,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
} }
try { 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); ".cfg", null);
try { try {
@ -1459,7 +1460,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
String json = new Gson().toJson(data); String json = new Gson().toJson(data);
s_logger.debug("VM data JSON IS:" + json); 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; String args = "-d " + json;