Search in sources :

Example 11 with ExecutionResult

use of com.cloud.legacymodel.ExecutionResult in project cosmic by MissionCriticalCloud.

the class LibvirtComputingResource method createFileInVR.

@Override
public ExecutionResult createFileInVR(final String routerIp, final String path, final String filename, final String content) {
    final File permKey = new File("/root/.ssh/id_rsa.cloud");
    String error = null;
    logger.debug("Creating file in VR " + filename);
    try {
        SshHelper.scpTo(routerIp, 3922, "root", permKey, null, path, content.getBytes(), filename, null);
    } catch (final Exception e) {
        logger.warn("Fail to create file " + path + filename + " in VR " + routerIp, e);
        error = e.getMessage();
    }
    return new ExecutionResult(error == null, error);
}
Also used : ExecutionResult(com.cloud.legacymodel.ExecutionResult) File(java.io.File) InternalErrorException(com.cloud.legacymodel.exceptions.InternalErrorException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) LibvirtException(org.libvirt.LibvirtException) SAXException(org.xml.sax.SAXException) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 12 with ExecutionResult

use of com.cloud.legacymodel.ExecutionResult in project cosmic by MissionCriticalCloud.

the class LibvirtComputingResource method executeInVR.

@Override
public ExecutionResult executeInVR(final String routerIp, final String script, final String args, final int timeout) {
    final Script command = new Script(this.routerProxyPath, timeout * 1000, logger);
    final AllLinesParser parser = new AllLinesParser();
    command.add(script);
    command.add(routerIp);
    if (args != null) {
        command.add(args);
    }
    String details = command.execute(parser);
    if (details == null) {
        details = parser.getLines().trim();
    }
    logger.debug("Executing script in VR " + script);
    return new ExecutionResult(command.getExitValue() == 0, details);
}
Also used : Script(com.cloud.utils.script.Script) AllLinesParser(com.cloud.utils.script.OutputInterpreter.AllLinesParser) ExecutionResult(com.cloud.legacymodel.ExecutionResult)

Example 13 with ExecutionResult

use of com.cloud.legacymodel.ExecutionResult in project cosmic by MissionCriticalCloud.

the class CitrixResourceBase method createFileInVR.

@Override
public ExecutionResult createFileInVR(final String routerIp, final String path, final String filename, final String content) {
    final Connection conn = getConnection();
    final String hostPath = "/tmp/";
    s_logger.debug("Copying VR with ip " + routerIp + " config file into host " + this._host.getIp());
    try {
        SshHelper.scpTo(this._host.getIp(), 22, this._username, null, this._password.peek(), hostPath, content.getBytes(Charset.defaultCharset()), filename, null);
    } catch (final Exception e) {
        s_logger.warn("scp VR config file into host " + this._host.getIp() + " failed with exception " + e.getMessage().toString());
    }
    final String rc = callHostPlugin(conn, "vmops", "createFileInDomr", "domrip", routerIp, "srcfilepath", hostPath + filename, "dstfilepath", path);
    s_logger.debug("VR Config file " + filename + " got created in VR, ip " + routerIp + " with content \n" + content);
    return new ExecutionResult(rc.startsWith("succ#"), rc.substring(5));
}
Also used : Connection(com.xensource.xenapi.Connection) URLConnection(java.net.URLConnection) ExecutionResult(com.cloud.legacymodel.ExecutionResult) XenAPIException(com.xensource.xenapi.Types.XenAPIException) XmlRpcException(org.apache.xmlrpc.XmlRpcException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) TimeoutException(java.util.concurrent.TimeoutException) SAXException(org.xml.sax.SAXException) ConfigurationException(javax.naming.ConfigurationException) MalformedURLException(java.net.MalformedURLException) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Aggregations

ExecutionResult (com.cloud.legacymodel.ExecutionResult)13 Answer (com.cloud.legacymodel.communication.answer.Answer)4 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)4 IOException (java.io.IOException)4 URISyntaxException (java.net.URISyntaxException)4 ConfigurationException (javax.naming.ConfigurationException)4 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)4 SAXException (org.xml.sax.SAXException)4 CheckS2SVpnConnectionsAnswer (com.cloud.legacymodel.communication.answer.CheckS2SVpnConnectionsAnswer)3 GetDomRVersionAnswer (com.cloud.legacymodel.communication.answer.GetDomRVersionAnswer)3 XenAPIException (com.xensource.xenapi.Types.XenAPIException)3 MalformedURLException (java.net.MalformedURLException)3 TimeoutException (java.util.concurrent.TimeoutException)3 XmlRpcException (org.apache.xmlrpc.XmlRpcException)3 CheckRouterAnswer (com.cloud.legacymodel.communication.answer.CheckRouterAnswer)2 GroupAnswer (com.cloud.legacymodel.communication.answer.GroupAnswer)2 NetworkUsageCommand (com.cloud.legacymodel.communication.command.NetworkUsageCommand)2 Connection (com.xensource.xenapi.Connection)2 URLConnection (java.net.URLConnection)2 Test (org.junit.Test)2