From 1e6dbcbd3daae636eea1fd88dba45602db60368b Mon Sep 17 00:00:00 2001 From: Chiradeep Vittal Date: Tue, 7 Sep 2010 22:07:45 -0700 Subject: [PATCH] migration from 2.1 to 2.2 on account of new systemvm template work in progress don't need the map --- .../hypervisor/xen/resource/CitrixHelper.java | 6 +-- .../xen/resource/CitrixResourceBase.java | 4 +- .../src/com/cloud/storage/DiskOfferingVO.java | 6 ++- scripts/network/domr/ipassoc.sh | 4 +- .../com/cloud/network/NetworkManagerImpl.java | 6 +-- .../storage/LocalStoragePoolListener.java | 1 + server/src/com/cloud/test/DatabaseConfig.java | 6 +++ setup/db/data-21to22.sql | 4 ++ setup/db/templates.xenserver.sql | 2 +- tools/systemvm/debian/buildsystemvm.sh | 2 +- .../debian/config/etc/apache2/ports.conf | 23 +++++++++++ .../etc/apache2/sites-available/default | 2 +- .../etc/apache2/sites-available/default-ssl | 2 +- .../etc/apache2/sites-enabled/000-default | 41 ------------------- .../debian/config/etc/haproxy/haproxy.cfg | 2 +- .../config/etc/init.d/cloud-early-config | 21 ++++++++-- 16 files changed, 72 insertions(+), 60 deletions(-) create mode 100644 tools/systemvm/debian/config/etc/apache2/ports.conf delete mode 100644 tools/systemvm/debian/config/etc/apache2/sites-enabled/000-default diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixHelper.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixHelper.java index eaa22692483..23de8d0a0af 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixHelper.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixHelper.java @@ -45,7 +45,7 @@ public class CitrixHelper { _guestOsMap.put("CentOS 5.3 (64-bit)", "CentOS 5.3 x64"); _guestOsMap.put("CentOS 5.4 (32-bit)", "CentOS 5.4"); _guestOsMap.put("CentOS 5.4 (64-bit)", "CentOS 5.4 x64"); - _guestOsMap.put("Debian Lenny 5.0 (32-bit)", "Debian Lenny 5.0"); + _guestOsMap.put("Debian Lenny 5.0 (32-bit)", "Debian Lenny 5.0 (32-bit)"); _guestOsMap.put("Oracle Enterprise Linux 5.0 (32-bit)", "Oracle Enterprise Linux 5.0"); _guestOsMap.put("Oracle Enterprise Linux 5.0 (64-bit)", "Oracle Enterprise Linux 5.0 x64"); _guestOsMap.put("Oracle Enterprise Linux 5.1 (32-bit)", "Oracle Enterprise Linux 5.1"); @@ -106,7 +106,7 @@ public class CitrixHelper { _guestOsList.add("CentOS 5.3 x64"); _guestOsList.add("CentOS 5.4"); _guestOsList.add("CentOS 5.4 x64"); - _guestOsList.add("Debian Lenny 5.0"); + _guestOsList.add("Debian Lenny 5.0 (32-bit)"); _guestOsList.add("Oracle Enterprise Linux 5.0"); _guestOsList.add("Oracle Enterprise Linux 5.0 x64"); _guestOsList.add("Oracle Enterprise Linux 5.1"); @@ -158,6 +158,6 @@ public class CitrixHelper { } public static String getGuestOsType(long guestOsId) { - return _guestOsMap.get(guestOsId-1); + return _guestOsList.get((int) (guestOsId-1)); } } diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 7c323c776ba..80521c5910e 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -753,7 +753,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR } protected Pair createVmFromTemplate(Connection conn, VirtualMachineTO vmSpec, Host host) throws XenAPIException, XmlRpcException { - String guestOsTypeName = CitrixHelper.getGuestOsType(vmSpec.getOs()); + String guestOsTypeName = getGuestOsType(vmSpec.getOs()); Set templates = VM.getByNameLabel(conn, guestOsTypeName); assert templates.size() == 1 : "Should only have 1 template but found " + templates.size(); VM template = templates.iterator().next(); @@ -2517,7 +2517,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR Set templates; VM vm = null; String stdType = cmd.getGuestOSDescription(); - String guestOsTypeName = CitrixHelper.getGuestOsType(stdType); + String guestOsTypeName = getGuestOsType(stdType); templates = VM.getByNameLabel(conn, guestOsTypeName); assert templates.size() == 1 : "Should only have 1 template but found " + templates.size(); VM template = templates.iterator().next(); diff --git a/core/src/com/cloud/storage/DiskOfferingVO.java b/core/src/com/cloud/storage/DiskOfferingVO.java index eaed5fa3d4b..48f817a2f9f 100644 --- a/core/src/com/cloud/storage/DiskOfferingVO.java +++ b/core/src/com/cloud/storage/DiskOfferingVO.java @@ -234,5 +234,9 @@ public class DiskOfferingVO implements DiskOffering { buf.delete(buf.length() - 1, buf.length()); setTags(buf.toString()); - } + } + + public void setUseLocalStorage(boolean useLocalStorage) { + this.useLocalStorage = useLocalStorage; + } } diff --git a/scripts/network/domr/ipassoc.sh b/scripts/network/domr/ipassoc.sh index 91b0f1d3698..14d932c5308 100755 --- a/scripts/network/domr/ipassoc.sh +++ b/scripts/network/domr/ipassoc.sh @@ -57,7 +57,7 @@ add_nat_entry() { ssh -p 3922 -o StrictHostKeyChecking=no -i $cert root@$dRIp "\ ip addr add dev $correctVif $pubIp iptables -t nat -I POSTROUTING -j SNAT -o $correctVif --to-source $pubIp ; - /sbin/arping -c 3 -I $correctVif -A -U -s $pubIp $pubIp; + arping -c 3 -I $correctVif -A -U -s $pubIp $pubIp; " if [ $? -gt 0 -a $? -ne 2 ] then @@ -91,7 +91,7 @@ add_an_ip () { ssh -p 3922 -o StrictHostKeyChecking=no -i $cert root@$dRIp "\ ifconfig $correctVif up; ip addr add dev $correctVif $pubIp ; - /sbin/arping -c 3 -I $correctVif -A -U -s $pubIp $pubIp; + arping -c 3 -I $correctVif -A -U -s $pubIp $pubIp; " return $? } diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 58d87e31749..7163e7b8586 100644 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -1831,11 +1831,11 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager _offering = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtualized, useLocalStorage, true, null); _offering.setUniqueName("Cloud.Com-SoftwareRouter"); _offering = _serviceOfferingDao.persistSystemServiceOffering(_offering); - _template = _templateDao.findById(_routerTemplateId); + _template = _templateDao.findRoutingTemplate(); if (_template == null) { s_logger.error("Unable to find system vm template."); - - // throw new ConfigurationException("Unable to find the template for the router: " + _routerTemplateId); + } else { + _routerTemplateId = _template.getId(); } _publicNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmPublicNetwork, TrafficType.Public, null); diff --git a/server/src/com/cloud/storage/LocalStoragePoolListener.java b/server/src/com/cloud/storage/LocalStoragePoolListener.java index 0f5770dddc8..b113ec1a909 100644 --- a/server/src/com/cloud/storage/LocalStoragePoolListener.java +++ b/server/src/com/cloud/storage/LocalStoragePoolListener.java @@ -91,6 +91,7 @@ public class LocalStoragePoolListener implements Listener { pool = new StoragePoolVO(poolId, name, pInfo.getUuid(), pInfo.getPoolType(), host.getDataCenterId(), host.getPodId(), pInfo.getAvailableBytes(), pInfo.getCapacityBytes(), pInfo.getHost(), 0, pInfo.getHostPath()); + pool.setStatus(Status.Up); pool.setClusterId(host.getClusterId()); pool.setStatus(Status.Up); _storagePoolDao.persist(pool, pInfo.getDetails()); diff --git a/server/src/com/cloud/test/DatabaseConfig.java b/server/src/com/cloud/test/DatabaseConfig.java index 7beda280aa1..1f2e6b0db21 100644 --- a/server/src/com/cloud/test/DatabaseConfig.java +++ b/server/src/com/cloud/test/DatabaseConfig.java @@ -771,6 +771,11 @@ public class DatabaseConfig { int diskSpace = Integer.parseInt(_currentObjectParams.get("diskSpace")); // boolean mirroring = Boolean.parseBoolean(_currentObjectParams.get("mirrored")); String tags = _currentObjectParams.get("tags"); + String useLocal = _currentObjectParams.get("useLocal"); + boolean local = false; + if (useLocal != null) { + local = Boolean.parseBoolean(useLocal); + } if (tags != null && tags.length() > 0) { String[] tokens = tags.split(","); @@ -782,6 +787,7 @@ public class DatabaseConfig { tags = newTags.toString(); } DiskOfferingVO diskOffering = new DiskOfferingVO(domainId, name, displayText, diskSpace, tags); + diskOffering.setUseLocalStorage(local); DiskOfferingDaoImpl offering = ComponentLocator.inject(DiskOfferingDaoImpl.class); try { offering.persist(diskOffering); diff --git a/setup/db/data-21to22.sql b/setup/db/data-21to22.sql index 0af83cc2afd..791436ff3c5 100644 --- a/setup/db/data-21to22.sql +++ b/setup/db/data-21to22.sql @@ -4,5 +4,9 @@ use cloud; START TRANSACTION; DELETE FROM configuration where name='upgrade.url'; +DELETE FROM configuration where name='router.template.id'; +UPDATE vm_template set unique_name='routing_old' where id=1; +INSERT INTO vm_template (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones) + VALUES (10, 'routing', 'SystemVM Template', 0, now(), 'ext3', 0, 64, 1, 'http://download.cloud.com/releases/2.2/systemvm.vhd.bz2', 'bcc7f290f4c27ab4d0fe95d1012829ea', 0, 'SystemVM Template', 'VHD', 15, 0, 1); COMMIT; diff --git a/setup/db/templates.xenserver.sql b/setup/db/templates.xenserver.sql index 0432c97716f..02651fd99a8 100644 --- a/setup/db/templates.xenserver.sql +++ b/setup/db/templates.xenserver.sql @@ -1,5 +1,5 @@ INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones) - VALUES (1, 'routing', 'SystemVM Template', 0, now(), 'ext3', 0, 64, 1, 'http://download.cloud.com/releases/2.0.0RC5/systemvm.vhd.bz2', '31cd7ce94fe68c973d5dc37c3349d02e', 0, 'SystemVM Template', 'VHD', 12, 0, 1); + VALUES (1, 'routing', 'SystemVM Template', 0, now(), 'ext3', 0, 64, 1, 'http://download.cloud.com/releases/2.2/systemvm.vhd.bz2', 'bcc7f290f4c27ab4d0fe95d1012829ea', 0, 'SystemVM Template', 'VHD', 15, 0, 1); INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones) VALUES (2, 'centos53-x86_64', 'CentOS 5.3(x86_64) no GUI', 1, now(), 'ext3', 0, 64, 1, 'http://download.cloud.com/templates/builtin/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2', 'b63d854a9560c013142567bbae8d98cf', 0, 'CentOS 5.3(x86_64) no GUI', 'VHD', 12, 1, 1); diff --git a/tools/systemvm/debian/buildsystemvm.sh b/tools/systemvm/debian/buildsystemvm.sh index 3ff17f126fe..a8266d37631 100755 --- a/tools/systemvm/debian/buildsystemvm.sh +++ b/tools/systemvm/debian/buildsystemvm.sh @@ -331,7 +331,7 @@ packages() { DEBCONF_DB_OVERRIDE=’File{/root/config.dat}’ export DEBIAN_FRONTEND DEBIAN_PRIORITY DEBCONF_DB_OVERRIDE - chroot . apt-get --no-install-recommends -q -y --force-yes install rsyslog chkconfig insserv net-tools ifupdown vim-tiny netbase iptables openssh-server grub e2fsprogs dhcp3-client dnsmasq tcpdump socat wget apache2 ssl-cert python bzip2 sed gawk diff grep gzip less tar telnet xl2tpd traceroute openswan psmisc inetutils-ping arping httping dnsutils zip unzip ethtool uuid + chroot . apt-get --no-install-recommends -q -y --force-yes install rsyslog chkconfig insserv net-tools ifupdown vim-tiny netbase iptables openssh-server grub e2fsprogs dhcp3-client dnsmasq tcpdump socat wget apache2 ssl-cert python bzip2 sed gawk diff grep gzip less tar telnet xl2tpd traceroute openswan psmisc inetutils-ping iputils-arping httping dnsutils zip unzip ethtool uuid chroot . apt-get --no-install-recommends -q -y --force-yes install haproxy nfs-common diff --git a/tools/systemvm/debian/config/etc/apache2/ports.conf b/tools/systemvm/debian/config/etc/apache2/ports.conf new file mode 100644 index 00000000000..369cb295e00 --- /dev/null +++ b/tools/systemvm/debian/config/etc/apache2/ports.conf @@ -0,0 +1,23 @@ +# If you just change the port or add more ports here, you will likely also +# have to change the VirtualHost statement in +# /etc/apache2/sites-enabled/000-default +# This is also true if you have upgraded from before 2.2.9-3 (i.e. from +# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and +# README.Debian.gz + +NameVirtualHost 10.1.1.1:80 +Listen 10.1.1.1:80 + + + # If you add NameVirtualHost *:443 here, you will also have to change + # the VirtualHost statement in /etc/apache2/sites-available/default-ssl + # to + # Server Name Indication for SSL named virtual hosts is currently not + # supported by MSIE on Windows XP. + Listen 10.1.1.1:443 + + + + Listen 10.1.1.1:443 + + diff --git a/tools/systemvm/debian/config/etc/apache2/sites-available/default b/tools/systemvm/debian/config/etc/apache2/sites-available/default index 75d4c4059f2..ae009b71ca2 100644 --- a/tools/systemvm/debian/config/etc/apache2/sites-available/default +++ b/tools/systemvm/debian/config/etc/apache2/sites-available/default @@ -1,4 +1,4 @@ - + ServerAdmin webmaster@localhost DocumentRoot /var/www/html diff --git a/tools/systemvm/debian/config/etc/apache2/sites-available/default-ssl b/tools/systemvm/debian/config/etc/apache2/sites-available/default-ssl index ca44850f2f2..0eea44d0103 100644 --- a/tools/systemvm/debian/config/etc/apache2/sites-available/default-ssl +++ b/tools/systemvm/debian/config/etc/apache2/sites-available/default-ssl @@ -1,5 +1,5 @@ - + ServerAdmin webmaster@localhost DocumentRoot /var/www/html diff --git a/tools/systemvm/debian/config/etc/apache2/sites-enabled/000-default b/tools/systemvm/debian/config/etc/apache2/sites-enabled/000-default deleted file mode 100644 index 75d4c4059f2..00000000000 --- a/tools/systemvm/debian/config/etc/apache2/sites-enabled/000-default +++ /dev/null @@ -1,41 +0,0 @@ - - ServerAdmin webmaster@localhost - - DocumentRoot /var/www/html - - Options FollowSymLinks - AllowOverride None - - - Options Indexes FollowSymLinks MultiViews - AllowOverride All - Order allow,deny - allow from all - - - ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ - - AllowOverride None - Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch - Order allow,deny - Allow from all - - - ErrorLog ${APACHE_LOG_DIR}/error.log - - # Possible values include: debug, info, notice, warn, error, crit, - # alert, emerg. - LogLevel warn - - CustomLog ${APACHE_LOG_DIR}/access.log combined - - Alias /doc/ "/usr/share/doc/" - - Options Indexes MultiViews FollowSymLinks - AllowOverride None - Order deny,allow - Deny from all - Allow from 127.0.0.0/255.0.0.0 ::1/128 - - - diff --git a/tools/systemvm/debian/config/etc/haproxy/haproxy.cfg b/tools/systemvm/debian/config/etc/haproxy/haproxy.cfg index 1a34373de68..94737ac328e 100644 --- a/tools/systemvm/debian/config/etc/haproxy/haproxy.cfg +++ b/tools/systemvm/debian/config/etc/haproxy/haproxy.cfg @@ -22,5 +22,5 @@ defaults timeout server 50000 -listen 0.0.0.0:9 +listen cloud-default 0.0.0.0:35999 option transparent diff --git a/tools/systemvm/debian/config/etc/init.d/cloud-early-config b/tools/systemvm/debian/config/etc/init.d/cloud-early-config index 0c4eded6140..11efc5c1afc 100755 --- a/tools/systemvm/debian/config/etc/init.d/cloud-early-config +++ b/tools/systemvm/debian/config/etc/init.d/cloud-early-config @@ -162,17 +162,27 @@ setup_dnsmasq() { } setup_sshd(){ - [ -f /etc/ssh/sshd_config ] && sed -i -e "s/^[#]*ListenAddress.*$/ListenAddress $ETH1_IP/" /etc/ssh/sshd_config + local ip=$1 + [ -f /etc/ssh/sshd_config ] && sed -i -e "s/^[#]*ListenAddress.*$/ListenAddress $ip/" /etc/ssh/sshd_config +} + +setup_apache2() { + [ -f /etc/apache2/sites-available/default ] && sed -i -e "s///" /etc/apache2/sites-available/default + [ -f /etc/apache2/sites-available/default-ssl ] && sed -i -e "s///" /etc/apache2/sites-available/default-ssl + [ -f /etc/apache2/ports.conf ] && sed -i -e "s/Listen .*:80/Listen $ETH0_IP:80/g" /etc/apache2/ports.conf + [ -f /etc/apache2/ports.conf ] && sed -i -e "s/Listen .*:443/Listen $ETH0_IP:443/g" /etc/apache2/ports.conf + [ -f /etc/apache2/ports.conf ] && sed -i -e "s/NameVirtualHost .*:80/NameVirtualHost $ETH0_IP:80/g" /etc/apache2/ports.conf } setup_router() { setup_common eth0 eth1 eth2 setup_dnsmasq + setup_apache2 sed -i /gateway/d /etc/hosts echo "$ETH0_IP $NAME" >> /etc/hosts - setup_sshd + setup_sshd $ETH1_IP enable_svc dnsmasq 1 enable_svc haproxy 1 @@ -185,11 +195,12 @@ setup_router() { setup_dhcpsrvr() { setup_common eth0 eth1 setup_dnsmasq + setup_apache2 sed -i /gateway/d /etc/hosts echo "$ETH0_IP $NAME" >> /etc/hosts - setup_sshd + setup_sshd $ETH1_IP enable_svc dnsmasq 1 enable_svc haproxy 0 @@ -207,6 +218,8 @@ setup_secstorage() { echo "$public_ip $NAME" >> /etc/hosts cp /etc/iptables/iptables-secstorage /etc/iptables/rules + setup_sshd $ETH0_IP + enable_fwding 0 enable_svc haproxy 0 enable_svc dnsmasq 0 @@ -214,6 +227,7 @@ setup_secstorage() { enable_svc cloud 1 } + setup_console_proxy() { setup_common eth0 eth1 eth2 public_ip=$ETH2_IP @@ -221,6 +235,7 @@ setup_console_proxy() { sed -i /gateway/d /etc/hosts echo "$public_ip $NAME" >> /etc/hosts cp /etc/iptables/iptables-consoleproxy /etc/iptables/rules + setup_sshd $ETH0_IP enable_fwding 0 enable_svc haproxy 0