mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
add console proxy support for devcloud
This commit is contained in:
parent
1f8e99439c
commit
27e9cdbece
@ -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>
|
||||
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1451,6 +1451,18 @@ def bumpUpPriority(session, args):
|
||||
|
||||
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):
|
||||
#hack for XCP on ubuntu 12.04, as can't attach iso to a vm
|
||||
@ -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})
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -466,7 +468,11 @@ 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) {
|
||||
@ -1530,6 +1536,11 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
_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.");
|
||||
}
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user