cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [28/30] git commit: add console proxy support for devcloud
Date Fri, 06 Jul 2012 19:03:39 GMT
add console proxy support for devcloud


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/27e9cdbe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/27e9cdbe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/27e9cdbe

Branch: refs/heads/vpc
Commit: 27e9cdbece932bae9a68d5ec28bf2941f4fc7545
Parents: 1f8e994
Author: Edison Su <sudison@gmail.com>
Authored: Tue Jul 3 23:38:24 2012 -0700
Committer: Edison Su <sudison@gmail.com>
Committed: Tue Jul 3 23:38:39 2012 -0700

----------------------------------------------------------------------
 build/build-devcloud.xml                           |    6 ++-
 .../hypervisor/xen/resource/XcpOssResource.java    |   39 +++++++++++++++
 scripts/vm/hypervisor/xenserver/xcposs/vmops       |   15 +++++-
 .../consoleproxy/ConsoleProxyManagerImpl.java      |   15 +++++-
 .../secondary/SecondaryStorageManagerImpl.java     |    2 +-
 setup/db/deploy-db-clouddev.sh                     |   20 ++++++++
 6 files changed, 91 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/27e9cdbe/build/build-devcloud.xml
----------------------------------------------------------------------
diff --git a/build/build-devcloud.xml b/build/build-devcloud.xml
index 06bdf69..5b7bcdb 100644
--- a/build/build-devcloud.xml
+++ b/build/build-devcloud.xml
@@ -35,12 +35,14 @@
 
   <target name="rdeploydb">
     <echo message="ant rdeploydb"/>
-    <sshexec host="${host}" port="${port}" username="root" password="password" command="echo
$CATALINA_HOME; export CATALINA_HOME=/opt/cloudstack/apache-tomcat-6.0.32;killall java;cd
/opt/cloudstack/incubator-cloudstack;ant deploycddb"/>
+    <sshexec host="${host}" port="${port}" username="root" password="password" command="echo
$CATALINA_HOME; export CATALINA_HOME=/opt/cloudstack/apache-tomcat-6.0.32;killall java;cd
/opt/cloudstack/incubator-cloudstack;ant deploycddb -Drhost=${host}"/>
   </target>
 
   <target name="deploycddb" description="deploy specific db configuration for clouddev"
depends="deploydb">
     <exec dir="${db.scripts.dir}" executable="bash">
       <arg value="deploy-db-clouddev.sh" />
+      <arg value="${host}" />
+      <arg value="8443" />
     </exec>
   </target>
 
@@ -51,7 +53,7 @@
   
   <target name="rdebug">
     <echo message="ant debug"/>
-    <sshexec host="${host}" port="${port}" username="root" password="password" command="killall
java;sleep 1;echo $CATALINA_HOME; export CATALINA_HOME=/opt/cloudstack/apache-tomcat-6.0.32;cd
/opt/cloudstack/incubator-cloudstack;ant deploy-server; ant debug"/>
+    <sshexec host="${host}" port="${port}" username="root" password="password" command="killall
java;sleep 1;export CATALINA_HOME=/opt/cloudstack/apache-tomcat-6.0.32;cd /opt/cloudstack/incubator-cloudstack;ant
deploy-server; ant debug "/>
   </target>
 
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/27e9cdbe/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpOssResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpOssResource.java
b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpOssResource.java
index ef44f5e..d4260c7 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpOssResource.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpOssResource.java
@@ -31,10 +31,18 @@ import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.Command;
 import com.cloud.agent.api.NetworkUsageAnswer;
 import com.cloud.agent.api.NetworkUsageCommand;
+import com.cloud.agent.api.StartAnswer;
+import com.cloud.agent.api.StartCommand;
 import com.cloud.agent.api.StartupRoutingCommand;
+import com.cloud.agent.api.StopAnswer;
+import com.cloud.agent.api.StopCommand;
+import com.cloud.agent.api.to.NicTO;
+import com.cloud.agent.api.to.VirtualMachineTO;
+import com.cloud.network.Networks.TrafficType;
 import com.cloud.resource.ServerResource;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.script.Script;
+import com.cloud.vm.VirtualMachine;
 import com.xensource.xenapi.Connection;
 import com.xensource.xenapi.Types;
 import com.xensource.xenapi.VBD;
@@ -124,4 +132,35 @@ public class XcpOssResource extends CitrixResourceBase {
             return super.executeRequest(cmd);
         }
     }
+    
+    @Override
+    public StartAnswer execute(StartCommand cmd) {
+    	StartAnswer answer = super.execute(cmd);
+    	
+    	VirtualMachineTO vmSpec = cmd.getVirtualMachine();
+    	if (vmSpec.getType() == VirtualMachine.Type.ConsoleProxy) {
+    		Connection conn = getConnection();
+    		String publicIp = null;
+    		for (NicTO nic : vmSpec.getNics()) {
+    			if (nic.getType() == TrafficType.Guest) {
+    				publicIp = nic.getIp();
+    			}
+    		}
+    		callHostPlugin(conn, "vmops", "setDNATRule", "ip", publicIp, "port", "8443", "add",
"true");
+    	}
+    	
+    	return answer;
+    }
+    
+    @Override
+    public StopAnswer execute(StopCommand cmd) {
+    	StopAnswer answer = super.execute(cmd);
+    	String vmName = cmd.getVmName();
+    	if (vmName.startsWith("v-")) {
+    		Connection conn = getConnection();
+    		callHostPlugin(conn, "vmops", "setDNATRule", "add", "false");
+    	}
+    	return answer;
+    }
+    
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/27e9cdbe/scripts/vm/hypervisor/xenserver/xcposs/vmops
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/xcposs/vmops b/scripts/vm/hypervisor/xenserver/xcposs/vmops
index 3ea127e..c8e6013 100644
--- a/scripts/vm/hypervisor/xenserver/xcposs/vmops
+++ b/scripts/vm/hypervisor/xenserver/xcposs/vmops
@@ -1450,6 +1450,18 @@ def bumpUpPriority(session, args):
         txt = ''
 
     return txt
+    
+@echo
+def setDNATRule(session, args):
+    add = args["add"]
+    if add == "false":
+        util.pread2(["iptables", "-t", "nat", "-F"])
+    else:
+        ip = args["ip"]
+        port = args["port"]
+        util.pread2(["iptables", "-t", "nat", "-F"])
+        util.pread2(["iptables", "-t", "nat", "-A", "PREROUTING", "-i", "xenbr0", "-p", "tcp",
"--dport", port, "-m", "state", "--state", "NEW", "-j", "DNAT", "--to-destination", ip +":443"])
+    return ""
 
 @echo
 def createISOVHD(session, args):
@@ -1533,4 +1545,5 @@ if __name__ == "__main__":
                             "cleanup_rules":cleanup_rules, "checkRouter":checkRouter,
                             "bumpUpPriority":bumpUpPriority, "getDomRVersion":getDomRVersion,
                             "kill_copy_process":kill_copy_process,
-                            "createISOVHD":createISOVHD})
+                            "createISOVHD":createISOVHD,
+                            "setDNATRule":setDNATRule})

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/27e9cdbe/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
index 890c378..6fef240 100755
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
@@ -262,6 +262,8 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
     private Map<Long, ConsoleProxyLoadInfo> _zoneVmCountMap; // map <zone id, info
about running VMs count in zone>
     
     private String _hashKey;
+    private String _staticPublicIp;
+    private int _staticPort;
 
     private final GlobalLock _allocProxyLock = GlobalLock.getInternLock(getAllocProxyLockName());
 
@@ -465,8 +467,12 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager,
ConsoleProx
 
         KeystoreVO ksVo = _ksDao.findByName(ConsoleProxyManager.CERTIFICATE_NAME);
         assert (ksVo != null);
-
-        return new ConsoleProxyInfo(proxy.isSslEnabled(), proxy.getPublicIpAddress(), _consoleProxyPort,
proxy.getPort(), ksVo.getDomainSuffix());
+        
+        if (_staticPublicIp == null) {
+        	return new ConsoleProxyInfo(proxy.isSslEnabled(), proxy.getPublicIpAddress(), _consoleProxyPort,
proxy.getPort(), ksVo.getDomainSuffix());
+        } else {
+        	return new ConsoleProxyInfo(proxy.isSslEnabled(), _staticPublicIp, _consoleProxyPort,
_staticPort, ksVo.getDomainSuffix());
+        }
     }
 
     public ConsoleProxyVO doAssignProxy(long dataCenterId, long vmId) {
@@ -1529,6 +1535,11 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager,
ConsoleProx
         _loadScanner = new SystemVmLoadScanner<Long>(this);
         _loadScanner.initScan(STARTUP_DELAY, _capacityScanInterval);
         _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
+        
+        _staticPublicIp = _configDao.getValue("consoleproxy.static.publicIp");
+        if (_staticPublicIp != null) {
+        	_staticPort = NumbersUtil.parseInt(_configDao.getValue("consoleproxy.static.port"),
8443);
+        }
 
         if (s_logger.isInfoEnabled()) {
             s_logger.info("Console Proxy Manager is configured.");

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/27e9cdbe/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
index 74f5d9f..bb7fa02 100755
--- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
+++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
@@ -1063,7 +1063,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager,
V
             if (profile.getHypervisorType() == HypervisorType.Hyperv) {
                 buf.append(" resource=com.cloud.storage.resource.CifsSecondaryStorageResource");
             } else {
-                buf.append(" resource=com.cloud.storage.resource.PremiumSecondaryStorageResource");
+                buf.append(" resource=com.cloud.storage.resource.NfsSecondaryStorageResource");
             }
         } else {
             buf.append(" resource=com.cloud.storage.resource.NfsSecondaryStorageResource");

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/27e9cdbe/setup/db/deploy-db-clouddev.sh
----------------------------------------------------------------------
diff --git a/setup/db/deploy-db-clouddev.sh b/setup/db/deploy-db-clouddev.sh
index df2a38a..4aa544b 100644
--- a/setup/db/deploy-db-clouddev.sh
+++ b/setup/db/deploy-db-clouddev.sh
@@ -21,3 +21,23 @@ mysql --user=cloud --password=cloud < clouddev.sql
 if [ $? -ne 0 ]; then
    printf "failed to init cloudev db"
 fi
+mysql --user=cloud -t cloud --password=cloud -e "insert into configuration (name, value)
VALUES('consoleproxy.static.publicip', \"$1\")"
+mysql --user=cloud -t cloud --password=cloud -e "insert into configuration (name, value)
VALUES('consoleproxy.static.port', \"$2\")"
+
+vmids=`xe vm-list is-control-domain=false |grep uuid|awk '{print $5}'`
+for vm in $vmids
+    do
+        echo $vm
+        xe vm-shutdown uuid=$vm
+        xe vm-destroy uuid=$vm
+    done
+
+vdis=`xe vdi-list |grep ^uuid |awk '{print $5}'`
+for vdi in $vdis
+    do
+        xe vdi-destroy uuid=$vdi
+        if [ $? -gt 0 ];then
+            xe vdi-forget uuid=$vdi
+        fi
+
+    done


Mime
View raw message