You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bf...@apache.org on 2013/02/13 23:04:21 UTC

[20/50] [abbrv] Moved console-proxy into services

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/4869f0ca/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/AbstractRect.java
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/AbstractRect.java b/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/AbstractRect.java
new file mode 100644
index 0000000..a380e9c
--- /dev/null
+++ b/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/AbstractRect.java
@@ -0,0 +1,53 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.consoleproxy.vnc.packet.server;
+
+public abstract class AbstractRect implements Rect {
+
+    protected final int x;
+    protected final int y;
+    protected final int width;
+    protected final int height;
+
+    public AbstractRect(int x, int y, int width, int height) {
+        this.x = x;
+        this.y = y;
+        this.width = width;
+        this.height = height;
+    }
+
+    @Override
+    public int getX() {
+        return x;
+    }
+
+    @Override
+    public int getY() {
+        return y;
+    }
+
+    @Override
+    public int getWidth() {
+        return width;
+    }
+
+    @Override
+    public int getHeight() {
+        return height;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/4869f0ca/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/CopyRect.java
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/CopyRect.java b/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/CopyRect.java
new file mode 100644
index 0000000..caaecb5
--- /dev/null
+++ b/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/CopyRect.java
@@ -0,0 +1,39 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.consoleproxy.vnc.packet.server;
+
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.io.DataInputStream;
+import java.io.IOException;
+
+public class CopyRect extends AbstractRect {
+
+    private final int srcX, srcY;
+
+    public CopyRect(int x, int y, int width, int height, DataInputStream is) throws IOException {
+        super(x, y, width, height);
+
+        srcX = is.readUnsignedShort();
+        srcY = is.readUnsignedShort();
+    }
+
+    @Override
+    public void paint(BufferedImage image, Graphics2D graphics) {
+        graphics.copyArea(srcX, srcY, width, height, x - srcX, y - srcY);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/4869f0ca/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/FrameBufferSizeChangeRequest.java
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/FrameBufferSizeChangeRequest.java b/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/FrameBufferSizeChangeRequest.java
new file mode 100644
index 0000000..18f6987
--- /dev/null
+++ b/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/FrameBufferSizeChangeRequest.java
@@ -0,0 +1,39 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.consoleproxy.vnc.packet.server;
+
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+
+import com.cloud.consoleproxy.vnc.BufferedImageCanvas;
+
+public class FrameBufferSizeChangeRequest extends AbstractRect {
+
+    private final BufferedImageCanvas canvas;
+
+    public FrameBufferSizeChangeRequest(BufferedImageCanvas canvas, int width, int height) {
+        super(0, 0, width, height);
+        this.canvas = canvas;
+        canvas.setCanvasSize(width, height);
+    }
+
+    @Override
+    public void paint(BufferedImage offlineImage, Graphics2D graphics) {
+        canvas.setCanvasSize(width, height);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/4869f0ca/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/FramebufferUpdatePacket.java
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/FramebufferUpdatePacket.java b/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/FramebufferUpdatePacket.java
new file mode 100644
index 0000000..3bc43fd
--- /dev/null
+++ b/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/FramebufferUpdatePacket.java
@@ -0,0 +1,102 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.consoleproxy.vnc.packet.server;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+
+import com.cloud.consoleproxy.ConsoleProxyClientListener;
+import com.cloud.consoleproxy.vnc.BufferedImageCanvas;
+import com.cloud.consoleproxy.vnc.RfbConstants;
+import com.cloud.consoleproxy.vnc.VncScreenDescription;
+import com.cloud.consoleproxy.vnc.packet.server.CopyRect;
+import com.cloud.consoleproxy.vnc.packet.server.RawRect;
+import com.cloud.consoleproxy.vnc.packet.server.Rect;
+
+public class FramebufferUpdatePacket {
+
+    private final VncScreenDescription screen;
+    private final BufferedImageCanvas canvas;
+    private final ConsoleProxyClientListener clientListener;
+
+    public FramebufferUpdatePacket(BufferedImageCanvas canvas, VncScreenDescription screen, DataInputStream is, ConsoleProxyClientListener clientListener) throws IOException {
+
+        this.screen = screen;
+        this.canvas = canvas;
+        this.clientListener = clientListener;
+        readPacketData(is);
+    }
+
+    private void readPacketData(DataInputStream is) throws IOException {
+        is.skipBytes(1);// Skip padding
+
+        // Read number of rectangles
+        int numberOfRectangles = is.readUnsignedShort();
+
+        // For all rectangles
+        for (int i = 0; i < numberOfRectangles; i++) {
+
+            // Read coordinate of rectangle
+            int x = is.readUnsignedShort();
+            int y = is.readUnsignedShort();
+            int width = is.readUnsignedShort();
+            int height = is.readUnsignedShort();
+
+            int encodingType = is.readInt();
+
+            // Process rectangle
+            Rect rect;
+            switch (encodingType) {
+
+            case RfbConstants.ENCODING_RAW: {
+                rect = new RawRect(screen, x, y, width, height, is);
+                break;
+            }
+
+            case RfbConstants.ENCODING_COPY_RECT: {
+                rect = new CopyRect(x, y, width, height, is);
+                break;
+            }
+
+            case RfbConstants.ENCODING_DESKTOP_SIZE: {
+                rect = new FrameBufferSizeChangeRequest(canvas, width, height);
+                if (this.clientListener != null)
+                    this.clientListener.onFramebufferSizeChange(width, height);
+                break;
+            }
+
+            default:
+                throw new RuntimeException("Unsupported ecnoding: " + encodingType);
+            }
+
+            paint(rect, canvas);
+
+            if (this.clientListener != null)
+                this.clientListener.onFramebufferUpdate(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
+        }
+
+    }
+
+    public void paint(Rect rect, BufferedImageCanvas canvas) {
+        // Draw rectangle on offline buffer
+        rect.paint(canvas.getOfflineImage(), canvas.getOfflineGraphics());
+
+        // Request update of repainted area
+        canvas.repaint(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/4869f0ca/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/RawRect.java
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/RawRect.java b/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/RawRect.java
new file mode 100644
index 0000000..978a4c2
--- /dev/null
+++ b/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/RawRect.java
@@ -0,0 +1,75 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.consoleproxy.vnc.packet.server;
+
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferInt;
+import java.io.DataInputStream;
+import java.io.IOException;
+
+import com.cloud.consoleproxy.vnc.VncScreenDescription;
+
+public class RawRect extends AbstractRect {
+    private final int[] buf;
+
+    public RawRect(VncScreenDescription screen, int x, int y, int width, int height, DataInputStream is) throws IOException {
+        super(x, y, width, height);
+
+        byte[] bbuf = new byte[width * height * screen.getBytesPerPixel()];
+        is.readFully(bbuf);
+
+        // Convert array of bytes to array of int
+        int size = width * height;
+        buf = new int[size];
+        for (int i = 0, j = 0; i < size; i++, j += 4) {
+            buf[i] = (bbuf[j + 0] & 0xFF) | ((bbuf[j + 1] & 0xFF) << 8) | ((bbuf[j + 2] & 0xFF) << 16) | ((bbuf[j + 3] & 0xFF) << 24);
+        }
+
+    }
+
+    @Override
+    public void paint(BufferedImage image, Graphics2D graphics) {
+
+        DataBuffer dataBuf = image.getRaster().getDataBuffer();
+
+        switch (dataBuf.getDataType()) {
+
+        case DataBuffer.TYPE_INT: {
+            // We chose RGB888 model, so Raster will use DataBufferInt type
+            DataBufferInt dataBuffer = (DataBufferInt) dataBuf;
+
+            int imageWidth = image.getWidth();
+            int imageHeight = image.getHeight();
+
+            // Paint rectangle directly on buffer, line by line
+            int[] imageBuffer = dataBuffer.getData();
+            for (int srcLine = 0, dstLine = y; srcLine < height && dstLine < imageHeight; srcLine++, dstLine++) {
+                try {
+                    System.arraycopy(buf, srcLine * width, imageBuffer, x + dstLine * imageWidth, width);
+                } catch (IndexOutOfBoundsException e) {
+                }
+            }
+            break;
+        }
+
+        default:
+            throw new RuntimeException("Unsupported data buffer in buffered image: expected data buffer of type int (DataBufferInt). Actual data buffer type: " + dataBuf.getClass().getSimpleName());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/4869f0ca/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/Rect.java
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/Rect.java b/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/Rect.java
new file mode 100644
index 0000000..51edf12
--- /dev/null
+++ b/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/Rect.java
@@ -0,0 +1,33 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.consoleproxy.vnc.packet.server;
+
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+
+public interface Rect {
+
+    void paint(BufferedImage offlineImage, Graphics2D graphics);
+
+    int getX();
+
+    int getY();
+
+    int getWidth();
+
+    int getHeight();
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/4869f0ca/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/ServerCutText.java
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/ServerCutText.java b/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/ServerCutText.java
new file mode 100644
index 0000000..044f958
--- /dev/null
+++ b/services/console-proxy/server/src/com/cloud/consoleproxy/vnc/packet/server/ServerCutText.java
@@ -0,0 +1,49 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.consoleproxy.vnc.packet.server;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+
+import com.cloud.consoleproxy.util.Logger;
+import com.cloud.consoleproxy.vnc.RfbConstants;
+
+public class ServerCutText {
+    private static final Logger s_logger = Logger.getLogger(ServerCutText.class);
+
+    private String content;
+
+    public String getContent() {
+        return content;
+    }
+
+    public ServerCutText(DataInputStream is) throws IOException {
+        readPacketData(is);
+    }
+
+    private void readPacketData(DataInputStream is) throws IOException {
+        is.skipBytes(3);// Skip padding
+        int length = is.readInt();
+        byte buf[] = new byte[length];
+        is.readFully(buf);
+
+        content = new String(buf, RfbConstants.CHARSET);
+
+        /* LOG */s_logger.info("Clippboard content: " + content);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/4869f0ca/services/console-proxy/server/systemvm-descriptor.xml
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/systemvm-descriptor.xml b/services/console-proxy/server/systemvm-descriptor.xml
new file mode 100644
index 0000000..7efe7fd
--- /dev/null
+++ b/services/console-proxy/server/systemvm-descriptor.xml
@@ -0,0 +1,113 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+  <id>systemvm</id>
+  <formats>
+    <format>zip</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <dependencySets>
+    <dependencySet>
+      <outputDirectory></outputDirectory>
+    </dependencySet>
+  </dependencySets>
+  <fileSets>
+    <fileSet>
+      <directory>../scripts/storage/secondary/</directory>
+      <outputDirectory>scripts/storage/secondary</outputDirectory>
+      <directoryMode>555</directoryMode>
+      <fileMode>555</fileMode>
+    </fileSet>
+    <fileSet>
+      <directory>../scripts/storage/secondary/</directory>
+      <outputDirectory>scripts/storage/secondary</outputDirectory>
+      <directoryMode>555</directoryMode>
+      <fileMode>555</fileMode>
+    </fileSet>
+    <fileSet>
+      <directory>scripts</directory>
+      <outputDirectory></outputDirectory>
+      <directoryMode>555</directoryMode>
+      <fileMode>555</fileMode>
+    </fileSet>
+    <fileSet>
+      <directory>conf</directory>
+      <outputDirectory>conf</outputDirectory>
+      <directoryMode>555</directoryMode>
+      <fileMode>555</fileMode>
+      <includes>
+        <include>log4j-cloud.xml</include>
+	<include>consoleproxy.properties</include>
+	<include>agent.properties</include>
+      </includes>
+    </fileSet>
+    <fileSet>
+      <directory>../console-proxy/images</directory>
+      <outputDirectory>images</outputDirectory>
+      <directoryMode>555</directoryMode>
+      <fileMode>555</fileMode>
+      <includes>
+        <include>*.jpg</include>
+	<include>*.gif</include>
+        <include>*.png</include>
+        <include>*.cur</include>
+      </includes>
+    </fileSet>
+    <fileSet>
+      <directory>../console-proxy/js</directory>
+      <outputDirectory>js</outputDirectory>
+      <directoryMode>555</directoryMode>
+      <fileMode>555</fileMode>
+      <includes>
+        <include>*.js</include>
+      </includes>
+    </fileSet>
+    <fileSet>
+      <directory>../console-proxy/ui</directory>
+      <outputDirectory>ui</outputDirectory>
+      <directoryMode>555</directoryMode>
+      <fileMode>555</fileMode>
+      <includes>
+        <include>*.ftl</include>
+      </includes>
+    </fileSet>
+    <fileSet>
+      <directory>../console-proxy/css</directory>
+      <outputDirectory>css</outputDirectory>
+      <directoryMode>555</directoryMode>
+      <fileMode>555</fileMode>
+      <includes>
+        <include>*.css</include>
+      </includes>
+    </fileSet>
+    <fileSet>
+      <directory>../console-proxy/certs</directory>
+      <outputDirectory>certs</outputDirectory>
+      <directoryMode>555</directoryMode>
+      <fileMode>555</fileMode>
+      <includes>
+        <include>*.keystore</include>
+        <include>*.crt</include>
+        <include>*.key</include>
+      </includes>
+    </fileSet>
+  </fileSets>
+</assembly>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/4869f0ca/services/console-proxy/server/ui/viewer-bad-sid.ftl
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/ui/viewer-bad-sid.ftl b/services/console-proxy/server/ui/viewer-bad-sid.ftl
new file mode 100644
index 0000000..2f30ec3
--- /dev/null
+++ b/services/console-proxy/server/ui/viewer-bad-sid.ftl
@@ -0,0 +1,29 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+ 
+  http://www.apache.org/licenses/LICENSE-2.0
+    
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<html>
+<head>
+</head>
+<body>
+
+<div id="main_panel" tabindex="1">
+<p>Unable to start console session as access is denied because of bad sid</p>
+</div>
+
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/4869f0ca/services/console-proxy/server/ui/viewer-connect-failed.ftl
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/ui/viewer-connect-failed.ftl b/services/console-proxy/server/ui/viewer-connect-failed.ftl
new file mode 100644
index 0000000..9d907ca
--- /dev/null
+++ b/services/console-proxy/server/ui/viewer-connect-failed.ftl
@@ -0,0 +1,29 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+ 
+  http://www.apache.org/licenses/LICENSE-2.0
+    
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<html>
+<head>
+</head>
+<body>
+
+<div id="main_panel" tabindex="1">
+<p>Unable to start console session as connection is refused by the machine you are accessing</p>
+</div>
+
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/4869f0ca/services/console-proxy/server/ui/viewer-update.ftl
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/ui/viewer-update.ftl b/services/console-proxy/server/ui/viewer-update.ftl
new file mode 100644
index 0000000..6bf9ab3
--- /dev/null
+++ b/services/console-proxy/server/ui/viewer-update.ftl
@@ -0,0 +1,24 @@
+<#--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+tileMap = [ ${tileSequence} ];
+<#if resized == true>
+	ajaxViewer.resize('main_panel', ${width}, ${height}, ${tileWidth}, ${tileHeight}); 
+</#if>
+ajaxViewer.refresh('${imgUrl}', tileMap, false);
+ 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/4869f0ca/services/console-proxy/server/ui/viewer.ftl
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/ui/viewer.ftl b/services/console-proxy/server/ui/viewer.ftl
new file mode 100644
index 0000000..62de193
--- /dev/null
+++ b/services/console-proxy/server/ui/viewer.ftl
@@ -0,0 +1,60 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+ 
+  http://www.apache.org/licenses/LICENSE-2.0
+    
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<html>
+<head>
+<script type="text/javascript" language="javascript" src="/resource/js/jquery.js"></script>
+<script type="text/javascript" language="javascript" src="/resource/js/ajaxviewer.js"></script>
+<script type="text/javascript" language="javascript" src="/resource/js/ajaxkeys.js"></script>
+<script type="text/javascript" language="javascript" src="/resource/js/handler.js"></script>
+<link rel="stylesheet" type="text/css" href="/resource/css/ajaxviewer.css"></link>
+<title>${title}</title>
+</head>
+<body>
+<div id="toolbar">
+<ul>
+	<li> 
+		<a href="#" onclick="javascript:sendCtrlAltDel();"> 
+			<span><img align="left" src="/resource/images/cad.gif" alt="Ctrl-Alt-Del" />Ctrl-Alt-Del</span> 
+		</a> 
+	</li>
+	<li> 
+		<a href="#" onclick="javascript:sendCtrlEsc();"> 
+			<span><img align="left" src="/resource/images/winlog.png" alt="Ctrl-Esc" style="width:16px;height:16px"/>Ctrl-Esc</span> 
+		</a> 
+	</li>
+</ul>
+<span id="light" class="dark"></span> 
+</div>
+
+<div id="main_panel" tabindex="1"></div>
+	
+<script language="javascript">
+
+var tileMap = [ ${tileSequence} ];
+var ajaxViewer = new AjaxViewer('main_panel', '${imgUrl}', '${updateUrl}', tileMap, 
+	${width}, ${height}, ${tileWidth}, ${tileHeight}, ${rawKeyboard});
+
+$(function() {
+	ajaxViewer.start();
+});
+
+</script>
+
+</body>
+</html>	

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/4869f0ca/services/console-proxy/server/vm-script/vmops
----------------------------------------------------------------------
diff --git a/services/console-proxy/server/vm-script/vmops b/services/console-proxy/server/vm-script/vmops
new file mode 100644
index 0000000..a9f70c8
--- /dev/null
+++ b/services/console-proxy/server/vm-script/vmops
@@ -0,0 +1,119 @@
+#!/bin/bash
+#
+# vmops		Script to start and stop the VMOps Agent.
+#
+# Author:       Chiradeep Vittal <ch...@vmops.com>
+# chkconfig: 2345 99 01
+# description: 	Start up the VMOps agent
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+# Source function library.
+if [ -f /etc/init.d/functions ]
+then
+  . /etc/init.d/functions
+fi
+
+_success() {
+  if [ -f /etc/init.d/functions ]
+  then
+    success
+  else
+    echo "Success"
+  fi
+}
+
+_failure() {
+  if [ -f /etc/init.d/functions ]
+  then
+    failure
+  else
+    echo "Failed"
+  fi
+}
+RETVAL=$?
+VMOPS_HOME="/usr/local/vmops"
+
+mkdir -p /var/log/vmops
+
+get_pids() {
+  local i
+  for i in $(ps -ef| grep java | grep -v grep | awk '{print $2}'); 
+  do 
+    echo $(pwdx $i) | grep "$VMOPS_HOME" | grep -i console | awk -F: '{print $1}'; 
+  done
+}
+
+start() {
+   local pid=$(get_pids)
+   echo -n "Starting VMOps Console Proxy: "
+   if [ -f $VMOPS_HOME/consoleproxy/run.sh ];
+   then
+     if [ "$pid" == "" ]
+     then
+       (cd $VMOPS_HOME/consoleproxy; nohup ./run.sh > /var/log/vmops/vmops.out 2>&1 & )
+       pid=$(get_pids)
+       echo $pid > /var/run/vmops.pid 
+     fi
+     _success
+   else
+     _failure
+   fi
+   echo
+}
+
+stop() {
+  local pid
+  echo -n  "Stopping VMOps agent: "
+  for pid in $(get_pids)
+  do
+    kill $pid
+  done
+  _success
+  echo
+}
+
+status() {
+  local pids=$(get_pids)
+  if [ "$pids" == "" ]
+  then
+    echo "VMOps agent is not running"
+    return 1
+  fi
+  echo "VMOps agent is running: process id: $pids"
+  return 0
+}
+
+
+case "$1" in
+   start) start
+	  ;;
+    stop) stop
+ 	  ;;
+    status) status
+ 	  ;;
+ restart) stop
+          start
+ 	  ;;
+       *) echo $"Usage: $0 {start|stop|status|restart}"
+	  exit 1
+	  ;;
+esac
+
+exit $RETVAL

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/4869f0ca/services/pom.xml
----------------------------------------------------------------------
diff --git a/services/pom.xml b/services/pom.xml
new file mode 100644
index 0000000..2648851
--- /dev/null
+++ b/services/pom.xml
@@ -0,0 +1,36 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>cloud-services</artifactId>
+  <name>Apache CloudStack Cloud Services</name>
+  <packaging>pom</packaging>
+  <parent>
+    <groupId>org.apache.cloudstack</groupId>
+    <artifactId>cloudstack</artifactId>
+    <version>4.1.0-SNAPSHOT</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+  <build>
+    <defaultGoal>install</defaultGoal>
+  </build>
+  <modules>
+    <module>console-proxy</module>
+  </modules>
+</project>