|
167 | 167 | @Local(value = ServerResource.class) |
168 | 168 | public abstract class CitrixResourceBase implements ServerResource, HypervisorResource, VirtualRouterDeployer { |
169 | 169 |
|
| 170 | + private final static int BASE_TO_CONVERT_BYTES_INTO_KILOBYTES = 1024; |
| 171 | + |
170 | 172 | public enum SRType { |
171 | 173 | EXT, FILE, ISCSI, ISO, LVM, LVMOHBA, LVMOISCSI, NFS; |
172 | 174 |
|
@@ -2306,7 +2308,7 @@ public SR getIscsiSR(final Connection conn, final String srNameLabel, final Stri |
2306 | 2308 | } |
2307 | 2309 | if (target.equals(dc.get("target")) && targetiqn.equals(dc.get("targetIQN")) && lunid.equals(dc.get("lunid"))) { |
2308 | 2310 | throw new CloudRuntimeException("There is a SR using the same configuration target:" + dc.get("target") + ", targetIQN:" + dc.get("targetIQN") |
2309 | | - + ", lunid:" + dc.get("lunid") + " for pool " + srNameLabel + "on host:" + _host.getUuid()); |
| 2311 | + + ", lunid:" + dc.get("lunid") + " for pool " + srNameLabel + "on host:" + _host.getUuid()); |
2310 | 2312 | } |
2311 | 2313 | } |
2312 | 2314 | deviceConfig.put("target", target); |
@@ -2617,7 +2619,7 @@ protected XsLocalNetwork getManagementNetwork(final Connection conn) throws XmlR |
2617 | 2619 | final Bond bond = mgmtPifRec.bondSlaveOf; |
2618 | 2620 | if (!isRefNull(bond)) { |
2619 | 2621 | final String msg = "Management interface is on slave(" + mgmtPifRec.uuid + ") of bond(" + bond.getUuid(conn) + ") on host(" + _host.getUuid() |
2620 | | - + "), please move management interface to bond!"; |
| 2622 | + + "), please move management interface to bond!"; |
2621 | 2623 | s_logger.warn(msg); |
2622 | 2624 | throw new CloudRuntimeException(msg); |
2623 | 2625 | } |
@@ -2837,7 +2839,7 @@ public SR getNfsSR(final Connection conn, final String poolid, final String uuid |
2837 | 2839 |
|
2838 | 2840 | if (server.equals(dc.get("server")) && serverpath.equals(dc.get("serverpath"))) { |
2839 | 2841 | throw new CloudRuntimeException("There is a SR using the same configuration server:" + dc.get("server") + ", serverpath:" + dc.get("serverpath") |
2840 | | - + " for pool " + uuid + " on host:" + _host.getUuid()); |
| 2842 | + + " for pool " + uuid + " on host:" + _host.getUuid()); |
2841 | 2843 | } |
2842 | 2844 |
|
2843 | 2845 | } |
@@ -3324,20 +3326,22 @@ public HashMap<String, VmStatsEntry> getVmStats(final Connection conn, final Get |
3324 | 3326 | if (param.contains("cpu")) { |
3325 | 3327 | vmStatsAnswer.setNumCPUs(vmStatsAnswer.getNumCPUs() + 1); |
3326 | 3328 | vmStatsAnswer.setCPUUtilization(vmStatsAnswer.getCPUUtilization() + getDataAverage(dataNode, col, numRows)); |
3327 | | - } else if (param.matches("vif_\\d*_rx")) { |
3328 | | - vmStatsAnswer.setNetworkReadKBs(vmStatsAnswer.getNetworkReadKBs() + getDataAverage(dataNode, col, numRows) / 1000); |
3329 | | - } else if (param.matches("vif_\\d*_tx")) { |
3330 | | - vmStatsAnswer.setNetworkWriteKBs(vmStatsAnswer.getNetworkWriteKBs() + getDataAverage(dataNode, col, numRows) / 1000); |
3331 | | - } else if (param.matches("vbd_.*_read")) { |
3332 | | - vmStatsAnswer.setDiskReadKBs(vmStatsAnswer.getDiskReadKBs() + getDataAverage(dataNode, col, numRows) / 1000); |
3333 | | - } else if (param.matches("vbd_.*_write")) { |
3334 | | - vmStatsAnswer.setDiskWriteKBs(vmStatsAnswer.getDiskWriteKBs() + getDataAverage(dataNode, col, numRows) / 1000); |
3335 | | - } else if (param.contains("memory_internal_free")) { |
3336 | | - vmStatsAnswer.setIntFreeMemoryKBs(vmStatsAnswer.getIntFreeMemoryKBs() + getDataAverage(dataNode, col, numRows) / 1024); |
3337 | | - } else if (param.contains("memory_target")) { |
3338 | | - vmStatsAnswer.setTargetMemoryKBs(vmStatsAnswer.getTargetMemoryKBs() + getDataAverage(dataNode, col, numRows) / 1024); |
3339 | | - } else if (param.contains("memory")) { |
3340 | | - vmStatsAnswer.setMemoryKBs(vmStatsAnswer.getMemoryKBs() + getDataAverage(dataNode, col, numRows) / 1024); |
| 3329 | + } else { |
| 3330 | + if (param.matches("vif_\\d*_rx")) { |
| 3331 | + vmStatsAnswer.setNetworkReadKBs(vmStatsAnswer.getNetworkReadKBs() + getDataAverage(dataNode, col, numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES); |
| 3332 | + } else if (param.matches("vif_\\d*_tx")) { |
| 3333 | + vmStatsAnswer.setNetworkWriteKBs(vmStatsAnswer.getNetworkWriteKBs() + getDataAverage(dataNode, col, numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES); |
| 3334 | + } else if (param.matches("vbd_.*_read")) { |
| 3335 | + vmStatsAnswer.setDiskReadKBs(vmStatsAnswer.getDiskReadKBs() + getDataAverage(dataNode, col, numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES); |
| 3336 | + } else if (param.matches("vbd_.*_write")) { |
| 3337 | + vmStatsAnswer.setDiskWriteKBs(vmStatsAnswer.getDiskWriteKBs() + getDataAverage(dataNode, col, numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES); |
| 3338 | + } else if (param.contains("memory_internal_free")) { |
| 3339 | + vmStatsAnswer.setIntFreeMemoryKBs(vmStatsAnswer.getIntFreeMemoryKBs() + getDataAverage(dataNode, col, numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES); |
| 3340 | + } else if (param.contains("memory_target")) { |
| 3341 | + vmStatsAnswer.setTargetMemoryKBs(vmStatsAnswer.getTargetMemoryKBs() + getDataAverage(dataNode, col, numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES); |
| 3342 | + } else if (param.contains("memory")) { |
| 3343 | + vmStatsAnswer.setMemoryKBs(vmStatsAnswer.getMemoryKBs() + getDataAverage(dataNode, col, numRows) / BASE_TO_CONVERT_BYTES_INTO_KILOBYTES); |
| 3344 | + } |
3341 | 3345 | } |
3342 | 3346 |
|
3343 | 3347 | } |
@@ -5080,8 +5084,8 @@ public boolean createVmdataFiles(final String vmName, final List<String[]> vmDat |
5080 | 5084 | if (result && content != null && !content.isEmpty()) { |
5081 | 5085 | File file = new File(folder+"/"+fileName+".txt"); |
5082 | 5086 | try (OutputStreamWriter fw = new OutputStreamWriter(new FileOutputStream(file.getAbsoluteFile()),"UTF-8"); |
5083 | | - BufferedWriter bw = new BufferedWriter(fw); |
5084 | | - ) { |
| 5087 | + BufferedWriter bw = new BufferedWriter(fw); |
| 5088 | + ) { |
5085 | 5089 | bw.write(content); |
5086 | 5090 | s_logger.debug("created file: "+ file + " in folder:"+folder); |
5087 | 5091 | } catch (final IOException ex) { |
|
0 commit comments