use of com.cloud.utils.ExecutionResult in project cloudstack by apache.
the class Ovm3VirtualRoutingSupport method networkUsage.
/* copy paste, why isn't this just generic in the VirtualRoutingResource ? */
private String networkUsage(final String privateIpAddress, final String option, final String ethName) {
String args = null;
if ("get".equals(option)) {
args = "-g";
} else if (CREATE.equals(option)) {
args = "-c";
} else if ("reset".equals(option)) {
args = "-r";
} else if ("addVif".equals(option)) {
args = "-a";
args += ethName;
} else if ("deleteVif".equals(option)) {
args = "-d";
args += ethName;
}
ExecutionResult result = vrr.executeInVR(privateIpAddress, "netusage.sh", args);
if (result == null || !result.isSuccess()) {
return null;
}
return result.getDetails();
}
use of com.cloud.utils.ExecutionResult in project cloudstack by apache.
the class Ovm3VirtualRoutingResource method createFileInVR.
@Override
public ExecutionResult createFileInVR(String routerIp, String path, String filename, String content) {
String error = null;
logger.debug("createFileInVR via " + agentName + " on " + routerIp + ": " + path + "/" + filename + ", content: " + content);
try {
CloudstackPlugin cSp = new CloudstackPlugin(c);
boolean result = cSp.ovsDomrUploadFile(routerIp, path, filename, content);
return new ExecutionResult(result, "");
} catch (Exception e) {
error = e.getMessage();
logger.warn("createFileInVR failed for " + path + "/" + filename + " in VR " + routerIp + " via " + agentName + ": " + error, e);
}
return new ExecutionResult(error == null, error);
}
use of com.cloud.utils.ExecutionResult in project cloudstack by apache.
the class XenServer56NetworkUsageCommandWrapper method executeNetworkUsage.
protected NetworkUsageAnswer executeNetworkUsage(final NetworkUsageCommand command, final XenServer56Resource xenServer56) {
try {
final String option = command.getOption();
final String publicIp = command.getGatewayIP();
String args = " -l " + publicIp + " ";
if (option.equals("get")) {
args += "-g";
} else if (option.equals("create")) {
args += "-c";
final String vpcCIDR = command.getVpcCIDR();
args += " -v " + vpcCIDR;
} else if (option.equals("reset")) {
args += "-r";
} else if (option.equals("vpn")) {
args += "-n";
} else if (option.equals("remove")) {
args += "-d";
} else {
return new NetworkUsageAnswer(command, "success", 0L, 0L);
}
final ExecutionResult result = xenServer56.executeInVR(command.getPrivateIP(), "vpc_netusage.sh", args);
final String detail = result.getDetails();
if (!result.isSuccess()) {
throw new Exception(" vpc network usage plugin call failed ");
}
if (option.equals("get") || option.equals("vpn")) {
final long[] stats = new long[2];
if (detail != null) {
final String[] splitResult = detail.split(":");
int i = 0;
while (i < splitResult.length - 1) {
stats[0] += Long.parseLong(splitResult[i++]);
stats[1] += Long.parseLong(splitResult[i++]);
}
return new NetworkUsageAnswer(command, "success", stats[0], stats[1]);
}
}
return new NetworkUsageAnswer(command, "success", 0L, 0L);
} catch (final Exception ex) {
s_logger.warn("Failed to get network usage stats due to ", ex);
return new NetworkUsageAnswer(command, ex);
}
}
use of com.cloud.utils.ExecutionResult in project cloudstack by apache.
the class VmwareResource method createFileInVR.
@Override
public ExecutionResult createFileInVR(String routerIp, String filePath, String fileName, String content) {
VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
File keyFile = mgr.getSystemVMKeyFile();
try {
SshHelper.scpTo(routerIp, 3922, "root", keyFile, null, filePath, content.getBytes("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());
}
return new ExecutionResult(true, null);
}
use of com.cloud.utils.ExecutionResult in project cloudstack by apache.
the class VmwareResource method prepareNetworkElementCommand.
private ExecutionResult prepareNetworkElementCommand(SetNetworkACLCommand cmd) {
NicTO nic = cmd.getNic();
String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
String routerIp = getRouterSshControlIp(cmd);
try {
int ethDeviceNum = findRouterEthDeviceIndex(routerName, routerIp, nic.getMac());
nic.setDeviceId(ethDeviceNum);
} catch (Exception e) {
String msg = "Prepare SetNetworkACL failed due to " + e.toString();
s_logger.error(msg, e);
return new ExecutionResult(false, msg);
}
return new ExecutionResult(true, null);
}
Aggregations