Search in sources :

Example 21 with ExecutionResult

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);
}
Also used : ExecutionResult(com.cloud.utils.ExecutionResult) NicTO(com.cloud.agent.api.to.NicTO)

Example 22 with ExecutionResult

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);
}
Also used : ExecutionResult(com.cloud.utils.ExecutionResult) NicTO(com.cloud.agent.api.to.NicTO)

Example 23 with ExecutionResult

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);
}
Also used : ExecutionResult(com.cloud.utils.ExecutionResult) NetworkUsageAnswer(com.cloud.agent.api.NetworkUsageAnswer)

Example 24 with ExecutionResult

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);
}
Also used : ExecutionResult(com.cloud.utils.ExecutionResult) ConnectionTest(com.cloud.hypervisor.ovm3.objects.ConnectionTest) Test(org.junit.Test) ConnectionTest(com.cloud.hypervisor.ovm3.objects.ConnectionTest) CloudStackPluginTest(com.cloud.hypervisor.ovm3.objects.CloudStackPluginTest) LinuxTest(com.cloud.hypervisor.ovm3.objects.LinuxTest) NetworkTest(com.cloud.hypervisor.ovm3.objects.NetworkTest) XenTest(com.cloud.hypervisor.ovm3.objects.XenTest) Ovm3SupportTest(com.cloud.hypervisor.ovm3.support.Ovm3SupportTest) XmlTestResultTest(com.cloud.hypervisor.ovm3.objects.XmlTestResultTest) Ovm3ConfigurationTest(com.cloud.hypervisor.ovm3.resources.helpers.Ovm3ConfigurationTest)

Example 25 with ExecutionResult

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());
}
Also used : ExecutionResult(com.cloud.utils.ExecutionResult) Test(org.junit.Test) ConnectionTest(com.cloud.hypervisor.ovm3.objects.ConnectionTest) CloudStackPluginTest(com.cloud.hypervisor.ovm3.objects.CloudStackPluginTest) LinuxTest(com.cloud.hypervisor.ovm3.objects.LinuxTest) NetworkTest(com.cloud.hypervisor.ovm3.objects.NetworkTest) XenTest(com.cloud.hypervisor.ovm3.objects.XenTest) Ovm3SupportTest(com.cloud.hypervisor.ovm3.support.Ovm3SupportTest) XmlTestResultTest(com.cloud.hypervisor.ovm3.objects.XmlTestResultTest) Ovm3ConfigurationTest(com.cloud.hypervisor.ovm3.resources.helpers.Ovm3ConfigurationTest)

Aggregations

ExecutionResult (com.cloud.utils.ExecutionResult)50 InternalErrorException (com.cloud.exception.InternalErrorException)23 IOException (java.io.IOException)20 ConfigurationException (javax.naming.ConfigurationException)20 IpAddressTO (com.cloud.agent.api.to.IpAddressTO)16 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)16 URISyntaxException (java.net.URISyntaxException)13 NicTO (com.cloud.agent.api.to.NicTO)11 ConnectException (java.net.ConnectException)11 RemoteException (java.rmi.RemoteException)11 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)9 SAXException (org.xml.sax.SAXException)9 XenAPIException (com.xensource.xenapi.Types.XenAPIException)8 MalformedURLException (java.net.MalformedURLException)8 TimeoutException (java.util.concurrent.TimeoutException)8 XmlRpcException (org.apache.xmlrpc.XmlRpcException)8 CloudException (com.cloud.exception.CloudException)7 Connection (com.xensource.xenapi.Connection)7 UnsupportedEncodingException (java.io.UnsupportedEncodingException)7 URI (java.net.URI)7