Search in sources :

Example 1 with ConsoleProxyLoadAnswer

use of com.cloud.agent.api.proxy.ConsoleProxyLoadAnswer in project cloudstack by apache.

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.agent.api.proxy.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.agent.api.proxy.ConsoleProxyLoadAnswer in project cloudstack by apache.

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.agent.api.proxy.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.agent.api.proxy.ConsoleProxyLoadAnswer in project CloudStack-archive by CloudStack-extras.

the class LibvirtComputingResource 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));
        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.agent.api.proxy.ConsoleProxyLoadAnswer) InputStreamReader(java.io.InputStreamReader) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) URL(java.net.URL) URLConnection(java.net.URLConnection)

Example 4 with ConsoleProxyLoadAnswer

use of com.cloud.agent.api.proxy.ConsoleProxyLoadAnswer in project CloudStack-archive by CloudStack-extras.

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));
        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.agent.api.proxy.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 5 with ConsoleProxyLoadAnswer

use of com.cloud.agent.api.proxy.ConsoleProxyLoadAnswer in project cloudstack by apache.

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.agent.api.proxy.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.agent.api.proxy.ConsoleProxyLoadAnswer)5 BufferedReader (java.io.BufferedReader)5 IOException (java.io.IOException)5 InputStream (java.io.InputStream)5 InputStreamReader (java.io.InputStreamReader)5 URL (java.net.URL)5 URLConnection (java.net.URLConnection)5 FileInputStream (java.io.FileInputStream)1