mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-6607: Correct the result of VpcNetworkUsage
Blank or not shouldn't be used to indicate command is failure or not.
This commit is contained in:
parent
98307bfcea
commit
10de19e4dd
|
|
@ -26,6 +26,7 @@ import com.cloud.agent.api.NetworkUsageAnswer;
|
|||
import com.cloud.agent.api.NetworkUsageCommand;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.utils.ExecutionResult;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.script.Script;
|
||||
import com.cloud.utils.ssh.SSHCmdHelper;
|
||||
|
|
@ -166,11 +167,15 @@ public class XenServer56Resource extends CitrixResourceBase {
|
|||
return new NetworkUsageAnswer(cmd, "success", 0L, 0L);
|
||||
}
|
||||
|
||||
String result = executeInVR(cmd.getPrivateIP(), "vpc_netusage.sh", args).getDetails();
|
||||
ExecutionResult result = executeInVR(cmd.getPrivateIP(), "vpc_netusage.sh", args);
|
||||
String detail = result.getDetails();
|
||||
if (!result.isSuccess()) {
|
||||
throw new Exception(" vpc network usage plugin call failed ");
|
||||
}
|
||||
if (option.equals("get") || option.equals("vpn")) {
|
||||
long[] stats = new long[2];
|
||||
if (result != null) {
|
||||
String[] splitResult = result.split(":");
|
||||
if (detail != null) {
|
||||
String[] splitResult = detail.split(":");
|
||||
int i = 0;
|
||||
while (i < splitResult.length - 1) {
|
||||
stats[0] += (new Long(splitResult[i++])).longValue();
|
||||
|
|
@ -179,9 +184,6 @@ public class XenServer56Resource extends CitrixResourceBase {
|
|||
return new NetworkUsageAnswer(cmd, "success", stats[0], stats[1]);
|
||||
}
|
||||
}
|
||||
if (result == null || result.isEmpty()) {
|
||||
throw new Exception(" vpc network usage plugin call failed ");
|
||||
}
|
||||
return new NetworkUsageAnswer(cmd, "success", 0L, 0L);
|
||||
} catch (Exception ex) {
|
||||
s_logger.warn("Failed to get network usage stats due to ", ex);
|
||||
|
|
|
|||
Loading…
Reference in New Issue