From 3839239a21fc14a64acc18900ae303961036ef91 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Sun, 17 Dec 2017 12:55:26 +0530 Subject: [PATCH] CLOUDSTACK-10194: Use packer for building systemvmtemplates - This migrates the current systemvmtemplate build system from veewee/virtualbox to packer and qemu based. - This also introduces and updates a CentOS7 built-in template. - Remove old appliance build scripts and files. - Adds iftop package (CLOUDSTACK-9785) Signed-off-by: Rohit Yadav --- pom.xml | 8 +- tools/appliance/.ruby-version | 1 - tools/appliance/.rvmrc | 24 -- tools/appliance/README.md | 107 +----- tools/appliance/build.sh | 358 +++--------------- tools/appliance/builtin/http/kickstart.cfg | 91 +++++ .../builtin/scripts/base.sh} | 15 +- .../{Gemfile => builtin/scripts/cleanup.sh} | 20 +- tools/appliance/builtin/template.json | 53 +++ tools/appliance/convert/Convert.class | Bin 984 -> 0 bytes tools/appliance/convert/Convert.java | 36 -- tools/appliance/convert_ovf_vbox_to_esx.xslt | 42 -- tools/appliance/definitions/builtin/base.sh | 14 - .../appliance/definitions/builtin/cleanup.sh | 21 - .../definitions/builtin/definition.rb | 33 -- .../definitions/builtin/install-xs-tools.sh | 10 - tools/appliance/definitions/builtin/ks.cfg | 35 -- .../definitions/builtin/postinstall.sh | 54 --- .../appliance/definitions/builtin/zerodisk.sh | 3 - .../definitions/debianbase/cleanup.sh | 49 --- .../definitions/debianbase/configure_login.sh | 78 ---- .../definitions/debianbase/definition.rb | 80 ---- .../definitions/debianbase/preseed.cfg | 129 ------- .../definitions/debianbase/zerodisk.sh | 43 --- tools/appliance/definitions/devcloud/base.sh | 12 - .../appliance/definitions/devcloud/cleanup.sh | 21 - .../definitions/devcloud/definition.rb | 45 --- .../definitions/devcloud/postinstall.sh | 60 --- .../definitions/devcloud/preseed.cfg | 357 ----------------- .../definitions/devcloud/zerodisk.sh | 11 - tools/appliance/shar_cloud_scripts.sh | 2 +- .../http}/preseed.cfg | 13 +- .../scripts}/apt_upgrade.sh | 5 +- .../scripts}/authorized_keys.sh | 0 .../scripts}/cleanup.sh | 0 .../scripts}/configure_acpid.sh | 0 .../scripts}/configure_conntrack.sh | 0 .../scripts}/configure_grub.sh | 4 + .../scripts}/configure_locale.sh | 0 .../scripts}/configure_login.sh | 0 .../scripts}/configure_networking.sh | 0 .../scripts}/configure_persistent_config.sh | 1 - .../scripts}/configure_systemvm_services.sh | 0 .../scripts}/definition.rb | 4 +- .../scripts}/finalize.sh | 8 +- .../scripts}/install_systemvm_packages.sh | 16 +- .../appliance/systemvmtemplate/template.json | 82 ++++ tools/appliance/test.sh | 180 --------- tools/appliance/vbox_disk_clean.rb | 49 --- tools/appliance/vbox_vm_clean.rb | 77 ---- tools/vagrant/devcloud/Vagrantfile | 206 ---------- .../devcloud/templates/tmpl/1/1/README | 1 - .../devcloud/templates/tmpl/1/5/README | 2 - tools/vagrant/systemvm/.gitignore | 52 --- tools/vagrant/systemvm/.ruby-version | 1 - tools/vagrant/systemvm/.rvmrc | 24 -- tools/vagrant/systemvm/README.md | 30 -- tools/vagrant/systemvm/VBoxManage | 41 -- tools/vagrant/systemvm/Vagrantfile | 123 ------ tools/vagrant/systemvm/test.sh | 213 ----------- tools/vagrant/systemvm/vagrant.pub | 1 - 61 files changed, 343 insertions(+), 2602 deletions(-) delete mode 100644 tools/appliance/.ruby-version delete mode 100644 tools/appliance/.rvmrc create mode 100644 tools/appliance/builtin/http/kickstart.cfg rename tools/{vagrant/systemvm/Gemfile => appliance/builtin/scripts/base.sh} (65%) rename tools/appliance/{Gemfile => builtin/scripts/cleanup.sh} (74%) create mode 100644 tools/appliance/builtin/template.json delete mode 100644 tools/appliance/convert/Convert.class delete mode 100644 tools/appliance/convert/Convert.java delete mode 100644 tools/appliance/convert_ovf_vbox_to_esx.xslt delete mode 100644 tools/appliance/definitions/builtin/base.sh delete mode 100644 tools/appliance/definitions/builtin/cleanup.sh delete mode 100644 tools/appliance/definitions/builtin/definition.rb delete mode 100644 tools/appliance/definitions/builtin/install-xs-tools.sh delete mode 100644 tools/appliance/definitions/builtin/ks.cfg delete mode 100644 tools/appliance/definitions/builtin/postinstall.sh delete mode 100644 tools/appliance/definitions/builtin/zerodisk.sh delete mode 100644 tools/appliance/definitions/debianbase/cleanup.sh delete mode 100644 tools/appliance/definitions/debianbase/configure_login.sh delete mode 100644 tools/appliance/definitions/debianbase/definition.rb delete mode 100644 tools/appliance/definitions/debianbase/preseed.cfg delete mode 100644 tools/appliance/definitions/debianbase/zerodisk.sh delete mode 100644 tools/appliance/definitions/devcloud/base.sh delete mode 100644 tools/appliance/definitions/devcloud/cleanup.sh delete mode 100644 tools/appliance/definitions/devcloud/definition.rb delete mode 100644 tools/appliance/definitions/devcloud/postinstall.sh delete mode 100644 tools/appliance/definitions/devcloud/preseed.cfg delete mode 100644 tools/appliance/definitions/devcloud/zerodisk.sh rename tools/appliance/{definitions/systemvmtemplate => systemvmtemplate/http}/preseed.cfg (92%) rename tools/appliance/{definitions/systemvmtemplate => systemvmtemplate/scripts}/apt_upgrade.sh (97%) rename tools/appliance/{definitions/systemvmtemplate => systemvmtemplate/scripts}/authorized_keys.sh (100%) rename tools/appliance/{definitions/systemvmtemplate => systemvmtemplate/scripts}/cleanup.sh (100%) rename tools/appliance/{definitions/systemvmtemplate => systemvmtemplate/scripts}/configure_acpid.sh (100%) rename tools/appliance/{definitions/systemvmtemplate => systemvmtemplate/scripts}/configure_conntrack.sh (100%) rename tools/appliance/{definitions/systemvmtemplate => systemvmtemplate/scripts}/configure_grub.sh (92%) rename tools/appliance/{definitions/systemvmtemplate => systemvmtemplate/scripts}/configure_locale.sh (100%) rename tools/appliance/{definitions/systemvmtemplate => systemvmtemplate/scripts}/configure_login.sh (100%) rename tools/appliance/{definitions/systemvmtemplate => systemvmtemplate/scripts}/configure_networking.sh (100%) rename tools/appliance/{definitions/systemvmtemplate => systemvmtemplate/scripts}/configure_persistent_config.sh (99%) rename tools/appliance/{definitions/systemvmtemplate => systemvmtemplate/scripts}/configure_systemvm_services.sh (100%) rename tools/appliance/{definitions/systemvmtemplate => systemvmtemplate/scripts}/definition.rb (93%) rename tools/appliance/{definitions/systemvmtemplate => systemvmtemplate/scripts}/finalize.sh (95%) rename tools/appliance/{definitions/systemvmtemplate => systemvmtemplate/scripts}/install_systemvm_packages.sh (98%) create mode 100644 tools/appliance/systemvmtemplate/template.json delete mode 100644 tools/appliance/test.sh delete mode 100755 tools/appliance/vbox_disk_clean.rb delete mode 100755 tools/appliance/vbox_vm_clean.rb delete mode 100644 tools/vagrant/devcloud/Vagrantfile delete mode 100644 tools/vagrant/devcloud/templates/tmpl/1/1/README delete mode 100644 tools/vagrant/devcloud/templates/tmpl/1/5/README delete mode 100644 tools/vagrant/systemvm/.gitignore delete mode 100644 tools/vagrant/systemvm/.ruby-version delete mode 100644 tools/vagrant/systemvm/.rvmrc delete mode 100644 tools/vagrant/systemvm/README.md delete mode 100755 tools/vagrant/systemvm/VBoxManage delete mode 100644 tools/vagrant/systemvm/Vagrantfile delete mode 100755 tools/vagrant/systemvm/test.sh delete mode 100644 tools/vagrant/systemvm/vagrant.pub diff --git a/pom.xml b/pom.xml index 39a611d5e9d..00a3542bc27 100644 --- a/pom.xml +++ b/pom.xml @@ -880,14 +880,8 @@ services/secondary-storage/conf/agent.properties services/secondary-storage/conf/environment.properties test/systemvm/README.md - tools/appliance/.ruby-version - tools/vagrant/systemvm/vagrant.pub - tools/vagrant/systemvm/.ruby-version tools/devcloud/basebuild/puppet-devcloudinitial/files/network.conf - tools/appliance/definitions/devcloud/* - tools/appliance/definitions/systemvmtemplate/* - tools/appliance/definitions/systemvm64template/* - tools/appliance/definitions/builtin/* + tools/appliance/*/template.json tools/cli/cloudmonkey.egg-info/* tools/devcloud/src/deps/boxes/basebox-build/definition.rb tools/devcloud/src/deps/boxes/basebox-build/preseed.cfg diff --git a/tools/appliance/.ruby-version b/tools/appliance/.ruby-version deleted file mode 100644 index bc9bac6213b..00000000000 --- a/tools/appliance/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.3.0p0 diff --git a/tools/appliance/.rvmrc b/tools/appliance/.rvmrc deleted file mode 100644 index 573ecb78640..00000000000 --- a/tools/appliance/.rvmrc +++ /dev/null @@ -1,24 +0,0 @@ -# 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. - -rvm use ruby-2.3.0@vagrant-release-cloudstack --create -export VAGRANT_HOME=$HOME/.vagrant.d-release-cloudstack -bundle check > /dev/null 2>&1 -RETVAL=$? -if [ $RETVAL -ne 0 ]; then - bundle install -fi diff --git a/tools/appliance/README.md b/tools/appliance/README.md index 403eb45bb44..6d8370fdfa4 100644 --- a/tools/appliance/README.md +++ b/tools/appliance/README.md @@ -17,104 +17,27 @@ under the License. =========================================================== +# Introduction + +This is used to build appliances for use with CloudStack. Currently two +build profiles are available for building systemvmtemplate (Debian based) and +CentOS based built-in user VM template. + # Setting up Tools and Environment - - Install latest VirtualBox (5.0+) - - Install tools for exporting appliances: qemu-img, vboxmanage, vhd-util, ovftool - - Install [RVM](https://rvm.io/rvm/install) - - Install dependencies (tested on Ubuntu 16.04): - apt-get install sharutils libxslt1-dev libxml2-dev zlib1g-dev build-essential ruby ruby-bundler ruby-dev qemu-utils blktap-utils faketime - - Setup paths: - export PATH=~/.rvm/bin:$PATH - - Install Ruby 2.3.0, if it installed some other version: - rvm install 2.3.0 - - Set rvm to use that 2.3.0 - rvm use ruby-2.3.0 - - Install bundler: (if you get any openssl issue see https://rvm.io/packages/openssl) - gem install bundler +- Install packer and latest KVM, qemu on a Linux machine +- Install tools for exporting appliances: qemu-img, ovftool, faketime +- Build and install `vhd-util` as described in build.sh or use pre-built + binaries at: -All the dependencies will be fetched automatically. + http://packages.shapeblue.com/systemvmtemplate/vhd-util + http://packages.shapeblue.com/systemvmtemplate/libvhd.so.1.0 -To save some time if you've downloaded iso of your distro, put the isos in: -tools/appliance/iso/ - -# Setting up jenkins (CI) builds - -All the tools listed above are expected to be available. If you follow - - http://rvm.io/integration/jenkins - -then you'll need to do a bit of logic to load RVM in jenkins. In the -build script you put into jenkins, start it with -``` -#!/bin/bash -l -``` - -to ensure a login shell, then add something like -``` -# inspired by https://github.com/CloudBees-community/rubyci-clickstart/blob/master/bin/run-ci -# also see https://rvm.io/integration/jenkins -# .rvmrc won't get trusted/auto-loaded by jenkins by default -export VAGRANT_HOME=$HOME/.vagrant.d-release-cloudstack -rvm use ruby-1.9.3@vagrant-release-cloudstack --create -# do not use --deployment since that requires Gemfile.lock...and we prefer an up-to-date veewee -bundle_args="--path vendor/bundle" -``` - - -# How to build SystemVMs automatically +# How to build appliances Just run build.sh, it will export archived appliances for KVM, XenServer, VMWare and HyperV in `dist` directory: - bundle install - bash build.sh systemvm64template + bash build.sh systemvmtemplate + bash build.sh builtin -# Building SystemVM template appliance manually - -List available appliances one can build: - - veewee vbox list - -Modify scripts in definitions/*appliance*/ as per needs. -Build systemvm template appliance: - - veewee vbox build 'systemvmtemplate' - -Start the box: - - veewee vbox up 'systemvmtemplate' - -Halt the box: - - veewee vbox halt 'systemvmtemplate' - -Now VirtualBox can be used to export appliance. - -To build the systemvm64template by hand using veewee, set VM_ARCH=amd64 and use -the systemvmtemplate: - - export VM_ARCH=amd64 - cp -r definitions/systemvmtemplate definitions/systemvm64template - veewee vbox build 'systemvm64template' - -Troubleshooting -=============== -If you see following line in the screen, then veewee is failing -extracting vboxmanage version. - - Downloading vbox guest additions iso v - http://download.virtualbox.org/vi - -You would be able to check it manually by typing: - - vboxmanage --version - -If you're using Fedora for example, you'll need to install `kernel-devel` -package and run `/etc/init.d/vboxdrv setup` to get veewee working. - -Testing -======= -The ./test.sh script tries out a few different default ways to invoke build.sh. - -See ../vagrant/systemvm for a test setup that uses vagrant+serverspec to -provide actual integration tests that verify the built systemvm is up to spec. diff --git a/tools/appliance/build.sh b/tools/appliance/build.sh index ab3cac891bd..8b1032ecc8b 100755 --- a/tools/appliance/build.sh +++ b/tools/appliance/build.sh @@ -1,6 +1,4 @@ #!/bin/bash -l -# note: the -l is needed here for bash to always make a login shell and load rvm if it hasn't been loaded -# # 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 @@ -18,35 +16,21 @@ # specific language governing permissions and limitations # under the License. -# build script which wraps around veewee and virtualbox to create the systemvm template +# build script which wraps around packer and virtualbox to create the systemvm template function usage() { cat </dev/null || echo unknown) | sed -e 's/remotes\/.*\///g' | sed -e 's|/|_|g'` -fi - -branch_tag= -if [ ! -z "${branch}" ]; then - branch_tag="-${branch}" -fi - version_tag= if [ ! -z "${version}" ]; then if [ ! -z "${BUILD_NUMBER}" ]; then @@ -152,10 +101,7 @@ elif [ ! -z "${BUILD_NUMBER}" ]; then version_tag="-${BUILD_NUMBER}" fi -appliance_build_name=${appliance}${branch_tag}${version_tag} - -# mac address of the vm we create -mac_address= +appliance_build_name=${appliance}${version_tag} ### ### Generic helper functions @@ -244,151 +190,29 @@ function retry() { ### function create_definition() { - if [ "${appliance}" == "systemvm64template" ]; then - arch="amd64" - export VM_ARCH="${arch}" - rm -rf definitions/systemvm64template # in case of left-over cruft from failed build - cp -r definitions/systemvmtemplate definitions/systemvm64template - add_on_exit rm -rf definitions/systemvm64template - fi - if [ "${appliance}" != "${appliance_build_name}" ]; then - cp -r "definitions/${appliance}" "definitions/${appliance_build_name}" + cp -r "${appliance}" "${appliance_build_name}" set +e if [ ! -z "${version}" ]; then sed ${sed_regex_option} -i -e "s/^CLOUDSTACK_RELEASE=.+/CLOUDSTACK_RELEASE=${version}/" \ - "definitions/${appliance_build_name}/configure_systemvm_services.sh" - fi - if [ ! -z "${ssh_key}" ]; then - # ssh key lines can contain / - sed ${sed_regex_option} -i -e "s|^key=.+|key=\"${ssh_key}\"|" \ - "definitions/${appliance_build_name}/authorized_keys.sh" + "${appliance_build_name}/configure_systemvm_services.sh" fi set -e - add_on_exit rm -rf "definitions/${appliance_build_name}" + add_on_exit rm -rf "${appliance_build_name}" fi ./shar_cloud_scripts.sh add_on_exit rm -f cloud_scripts_shar_archive.sh } -function setup_ruby() { - bundle check || bundle install ${BUNDLE_ARGS} -} - -function stop_vbox() { - log INFO "stoppping all virtualbox vms for ${USER}" - bundle exec ./vbox_vm_clean.rb -} - -function clean_vbox() { - log INFO "deleting all virtualbox vms and disks for ${USER}" - bundle exec ./vbox_vm_clean.rb --delete --kill - bundle exec ./vbox_disk_clean.rb -} - function prepare() { log INFO "preparing for build" - setup_ruby rm -rf dist *.ova *.vhd *.vdi *.qcow* *.bz2 *.vmdk *.ovf - mkdir dist } -function veewee_destroy() { - log INFO "destroying existing veewee image, if any" - set +e - bundle exec veewee vbox destroy "${appliance_build_name}" ${VEEWEE_ARGS} - set -e -} - -function veewee_build() { - log INFO "building new image with veewee" - bundle exec veewee vbox build "${appliance_build_name}" ${VEEWEE_BUILD_ARGS} -} - -function veewee_halt() { - log INFO "shutting down new vm with veewee" - bundle exec veewee vbox halt "${appliance_build_name}" ${VEEWEE_ARGS} -} - -function save_mac_address() { - log INFO "saving new vm mac address" - mac_address=`vboxmanage showvminfo --details --machinereadable ${appliance_build_name} | grep macaddress1= | sed 's/macaddress1=//' | sed 's/"//g'` - if [ "${mac_address}" == "" ]; then - error "Could not find mac address for appliance ${appliance_build_name}" - fi -} - -function check_appliance_shutdown() { - log INFO "waiting for veewee appliance to shut down..." - ! (vboxmanage list runningvms | grep "${appliance_build_name}") - local result=$? - if [ ${result} -eq 0 ]; then - log INFO "...veewee appliance shut down ok" - else - log INFO "...veewee appliance still running" - fi - return ${result} -} - -function check_appliance_disk_ready() { - log INFO "waiting for veewee appliance disk to be available..." - # local hdd_path="vboxmanage showvminfo '${appliance_build_name}' --machinereadable | \ - # egrep '(SATA|IDE) Controller-[0-9]+-[0-9]+' | grep -v '.iso' | \ - # grep -v '="none"' | egrep -o '=".*"' | sed 's/=//' | sed 's/"//g'" - local hdd_path=`vboxmanage list hdds | grep "${appliance_build_name}\/" | grep vdi | \ - cut -c 14- | sed ${sed_regex_option} 's/^ *//'` - disk_state=`vboxmanage showhdinfo "${hdd_path}" | egrep '^State:' | sed 's/State://' | egrep -o '[a-zA-Z]+' | awk '{print tolower($0)}'` - if [ "${disk_state}" == "notcreated" ]; then - log ERROR "disk ${hdd_path} in state notcreated" - return 1 - elif [ "${disk_state}" == "created" ]; then - log INFO "disk ${hdd_path} in state created" - return 0 - elif [ "${disk_state}" == "lockedread" ]; then - log INFO "disk ${hdd_path} in state lockedread" - return 1 - elif [ "${disk_state}" == "lockedwrite" ]; then - log INFO "disk ${hdd_path} in state lockedwrite" - return 1 - elif [ "${disk_state}" == "inaccessible" ]; then - log INFO "disk ${hdd_path} in state inaccessible" - return 1 - elif [ "${disk_state}" == "creating" ]; then - log WARN "disk ${hdd_path} in state creating" - return 1 - elif [ "${disk_state}" == "deleting" ]; then - log WARN "disk ${hdd_path} in state deleting" - return 1 - else - log WARN "disk ${hdd_path} has unknown disk state ${disk_state}" - return 1 - fi -} - -function remove_shares() { - log INFO "removing shared folders from appliance..." - set +e - local shared_folders=`vboxmanage showvminfo "${appliance_build_name}" | grep Name | grep Host` - if [ "${shared_folders}" == "" ]; then - return 0 - fi - folder_name=`echo "${shared_folders}" | head -1 | cut -c 8- | cut -d \' -f 1` - vboxmanage sharedfolder remove "${appliance_build_name}" --name "${folder_name}" - ! (vboxmanage showvminfo "${appliance_build_name}" | grep Name | grep Host) - local result=$? - set -e - if [ ${result} -eq 0 ]; then - log INFO "...veewee appliance shared folders removed" - else - log INFO "...veewee appliance still has shared folders" - fi - return ${result} -} - -function compact_hdd() { - log INFO "compacting image" - vboxmanage modifyhd "${1}" --compact +function packer_build() { + log INFO "building new image with packer" + cd ${appliance_build_name} && packer build template.json && cd .. } function stage_vmx (){ @@ -442,13 +266,12 @@ VMXFILE function xen_server_export() { log INFO "creating xen server export" - local hdd_path="${1}" set +e which faketime >/dev/null 2>&1 && which vhd-util >/dev/null 2>&1 local result=$? set -e if [ ${result} == 0 ]; then - vboxmanage internalcommands converttoraw -format vdi "${hdd_path}" img.raw + qemu-img convert -f qcow2 -O raw "dist/${appliance}" img.raw vhd-util convert -s 0 -t 1 -i img.raw -o stagefixed.vhd faketime '2010-01-01' vhd-util convert -s 1 -t 2 -i stagefixed.vhd -o "${appliance_build_name}-xen.vhd" rm -f *.bak @@ -463,117 +286,48 @@ function xen_server_export() { function ovm_export() { log INFO "creating OVM export" - local hdd_path="${1}" - rm -f img.raw - vboxmanage internalcommands converttoraw -format vdi "${hdd_path}" img.raw - mv img.raw ${appliance_build_name}-ovm.raw - bzip2 "${appliance_build_name}-ovm.raw" - mv "${appliance_build_name}-ovm.raw.bz2" dist/ + qemu-img convert -f qcow2 -O raw "dist/${appliance}" "dist/${appliance_build_name}-ovm.raw" + cd dist && bzip2 "${appliance_build_name}-ovm.raw" && cd .. log INFO "${appliance} exported for OracleVM: dist/${appliance_build_name}-ovm.raw.bz2" } function kvm_export() { + log INFO "creating kvm export" set +e - which faketime >/dev/null 2>&1 && which vhd-util >/dev/null 2>&1 - local result=$? - set -e - if [ ${result} == 0 ]; then - log INFO "creating kvm export" - local hdd_path="${1}" - rm -f raw.img - vboxmanage internalcommands converttoraw -format vdi "${hdd_path}" raw.img - set +e - qemu-img convert -o compat=0.10 -f raw -c -O qcow2 raw.img "${appliance_build_name}-kvm.qcow2" - local qemuresult=$? - set -e - if [ ${qemuresult} != 0 ]; then - log INFO "'qemu-img convert' failed, trying without compat option" - qemu-img convert -f raw -c -O qcow2 raw.img "${appliance_build_name}-kvm.qcow2" - fi - add_on_exit rm -f raw.img - bzip2 "${appliance_build_name}-kvm.qcow2" - mv "${appliance_build_name}-kvm.qcow2.bz2" dist/ - log INFO "${appliance} exported for KVM: dist/${appliance_build_name}-kvm.qcow2.bz2" - else - log WARN "** Skipping ${appliance_build_name} export for KVM: qemu-img is missing. **" - fi + qemu-img convert -o compat=0.10 -f qcow2 -c -O qcow2 "dist/${appliance}" "dist/${appliance_build_name}-kvm.qcow2" + local qemuresult=$? + cd dist && bzip2 "${appliance_build_name}-kvm.qcow2" && cd .. + log INFO "${appliance} exported for KVM: dist/${appliance_build_name}-kvm.qcow2.bz2" } function vmware_export() { log INFO "creating vmware export" - local machine_uuid="${1}" - local hdd_uuid="${2}" - vboxmanage clonehd "${hdd_uuid}" "${appliance_build_name}-vmware.vmdk" --format VMDK + qemu-img convert -f qcow2 -O vmdk "dist/${appliance}" "dist/${appliance_build_name}-vmware.vmdk" if ! ovftool_loc="$(type -p "ovftool")" || [ -z "$ovftool_loc" ]; then - log INFO "ovftool not found, using traditional method to export ova file" - vboxmanage export "${machine_uuid}" --output "${appliance_build_name}-vmware.ovf" - log INFO "${appliance} exported for VMWare: dist/${appliance_build_name}-vmware.{vmdk.bz2,ovf}" - add_on_exit rm -f ${appliance_build_name}-vmware.ovf - add_on_exit rm -f ${appliance_build_name}-vmware-disk[0-9].vmdk - - # xsltproc doesn't support this XSLT so we use java to run this one XSLT - mv ${appliance_build_name}-vmware.ovf ${appliance_build_name}-vmware.ovf-orig - java -cp convert Convert convert_ovf_vbox_to_esx.xslt \ - ${appliance_build_name}-vmware.ovf-orig \ - ${appliance_build_name}-vmware.ovf - add_on_exit rm -f ${appliance_build_name}-vmware.ovf-orig - chmod 666 *.vmdk *.ovf - tar -cf ${appliance_build_name}-vmware.ova \ - ${appliance_build_name}-vmware.ovf \ - ${appliance_build_name}-vmware-disk[0-9].vmdk - else - log INFO "ovftool found, using it to export ova file" - chmod 666 ${appliance_build_name}-vmware.vmdk - stage_vmx ${appliance_build_name}-vmware ${appliance_build_name}-vmware.vmdk - ovftool ${appliance_build_name}-vmware.vmx ${appliance_build_name}-vmware.ova + log INFO "ovftool not found, skipping ova generation for VMware" + return fi - mv ${appliance_build_name}-vmware.ova dist/ + + log INFO "ovftool found, using it to export ova file" + CDIR=$PWD + cd dist + chmod 666 ${appliance_build_name}-vmware.vmdk + stage_vmx ${appliance_build_name}-vmware ${appliance_build_name}-vmware.vmdk + ovftool ${appliance_build_name}-vmware.vmx ${appliance_build_name}-vmware.ova + rm -f *vmx *vmdk + cd $CDIR log INFO "${appliance} exported for VMWare: dist/${appliance_build_name}-vmware.ova" } -function vagrant_export() { - log INFO "creating vagrant export" - local machine_uuid="${1}" - # this is based on veewee export logic, but, we don't want to use veewee export, - # since it makes optimistic assumptions about VM shutdown/halt leading to available - # disks and the like - # predicting VBoxManage disk naming seems problematic - # disk="${appliance_build_name}-vmware.ovf" - # image="${appliance_build_name}-vmware-disk1.vmdk" - mkdir -p "box/${appliance_build_name}" - # cp "${disk}" "box/${appliance_build_name}/box.ovf" - # cp "${image}" "box/${appliance_build_name}/box-disk1.vmdk" - cat >box/${appliance_build_name}/Vagrantfile < dist/md5sum.txt + # process the disk at dist + kvm_export + ovm_export + xen_server_export + vmware_export + hyperv_export + rm -f "dist/${appliance}" + cd dist && md5sum * > md5sum.txt && cd .. + cd dist && sha512sum * > sha512sum.txt && cd .. add_on_exit log INFO "BUILD SUCCESSFUL" } diff --git a/tools/appliance/builtin/http/kickstart.cfg b/tools/appliance/builtin/http/kickstart.cfg new file mode 100644 index 00000000000..80a5d6d9255 --- /dev/null +++ b/tools/appliance/builtin/http/kickstart.cfg @@ -0,0 +1,91 @@ +# 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. + +# Run the installer +install +# Use cdrom media +cdrom +lang en_US.UTF-8 +keyboard us +network --bootproto=dhcp --hostname=builtin-centos7 +rootpw password +firewall --disabled +selinux --disabled +timezone UTC +unsupported_hardware +bootloader --location=mbr +text +skipx +zerombr +clearpart --all --initlabel +autopart +auth --enableshadow --passalgo=sha512 --kickstart +firstboot --disabled +eula --agreed +services --disabled="chronyd" --enabled="sshd" +reboot +user --name=cloud --plaintext --password cloud + +%packages --ignoremissing --excludedocs +@^minimal +@core +kexec-tools +# unnecessary firmware +-aic94xx-firmware +-atmel-firmware +-b43-openfwwf +-bfa-firmware +-ipw2100-firmware +-ipw2200-firmware +-ivtv-firmware +-iwl100-firmware +-iwl1000-firmware +-iwl3945-firmware +-iwl4965-firmware +-iwl5000-firmware +-iwl5150-firmware +-iwl6000-firmware +-iwl6000g2a-firmware +-iwl6050-firmware +-libertas-usb8388-firmware +-ql2100-firmware +-ql2200-firmware +-ql23xx-firmware +-ql2400-firmware +-ql2500-firmware +-rt61pci-firmware +-rt73usb-firmware +-xorg-x11-drv-ati-firmware +-zd1211-firmware + +%end + +%post +exec < /dev/tty3 > /dev/tty3 +chvt 3 +echo +echo "################################" +echo "# Running Post Configuration #" +echo "################################" +( +echo "cloud ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers +sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers +/usr/bin/yum -y --enablerepo extras install epel-release +) 2>&1 | /usr/bin/tee /var/log/post_install.log +chvt 1 + +%end diff --git a/tools/vagrant/systemvm/Gemfile b/tools/appliance/builtin/scripts/base.sh similarity index 65% rename from tools/vagrant/systemvm/Gemfile rename to tools/appliance/builtin/scripts/base.sh index cd0fea4b1b6..30e6438de9e 100644 --- a/tools/vagrant/systemvm/Gemfile +++ b/tools/appliance/builtin/scripts/base.sh @@ -15,6 +15,17 @@ # specific language governing permissions and limitations # under the License. -source 'https://rubygems.org' +set -eux -gem 'vagrant-wrapper' +sed -i 's/^GSS/\#GSS/g' /etc/ssh/sshd_config +echo "PermitRootLogin yes" >> /etc/ssh/sshd_config +echo "UseDNS no" >> /etc/ssh/sshd_config + +yum -y update + +yum install -y tmux vim htop wget telnet tcpdump sed awk ssh httpd net-tools open-vm-tools +systemctl enable httpd + +iptables -I INPUT -p tcp -m tcp --dport 22 -j ACCEPT +iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT +iptables-save > /etc/sysconfig/iptables diff --git a/tools/appliance/Gemfile b/tools/appliance/builtin/scripts/cleanup.sh similarity index 74% rename from tools/appliance/Gemfile rename to tools/appliance/builtin/scripts/cleanup.sh index 8930c3b06da..811b30dbe8a 100644 --- a/tools/appliance/Gemfile +++ b/tools/appliance/builtin/scripts/cleanup.sh @@ -15,11 +15,17 @@ # specific language governing permissions and limitations # under the License. -source 'https://rubygems.org' +set -ux -gem 'veewee', '~> 0.4.5.1' -gem 'em-winrm' -gem 'sys-proctable' -gem 'net-scp' -gem 'net-ssh' -gem 'progressbar', '0.21.0' +rm -f /etc/udev/rules.d/70-persistent* + +yum -y clean all + +fstrim -av +dd if=/dev/zero of=/EMPTY bs=1M +rm -f /EMPTY +# Block until the empty file has been removed, otherwise, Packer +# will try to kill the box while the disk is still full and that's bad +sync +sync +sync diff --git a/tools/appliance/builtin/template.json b/tools/appliance/builtin/template.json new file mode 100644 index 00000000000..c9881c15e5e --- /dev/null +++ b/tools/appliance/builtin/template.json @@ -0,0 +1,53 @@ +{ + "description": "CentOS 7 x86_64 Built-in template for CloudStack", + "provisioners": [ + { + "type": "shell", + "scripts": [ + "scripts/base.sh", + "scripts/cleanup.sh" + ] + } + ], + "builders": [ + { + "type": "qemu", + "accelerator": "kvm", + "headless": true, + "qemuargs": [ + [ "-m", "512M" ], + [ "-smp", "cpus=1,maxcpus=1,cores=1" ] + ], + "disk_size": 10240, + "format": "qcow2", + "disk_interface": "virtio", + "net_device": "virtio-net", + + "iso_url": "http://mirror.nbrc.ac.in/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1708.iso", + "iso_checksum": "5848f2fd31c7acf3811ad88eaca6f4aa", + "iso_checksum_type": "md5", + + "vm_name": "builtin", + "output_directory": "../dist", + + "http_directory": "http", + "http_port_min": 10082, + "http_port_max": 10089, + + "ssh_host_port_min": 2222, + "ssh_host_port_max": 2229, + + "ssh_username": "root", + "ssh_password": "password", + "ssh_port": 22, + "ssh_wait_timeout": "30m", + + "boot_wait": "10s", + "boot_command": [ + " text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}//kickstart.cfg" + ], + + "shutdown_command": "shutdown -P now" + } + ] +} diff --git a/tools/appliance/convert/Convert.class b/tools/appliance/convert/Convert.class deleted file mode 100644 index 3f243418fff20c041ed3ad6d5fc9a874cd6900cb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 984 zcma)5U2hUW6g>kA1KYJ9)>bK0T0h!_eyrk~7=38OkYJmXYSQ#+!Liu}X3g$U>Cf_| z7)ksA{wU*}T}nyQ6!&57&bfE)xp&UoKYxGy22jB(6BcqNR*>f?aIBgz@YqBWMGdZT zteeQ_%@aK3c*gOZA^paao_foWv`e2Ej6MI0V3=!oQtbD-EfE~KtqvhZ*YzaBvVGDx zbI)C;u_|*@(PN)Lmb~Ou`I1^=w=sn-jNp+TOz3f=nh4Vjo4n^4O zD2^8vUZTRlM^!P*UpIEpIumWhuy{pQKN$DNkdII)l=JDZ-n@{??N4}Z?Y-H`(N$9- zmiRXI7>7Wl`_1G zgKiSVT2!Z2LG;BbEiz=sf-_X_zJVd&|d;fKQCJ6Xtzq1kxi8cU_a=G zq^30;fjMNcfctbrhlVsCDY74aBGDKkc|3%1TuxR7NDYwwxV3!=zCXr|5&qiP$r(dr v;^ - - - - vmx-07 - - - - - scsiController0 - SCSI Controller - scsiController0 - - lsilogic - 6 - - - - - - - - - - diff --git a/tools/appliance/definitions/builtin/base.sh b/tools/appliance/definitions/builtin/base.sh deleted file mode 100644 index 38138695daa..00000000000 --- a/tools/appliance/definitions/builtin/base.sh +++ /dev/null @@ -1,14 +0,0 @@ -# Base install - -sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers - -cat > /etc/yum.repos.d/epel.repo << EOM -[epel] -name=epel -baseurl=http://download.fedoraproject.org/pub/epel/6/\$basearch -enabled=1 -gpgcheck=0 -EOM - -# Make ssh faster by not waiting on DNS -echo "UseDNS no" >> /etc/ssh/sshd_config diff --git a/tools/appliance/definitions/builtin/cleanup.sh b/tools/appliance/definitions/builtin/cleanup.sh deleted file mode 100644 index 825a0091d2c..00000000000 --- a/tools/appliance/definitions/builtin/cleanup.sh +++ /dev/null @@ -1,21 +0,0 @@ -# Clean up unneeded packages. -yum -y erase gtk2 libX11 hicolor-icon-theme avahi freetype bitstream-vera-fonts -yum -y clean all - -#rm -rf /etc/yum.repos.d/{puppetlabs,epel}.repo -rm -rf VBoxGuestAdditions_*.iso -rm -rf xs-tools*.iso - -# Ensure that udev doesn't screw us with network device naming. -ln -sf /dev/null /lib/udev/rules.d/75-persistent-net-generator.rules -rm -f /etc/udev/rules.d/70-persistent-net.rules - -# On startup, remove HWADDR from the eth0 interface. -cp -f /etc/sysconfig/network-scripts/ifcfg-eth0 /tmp/eth0 -sed "/^HWADDR/d" /tmp/eth0 > /etc/sysconfig/network-scripts/ifcfg-eth0 -sed -e "s/dhcp/none/;s/eth0/eth1/" /etc/sysconfig/network-scripts/ifcfg-eth0 > /etc/sysconfig/network-scripts/ifcfg-eth1 - -# Prevent way too much CPU usage in VirtualBox by disabling APIC. -sed -e 's/\tkernel.*/& noapic/' /boot/grub/grub.conf > /tmp/new_grub.conf -mv /boot/grub/grub.conf /boot/grub/grub.conf.bak -mv /tmp/new_grub.conf /boot/grub/grub.conf diff --git a/tools/appliance/definitions/builtin/definition.rb b/tools/appliance/definitions/builtin/definition.rb deleted file mode 100644 index a994728c8e6..00000000000 --- a/tools/appliance/definitions/builtin/definition.rb +++ /dev/null @@ -1,33 +0,0 @@ -Veewee::Definition.declare({ - :cpu_count => '1', - :memory_size=> '2048', - :disk_size => '8000', :disk_format => 'VDI', :hostiocache => 'off', - :os_type_id => 'RedHat6_64', - :iso_file => "CentOS-6.4-x86_64-minimal.iso", - :iso_src => "http://centos.mirror.net.in/centos/6.4/isos/x86_64/CentOS-6.4-x86_64-minimal.iso", - :iso_md5 => "4a5fa01c81cc300f4729136e28ebe600", - :iso_download_timeout => "1000", - :boot_wait => "10", - :boot_cmd_sequence => [ - ' text ks=http://%IP%:%PORT%/ks.cfg' - ], - :kickstart_port => "7122", - :kickstart_timeout => "10000", - :kickstart_file => "ks.cfg", - :ssh_login_timeout => "10000", - :ssh_user => "root", - :ssh_password => "password", - :ssh_key => "", - :ssh_host_port => "7222", - :ssh_guest_port => "22", - :sudo_cmd => "echo '%p'|sudo -S sh '%f'", - :shutdown_cmd => "halt -p", - :postinstall_files => [ - "base.sh", - "postinstall.sh", - "install-xs-tools.sh", - "cleanup.sh", - "zerodisk.sh" - ], - :postinstall_timeout => "10000" -}) diff --git a/tools/appliance/definitions/builtin/install-xs-tools.sh b/tools/appliance/definitions/builtin/install-xs-tools.sh deleted file mode 100644 index 94f96c38568..00000000000 --- a/tools/appliance/definitions/builtin/install-xs-tools.sh +++ /dev/null @@ -1,10 +0,0 @@ -# get the latest xs tools available from xen.org -wget --no-check-certificate http://downloads.xen.org/XCP/debian/xs-tools-5.9.960.iso -O xs-tools.iso - -sudo mount -o loop xs-tools.iso /mnt - -#install the xs tools -sudo yes | sudo sh /mnt/Linux/install.sh - -#unmount and cleanup -sudo umount /mnt diff --git a/tools/appliance/definitions/builtin/ks.cfg b/tools/appliance/definitions/builtin/ks.cfg deleted file mode 100644 index 3034b057189..00000000000 --- a/tools/appliance/definitions/builtin/ks.cfg +++ /dev/null @@ -1,35 +0,0 @@ -install -cdrom -lang en_US.UTF-8 -keyboard us -network --bootproto=dhcp -rootpw password -firewall --enabled --service=ssh -authconfig --enableshadow --passalgo=sha512 -selinux --disabled -timezone UTC -bootloader --location=mbr - -text -skipx -zerombr - -clearpart --all --initlabel -autopart - -auth --useshadow --enablemd5 -firstboot --disabled -reboot - -%packages --nobase -@core -%end - -%post -/usr/bin/yum -y install sudo -/usr/sbin/groupadd veewee -/usr/sbin/useradd veewee -g veewee -G wheel -echo "veewee"|passwd --stdin veewee -echo "veewee ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/veewee -chmod 0440 /etc/sudoers.d/veewee -%end diff --git a/tools/appliance/definitions/builtin/postinstall.sh b/tools/appliance/definitions/builtin/postinstall.sh deleted file mode 100644 index ef595126c35..00000000000 --- a/tools/appliance/definitions/builtin/postinstall.sh +++ /dev/null @@ -1,54 +0,0 @@ -# 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. - -set -x - -install_packages() { - - # dev tools, ssh, nfs - yum -y install wget telnet tcpdump sed awk ssh htop - - # utlities - yum -y install httpd -} - -start_services() { - service httpd start -} - -httpd_configure() { - # start httpd on boot - chkconfig httpd on - # open port 80 - iptables -I INPUT -p tcp --dport 80 -j ACCEPT - # create a test page - echo "

Hello, World

" > /var/www/html/test.html - # give 755 permissions and ownership - chmod -R 755 /var/www/html/ - chown -R apache:apache /var/www/html/ -} - -begin=$(date +%s) - -install_packages -httpd_configure -start_services - -fin=$(date +%s) -t=$((fin-begin)) - -echo "Testing Builtin baked in $t seconds" diff --git a/tools/appliance/definitions/builtin/zerodisk.sh b/tools/appliance/definitions/builtin/zerodisk.sh deleted file mode 100644 index 938075a31e6..00000000000 --- a/tools/appliance/definitions/builtin/zerodisk.sh +++ /dev/null @@ -1,3 +0,0 @@ -# Zero out the free space to save space in the final image: -dd if=/dev/zero of=/EMPTY bs=1M -rm -f /EMPTY diff --git a/tools/appliance/definitions/debianbase/cleanup.sh b/tools/appliance/definitions/debianbase/cleanup.sh deleted file mode 100644 index cd32d5b42aa..00000000000 --- a/tools/appliance/definitions/debianbase/cleanup.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/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. - -set -e -set -x - -function cleanup_apt() { - #apt-get -y remove linux-headers-$(uname -r) build-essential - apt-get -y remove dictionaries-common busybox - apt-get -y autoremove - apt-get autoclean - apt-get clean -} - -# Removing leftover leases and persistent rules -function cleanup_dhcp() { - rm -f /var/lib/dhcp/* -} - -# Make sure Udev doesn't block our network -function cleanup_dev() { - echo "cleaning up udev rules" - rm -f /etc/udev/rules.d/70-persistent-net.rules - rm -rf /dev/.udev/ - rm -f /lib/udev/rules.d/75-persistent-net-generator.rules -} - -function cleanup() { - cleanup_apt - cleanup_dhcp - cleanup_dev -} - -return 2>/dev/null || cleanup diff --git a/tools/appliance/definitions/debianbase/configure_login.sh b/tools/appliance/definitions/debianbase/configure_login.sh deleted file mode 100644 index 36fccabc5fa..00000000000 --- a/tools/appliance/definitions/debianbase/configure_login.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/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. - -set -e -set -x - -function add_admin_group() { - groupadd -f -r admin -} - -function configure_cloud_user() { - usermod -a -G admin cloud - mkdir -p /home/cloud/.ssh - chmod 700 /home/cloud/.ssh - echo "cloud:`openssl rand -base64 32`" | chpasswd -} - -function configure_sudoers() { - cat >/etc/sudoers < /etc/sudoers.d/cloud -} - -# sshd_config is overwritten from cloud_scripts -#function configure_sshd() { -# grep "UseDNS no" /etc/ssh/sshd_config && \ -# grep "PasswordAuthentication no" /etc/ssh/sshd_config && \ -# return -# # Tweak sshd to prevent DNS resolution (speed up logins) -# echo 'UseDNS no' >> /etc/ssh/sshd_config -# -# # Require ssh keys for login -# sed -i -e 's/^.*PasswordAuthentication .*$/PasswordAuthentication no/g' /etc/ssh/sshd_config -#} - -function configure_inittab() { - grep "vc:2345:respawn:/sbin/getty" /etc/inittab && return - - # Fix inittab - cat >> /etc/inittab << EOF - -vc:2345:respawn:/sbin/getty 38400 hvc0 -EOF -} - -function configure_login() { - add_admin_group - configure_cloud_user - configure_sudoers - # configure_sshd - configure_inittab -} - -return 2>/dev/null || configure_login diff --git a/tools/appliance/definitions/debianbase/definition.rb b/tools/appliance/definitions/debianbase/definition.rb deleted file mode 100644 index 9e41e65946d..00000000000 --- a/tools/appliance/definitions/debianbase/definition.rb +++ /dev/null @@ -1,80 +0,0 @@ -# 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. - -arch = ENV['VM_ARCH'] || 'i386' - -architectures = { - :i386 => { - :os_type_id => 'Debian', - :iso_file => 'debian-7.6.0-i386-netinst.iso', - :iso_src => 'http://cdimage.debian.org/debian-cd/7.6.0/i386/iso-cd/debian-7.6.0-i386-netinst.iso', - :iso_md5 => '528e1a7315da1bbf50bd4d187880a519', - }, - :amd64 => { - :os_type_id => 'Debian_64', - :iso_file => 'debian-7.6.0-amd64-netinst.iso', - :iso_src => 'http://cdimage.debian.org/debian-cd/7.6.0/amd64/iso-cd/debian-7.6.0-amd64-netinst.iso', - :iso_md5 => '8a3c2ad7fd7a9c4c7e9bcb5cae38c135' - } -} - -config = { - :cpu_count => '1', - :memory_size => '256', - :disk_size => '2500', :disk_format => 'VDI', :hostiocache => 'off', - :iso_download_timeout => '1200', - :boot_wait => '10', - :boot_cmd_sequence => [ - '', - 'install ', - 'preseed/url=http://%IP%:%PORT%/preseed.cfg ', - 'debian-installer=en_US ', - 'auto ', - 'locale=en_US ', - 'kbd-chooser/method=us ', - 'netcfg/get_hostname=systemvm ', - 'netcfg/get_domain=apache.org ', - 'fb=false ', - 'debconf/frontend=noninteractive ', - 'console-setup/ask_detect=false ', - 'console-keymaps-at/keymap=us ', - 'keyboard-configuration/xkb-keymap=us ', - '' - ], - :kickstart_port => '7122', - :kickstart_timeout => '1200', - :kickstart_file => 'preseed.cfg', - :ssh_login_timeout => '1200', - :ssh_user => 'root', - :ssh_password => 'password', - :ssh_key => '', - :ssh_host_port => '7222', - :ssh_guest_port => '22', - :sudo_cmd => "echo '%p'|sudo -S sh '%f'", - :shutdown_cmd => 'halt -p', - :postinstall_files => [ - # basic minimal vm creation - 'configure_login.sh', - 'cleanup.sh', - 'zerodisk.sh' - ], - :postinstall_timeout => '1200' -} - -config.merge! architectures[arch.to_sym] - -Veewee::Definition.declare(config) diff --git a/tools/appliance/definitions/debianbase/preseed.cfg b/tools/appliance/definitions/debianbase/preseed.cfg deleted file mode 100644 index e6e5adbdd32..00000000000 --- a/tools/appliance/definitions/debianbase/preseed.cfg +++ /dev/null @@ -1,129 +0,0 @@ -# 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. - -### Localization -# Locale sets language and country. -d-i debian-installer/locale string en_US - -# Keyboard selection. -d-i console-keymaps-at/keymap select us - -### Network configuration -d-i netcfg/choose_interface select auto -d-i netcfg/get_hostname string debianbase -d-i netcfg/get_domain string cloudstack.org - -### Mirror settings -d-i mirror/country string manual -d-i mirror/http/hostname string http.us.debian.org -d-i mirror/http/directory string /debian -d-i mirror/http/proxy string - -### Clock and time zone setup -d-i clock-setup/utc boolean true -d-i time/zone string UTC -d-i clock-setup/ntp boolean true - -### Partitioning -d-i partman-auto/disk string /dev/sda -d-i partman-auto/method string regular -d-i partman-auto/choose_recipe select atomic -d-i partman-auto/expert_recipe string \ - boot-root :: \ - 30 50 100 ext4 \ - $primary{ } $bootable{ } \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /boot } \ - . \ - 300 40 400 ext4 \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ / } \ - . \ - 50 100 200 ext4 \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /home } \ - . \ - 650 20 1100 ext4 \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /usr } \ - . \ - 400 40 500 ext4 \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /opt } \ - . \ - 450 60 1000 ext4 \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /var } \ - . \ - 50 70 400 ext4 \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /tmp } \ - . \ - 70 512 300% linux-swap \ - method{ swap } format{ } \ - . -d-i partman/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true - -### Base system installation -# ... - -### Account setup -d-i passwd/root-login boolean true -d-i passwd/root-password password password -d-i passwd/root-password-again password password -d-i passwd/user-fullname string Cloud Stack -d-i passwd/username string cloud -d-i passwd/user-password password cloud -d-i passwd/user-password-again password cloud -d-i user-setup/encrypt-home boolean false -d-i user-setup/allow-password-weak boolean true -d-i passwd/user-default-groups string audio cdrom video admin - -### Apt setup -# ... - -### Package selection -tasksel tasksel/first multiselect ssh-server -d-i pkgsel/include string openssh-server ntp acpid sudo bzip2 -# Allowed values: none, safe-upgrade, full-upgrade -d-i pkgsel/upgrade select none - -popularity-contest popularity-contest/participate boolean false - -### Boot loader installation -d-i grub-installer/only_debian boolean true -d-i finish-install/reboot_in_progress note - -### Preseeding other packages -libssl1.0.0 libssl1.0.0/restart-services string -libssl1.0.0 libssl1.0.0/restart-failed error - -#### Advanced options -# Prevent packaged version of VirtualBox Guest Additions being installed: -d-i preseed/early_command string sed -i \ - '/in-target/idiscover(){/sbin/discover|grep -v VirtualBox;}' \ - /usr/lib/pre-pkgsel.d/20install-hwpackages diff --git a/tools/appliance/definitions/debianbase/zerodisk.sh b/tools/appliance/definitions/debianbase/zerodisk.sh deleted file mode 100644 index 581e868edc9..00000000000 --- a/tools/appliance/definitions/debianbase/zerodisk.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/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. - -set -e -set -x - -# clean up stuff copied in by veewee -function cleanup_veewee() { - # this has to be here since it is the last file to run (and we remove ourselves) - rm -fv /root/*.iso - rm -fv /root/{apt_upgrade,authorized_keys,build_time,cleanup,install_systemvm_packages,zerodisk}.sh - rm -fv /root/configure_{acpid,conntrack,grub,locale,login,networking,systemvm_services}.sh - rm -fv .veewee_version .veewee_params .vbox_version -} - -# Zero out the free space to save space in the final image: -function zero_disk() { - cleanup_veewee - - for path in / /boot /usr /var /opt /tmp /home - do - dd if=/dev/zero of=${path}/zero bs=1M || true - sync - rm -f ${path}/zero - done -} - -return 2>/dev/null || zero_disk diff --git a/tools/appliance/definitions/devcloud/base.sh b/tools/appliance/definitions/devcloud/base.sh deleted file mode 100644 index 7fec0fc342d..00000000000 --- a/tools/appliance/definitions/devcloud/base.sh +++ /dev/null @@ -1,12 +0,0 @@ -# Update the box -apt-get -y update -#below are needed for ruby perhaps -#apt-get -y install linux-headers-$(uname -r) build-essential -#apt-get -y install zlib1g-dev libssl-dev libreadline-gplv2-dev -apt-get -y install curl unzip -apt-get clean - -echo 'cloud ALL=NOPASSWD:/bin/chmod, /bin/cp, /bin/mkdir, /bin/mount, /bin/umount' > /etc/sudoers.d/cloud - -# Tweak sshd to prevent DNS resolution (speed up logins) -echo 'UseDNS no' >> /etc/ssh/sshd_config diff --git a/tools/appliance/definitions/devcloud/cleanup.sh b/tools/appliance/definitions/devcloud/cleanup.sh deleted file mode 100644 index 9e98ab03531..00000000000 --- a/tools/appliance/definitions/devcloud/cleanup.sh +++ /dev/null @@ -1,21 +0,0 @@ -# Clean up -#apt-get -y remove linux-headers-$(uname -r) build-essential -apt-get -y remove dictionaries-common busybox -apt-get -y autoremove -apt-get autoclean -apt-get clean - -# Removing leftover leases and persistent rules -echo "cleaning up dhcp leases" -rm /var/lib/dhcp/* - -# Make sure Udev doesn't block our network -echo "cleaning up udev rules" -rm /etc/udev/rules.d/70-persistent-net.rules -mkdir /etc/udev/rules.d/70-persistent-net.rules -rm -rf /dev/.udev/ -rm /lib/udev/rules.d/75-persistent-net-generator.rules - -echo "Adding a 2 sec delay to the interface up, to make the dhclient happy" -echo "pre-up sleep 2" >> /etc/network/interfaces - diff --git a/tools/appliance/definitions/devcloud/definition.rb b/tools/appliance/definitions/devcloud/definition.rb deleted file mode 100644 index 29a3f052a12..00000000000 --- a/tools/appliance/definitions/devcloud/definition.rb +++ /dev/null @@ -1,45 +0,0 @@ -Veewee::Definition.declare({ - :cpu_count => '1', - :memory_size=> '2048', - :disk_size => '32000', :disk_format => 'VDI', :hostiocache => 'off', - :os_type_id => 'Debian', - :iso_file => "debian-7.0.0-i386-netinst.iso", - :iso_src => "http://cdimage.debian.org/mirror/cdimage/archive/7.0.0/i386/iso-cd/debian-7.0.0-i386-netinst.iso", - :iso_md5 => "a6b93666a5393334accb7ac4ee28d949", - :iso_download_timeout => "1000", - :boot_wait => "10", :boot_cmd_sequence => [ - '', - 'install ', - 'preseed/url=http://%IP%:%PORT%/preseed.cfg ', - 'debian-installer=en_US ', - 'auto ', - 'locale=en_US ', - 'kbd-chooser/method=us ', - 'netcfg/get_hostname=systemvm ', - 'netcfg/get_domain=apache.org ', - 'fb=false ', - 'debconf/frontend=noninteractive ', - 'console-setup/ask_detect=false ', - 'console-keymaps-at/keymap=us ', - 'keyboard-configuration/xkb-keymap=us ', - '' - ], - :kickstart_port => "7122", - :kickstart_timeout => "10000", - :kickstart_file => "preseed.cfg", - :ssh_login_timeout => "10000", - :ssh_user => "root", - :ssh_password => "password", - :ssh_key => "", - :ssh_host_port => "7222", - :ssh_guest_port => "22", - :sudo_cmd => "echo '%p'|sudo -S sh '%f'", - :shutdown_cmd => "halt -p", - :postinstall_files => [ - "base.sh", - "postinstall.sh", - "cleanup.sh", - "zerodisk.sh" - ], - :postinstall_timeout => "10000" -}) diff --git a/tools/appliance/definitions/devcloud/postinstall.sh b/tools/appliance/definitions/devcloud/postinstall.sh deleted file mode 100644 index 9ec1240d369..00000000000 --- a/tools/appliance/definitions/devcloud/postinstall.sh +++ /dev/null @@ -1,60 +0,0 @@ -# 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. - -set -x - -install_packages() { - DEBIAN_FRONTEND=noninteractive - DEBIAN_PRIORITY=critical - - # utlities - apt-get --no-install-recommends -q -y --force-yes install python bzip2 sed gawk diffutils grep gzip less tar telnet wget zip unzip sudo - - # dev tools, ssh, nfs - apt-get --no-install-recommends -q -y --force-yes install git vim tcpdump ebtables iptables openssl openssh-server openjdk-6-jdk genisoimage python-pip nfs-kernel-server - - # mysql with root password=password - debconf-set-selections <<< 'mysql-server- mysql-server/root_password password password' - debconf-set-selections <<< 'mysql-server- mysql-server/root_password_again password password' - apt-get --no-install-recommends -q -y --force-yes install mysql-server - - # xen and xcp - apt-get --no-install-recommends -q -y --force-yes install linux-headers-3.2.0-4-686-pae xen-hypervisor-4.1-i386 xcp-xapi xcp-xe xcp-guest-templates xcp-vncterm xen-tools blktap-utils blktap-dkms qemu-keymaps qemu-utils - -} - -fix_locale() { - cat >> /etc/default/locale << EOF -LANG=en_US.UTF-8 -LC_ALL=en_US.UTF-8 -EOF - cat >> /etc/locale.gen << EOF -en_US.UTF-8 UTF-8 -EOF - - locale-gen en_US.UTF-8 -} - -begin=$(date +%s) - -install_packages -fix_locale - -fin=$(date +%s) -t=$((fin-begin)) - -echo "DevCloud baked in $t seconds" diff --git a/tools/appliance/definitions/devcloud/preseed.cfg b/tools/appliance/definitions/devcloud/preseed.cfg deleted file mode 100644 index ac9edd31213..00000000000 --- a/tools/appliance/definitions/devcloud/preseed.cfg +++ /dev/null @@ -1,357 +0,0 @@ -#### Contents of the preconfiguration file (for squeeze) -### Localization -# Locale sets language and country. -d-i debian-installer/locale string en_US - -# Keyboard selection. -#d-i console-tools/archs select at -d-i console-keymaps-at/keymap select us -# Example for a different keyboard architecture -#d-i console-keymaps-usb/keymap select mac-usb-us - -### Network configuration -# netcfg will choose an interface that has link if possible. This makes it -# skip displaying a list if there is more than one interface. -d-i netcfg/choose_interface select auto - -# To pick a particular interface instead: -#d-i netcfg/choose_interface select eth1 - -# If you have a slow dhcp server and the installer times out waiting for -# it, this might be useful. -#d-i netcfg/dhcp_timeout string 60 - -# If you prefer to configure the network manually, uncomment this line and -# the static network configuration below. -#d-i netcfg/disable_dhcp boolean true - -# If you want the preconfiguration file to work on systems both with and -# without a dhcp server, uncomment these lines and the static network -# configuration below. -#d-i netcfg/dhcp_failed note -#d-i netcfg/dhcp_options select Configure network manually - -# Static network configuration. -#d-i netcfg/get_nameservers string 192.168.1.1 -#d-i netcfg/get_ipaddress string 192.168.1.42 -#d-i netcfg/get_netmask string 255.255.255.0 -#d-i netcfg/get_gateway string 192.168.1.1 -#d-i netcfg/confirm_static boolean true - -# Any hostname and domain names assigned from dhcp take precedence over -# values set here. However, setting the values still prevents the questions -# from being shown, even if values come from dhcp. -d-i netcfg/get_hostname string systemvm -d-i netcfg/get_domain string cloudstack.org - -# Disable that annoying WEP key dialog. -d-i netcfg/wireless_wep string -# The wacky dhcp hostname that some ISPs use as a password of sorts. -#d-i netcfg/dhcp_hostname string radish - -# If non-free firmware is needed for the network or other hardware, you can -# configure the installer to always try to load it, without prompting. Or -# change to false to disable asking. -#d-i hw-detect/load_firmware boolean true - -### Network console -# Use the following settings if you wish to make use of the network-console -# component for remote installation over SSH. This only makes sense if you -# intend to perform the remainder of the installation manually. -#d-i anna/choose_modules string network-console -#d-i network-console/password password r00tme -#d-i network-console/password-again password r00tme - -### Mirror settings -# If you select ftp, the mirror/country string does not need to be set. -#d-i mirror/protocol string ftp -d-i mirror/country string manual -d-i mirror/http/hostname string http.us.debian.org -d-i mirror/http/directory string /debian -d-i mirror/http/proxy string - -# Suite to install. -#d-i mirror/suite string testing -# Suite to use for loading installer components (optional). -#d-i mirror/udeb/suite string testing - -### Clock and time zone setup -# Controls whether or not the hardware clock is set to UTC. -d-i clock-setup/utc boolean true - -# You may set this to any valid setting for $TZ; see the contents of -# /usr/share/zoneinfo/ for valid values. -d-i time/zone string UTC - -# Controls whether to use NTP to set the clock during the install -d-i clock-setup/ntp boolean true -# NTP server to use. The default is almost always fine here. -#d-i clock-setup/ntp-server string ntp.example.com - -### Partitioning -# If the system has free space you can choose to only partition that space. -#d-i partman-auto/init_automatically_partition select biggest_free - -# Alternatively, you can specify a disk to partition. The device name must -# be given in traditional non-devfs format. -# Note: A disk must be specified, unless the system has only one disk. -# For example, to use the first SCSI/SATA hard disk: -d-i partman-auto/disk string /dev/sda -# In addition, you'll need to specify the method to use. -# The presently available methods are: "regular", "lvm" and "crypto" -d-i partman-auto/method string regular - -# If one of the disks that are going to be automatically partitioned -# contains an old LVM configuration, the user will normally receive a -# warning. This can be preseeded away... -#d-i partman-lvm/device_remove_lvm boolean true -# The same applies to pre-existing software RAID array: -#d-i partman-md/device_remove_md boolean true - -# And the same goes for the confirmation to write the lvm partitions. -#d-i partman-lvm/confirm boolean true -#d-i partman-lvm/confirm_nooverwrite boolean true - -#d-i partman/choose_partition select finish -#d-i partman-auto-lvm/guided_size string max - -# You can choose one of the three predefined partitioning recipes: -# - atomic: all files in one partition -# - home: separate /home partition -# - multi: separate /home, /usr, /var, and /tmp partitions -d-i partman-auto/choose_recipe select atomic -#d-i partman/default_filesystem string ext3 - -# Or provide a recipe of your own... -# The recipe format is documented in the file devel/partman-auto-recipe.txt. -# If you have a way to get a recipe file into the d-i environment, you can -# just point at it. -#d-i partman-auto/expert_recipe_file string /hd-media/recipe - -d-i partman-auto/expert_recipe string \ - boot-root :: \ - 40 50 100 ext4 \ - $primary{ } $bootable{ } \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /boot } \ - . \ - 400 40 500 ext4 \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ / } \ - . \ - 60 100 200 ext4 \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /home } \ - . \ - 500 30 1000 ext4 \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /usr } \ - . \ - 400 40 500 ext4 \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /opt } \ - . \ - 500 60 1000 ext4 \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /var } \ - . \ - 100 70 400 ext4 \ - method{ format } format{ } \ - use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /tmp } \ - . \ - 64 512 300% linux-swap \ - method{ swap } format{ } \ - . - -# If not, you can put an entire recipe into the preconfiguration file in one -# (logical) line. This example creates a small /boot partition, suitable -# swap, and uses the rest of the space for the root partition: -#d-i partman-auto/expert_recipe string \ -# boot-root :: \ -# 40 50 100 ext3 \ -# $primary{ } $bootable{ } \ -# method{ format } format{ } \ -# use_filesystem{ } filesystem{ ext3 } \ -# mountpoint{ /boot } \ -# . \ -# 500 10000 1000000000 ext3 \ -# method{ format } format{ } \ -# use_filesystem{ } filesystem{ ext3 } \ -# mountpoint{ / } \ -# . \ -# 64 512 300% linux-swap \ -# method{ swap } format{ } \ -# . - -#The preseed line that "selects finish" needs to be in a certain order in your preseed, the example-preseed does not follow this. -#http://ubuntuforums.org/archive/index.php/t-1504045.html - -# This makes partman automatically partition without confirmation, provided -# that you told it what to do using one of the methods above. -#d-i partman-partitioning/confirm_write_new_label boolean true -d-i partman/confirm_write_new_label boolean true -d-i partman/choose_partition select finish -d-i partman/confirm boolean true -d-i partman/confirm_nooverwrite boolean true - -### Base system installation -# Select the initramfs generator used to generate the initrd for 2.6 kernels. -#d-i base-installer/kernel/linux/initramfs-generators string yaird - -# The kernel image (meta) package to be installed; "none" can be used if no -# kernel is to be installed. -#d-i base-installer/kernel/image string linux-image-2.6-486 - -### Account setup -# Skip creation of a root account (normal user account will be able to -# use sudo). -d-i passwd/root-login boolean true -# Alternatively, to skip creation of a normal user account. -#d-i passwd/make-user boolean false - -# Root password, either in clear text -d-i passwd/root-password password password -d-i passwd/root-password-again password password -# or encrypted using an MD5 hash. -#d-i passwd/root-password-crypted password [MD5 hash] - -# To create a normal user account. -d-i passwd/user-fullname string Cloud Stack -d-i passwd/username string cloud -# Normal user's password, either in clear text -d-i passwd/user-password password cloud -d-i passwd/user-password-again password cloud -# or encrypted using an MD5 hash. -#d-i passwd/user-password-crypted password [MD5 hash] -# Create the first user with the specified UID instead of the default. -#d-i passwd/user-uid string 1010 -d-i user-setup/encrypt-home boolean false -d-i user-setup/allow-password-weak boolean true - -# The user account will be added to some standard initial groups. To -# override that, use this. -d-i passwd/user-default-groups string audio cdrom video admin - -### Apt setup -# You can choose to install non-free and contrib software. -#d-i apt-setup/non-free boolean true -#d-i apt-setup/contrib boolean true -# Uncomment this if you don't want to use a network mirror. -#d-i apt-setup/use_mirror boolean false -# Select which update services to use; define the mirrors to be used. -# Values shown below are the normal defaults. -#d-i apt-setup/services-select multiselect security, volatile -#d-i apt-setup/security_host string security.debian.org -#d-i apt-setup/volatile_host string volatile.debian.org - - -# By default the installer requires that repositories be authenticated -# using a known gpg key. This setting can be used to disable that -# authentication. Warning: Insecure, not recommended. -#d-i debian-installer/allow_unauthenticated string true - -### Package selection -tasksel tasksel/first multiselect ssh-server -# If the desktop task is selected, install the kde and xfce desktops -# instead of the default gnome desktop. -#tasksel tasksel/desktop multiselect kde, xfce - -# Individual additional packages to install -d-i pkgsel/include string openssh-server ntp acpid sudo bzip2 - -# Whether to upgrade packages after debootstrap. -# Allowed values: none, safe-upgrade, full-upgrade -d-i pkgsel/upgrade select none - -# Some versions of the installer can report back on what software you have -# installed, and what software you use. The default is not to report back, -# but sending reports helps the project determine what software is most -# popular and include it on CDs. -popularity-contest popularity-contest/participate boolean false - -### Boot loader installation -# Grub is the default boot loader (for x86). If you want lilo installed -# instead, uncomment this: -#d-i grub-installer/skip boolean true -# To also skip installing lilo, and install no bootloader, uncomment this -# too: -#d-i lilo-installer/skip boolean true - -# This is fairly safe to set, it makes grub install automatically to the MBR -# if no other operating system is detected on the machine. -d-i grub-installer/only_debian boolean true - -# This one makes grub-installer install to the MBR if it also finds some other -# OS, which is less safe as it might not be able to boot that other OS. -#d-i grub-installer/with_other_os boolean true - -# Alternatively, if you want to install to a location other than the mbr, -# uncomment and edit these lines: -#d-i grub-installer/only_debian boolean false -#d-i grub-installer/with_other_os boolean false -#d-i grub-installer/bootdev string (hd0,0) -# To install grub to multiple disks: -#d-i grub-installer/bootdev string (hd0,0) (hd1,0) (hd2,0) - -# Optional password for grub, either in clear text -#d-i grub-installer/password password r00tme -#d-i grub-installer/password-again password r00tme -# or encrypted using an MD5 hash, see grub-md5-crypt(8). -#d-i grub-installer/password-crypted password [MD5 hash] - -### Finishing up the installation -# During installations from serial console, the regular virtual consoles -# (VT1-VT6) are normally disabled in /etc/inittab. Uncomment the next -# line to prevent this. -#d-i finish-install/keep-consoles boolean true - -# Avoid that last message about the install being complete. -d-i finish-install/reboot_in_progress note - -# This will prevent the installer from ejecting the CD during the reboot, -# which is useful in some situations. -#d-i cdrom-detect/eject boolean false - -# This is how to make the installer shutdown when finished, but not -# reboot into the installed system. -#d-i debian-installer/exit/halt boolean true -# This will power off the machine instead of just halting it. -#d-i debian-installer/exit/poweroff boolean true - -### Preseeding other packages -# Depending on what software you choose to install, or if things go wrong -# during the installation process, it's possible that other questions may -# be asked. You can preseed those too, of course. To get a list of every -# possible question that could be asked during an install, do an -# installation, and then run these commands: -# debconf-get-selections --installer > file -# debconf-get-selections >> file - - -#### Advanced options -### Running custom commands during the installation -# d-i preseeding is inherently not secure. Nothing in the installer checks -# for attempts at buffer overflows or other exploits of the values of a -# preconfiguration file like this one. Only use preconfiguration files from -# trusted locations! To drive that home, and because it's generally useful, -# here's a way to run any shell command you'd like inside the installer, -# automatically. - -# This first command is run as early as possible, just after -# preseeding is read. -# Prevent packaged version of VirtualBox Guest Additions being installed: -d-i preseed/early_command string sed -i \ - '/in-target/idiscover(){/sbin/discover|grep -v VirtualBox;}' \ - /usr/lib/pre-pkgsel.d/20install-hwpackages - -# This command is run just before the install finishes, but when there is -# still a usable /target directory. You can chroot to /target and use it -# directly, or use the apt-install and in-target commands to easily install -# packages and run commands in the target system. diff --git a/tools/appliance/definitions/devcloud/zerodisk.sh b/tools/appliance/definitions/devcloud/zerodisk.sh deleted file mode 100644 index a70d3e6ee89..00000000000 --- a/tools/appliance/definitions/devcloud/zerodisk.sh +++ /dev/null @@ -1,11 +0,0 @@ -# Clean up stuff copied in by veewee -rm -fv /root/*.iso -rm -fv /root/base.sh /root/cleanup.sh /root/postinstall.sh /root/zerodisk.sh -rm -fv .veewee_version .veewee_params .vbox_version - -echo "Cleaning up" - -# Zero out the free space to save space in the final image: -dd if=/dev/zero of=/zero bs=1M -sync -rm -fv /zero diff --git a/tools/appliance/shar_cloud_scripts.sh b/tools/appliance/shar_cloud_scripts.sh index 30ae2cb6f40..7847b855c33 100755 --- a/tools/appliance/shar_cloud_scripts.sh +++ b/tools/appliance/shar_cloud_scripts.sh @@ -16,7 +16,7 @@ # specific language governing permissions and limitations # under the License. -# since veewee wants .sh files to execute, we'll give it a shar +# since packer wants .sh files to execute, we'll give it a shar set -e set -x diff --git a/tools/appliance/definitions/systemvmtemplate/preseed.cfg b/tools/appliance/systemvmtemplate/http/preseed.cfg similarity index 92% rename from tools/appliance/definitions/systemvmtemplate/preseed.cfg rename to tools/appliance/systemvmtemplate/http/preseed.cfg index 0f6c265f19c..5a286fc6029 100644 --- a/tools/appliance/definitions/systemvmtemplate/preseed.cfg +++ b/tools/appliance/systemvmtemplate/http/preseed.cfg @@ -52,26 +52,25 @@ d-i time/zone string UTC d-i clock-setup/ntp boolean true ### Partitioning -d-i partman-auto/disk string /dev/sda +d-i partman-auto/disk string /dev/vda d-i partman-auto/method string regular -d-i partman-auto/choose_recipe select atomic d-i partman-auto/expert_recipe string \ boot-root :: \ - 50 50 100 ext2 \ + 80 50 100 ext2 \ $primary{ } $bootable{ } \ method{ format } format{ } \ use_filesystem{ } filesystem{ ext2 } \ mountpoint{ /boot } \ . \ - 1300 40 1600 ext4 \ + 1100 40 1600 ext4 \ method{ format } format{ } \ use_filesystem{ } filesystem{ ext4 } \ mountpoint{ / } \ . \ - 350 60 500 ext4 \ + 600 60 800 ext4 \ method{ format } format{ } \ use_filesystem{ } filesystem{ ext4 } \ - mountpoint{ /var/log } \ + mountpoint{ /var } \ . \ 100 90 200 ext4 \ method{ format } format{ } \ @@ -103,7 +102,7 @@ d-i user-setup/encrypt-home boolean false d-i user-setup/allow-password-weak boolean true d-i passwd/user-default-groups string audio cdrom video admin -#openssh-server openssh-server/permit-root-login boolean true +openssh-server openssh-server/permit-root-login boolean true ### Apt setup # ... diff --git a/tools/appliance/definitions/systemvmtemplate/apt_upgrade.sh b/tools/appliance/systemvmtemplate/scripts/apt_upgrade.sh similarity index 97% rename from tools/appliance/definitions/systemvmtemplate/apt_upgrade.sh rename to tools/appliance/systemvmtemplate/scripts/apt_upgrade.sh index 4d5ff2626d8..7387159696f 100644 --- a/tools/appliance/definitions/systemvmtemplate/apt_upgrade.sh +++ b/tools/appliance/systemvmtemplate/scripts/apt_upgrade.sh @@ -49,10 +49,11 @@ function apt_upgrade() { add_backports rm -fv /root/*.iso - apt-get -y autoremove - apt-get autoclean apt-get -q -y update apt-get -q -y upgrade + apt-get -y autoremove --purge + apt-get autoclean + apt-get clean } return 2>/dev/null || apt_upgrade diff --git a/tools/appliance/definitions/systemvmtemplate/authorized_keys.sh b/tools/appliance/systemvmtemplate/scripts/authorized_keys.sh similarity index 100% rename from tools/appliance/definitions/systemvmtemplate/authorized_keys.sh rename to tools/appliance/systemvmtemplate/scripts/authorized_keys.sh diff --git a/tools/appliance/definitions/systemvmtemplate/cleanup.sh b/tools/appliance/systemvmtemplate/scripts/cleanup.sh similarity index 100% rename from tools/appliance/definitions/systemvmtemplate/cleanup.sh rename to tools/appliance/systemvmtemplate/scripts/cleanup.sh diff --git a/tools/appliance/definitions/systemvmtemplate/configure_acpid.sh b/tools/appliance/systemvmtemplate/scripts/configure_acpid.sh similarity index 100% rename from tools/appliance/definitions/systemvmtemplate/configure_acpid.sh rename to tools/appliance/systemvmtemplate/scripts/configure_acpid.sh diff --git a/tools/appliance/definitions/systemvmtemplate/configure_conntrack.sh b/tools/appliance/systemvmtemplate/scripts/configure_conntrack.sh similarity index 100% rename from tools/appliance/definitions/systemvmtemplate/configure_conntrack.sh rename to tools/appliance/systemvmtemplate/scripts/configure_conntrack.sh diff --git a/tools/appliance/definitions/systemvmtemplate/configure_grub.sh b/tools/appliance/systemvmtemplate/scripts/configure_grub.sh similarity index 92% rename from tools/appliance/definitions/systemvmtemplate/configure_grub.sh rename to tools/appliance/systemvmtemplate/scripts/configure_grub.sh index 53ffb2dc306..1391eb993cd 100644 --- a/tools/appliance/definitions/systemvmtemplate/configure_grub.sh +++ b/tools/appliance/systemvmtemplate/scripts/configure_grub.sh @@ -20,6 +20,10 @@ set -e set -x function configure_grub() { + echo "blacklist floppy" > /etc/modprobe.d/blacklist-floppy.conf + rmmod floppy || true + update-initramfs -u + cat > /etc/default/grub < 'Debian_64', :iso_file => 'debian-9.3.0-amd64-netinst.iso', :iso_src => 'https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-9.3.0-amd64-netinst.iso', - :iso_sha512 => '8775231d6f56a3d8f116eb64fe048f5cbd2ea0f8c092a1cb7608bcb4106f9c85cb69ce68f53bd381019ab40f1c0316843036daf3fd9107c81c58a240334cc747' + :iso_md5 => '8775231d6f56a3d8f116eb64fe048f5cbd2ea0f8c092a1cb7608bcb4106f9c85cb69ce68f53bd381019ab40f1c0316843036daf3fd9107c81c58a240334cc747' } } @@ -77,7 +77,7 @@ config = { # turning it into a systemvm 'install_systemvm_packages.sh', 'configure_conntrack.sh', - '../../cloud_scripts_shar_archive.sh', + #'../../cloud_scripts_shar_archive.sh', 'configure_systemvm_services.sh', 'authorized_keys.sh', 'configure_persistent_config.sh', diff --git a/tools/appliance/definitions/systemvmtemplate/finalize.sh b/tools/appliance/systemvmtemplate/scripts/finalize.sh similarity index 95% rename from tools/appliance/definitions/systemvmtemplate/finalize.sh rename to tools/appliance/systemvmtemplate/scripts/finalize.sh index febae7bacc1..260bddff4e5 100644 --- a/tools/appliance/definitions/systemvmtemplate/finalize.sh +++ b/tools/appliance/systemvmtemplate/scripts/finalize.sh @@ -39,8 +39,8 @@ END echo 'cloud ALL=NOPASSWD:/bin/chmod, /bin/cp, /bin/mkdir, /bin/mount, /bin/umount, /sbin/halt' > /etc/sudoers.d/cloud } -# clean up stuff copied in by veewee -function cleanup_veewee() { +# clean up stuff copied in +function cleanup_final() { # this has to be here since it is the last file to run (and we remove ourselves) cd /home/cloud rm -fv *.iso @@ -64,10 +64,10 @@ function zero_disk() { function finalize() { configure_misc configure_sudoers - cleanup_veewee + cleanup_final sync zero_disk - halt -p + sync } return 2>/dev/null || finalize diff --git a/tools/appliance/definitions/systemvmtemplate/install_systemvm_packages.sh b/tools/appliance/systemvmtemplate/scripts/install_systemvm_packages.sh similarity index 98% rename from tools/appliance/definitions/systemvmtemplate/install_systemvm_packages.sh rename to tools/appliance/systemvmtemplate/scripts/install_systemvm_packages.sh index 30ad66dd4ef..fc35987c17f 100644 --- a/tools/appliance/definitions/systemvmtemplate/install_systemvm_packages.sh +++ b/tools/appliance/systemvmtemplate/scripts/install_systemvm_packages.sh @@ -45,16 +45,9 @@ function install_packages() { local apt_get="apt-get --no-install-recommends -q -y" - #32 bit architecture support:: not required for 32 bit template - if [ "${arch}" != "i386" ]; then - dpkg --add-architecture i386 - apt-get update - ${apt_get} install links:i386 libuuid1:i386 libc6:i386 - fi - ${apt_get} install grub-legacy \ rsyslog logrotate cron net-tools ifupdown tmux vim htop netbase iptables \ - openssh-server e2fsprogs tcpdump socat wget \ + openssh-server e2fsprogs tcpdump iftop socat wget \ python bzip2 sed gawk diffutils grep gzip less tar telnet ftp rsync traceroute psmisc lsof procps \ inetutils-ping iputils-arping httping curl \ dnsutils zip unzip ethtool uuid file iproute acpid sudo \ @@ -83,6 +76,13 @@ function install_packages() { apt-get autoclean apt-get clean + #32 bit architecture support:: not required for 32 bit template + if [ "${arch}" != "i386" ]; then + dpkg --add-architecture i386 + apt-get update + ${apt_get} install links:i386 libuuid1:i386 libc6:i386 + fi + # Install xenserver guest utilities as debian repos don't have it wget https://mirrors.kernel.org/ubuntu/pool/universe/x/xe-guest-utilities/xe-guest-utilities_7.4.0-0ubuntu1_amd64.deb dpkg -i xe-guest-utilities_7.4.0-0ubuntu1_amd64.deb diff --git a/tools/appliance/systemvmtemplate/template.json b/tools/appliance/systemvmtemplate/template.json new file mode 100644 index 00000000000..99c718be5a2 --- /dev/null +++ b/tools/appliance/systemvmtemplate/template.json @@ -0,0 +1,82 @@ +{ + "_license": "Apache License 2.0", + "description": "CloudStack SystemVM template", + "provisioners": [ + { + "type": "shell", + "execute_command": "echo 'cloud'|sudo -S bash '{{.Path}}'", + "scripts": [ + "scripts/apt_upgrade.sh", + "scripts/configure_grub.sh", + "scripts/configure_locale.sh", + "scripts/configure_networking.sh", + "scripts/configure_acpid.sh", + "scripts/install_systemvm_packages.sh", + "scripts/configure_conntrack.sh", + "../cloud_scripts_shar_archive.sh", + "scripts/configure_systemvm_services.sh", + "scripts/authorized_keys.sh", + "scripts/configure_persistent_config.sh", + "scripts/configure_login.sh", + "scripts/cleanup.sh", + "scripts/finalize.sh" + ] + } + ], + "builders": [ + { + "type": "qemu", + "accelerator": "kvm", + "headless": true, + "qemuargs": [ + [ "-m", "512M" ], + [ "-smp", "cpus=1,maxcpus=1,cores=1" ] + ], + "disk_size": 2100, + "format": "qcow2", + + "disk_interface": "virtio", + "net_device": "virtio-net", + + "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-9.3.0-amd64-netinst.iso", + "iso_checksum": "8775231d6f56a3d8f116eb64fe048f5cbd2ea0f8c092a1cb7608bcb4106f9c85cb69ce68f53bd381019ab40f1c0316843036daf3fd9107c81c58a240334cc747", + "iso_checksum_type": "sha512", + + "vm_name": "systemvmtemplate", + "output_directory": "../dist", + + "http_directory": "http", + "http_port_min": 10082, + "http_port_max": 10089, + + "ssh_host_port_min": 2222, + "ssh_host_port_max": 2229, + + "ssh_username": "cloud", + "ssh_password": "cloud", + "ssh_port": 22, + "ssh_wait_timeout": "30m", + + "boot_wait": "10s", + "boot_command": [ + "", + "install ", + " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ", + " debian-installer=en_US ", + " auto ", + " locale=en_US ", + " kbd-chooser/method=us ", + " netcfg/get_hostname=systemvm ", + " netcfg/get_domain=apache.org ", + " fb=false ", + " debconf/frontend=noninteractive ", + " console-setup/ask_detect=false ", + " console-keymaps-at/keymap=us ", + " keyboard-configuration/xkb-keymap=us ", + "" + ], + + "shutdown_command": "sudo halt -p" + } + ] +} diff --git a/tools/appliance/test.sh b/tools/appliance/test.sh deleted file mode 100644 index 5cd7316eac3..00000000000 --- a/tools/appliance/test.sh +++ /dev/null @@ -1,180 +0,0 @@ -#!/bin/bash -xl -# note: the -l is needed here for bash to always make a login shell and load rvm if it hasn't been loaded -# -# 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. - -# test script for build.sh which tries a variety of options/configs to make different vms - -set -e - -DEBUG="${DEBUG:-}" -TRACE="${TRACE:-0}" - -### -### Configuration -### - -if [[ "${DEBUG}" == "1" ]]; then - set -x -fi - -# which test to run -test_to_run=${1:-} -# build.sh settings for running the tests -appliance=debianbase -version=`date "+%Y%m%d%H%M%S"` -branch=`git status | grep '# On branch' | awk '{print $4}'` -BUILD_NUMBER="${BUILD_NUMBER:-}" -ssh_key= - -# where we are running the tests from -CURR_DIR=${PWD} -# where this script is -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# ensure we are running in isolation -if [ ${CURR_DIR} == ${SCRIPT_DIR} ]; then - mkdir -p ../appliance-work - cd ../appliance-work - CURR_DIR=${PWD} -fi - -### -### testing 'framework' -### - -function test_result() { - log INFO "$@" - add_on_exit log INFO "$@" -} - -function run_test() { - set +e - cleanup - fixture - log INFO running test: "$@" - eval $@ - result=$? - if ${result}; then - test_result "$@" FAIL - else - test_result "$@" OK - fi - cleanup - set -e -} - -function cleanup() { - ( - cd ${CURR_DIR}; - rm -rf iso definitions Gemfile shar_cloud_scripts convert_ovf_vbox_to_esx.xslt .rvmrc; - ) -} - -function fixture() { - ( - cd ${CURR_DIR}; - mkdir -p ${SCRIPT_DIR}/iso; - ln -s ${SCRIPT_DIR}/iso; - mkdir definitions; - ln -s ${SCRIPT_DIR}/definitions/${appliance} definitions/${appliance}; - - ln -s ${SCRIPT_DIR}/Gemfile; - ln -s ${SCRIPT_DIR}/shar_cloud_scripts.sh; - ln -s ${SCRIPT_DIR}/convert_ovf_vbox_to_esx.xslt; - ln -s ${SCRIPT_DIR}/.rvmrc; - ) -} - -### -### Test definitions -### - -function do_test_vm() { - prepare - create_definition - veewee_build - retry 10 check_appliance_shutdown - retry 10 remove_shares - veewee_destroy -} - -function do_test_export() { - prepare - create_definition - veewee_build - retry 10 check_appliance_shutdown - retry 10 remove_shares - - # Get appliance uuids - local vm_info=`vboxmanage showvminfo "${appliance_build_name}"` - local machine_uuid=`echo "${vm_info}" | grep UUID | head -1 | awk '{print $2}'` - local hdd_uuid=`echo "${vm_info}" | grep vdi | head -1 | awk '{print $8}' | cut -d ')' -f 1` - local hdd_path=`vboxmanage list hdds | grep "${appliance_build_name}\/" | grep vdi | \ - cut -c 14- | sed ${sed_regex_option} 's/^ *//'` - - compact_hdd "${hdd_uuid}" - xen_server_export "${hdd_path}" - kvm_export "${hdd_path}" - vmware_export "${machine_uuid}" "${hdd_uuid}" - hyperv_export "${hdd_uuid}" - - veewee_destroy -} - -function test_basic_veewee_invocation() { - appliance=debianbase - appliance_build_name=${appliance}${branch_tag}${version_tag} - do_test_vm -} - -function test_export() { - appliance=debianbase - appliance_build_name=${appliance}${branch_tag}${version_tag} - do_test_export -} - -function test_systemvm() { - appliance=systemvmtemplate - appliance_build_name=${appliance}${branch_tag}${version_tag} - do_test_vm -} - -function test_systemvm64() { - appliance=systemvm64template - appliance_build_name=${appliance}${branch_tag}${version_tag} - do_test_vm -} - -function test_suite() { - if [ "${test_to_run}" == "" ]; then - # list of all tests goes here - run_test test_basic_veewee_invocation - run_test test_systemvm - run_test test_systemvm64 - run_test test_export - else - run_test "${test_to_run}" - fi -} - -### -### Main invocation -### - -source ${SCRIPT_DIR}/build.sh -return 2>/dev/null || test_suite diff --git a/tools/appliance/vbox_disk_clean.rb b/tools/appliance/vbox_disk_clean.rb deleted file mode 100755 index 9bbe801ba10..00000000000 --- a/tools/appliance/vbox_disk_clean.rb +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env ruby -# 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. - -lines = `VBoxManage list hdds` -disks = lines.split(/\n\s*\n/) -disks.each do |disk| - disk_lines = disk.split(/\n/) - disk_config = {} - disk_lines.each do |line| - pair = line.split(/:\s*/) - disk_config[pair[0]] = pair[1] - # if pair[0] == 'Location' - # location = pair[1] - - # if location.include? '/Snapshots/' - # disk_config['is_snapshot'] = true - # end - # if location.include? '/VirtualBox VMs/' - # disk_config['vm_name'] = location.split('/VirtualBox VMs/')[1].split('/')[0] - # disk_config['disk_name'] = location.split('/')[-1] - # disk_config['is_virtualbox_vm'] = true - # else - # disk_config['is_virtualbox_vm'] = false - # disk_config['disk_name'] = location.split('/')[-1] - # end - # end - end - - if disk_config.include? 'Location' - cmd="VBoxManage closemedium disk '#{disk_config['Location']}' --delete" - puts cmd - `#{cmd}` - end -end diff --git a/tools/appliance/vbox_vm_clean.rb b/tools/appliance/vbox_vm_clean.rb deleted file mode 100755 index ba0a1cc4049..00000000000 --- a/tools/appliance/vbox_vm_clean.rb +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env ruby -# 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. - -# script that tries hard to forcibly shut down all vms - -# gem install sys-proctable -require 'sys/proctable' - -include Sys - -do_delete = (ARGV.include? 'delete' or ARGV.include? '--delete' or ARGV.include? '-d') -do_kill = (ARGV.include? 'kill' or ARGV.include? '--kill' or ARGV.include? '-k') - -lines = `VBoxManage list vms` -vms = lines.split(/\n/) -if vms.nil? - vms = [] -end -vms.each do |vmline| - vm_info = /\"(.*)\"[^{]*\{(.*)\}/.match(vmline) - next if vm_info.nil? - vm_name = vm_info[1] - vm_uuid = vm_info[2] - - cmd="VBoxManage controlvm #{vm_name} poweroff" - puts cmd - `#{cmd}` - if do_delete - sleep(1) - cmd="VBoxManage unregistervm #{vm_name} --delete" - puts cmd - `#{cmd}` - end - - if do_kill - sleep(1) - # ps x | grep VBoxHeadless | grep systemvm64template-4.4.0 | egrep -o '^\s*[0-9]+' | xargs kill - ProcTable.ps do |p| - next unless p.cmdline.include? "VBoxHeadless" - next unless p.cmdline.include? vm_name - # not all rubies / proctables expose ruid - if defined? p.ruid - # VBoxManage should only list _our_ vms, but just to be safe... - next unless p.ruid == Process.uid - end - - puts "kill -SIGKILL #{p.pid}" - begin - Process.kill("KILL", p.pid) - rescue => exception - puts exception.backtrace - end - sleep(5) - puts "kill -SIGTERM #{p.pid}" - begin - Process.kill("TERM", p.pid) - rescue => exception - puts exception.backtrace - end - end - end -end diff --git a/tools/vagrant/devcloud/Vagrantfile b/tools/vagrant/devcloud/Vagrantfile deleted file mode 100644 index ca99fee293e..00000000000 --- a/tools/vagrant/devcloud/Vagrantfile +++ /dev/null @@ -1,206 +0,0 @@ -# -*- mode: ruby -*- -# 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. -# -# vi: set ft=ruby : - -# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! -VAGRANTFILE_API_VERSION = "2" - -$mysql_script = <