Package com.cloud.utils.script

Examples of com.cloud.utils.script.Script


        String[] results = new String[cmd.getRules().length];
        int i = 0;
        boolean endResult = true;
        for (StaticNatRuleTO rule : cmd.getRules()) {
            String result = null;
            final Script command = new Script(_firewallPath, _timeout, s_logger);
            command.add(routerIp);
            command.add(rule.revoked() ? "-D" : "-A");
           
            //1:1 NAT needs instanceip;publicip;domrip;op
            command.add(" -l ", rule.getSrcIp());
            command.add(" -r ", rule.getDstIp());
           
            if (rule.getProtocol() != null) {
                command.add(" -P ", rule.getProtocol().toLowerCase());
            }
           
            command.add(" -d ", rule.getStringSrcPortRange());
            command.add(" -G ") ;
           
            result = command.execute();
            if (result == null) {
                results[i++] = null;
            } else {
                results[i++] = "Failed";
                endResult = false;
View Full Code Here


        return brName;
    }

    private void createVnet(String vnetId, String pif)
            throws InternalErrorException {
        final Script command = new Script(_modifyVlanPath, _timeout, s_logger);
        command.add("-v", vnetId);
        command.add("-p", pif);
        command.add("-o", "add");

        final String result = command.execute();
        if (result != null) {
            throw new InternalErrorException("Failed to create vnet " + vnetId
                    + ": " + result);
        }
    }
View Full Code Here

    private void createControlNetwork() throws LibvirtException {
        createControlNetwork(_bridges.get("linklocal"));
    }

    private void deletExitingLinkLocalRoutTable(String linkLocalBr) {
        Script command = new Script("/bin/bash", _timeout);
        command.add("-c");
        command.add("ip route | grep " + NetUtils.getLinkLocalCIDR());
        OutputInterpreter.AllLinesParser parser = new OutputInterpreter.AllLinesParser();
        String result = command.execute(parser);
        boolean foundLinkLocalBr = false;
        if (result == null && parser.getLines() != null) {
            String[] lines = parser.getLines().split("\\n");
            for (String line : lines) {
                String[] tokens = line.split(" ");
View Full Code Here

        }

    }

    private boolean isBridgeExists(String bridgeName) {
        Script command = new Script("/bin/sh", _timeout);
        command.add("-c");
        command.add("brctl show|grep " + bridgeName);
        final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser();
        String result = command.execute(parser);
        if (result != null || parser.getLine() == null) {
            return false;
        } else {
            return true;
        }
View Full Code Here

                s_logger.warn("Failed to create temporary file: is " + tmpDir + " full?", e);
                return new Answer(cmd, false, "Failed to create or write to temporary file: is " + tmpDir + " full? " + e.getMessage() );
            }
      

            final Script command  = new Script(_vmDataPath, _timeout, s_logger);
            command.add("-r", cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP));
            command.add("-v", cmd.getVmIpAddress());
            command.add("-F", folder);
            command.add("-f", file);

            if (tmpFile != null) {
                command.add("-d", tmpFile.getAbsolutePath());
            }

            final String result = command.execute();

            if (tmpFile != null) {
                boolean deleted = tmpFile.delete();
                if (!deleted) {
                    s_logger.warn("Failed to clean up temp file after sending vmdata");
View Full Code Here

        if (routerIp == null) {
            routerIp = "none";
        }

        final Script command = new Script(_loadbPath, _timeout, s_logger);

        command.add("-i", routerIp);
        command.add("-f", cfgFile);

        StringBuilder sb = new StringBuilder();
        if (addRules.length > 0) {
            for (int i=0; i< addRules.length; i++) {
                sb.append(addRules[i]).append(',');
            }
            command.add("-a", sb.toString());
        }

        sb = new StringBuilder();
        if (removeRules.length > 0) {
            for (int i=0; i< removeRules.length; i++) {
                sb.append(removeRules[i]).append(',');
            }
            command.add("-d", sb.toString());
        }

        sb = new StringBuilder();
        if (statsRules.length > 0) {
            for (int i=0; i< statsRules.length; i++) {
                sb.append(statsRules[i]).append(',');
            }
            command.add("-s", sb.toString());
        }
       
        return command.execute();
    }
View Full Code Here

            return new Answer(cmd);
        }
    }

    protected synchronized Answer execute (final DhcpEntryCommand cmd) {
        final Script command  = new Script(_dhcpEntryPath, _timeout, s_logger);
        command.add("-r", cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP));
        command.add("-v", cmd.getVmIpAddress());
        command.add("-m", cmd.getVmMac());
        command.add("-n", cmd.getVmName());
       
        if (cmd.getDefaultRouter() != null) {
            command.add("-d", cmd.getDefaultRouter());
        }
        if (cmd.getStaticRoutes() != null) {
          command.add("-s", cmd.getStaticRoutes());
        }
       
        if (cmd.getDefaultDns() != null) {
          command.add("-N", cmd.getDefaultDns());
        }

        final String result = command.execute();
        return new Answer(cmd, result==null, result);
    }
View Full Code Here

        return routerProxyWithParser("checkrouter.sh", routerIP, null);
    }
   
   
    public String routerProxyWithParser(String script, String routerIP, String args) {
        final Script command  = new Script(_routerProxyPath, _timeout, s_logger);
        final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser();
        command.add(script);
        command.add(routerIP);
        if ( args != null ) {
            command.add(args);
        }
        String result = command.execute(parser);
        if (result == null) {
            return parser.getLine();
        }
        return null;
    }
View Full Code Here

        }
        return new CheckS2SVpnConnectionsAnswer(cmd, true, result);
    }
   
    public String routerProxy(String script, String routerIP, String args) {
        final Script command  = new Script(_routerProxyPath, _timeout, s_logger);
        command.add(script);
        command.add(routerIP);
        if ( args != null ) {
            command.add(args);
        }
        return command.execute();
    }
View Full Code Here

        return new CheckRouterAnswer(cmd, result, true);
    }

    protected Answer execute(BumpUpPriorityCommand cmd) {
        final String routerPrivateIPAddress = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
        final Script command  = new Script(_bumpUpPriorityPath, _timeout, s_logger);
        final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser();
        command.add(routerPrivateIPAddress);
        String result = command.execute(parser);
        if (result != null) {
            return new Answer(cmd, false, "BumpUpPriorityCommand failed: " + result);
        }
        return new Answer(cmd, true, null);
    }
View Full Code Here

TOP

Related Classes of com.cloud.utils.script.Script

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.