Repository: cloudstack Updated Branches: refs/heads/master da233c7bf -> 66cded75e
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/development-installation/files/default/createtmplt.sh ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/development-installation/files/default/createtmplt.sh b/tools/devcloud4/common/development-installation/files/default/createtmplt.sh new file mode 100755 index 0000000..6b31232 --- /dev/null +++ b/tools/devcloud4/common/development-installation/files/default/createtmplt.sh @@ -0,0 +1,239 @@ +#!/usr/bin/env bash +# 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. + + + +# $Id: createtmplt.sh 9132 2010-06-04 20:17:43Z manuel $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/secondary/createtmplt.sh $ +# createtmplt.sh -- install a template + +usage() { + printf "Usage: %s: -t <template-fs> -n <templatename> -f <root disk file> -c <md5 cksum> -d <descr> -h [-u] [-v]\n" $(basename $0) >&2 +} + + +#set -x +ulimit -f 41943040 #40GiB in blocks +ulimit -c 0 + +rollback_if_needed() { + if [ $2 -gt 0 ] + then + printf "$3\n" + #back out all changes + rm -rf $1 + exit 2 +fi +} + +verify_cksum() { + echo "$1 $2" | md5sum -c --status + #printf "$1\t$2" | md5sum -c --status + if [ $? -gt 0 ] + then + printf "Checksum failed, not proceeding with install\n" + exit 3 + fi +} + +untar() { + local ft=$(file $1| awk -F" " '{print $2}') + case $ft in + USTAR) + printf "tar archives not supported\n" >&2 + return 1 + ;; + *) printf "$1" + return 0 + ;; + esac + +} + +is_compressed() { + local ft=$(file $1| awk -F" " '{print $2}') + local tmpfile=${1}.tmp + + case $ft in + gzip) ctype="gzip" + ;; + bzip2) ctype="bz2" + ;; + ZIP) ctype="zip" + ;; + *) echo "File $1 does not appear to be compressed" >&2 + return 1 + ;; + esac + echo "Uncompressing to $tmpfile (type $ctype)...could take a long time" >&2 + return 0 +} + +uncompress() { + local ft=$(file $1| awk -F" " '{print $2}') + local tmpfile=${1}.tmp + + case $ft in + gzip) gunzip -q -c $1 > $tmpfile + ;; + bzip2) bunzip2 -q -c $1 > $tmpfile + ;; + ZIP) unzip -q -p $1 | cat > $tmpfile + ;; + *) printf "$1" + return 0 + ;; + esac + + if [ $? -gt 0 ] + then + printf "Failed to uncompress file (filetype=$ft), exiting " + return 1 + fi + + rm -f $1 + printf $tmpfile + + return 0 +} + +create_from_file() { + local tmpltfs=$1 + local tmpltimg=$2 + local tmpltname=$3 + + [ -n "$verbose" ] && echo "Moving to $tmpltfs/$tmpltname...could take a while" >&2 + mv $tmpltimg /$tmpltfs/$tmpltname + +} + +tflag= +nflag= +fflag= +sflag= +hflag= +hvm=false +cleanup=false +dflag= +cflag= + +while getopts 'vuht:n:f:s:c:d:S:' OPTION +do + case $OPTION in + t) tflag=1 + tmpltfs="$OPTARG" + ;; + n) nflag=1 + tmpltname="$OPTARG" + ;; + f) fflag=1 + tmpltimg="$OPTARG" + ;; + s) sflag=1 + ;; + c) cflag=1 + cksum="$OPTARG" + ;; + d) dflag=1 + descr="$OPTARG" + ;; + S) Sflag=1 + size=$OPTARG + let "size>>=10" + ulimit -f $size + ;; + h) hflag=1 + hvm="true" + ;; + u) cleanup="true" + ;; + v) verbose="true" + ;; + ?) usage + exit 2 + ;; + esac +done + +isCifs() { + #TO:DO incase of multiple zone where cifs and nfs exists, + #then check if the template file is from cifs using df -P filename + #Currently only cifs is supported in hyperv zone. + mount | grep "type cifs" > /dev/null + echo $? +} + +if [ "$tflag$nflag$fflag$sflag" != "1111" ] +then + usage + exit 2 +fi + +mkdir -p $tmpltfs + +if [ ! -f $tmpltimg ] +then + printf "root disk file $tmpltimg doesn't exist\n" + exit 3 +fi + +if [ -n "$cksum" ] +then + verify_cksum $cksum $tmpltimg +fi +[ -n "$verbose" ] && is_compressed $tmpltimg +tmpltimg2=$(uncompress $tmpltimg) +rollback_if_needed $tmpltfs $? "failed to uncompress $tmpltimg\n" + +tmpltimg2=$(untar $tmpltimg2) +rollback_if_needed $tmpltfs $? "tar archives not supported\n" + +if [ ${tmpltname%.vhd} != ${tmpltname} ] +then + if [ $(isCifs) -ne 0 ] ; + then + if which vhd-util &>/dev/null + then + vhd-util read -p -n ${tmpltimg2} > /dev/null + rollback_if_needed $tmpltfs $? "vhd check of $tmpltimg2 failed\n" + vhd-util set -n ${tmpltimg2} -f "hidden" -v "0" > /dev/null + rollback_if_needed $tmpltfs $? "vhd remove $tmpltimg2 hidden failed\n" + fi + fi +fi + +imgsize=$(ls -l $tmpltimg2| awk -F" " '{print $5}') + +create_from_file $tmpltfs $tmpltimg2 $tmpltname + +touch /$tmpltfs/template.properties +rollback_if_needed $tmpltfs $? "Failed to create template.properties file" +echo -n "" > /$tmpltfs/template.properties + +today=$(date '+%m_%d_%Y') +echo "filename=$tmpltname" > /$tmpltfs/template.properties +echo "description=$descr" >> /$tmpltfs/template.properties +echo "checksum=$cksum" >> /$tmpltfs/template.properties +echo "hvm=$hvm" >> /$tmpltfs/template.properties +echo "size=$imgsize" >> /$tmpltfs/template.properties + +if [ "$cleanup" == "true" ] +then + rm -f $tmpltimg +fi + +exit 0 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/development-installation/metadata.rb ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/development-installation/metadata.rb b/tools/devcloud4/common/development-installation/metadata.rb new file mode 100644 index 0000000..c240755 --- /dev/null +++ b/tools/devcloud4/common/development-installation/metadata.rb @@ -0,0 +1,42 @@ +# +# 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. +# + +name 'development-installation' +maintainer 'Ian Duffy' +maintainer_email 'i...@ianduffy.ie' +license 'Apache 2' +description 'Wrapper around several different cookbooks.' +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +version '0.1.0' + +depends 'mysql', '= 5.6.1' +depends 'cloudstack', '>= 3.0.0' +depends 'nfs', '>= 2.0.0' + +supports 'centos' +supports 'redhat' +supports 'debian' +supports 'ubuntu' +supports 'fedora' +supports 'oracle' + +provides 'development-installation::default' +provides 'development-installation::database_server' +provides 'development-installation::nfs_server' +provides 'development-installation::system_templates.rb' http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/development-installation/recipes/database_server.rb ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/development-installation/recipes/database_server.rb b/tools/devcloud4/common/development-installation/recipes/database_server.rb new file mode 100644 index 0000000..28a374c --- /dev/null +++ b/tools/devcloud4/common/development-installation/recipes/database_server.rb @@ -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. +# + +include_recipe 'mysql::server' +include_recipe 'mysql::client' + +include_recipe 'cloudstack::mysql_conf' + http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/development-installation/recipes/default.rb ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/development-installation/recipes/default.rb b/tools/devcloud4/common/development-installation/recipes/default.rb new file mode 100644 index 0000000..617acc7 --- /dev/null +++ b/tools/devcloud4/common/development-installation/recipes/default.rb @@ -0,0 +1,27 @@ +# +# 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. +# + +service 'iptables' do + action [:disable, :stop] + only_if { platform?(%w{redhat centos fedora oracle}) } +end + +include_recipe 'development-installation::nfsshares' +include_recipe 'development-installation::system_templates' +include_recipe 'development-installation::database_server' \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/development-installation/recipes/nfsshares.rb ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/development-installation/recipes/nfsshares.rb b/tools/devcloud4/common/development-installation/recipes/nfsshares.rb new file mode 100644 index 0000000..100eab9 --- /dev/null +++ b/tools/devcloud4/common/development-installation/recipes/nfsshares.rb @@ -0,0 +1,48 @@ +# +# 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. +# + +include_recipe 'nfs::server' + +directory node['cloudstack']['secondary']['path'] do + owner 'root' + group 'root' + action :create + recursive true +end + +nfs_export node['cloudstack']['secondary']['path'] do + network '*' + writeable true + sync false + options %w(no_root_squash no_subtree_check) +end + +directory node['cloudstack']['primary']['path'] do + owner 'root' + group 'root' + action :create + recursive true +end + +nfs_export node['cloudstack']['primary']['path'] do + network '*' + writeable true + sync false + options %w(no_root_squash no_subtree_check) +end http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/development-installation/recipes/system_templates.rb ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/development-installation/recipes/system_templates.rb b/tools/devcloud4/common/development-installation/recipes/system_templates.rb new file mode 100644 index 0000000..7723f26 --- /dev/null +++ b/tools/devcloud4/common/development-installation/recipes/system_templates.rb @@ -0,0 +1,38 @@ +# +# 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. +# + +cookbook_file 'cloud-install-sys-tmplt' do + action :create_if_missing + mode 0755 + path node['cloudstack']['cloud-install-sys-tmplt'] +end + +cookbook_file 'createtmplt.sh' do + action :create_if_missing + mode 0755 + path node['cloudstack']['createtmplt'] +end + +cloudstack_system_template 'xenserver' do + template_id '1' + nfs_path node['cloudstack']['secondary']['path'] + nfs_server node['cloudstack']['secondary']['host'] + url node['cloudstack']['hypervisor_tpl']['xenserver'] + action :create +end \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/pom.xml ---------------------------------------------------------------------- diff --git a/tools/devcloud4/pom.xml b/tools/devcloud4/pom.xml new file mode 100644 index 0000000..6b1a84f --- /dev/null +++ b/tools/devcloud4/pom.xml @@ -0,0 +1,112 @@ +<!-- 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-devcloud4</artifactId> + <name>Apache CloudStack DevCloud4</name> + <packaging>pom</packaging> + <parent> + <groupId>org.apache.cloudstack</groupId> + <artifactId>cloud-tools</artifactId> + <version>4.6.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <dependencies> + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.cloudstack</groupId> + <artifactId>cloud-developer</artifactId> + <version>${project.version}</version> + <type>pom</type> + <optional>true</optional> + <scope>runtime</scope> + </dependency> + </dependencies> + + <build> + <defaultGoal>install</defaultGoal> + </build> + <profiles> + <profile> + <id>deploydb</id> + <activation> + <property> + <name>deploydb</name> + </property> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>properties-maven-plugin</artifactId> + <version>1.0-alpha-2</version> + <executions> + <execution> + <phase>initialize</phase> + <goals> + <goal>read-project-properties</goal> + </goals> + <configuration> + <files> + <file>${project.parent.parent.basedir}/utils/conf/db.properties</file> + <file>${project.parent.parent.basedir}/utils/conf/db.properties.override</file> + </files> + <quiet>true</quiet> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>sql-maven-plugin</artifactId> + <version>1.5</version> + <dependencies> + <!-- specify the dependent jdbc driver here --> + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + <version>${cs.mysql.version}</version> + </dependency> + </dependencies> + <configuration> + <driver>org.gjt.mm.mysql.Driver</driver> + <url>jdbc:mysql://${db.cloud.host}:${db.cloud.port}/cloud</url> + <username>${db.cloud.username}</username> + <password>${db.cloud.password}</password> + <!--all executions are ignored if -Dmaven.test.skip=true --> + <skip>${maven.test.skip}</skip> + <forceMojoExecution>true</forceMojoExecution> + </configuration> + <executions> + <execution> + <id>create-schema</id> + <phase>process-resources</phase> + <goals> + <goal>execute</goal> + </goals> + <configuration> + <srcFiles> + <srcFile>${basedir}/prefill.sql</srcFile> + </srcFiles> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/prefill.sql ---------------------------------------------------------------------- diff --git a/tools/devcloud4/prefill.sql b/tools/devcloud4/prefill.sql new file mode 100644 index 0000000..d06de50 --- /dev/null +++ b/tools/devcloud4/prefill.sql @@ -0,0 +1,34 @@ +-- 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. + +REPLACE INTO `cloud`.`disk_offering` (id, name, uuid, display_text, created, use_local_storage, type, disk_size) VALUES (17, 'Devcloud4 offering', UUID(), 'Devcloud4 offering', NOW(), 1, 'Service', 0); +REPLACE INTO `cloud`.`service_offering` (id, cpu, speed, ram_size) VALUES (17, 1, 200, 256); +REPLACE INTO `cloud`.`disk_offering` (name, uuid, display_text, created, use_local_storage, type, disk_size) VALUES ('Devcloud4 disk offering', UUID(), 'Devcloud4 disk offering', NOW(), 1, 'Disk', 1073741824); +REPLACE INTO `cloud`.`configuration` (category, instance, component, name, value) VALUES ('Advanced', 'DEFAULT', 'management-server', 'integration.api.port', '8096'); +REPLACE INTO `cloud`.`configuration` (instance, name,value) VALUE('DEFAULT','router.ram.size', '256'); +REPLACE INTO `cloud`.`configuration` (instance, name,value) VALUE('DEFAULT','router.cpu.mhz','256'); +REPLACE INTO `cloud`.`configuration` (instance, name,value) VALUE('DEFAULT','console.ram.size','256'); +REPLACE INTO `cloud`.`configuration` (instance, name,value) VALUE('DEFAULT','console.cpu.mhz', '256'); +REPLACE INTO `cloud`.`configuration` (instance, name,value) VALUE('DEFAULT','ssvm.ram.size','256'); +REPLACE INTO `cloud`.`configuration` (instance, name,value) VALUE('DEFAULT','ssvm.cpu.mhz','256'); +REPLACE INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'system.vm.use.local.storage', 'true'); +REPLACE INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'expunge.workers', '3'); +REPLACE INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'expunge.delay', '60'); +REPLACE INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'expunge.interval', '60'); +REPLACE INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'management.network.cidr', '0.0.0.0/0'); +REPLACE INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'secstorage.allowed.internal.sites', '0.0.0.0/0'); +UPDATE `cloud`.`vm_template` SET unique_name="Macchinina",name="Macchinina",url="http://dl.openvm.eu/cloudstack/macchinina/x86_64/macchinina-xen.vhd.bz2",checksum="30985504bc31bf0cd3b9d2c6ca7944d3",display_text="Macchinina" where id=5; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/pom.xml ---------------------------------------------------------------------- diff --git a/tools/pom.xml b/tools/pom.xml index ed2d806..1885b9d 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -37,6 +37,7 @@ <module>apidoc</module> <module>marvin</module> <module>devcloud</module> - <module>devcloud-kvm</module> + <module>devcloud4</module> + <module>devcloud-kvm</module> </modules> </project>