Search in sources :

Example 1 with ConsoleProxyLoadAnswer

use of com.cloud.legacymodel.communication.answer.ConsoleProxyLoadAnswer in project cosmic by MissionCriticalCloud.

the class ConsoleProxyResource method executeProxyLoadScan.

private Answer executeProxyLoadScan(final Command cmd, final long proxyVmId, final String proxyVmName, final String proxyManagementIp, final int cmdPort) {
    String result = null;
    final StringBuffer sb = new StringBuffer();
    sb.append("http://").append(proxyManagementIp).append(":" + cmdPort).append("/cmd/getstatus");
    boolean success = true;
    try {
        final URL url = new URL(sb.toString());
        final URLConnection conn = url.openConnection();
        final InputStream is = conn.getInputStream();
        final BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
        final StringBuilder sb2 = new StringBuilder();
        String line = null;
        try {
            while ((line = reader.readLine()) != null) {
                sb2.append(line + "\n");
            }
            result = sb2.toString();
        } catch (final IOException e) {
            success = false;
        } finally {
            try {
                is.close();
            } catch (final IOException e) {
                s_logger.warn("Exception when closing , console proxy address : " + proxyManagementIp);
                success = false;
            }
        }
    } catch (final IOException e) {
        s_logger.warn("Unable to open console proxy command port url, console proxy address : " + proxyManagementIp);
        success = false;
    }
    return new ConsoleProxyLoadAnswer(cmd, proxyVmId, proxyVmName, success, result);
}
Also used : ConsoleProxyLoadAnswer(com.cloud.legacymodel.communication.answer.ConsoleProxyLoadAnswer) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) URL(java.net.URL) URLConnection(java.net.URLConnection)

Example 2 with ConsoleProxyLoadAnswer

use of com.cloud.legacymodel.communication.answer.ConsoleProxyLoadAnswer in project cosmic by MissionCriticalCloud.

the class LibvirtConsoleProxyLoadCommandWrapper method executeProxyLoadScan.

public Answer executeProxyLoadScan(final Command cmd, final long proxyVmId, final String proxyVmName, final String proxyManagementIp, final int cmdPort) {
    String result = null;
    final StringBuffer sb = new StringBuffer();
    sb.append("http://").append(proxyManagementIp).append(":" + cmdPort).append("/cmd/getstatus");
    boolean success = true;
    try {
        final URL url = new URL(sb.toString());
        final URLConnection conn = url.openConnection();
        final InputStream is = conn.getInputStream();
        final BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
        final StringBuilder sb2 = new StringBuilder();
        String line = null;
        try {
            while ((line = reader.readLine()) != null) {
                sb2.append(line + "\n");
            }
            result = sb2.toString();
        } catch (final IOException e) {
            success = false;
        } finally {
            try {
                is.close();
            } catch (final IOException e) {
                s_logger.warn("Exception when closing , console proxy address : " + proxyManagementIp);
                success = false;
            }
        }
    } catch (final IOException e) {
        s_logger.warn("Unable to open console proxy command port url, console proxy address : " + proxyManagementIp);
        success = false;
    }
    return new ConsoleProxyLoadAnswer(cmd, proxyVmId, proxyVmName, success, result);
}
Also used : ConsoleProxyLoadAnswer(com.cloud.legacymodel.communication.answer.ConsoleProxyLoadAnswer) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) URL(java.net.URL) URLConnection(java.net.URLConnection)

Example 3 with ConsoleProxyLoadAnswer

use of com.cloud.legacymodel.communication.answer.ConsoleProxyLoadAnswer in project cosmic by MissionCriticalCloud.

the class CitrixConsoleProxyLoadCommandWrapper method executeProxyLoadScan.

protected Answer executeProxyLoadScan(final Command cmd, final long proxyVmId, final String proxyVmName, final String proxyManagementIp, final int cmdPort) {
    String result = null;
    final StringBuffer sb = new StringBuffer();
    sb.append("http://").append(proxyManagementIp).append(":" + cmdPort).append("/cmd/getstatus");
    boolean success = true;
    try {
        final URL url = new URL(sb.toString());
        final URLConnection conn = url.openConnection();
        // setting TIMEOUTs to avoid possible waiting until death situations
        conn.setConnectTimeout(5000);
        conn.setReadTimeout(5000);
        final InputStream is = conn.getInputStream();
        final BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
        final StringBuilder sb2 = new StringBuilder();
        String line = null;
        try {
            while ((line = reader.readLine()) != null) {
                sb2.append(line + "\n");
            }
            result = sb2.toString();
        } catch (final IOException e) {
            success = false;
        } finally {
            try {
                is.close();
            } catch (final IOException e) {
                s_logger.warn("Exception when closing , console proxy address : " + proxyManagementIp);
                success = false;
            }
        }
    } catch (final IOException e) {
        s_logger.warn("Unable to open console proxy command port url, console proxy address : " + proxyManagementIp);
        success = false;
    }
    return new ConsoleProxyLoadAnswer(cmd, proxyVmId, proxyVmName, success, result);
}
Also used : ConsoleProxyLoadAnswer(com.cloud.legacymodel.communication.answer.ConsoleProxyLoadAnswer) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) URL(java.net.URL) URLConnection(java.net.URLConnection)

Aggregations

ConsoleProxyLoadAnswer (com.cloud.legacymodel.communication.answer.ConsoleProxyLoadAnswer)3 BufferedReader (java.io.BufferedReader)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 InputStreamReader (java.io.InputStreamReader)3 URL (java.net.URL)3 URLConnection (java.net.URLConnection)3