use of com.cloud.utils.ExecutionResult in project cloudstack by apache.
the class VirtualRoutingResourceTest method prepareNetworkElementCommand.
private ExecutionResult prepareNetworkElementCommand(final SetNetworkACLCommand cmd) {
final NicTO nic = cmd.getNic();
nic.setDeviceId(3);
return new ExecutionResult(true, null);
}
use of com.cloud.utils.ExecutionResult in project cloudstack by apache.
the class VirtualRoutingResourceTest method prepareNetworkElementCommand.
private ExecutionResult prepareNetworkElementCommand(final SetupGuestNetworkCommand cmd) {
final NicTO nic = cmd.getNic();
nic.setDeviceId(4);
return new ExecutionResult(true, null);
}
use of com.cloud.utils.ExecutionResult in project cloudstack by apache.
the class Ovm3VirtualRoutingSupport method vpcNetworkUsage.
/* copy paste, why isn't this just generic in the VirtualRoutingResource ? */
private NetworkUsageAnswer vpcNetworkUsage(NetworkUsageCommand cmd) {
String privateIp = cmd.getPrivateIP();
String option = cmd.getOption();
String publicIp = cmd.getGatewayIP();
String args = "-l " + publicIp + " ";
if ("get".equals(option)) {
args += "-g";
} else if (CREATE.equals(option)) {
args += "-c";
String vpcCIDR = cmd.getVpcCIDR();
args += " -v " + vpcCIDR;
} else if ("reset".equals(option)) {
args += "-r";
} else if ("vpn".equals(option)) {
args += "-n";
} else if ("remove".equals(option)) {
args += "-d";
} else {
return new NetworkUsageAnswer(cmd, SUCCESS, 0L, 0L);
}
ExecutionResult callResult = vrr.executeInVR(privateIp, "vpc_netusage.sh", args);
if (!callResult.isSuccess()) {
LOGGER.error("Unable to execute NetworkUsage command on DomR (" + privateIp + "), domR may not be ready yet. failure due to " + callResult.getDetails());
}
if ("get".equals(option) || "vpn".equals(option)) {
String result = callResult.getDetails();
if (result == null || result.isEmpty()) {
LOGGER.error(" vpc network usage get returns empty ");
}
long[] stats = new long[2];
if (result != null) {
String[] splitResult = result.split(":");
int i = 0;
while (i < splitResult.length - 1) {
stats[0] += (Long.parseLong(splitResult[i++]));
stats[1] += (Long.parseLong(splitResult[i++]));
}
return new NetworkUsageAnswer(cmd, SUCCESS, stats[0], stats[1]);
}
}
return new NetworkUsageAnswer(cmd, SUCCESS, 0L, 0L);
}
use of com.cloud.utils.ExecutionResult in project cloudstack by apache.
the class Ovm3VirtualRoutingResourceTest method executeInVRFailTest.
@Test
public void executeInVRFailTest() {
ConnectionTest con = new ConnectionTest();
virtualrouting.setConnection(con);
ExecutionResult result = virtualrouting.executeInVR(domrIp, cmd, args);
results.basicBooleanTest(result.isSuccess(), false);
}
use of com.cloud.utils.ExecutionResult in project cloudstack by apache.
the class Ovm3VirtualRoutingResourceTest method executeInVRTest.
@Test
public void executeInVRTest() {
con = support.prepConnectionResults();
cmd = "/opt/cloud/bin/" + cmd;
virtualrouting.setConnection(con);
ExecutionResult result = virtualrouting.executeInVR(domrIp, cmd, args);
results.basicBooleanTest(result.isSuccess());
}
Aggregations