Package com.cloud.utils

Examples of com.cloud.utils.ExecutionResult


            _vrLockMap.put(routerName, lock);
        }
        lock.lock();

        try {
            ExecutionResult rc = _vrDeployer.prepareCommand(cmd);
            if (!rc.isSuccess()) {
                s_logger.error("Failed to prepare VR command due to " + rc.getDetails());
                return new Answer(cmd, false, rc.getDetails());
            }

            assert cmd.getRouterAccessIp() != null : "Why there is no access IP for VR?";

            if (cmd.isQuery()) {
                return executeQueryCommand(cmd);
            }

            if (cmd instanceof AggregationControlCommand) {
                return execute((AggregationControlCommand)cmd);
            }

            if (_vrAggregateCommandsSet.containsKey(routerName)) {
                _vrAggregateCommandsSet.get(routerName).add(cmd);
                aggregated = true;
                // Clean up would be done after command has been executed
                //TODO: Deal with group answer as well
                return new Answer(cmd);
            }

            List<ConfigItem> cfg = generateCommandCfg(cmd);
            if (cfg == null) {
                return Answer.createUnsupportedCommandAnswer(cmd);
            }

            return applyConfig(cmd, cfg);
        } catch (final IllegalArgumentException e) {
            return new Answer(cmd, false, e.getMessage());
        } finally {
            lock.unlock();
            if (!aggregated) {
                ExecutionResult rc = _vrDeployer.cleanupCommand(cmd);
                if (!rc.isSuccess()) {
                    s_logger.error("Failed to cleanup VR command due to " + rc.getDetails());
                }
            }
        }
    }
View Full Code Here


    private Answer applyConfig(NetworkElementCommand cmd, List<ConfigItem> cfg) {
        int answersCount = cmd.getAnswersCount();

        // Use the last answer as final answer
        if (answersCount == 1) {
            ExecutionResult result = new ExecutionResult(true, "No configure to be applied");
            for (ConfigItem c : cfg) {
                result = applyConfigToVR(cmd, c);
                if (!result.isSuccess()) {
                    break;
                }
            }
            return new Answer(cmd, result.isSuccess(), result.getDetails());
        }

        ExecutionResult[] results = new ExecutionResult[answersCount];
        String[] resultsString = new String[answersCount];
        boolean finalResult = true;
View Full Code Here

        String args = "";
        for (String ip : cmd.getVpnIps()) {
            args += ip + " ";
        }

        ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.S2SVPN_CHECK, args);
        return new CheckS2SVpnConnectionsAnswer(cmd, result.isSuccess(), result.getDetails());
    }
View Full Code Here

    private GetRouterAlertsAnswer execute(GetRouterAlertsCommand cmd) {

        String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
        String args = cmd.getPreviousAlertTimeStamp();

        ExecutionResult result = _vrDeployer.executeInVR(routerIp, VRScripts.ROUTER_ALERTS, args);
        String alerts[] = null;
        String lastAlertTimestamp = null;

        if (result.isSuccess()) {
            if (!result.getDetails().isEmpty() && !result.getDetails().trim().equals("No Alerts")) {
                alerts = result.getDetails().trim().split("\\\\n");
                String[] lastAlert = alerts[alerts.length - 1].split(",");
                lastAlertTimestamp = lastAlert[0];
            }
            return new GetRouterAlertsAnswer(cmd, alerts, lastAlertTimestamp);
        } else {
            return new GetRouterAlertsAnswer(cmd, result.getDetails());
        }
    }
View Full Code Here

            return new GetRouterAlertsAnswer(cmd, result.getDetails());
        }
    }

    protected Answer execute(CheckRouterCommand cmd) {
        final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.RVR_CHECK, null);
        if (!result.isSuccess()) {
            return new CheckRouterAnswer(cmd, result.getDetails());
        }
        return new CheckRouterAnswer(cmd, result.getDetails(), true);
    }
View Full Code Here

        cfg.add(new ConfigItem(VRScripts.RVR_BUMPUP_PRI, null));
        return cfg;
    }

    protected Answer execute(GetDomRVersionCmd cmd) {
        final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VERSION, null);
        if (!result.isSuccess()) {
            return new GetDomRVersionAnswer(cmd, "GetDomRVersionCmd failed");
        }
        String[] lines = result.getDetails().split("&");
        if (lines.length != 2) {
            return new GetDomRVersionAnswer(cmd, result.getDetails());
        }
        return new GetDomRVersionAnswer(cmd, result.getDetails(), lines[0], lines[1]);
    }
View Full Code Here

                        }
                    }
                }
                String cfgFilePath = "/var/cache/cloud/";
                String cfgFileName = "VR-"+ UUID.randomUUID().toString() + ".cfg";
                ExecutionResult result = _vrDeployer.createFileInVR(cmd.getRouterAccessIp(), cfgFilePath, cfgFileName, sb.toString());
                if (!result.isSuccess()) {
                    return new Answer(cmd, false, result.getDetails());
                }

                // 120s is the minimal timeout
                int timeout = answerCounts * _eachTimeout;
                if (timeout < 120) {
                    timeout = 120;
                }
                result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VR_CFG, "-c " + cfgFilePath + cfgFileName, timeout);
                if (!result.isSuccess()) {
                    return new Answer(cmd, false, result.getDetails());
                }
                return new Answer(cmd);
            } finally {
                queue.clear();
                _vrAggregateCommandsSet.remove(routerName);
View Full Code Here

    @Override
    public ExecutionResult executeInVR(String routerIp, String script, String args, int timeout) {
        assertEquals(routerIp, ROUTERIP);
        verifyCommand(_currentCmd, script, args);
        return new ExecutionResult(true, null);
    }
View Full Code Here

    @Override
    public ExecutionResult createFileInVR(String routerIp, String path, String filename, String content) {
        assertEquals(routerIp, ROUTERIP);
        verifyFile(_currentCmd, path, filename, content);
        return new ExecutionResult(true, null);
    }
View Full Code Here

        } else if (cmd instanceof SetSourceNatCommand) {
            return prepareNetworkElementCommand((SetSourceNatCommand)cmd);
        } else if (cmd instanceof SetNetworkACLCommand) {
            return prepareNetworkElementCommand((SetNetworkACLCommand)cmd);
        }
        return new ExecutionResult(true, null);
    }
View Full Code Here

TOP

Related Classes of com.cloud.utils.ExecutionResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.