Move Devcloud4 into main repository
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/66cded75 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/66cded75 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/66cded75 Branch: refs/heads/master Commit: 66cded75e0f512b431d27cea2cffbc45deb3d859 Parents: da233c7 Author: Ian Duffy <i...@ianduffy.ie> Authored: Sat Apr 11 16:17:02 2015 +0100 Committer: Ian Duffy <i...@ianduffy.ie> Committed: Sat Apr 11 16:17:02 2015 +0100 ---------------------------------------------------------------------- tools/devcloud4/.gitignore | 4 + tools/devcloud4/README.md | 101 +++++++ tools/devcloud4/advanced/Berksfile | 27 ++ tools/devcloud4/advanced/README.md | 95 ++++++ tools/devcloud4/advanced/Vagrantfile | 115 ++++++++ .../devcloud4/advanced/chef_configuration.json | 24 ++ tools/devcloud4/advanced/marvin.cfg | 124 ++++++++ tools/devcloud4/basic/Berksfile | 27 ++ tools/devcloud4/basic/README.md | 83 ++++++ tools/devcloud4/basic/Vagrantfile | 81 ++++++ tools/devcloud4/basic/chef_configuration.json | 22 ++ tools/devcloud4/basic/marvin.cfg | 110 +++++++ .../binary-installation-advanced/Berksfile | 26 ++ .../binary-installation-advanced/Vagrantfile | 119 ++++++++ .../chef_configuration.json | 37 +++ .../binary-installation-advanced/marvin.cfg.erb | 123 ++++++++ .../binary-installation-basic/Berksfile | 26 ++ .../binary-installation-basic/Vagrantfile | 83 ++++++ .../chef_configuration.json | 34 +++ .../binary-installation-basic/marvin.cfg.erb | 109 +++++++ .../common/binary-installation/README.md | 0 .../attributes/database_server.rb | 22 ++ .../binary-installation/attributes/default.rb | 38 +++ .../common/binary-installation/metadata.rb | 42 +++ .../recipes/database_server.rb | 24 ++ .../binary-installation/recipes/default.rb | 27 ++ .../recipes/management_server.rb | 57 ++++ .../binary-installation/recipes/nfsshares.rb | 48 ++++ tools/devcloud4/common/configure-network.sh | 37 +++ .../common/development-installation/README.md | 0 .../attributes/database_server.rb | 22 ++ .../attributes/default.rb | 29 ++ .../files/default/cloud-install-sys-tmplt | 288 +++++++++++++++++++ .../files/default/createtmplt.sh | 239 +++++++++++++++ .../common/development-installation/metadata.rb | 42 +++ .../recipes/database_server.rb | 24 ++ .../development-installation/recipes/default.rb | 27 ++ .../recipes/nfsshares.rb | 48 ++++ .../recipes/system_templates.rb | 38 +++ tools/devcloud4/pom.xml | 112 ++++++++ tools/devcloud4/prefill.sql | 34 +++ tools/pom.xml | 3 +- 42 files changed, 2570 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/.gitignore ---------------------------------------------------------------------- diff --git a/tools/devcloud4/.gitignore b/tools/devcloud4/.gitignore new file mode 100644 index 0000000..3969b1b --- /dev/null +++ b/tools/devcloud4/.gitignore @@ -0,0 +1,4 @@ +tmp +cookbooks +*.lock +.vagrant \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/README.md ---------------------------------------------------------------------- diff --git a/tools/devcloud4/README.md b/tools/devcloud4/README.md new file mode 100644 index 0000000..00d6756 --- /dev/null +++ b/tools/devcloud4/README.md @@ -0,0 +1,101 @@ +# Devcloud 4 + +## Introduction + +The follow project aims to simplify getting a full Apache CloudStack environment running on your machine. You can either take the easy ride and run `vagrant up` in either one of the 'binary installation' directories or compile CloudStack yourself. See for instructions in the 'basic' and 'advanced' directories. + +The included VagrantFile will give you: + + - Management + - NFS Server + - MySQL Server + - Router + - * Cloudstack Management Server * (Only given in binary installation) + + - XenServer 6.2 + +## Getting started + +1. Due to the large amount of data to be pulled from the Internet, it's probably not a good idea to do this over WiFi or Mobile data. + +1. Given the amount of virtual machines this brings up it is recommended you have atleast 8gb of ram before attempting this. + +1. Ensure your system has `git` installed. + +1. When on Windows, make sure you've set the git option `autocrlf` to `false`: + + ``` + git config --global core.autocrlf false + ``` + +1. Clone the repository: + + ``` + git clone https://github.com/imduffy15/devcloud4.git + ``` + +1. Download and Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads) + + On Windows7, the Xenserver VM crashed immediately after booting with a General Protection Fault. + Installing VirtualBox version 4.3.6r91406 (https://www.virtualbox.org/wiki/Download_Old_Builds_4_3) fixed the problem, but only downgrade if the latest version does not work for you. + +1. Download and install [Vagrant](https://www.vagrantup.com/downloads.html) + +1. Ensure all Vagrant Plugins are installed: + + ```bash + vagrant plugin install vagrant-berkshelf vagrant-omnibus + ``` + +1. Download and install [ChefDK](https://downloads.chef.io/chef-dk/) + +### Configure virtualbox + +1. Open virtualbox and navigate to its preferences/settings window. + +1. Click onto the network tab and then onto the host only network tab. + +1. Configure your adapters as follows: + + - On Windows, the adapternames are different, and map as follows: + - vboxnet0: VirtualBox Host-Only Ethernet Adapter + - vboxnet1: VirtualBox Host-Only Ethernet Adapter 2 + - vboxnet2: VirtualBox Host-Only Ethernet Adapter 3 + + #### For Basic Networking you only need: + + ##### vboxnet0 + - IPv4 IP address of 192.168.22.1 + - Subnet of 255.255.255.0 + - DHCP server disabled + + #### For Advanced Networking you will need: + + + + ##### vboxnet1 + - IPv4 IP address of 192.168.23.1 + - Subnet of 255.255.255.0 + - DHCP server disabled + + + + ##### vboxnet2 + - IPv4 IP address of 192.168.24.1 + - Subnet of 255.255.255.0 + - DHCP server disabled + +## Defaults + +### Management Server + + - IP: 192.168.22.5 + - Username: vagrant or root + - Password: vagrant + +### Hypervisor + + - IP: 192.168.22.10 + - Username: root + - Password: password + http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/advanced/Berksfile ---------------------------------------------------------------------- diff --git a/tools/devcloud4/advanced/Berksfile b/tools/devcloud4/advanced/Berksfile new file mode 100644 index 0000000..616ca68 --- /dev/null +++ b/tools/devcloud4/advanced/Berksfile @@ -0,0 +1,27 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +source "https://api.berkshelf.com" + +cookbook 'hostname' +cookbook 'selinux' +cookbook 'nat-router', git: 'http://github.com/imduffy15/cookbook_nat-router' +cookbook 'cloudstack', git: 'https://github.com/imduffy15/cookbook_cloudstack-1' +cookbook 'development-installation', path: '../common/development-installation' +cookbook 'python', git: 'https://github.com/imduffy15/python.git' http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/advanced/README.md ---------------------------------------------------------------------- diff --git a/tools/devcloud4/advanced/README.md b/tools/devcloud4/advanced/README.md new file mode 100644 index 0000000..6171839 --- /dev/null +++ b/tools/devcloud4/advanced/README.md @@ -0,0 +1,95 @@ +### Configure virtualbox + +1. Open virtualbox and navigate to its preferences/settings window. + +1. Click onto the network tab and then onto the host only network tab. + +1. Configure your adapters as follows: + + ##### vboxnet0 + - IPv4 IP address of 192.168.22.1 + - Subnet of 255.255.255.0 + - DHCP server disabled + + ##### vboxnet1 + - IPv4 IP address of 192.168.23.1 + - Subnet of 255.255.255.0 + - DHCP server disabled + + ##### vboxnet2 + - IPv4 IP address of 192.168.24.1 + - Subnet of 255.255.255.0 + - DHCP server disabled + + +### Start the vagrant boxes + +```bash +vagrant up +``` + +*** Common issues: *** + +- 'Cannot forward the specified ports on this VM': There could be MySQL or some other + service running on the host OS causing vagrant to fail setting up local port forwarding. + + +### Start Cloudstack + +1. Clone the Cloudstack Repository: + + ``` + git clone https://github.com/apache/cloudstack.git + ``` + + *** Note: *** + + Personally I prefer to use the 4.3 codebase rather than master. If you wish to do the same: + + ``` + git reset --hard 0810029 + ``` + +1. Download vhd-util: + + ```bash + cd /path/to/cloudstack/repo + wget http://download.cloud.com.s3.amazonaws.com/tools/vhd-util -P scripts/vm/hypervisor/xenserver/ + chmod +x scripts/vm/hypervisor/xenserver/vhd-util + ``` + +1. Compile Cloudstack: + + ```bash + cd /path/to/cloudstack/repo + mvn -P developer,systemvm clean install -DskipTests=true + ``` + +1. Deploy Cloudstack Database: + + ```bash + cd /path/to/cloudstack/repo + mvn -P developer -pl developer,tools/devcloud4 -Ddeploydb + ``` + +1. Start Cloudstack: + + ```bash + cd /path/to/cloudstack/repo + mvn -pl :cloud-client-ui jetty:run + ``` + +1. Install Marvin: + + ``` + cd /path/to/cloudstack/repo + pip install tools/marvin/dist/Marvin-0.1.0.tar.gz + ``` + +1. Deploy: + + ``` + python -m marvin.deployDataCenter -i marvin.cfg + ``` + + http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/advanced/Vagrantfile ---------------------------------------------------------------------- diff --git a/tools/devcloud4/advanced/Vagrantfile b/tools/devcloud4/advanced/Vagrantfile new file mode 100644 index 0000000..0bf843b --- /dev/null +++ b/tools/devcloud4/advanced/Vagrantfile @@ -0,0 +1,115 @@ +# -*- mode: ruby -*- +# vi: set ft=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. +# + +VAGRANTFILE_API_VERSION = '2' + +Vagrant.require_version '>= 1.5.0' + +unless Vagrant.has_plugin?('vagrant-berkshelf') + raise 'vagrant-berkshelf is not installed!' +end + +unless Vagrant.has_plugin?('vagrant-omnibus') + raise 'vagrant-omnibus is not installed!' +end + +xenserver_networking_script = File.join(File.dirname(__FILE__), '../common/', 'configure-network.sh') + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + config.vm.define 'xenserver' do |xenserver| + xenserver.vm.box = 'duffy/xenserver' + + # Public Network (IP address is ignored.) + xenserver.vm.network :private_network, :auto_config => false, :ip => '192.168.23.10' + + # Guest Network (IP address is ignored.) + xenserver.vm.network :private_network, :auto_config => false, :ip => '192.168.24.10' + + # Configure Interfaces + + ## Configure Management Interface + xenserver.vm.provision 'shell' do |s| + s.path = xenserver_networking_script + s.args = %w(eth1 192.168.22.10 255.255.255.0 MGMT) + end + + ## Configure Public Interface + xenserver.vm.provision 'shell' do |s| + s.path = xenserver_networking_script + s.args = %w(eth2 na na PUBLIC) + end + + ## Configure Guest Interface + xenserver.vm.provision 'shell' do |s| + s.path = xenserver_networking_script + s.args = %w(eth3 na na GUEST) + end + + ## Tweak kernel + xenserver.vm.provision "shell", inline: "sed -i -e 's/net.bridge.bridge-nf-call-iptables = 1/net.bridge.bridge-nf-call-iptables = 0/g' -e 's/net.bridge.bridge-nf-call-arptables = 1/net.bridge.bridge-nf-call-arptables = 0/g' /etc/sysctl.conf && /sbin/sysctl -p /etc/sysctl.conf" + + ## Map host only networks and the adapters + xenserver.vm.provider 'virtualbox' do |v| + v.customize ['modifyvm', :id, '--nicpromisc2', 'allow-all'] + v.customize ['modifyvm', :id, '--nicpromisc3', 'allow-all'] + v.customize ['modifyvm', :id, '--nicpromisc4', 'allow-all'] + v.customize ['modifyvm', :id, '--hostonlyadapter2', 'vboxnet0'] + v.customize ['modifyvm', :id, '--hostonlyadapter3', 'vboxnet1'] + v.customize ['modifyvm', :id, '--hostonlyadapter4', 'vboxnet2'] + v.customize ["modifyvm", :id, '--nictype2', 'Am79C973'] + v.customize ["modifyvm", :id, '--nictype3', 'Am79C973'] + v.customize ["modifyvm", :id, '--nictype4', 'Am79C973'] + end + end + + config.vm.define 'management' do |management| + management.vm.box = 'chef/centos-6.5' + + # Configure management interface + management.vm.network :private_network, :auto_config => true, :ip => '192.168.22.5' + + # Configure public interface + management.vm.network :private_network, :auto_config => true, :ip => '192.168.23.5' + + # Port forward MySQL + management.vm.network 'forwarded_port', guest: 3306, host: 3306 + + management.vm.provider 'virtualbox' do |v| + v.customize ['modifyvm', :id, '--memory', 512] + v.customize ['modifyvm', :id, '--hostonlyadapter2', 'vboxnet0'] + v.customize ['modifyvm', :id, '--hostonlyadapter3', 'vboxnet1'] + v.customize ["modifyvm", :id, '--nictype2', 'Am79C973'] + v.customize ["modifyvm", :id, '--nictype3', 'Am79C973'] + end + + management.omnibus.chef_version = "11.16.4" + management.berkshelf.berksfile_path = File.join(File.dirname(__FILE__), 'Berksfile') + management.berkshelf.enabled = true + + CHEF_CONFIGURATION = JSON.parse(Pathname(__FILE__).dirname.join('chef_configuration.json').read) + + management.vm.provision 'chef_solo' do |chef| + chef.run_list = CHEF_CONFIGURATION.delete('run_list') + chef.json = CHEF_CONFIGURATION + end + end +end http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/advanced/chef_configuration.json ---------------------------------------------------------------------- diff --git a/tools/devcloud4/advanced/chef_configuration.json b/tools/devcloud4/advanced/chef_configuration.json new file mode 100644 index 0000000..40d5bce --- /dev/null +++ b/tools/devcloud4/advanced/chef_configuration.json @@ -0,0 +1,24 @@ +{ + "run_list": [ + "recipe[development-installation]", + "recipe[nat-router]" + ], + "iptables": { + "lans": ["eth1", "eth2"] + }, + "set_fqdn": "*.localdomain", + "selinux": { + "state": "permissive" + }, + "cloudstack": { + "secondary": { + "path": "/exports/secondary" + }, + "primary": { + "path": "/exports/primary" + }, + "hypervisor_tpl": { + "xenserver": "http://jenkins.buildacloud.org/job/build-systemvm64-master/lastSuccessfulBuild/artifact/tools/appliance/dist/systemvm64template-master-4.6.0-xen.vhd.bz2" + } + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/advanced/marvin.cfg ---------------------------------------------------------------------- diff --git a/tools/devcloud4/advanced/marvin.cfg b/tools/devcloud4/advanced/marvin.cfg new file mode 100644 index 0000000..9e2ac56 --- /dev/null +++ b/tools/devcloud4/advanced/marvin.cfg @@ -0,0 +1,124 @@ +# +# 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. +# + +{ + "zones": [ + { + "name": "DevCloud-Advanced-01", + "guestcidraddress": "10.1.1.0/24", + "localstorageenabled": true, + "dns1": "8.8.8.8", + "physical_networks": [ + { + "broadcastdomainrange": "Zone", + "vlan": "100-200", + "name": "DevCloud-Network-01", + "traffictypes": [ + { + "xen": "GUEST", + "typ": "Guest" + }, + { + "xen": "MGMT", + "typ": "Management" + }, + { + "xen": "PUBLIC", + "typ": "Public" + } + ], + "providers": [ + { + "broadcastdomainrange": "ZONE", + "name": "VirtualRouter" + }, + { + "broadcastdomainrange": "ZONE", + "name": "VpcVirtualRouter" + }, + { + "broadcastdomainrange": "ZONE", + "name": "InternalLbVm" + } + ], + "isolationmethods": [ + "VLAN" + ] + } + ], + "ipranges": [ + { + "startip": "192.168.23.100", + "endip": "192.168.23.120", + "netmask": "255.255.255.0", + "vlan": "untagged", + "gateway": "192.168.23.5" + } + ], + "networktype": "Advanced", + "pods": [ + { + "startip": "192.168.22.100", + "endip": "192.168.22.120", + "name": "DevCloud-POD-01", + "netmask": "255.255.255.0", + "clusters": [ + { + "clustername": "DevCloud-CLUSTER-01", + "hypervisor": "XenServer", + "hosts": [ + { + "username": "root", + "url": "http://192.168.22.10/", + "password": "password" + } + ], + "clustertype": "CloudManaged" + } + ], + "gateway": "192.168.22.5" + } + ], + "internaldns1": "8.8.8.8", + "secondaryStorages": [ + { + "url": "nfs://192.168.22.5/exports/secondary", + "provider": "NFS", + "details": [ ] + } + ] + } + ], + "logger": { + "LogFolderPath": "/tmp/" + }, + "mgtSvr": [ + { + "mgtSvrIp": "192.168.22.1", + "port": 8096 + } + ], + "dbSvr": { + "dbSvr": "127.0.0.1", + "port": 3306, + "user": "cloud", + "passwd": "cloud", + "db": "cloud" + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/basic/Berksfile ---------------------------------------------------------------------- diff --git a/tools/devcloud4/basic/Berksfile b/tools/devcloud4/basic/Berksfile new file mode 100644 index 0000000..616ca68 --- /dev/null +++ b/tools/devcloud4/basic/Berksfile @@ -0,0 +1,27 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +source "https://api.berkshelf.com" + +cookbook 'hostname' +cookbook 'selinux' +cookbook 'nat-router', git: 'http://github.com/imduffy15/cookbook_nat-router' +cookbook 'cloudstack', git: 'https://github.com/imduffy15/cookbook_cloudstack-1' +cookbook 'development-installation', path: '../common/development-installation' +cookbook 'python', git: 'https://github.com/imduffy15/python.git' http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/basic/README.md ---------------------------------------------------------------------- diff --git a/tools/devcloud4/basic/README.md b/tools/devcloud4/basic/README.md new file mode 100644 index 0000000..31cb62d --- /dev/null +++ b/tools/devcloud4/basic/README.md @@ -0,0 +1,83 @@ +### Configure virtualbox + +1. Open virtualbox and navigate to its preferences/settings window. + +1. Click onto the network tab and then onto the host only network tab. + +1. Configure your adapters as follows: + + ##### vboxnet0 + - IPv4 IP address of 192.168.22.1 + - Subnet of 255.255.255.0 + - DHCP server disabled + + +### Start the vagrant boxes + +```bash +vagrant up +``` + +*** Common issues: *** + +- 'Cannot forward the specified ports on this VM': There could be MySQL or some other + service running on the host OS causing vagrant to fail setting up local port forwarding. + + +### Start Cloudstack + +1. Clone the Cloudstack Repository: + + ``` + git clone https://github.com/apache/cloudstack.git + ``` + + *** Note: *** + + Personally I prefer to use the 4.3 codebase rather than master. If you wish to do the same: + + ``` + git reset --hard 0810029 + ``` + +1. Download vhd-util: + + ```bash + cd /path/to/cloudstack/repo + wget http://download.cloud.com.s3.amazonaws.com/tools/vhd-util -P scripts/vm/hypervisor/xenserver/ + chmod +x scripts/vm/hypervisor/xenserver/vhd-util + ``` + +1. Compile Cloudstack: + + ```bash + cd /path/to/cloudstack/repo + mvn -P developer,systemvm clean install -DskipTests=true + ``` + +1. Deploy Cloudstack Database: + + ```bash + cd /path/to/cloudstack/repo + mvn -P developer -pl developer,tools/devcloud4 -Ddeploydb + ``` + +1. Start Cloudstack: + + ```bash + cd /path/to/cloudstack/repo + mvn -pl :cloud-client-ui jetty:run + ``` + +1. Install Marvin: + + ``` + cd /path/to/cloudstack/repo + pip install tools/marvin/dist/Marvin-4.6.0-SNAPSHOT.tar.gz --allow-external mysql-connector-python + ``` + +1. Deploying: + + ``` + python -m marvin.deployDataCenter -i marvin.cfg + ``` http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/basic/Vagrantfile ---------------------------------------------------------------------- diff --git a/tools/devcloud4/basic/Vagrantfile b/tools/devcloud4/basic/Vagrantfile new file mode 100644 index 0000000..5f22edc --- /dev/null +++ b/tools/devcloud4/basic/Vagrantfile @@ -0,0 +1,81 @@ +# -*- mode: ruby -*- +# vi: set ft=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. +# + +VAGRANTFILE_API_VERSION = '2' + +Vagrant.require_version '>= 1.5.0' + +unless Vagrant.has_plugin?('vagrant-berkshelf') + raise 'vagrant-berkshelf is not installed!' +end + +unless Vagrant.has_plugin?('vagrant-omnibus') + raise 'vagrant-omnibus is not installed!' +end + +xenserver_networking_script = File.join(File.dirname(__FILE__), '../common/', 'configure-network.sh') + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + config.vm.define 'xenserver' do |xenserver| + xenserver.vm.box = 'duffy/xenserver' + + ## Map host only networks and the adapters + xenserver.vm.provider 'virtualbox' do |v| + v.customize ['modifyvm', :id, '--hostonlyadapter2', 'vboxnet0'] + v.customize ['modifyvm', :id, '--nicpromisc2', 'allow-all'] + v.customize ["modifyvm", :id, '--nictype2', 'Am79C973'] + end + + # Configure Interface + ## Configure Management Interface + xenserver.vm.provision 'shell' do |s| + s.path = xenserver_networking_script + s.args = %w(eth1 192.168.22.10 255.255.255.0 MGMT) + end + + end + + config.vm.define 'management' do |management| + management.vm.box = 'chef/centos-6.5' + + management.vm.network :private_network, :auto_config => true, :ip => '192.168.22.5' + + management.vm.network 'forwarded_port', guest: 3306, host: 3306 + + management.vm.provider 'virtualbox' do |v| + v.customize ['modifyvm', :id, '--memory', 512] + v.customize ['modifyvm', :id, '--hostonlyadapter2', 'vboxnet0'] + v.customize ["modifyvm", :id, '--nictype2', 'Am79C973'] + end + + management.omnibus.chef_version = "11.16.4" + management.berkshelf.berksfile_path = File.join(File.dirname(__FILE__), 'Berksfile') + management.berkshelf.enabled = true + + CHEF_CONFIGURATION = JSON.parse(Pathname(__FILE__).dirname.join('chef_configuration.json').read) + + management.vm.provision 'chef_solo' do |chef| + chef.run_list = CHEF_CONFIGURATION.delete('run_list') + chef.json = CHEF_CONFIGURATION + end + end +end http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/basic/chef_configuration.json ---------------------------------------------------------------------- diff --git a/tools/devcloud4/basic/chef_configuration.json b/tools/devcloud4/basic/chef_configuration.json new file mode 100644 index 0000000..507a0de --- /dev/null +++ b/tools/devcloud4/basic/chef_configuration.json @@ -0,0 +1,22 @@ + +{ + "run_list": [ + "recipe[development-installation]", + "recipe[nat-router]" + ], + "set_fqdn": "*.localdomain", + "selinux": { + "state": "permissive" + }, + "cloudstack": { + "secondary": { + "path": "/exports/secondary" + }, + "primary": { + "path": "/exports/primary" + }, + "hypervisor_tpl": { + "xenserver": "http://jenkins.buildacloud.org/job/build-systemvm64-master/lastSuccessfulBuild/artifact/tools/appliance/dist/systemvm64template-master-4.6.0-xen.vhd.bz2" + } + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/basic/marvin.cfg ---------------------------------------------------------------------- diff --git a/tools/devcloud4/basic/marvin.cfg b/tools/devcloud4/basic/marvin.cfg new file mode 100644 index 0000000..dcc1b82 --- /dev/null +++ b/tools/devcloud4/basic/marvin.cfg @@ -0,0 +1,110 @@ +# +# 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. +# + +{ + "zones": [ + { + "name": "DevCloud-Basic-01", + "enabled": "True", + "physical_networks": [ + { + "broadcastdomainrange": "Zone", + "name": "Devcloud-Network-01", + "traffictypes": [ + { + "typ": "Guest" + }, + { + "typ": "Management" + } + ], + "providers": [ + { + "broadcastdomainrange": "ZONE", + "name": "VirtualRouter" + }, + { + "broadcastdomainrange": "Pod", + "name": "SecurityGroupProvider" + } + ] + } + ], + "dns2": "8.8.4.4", + "dns1": "8.8.8.8", + "securitygroupenabled": "true", + "localstorageenabled": "true", + "networktype": "Basic", + "pods": [ + { + "endip": "192.168.22.220", + "name": "DevCloud-POD-01", + "startip": "192.168.22.200", + "guestIpRanges": [ + { + "startip": "192.168.22.100", + "endip": "192.168.22.199", + "netmask": "255.255.255.0", + "gateway": "192.168.22.5" + } + ], + "netmask": "255.255.255.0", + "clusters": [ + { + "clustername": "DevCloud-CLUSTER-01", + "hypervisor": "XenServer", + "hosts": [ + { + "username": "root", + "url": "http://192.168.22.10/", + "password": "password" + } + ], + "clustertype": "CloudManaged" + } + ], + "gateway": "192.168.22.5" + } + ], + "internaldns1": "8.8.8.8", + "secondaryStorages": [ + { + "url": "nfs://192.168.22.5/exports/secondary", + "provider": "NFS" + } + ] + } + ], + "logger": { + "LogFolderPath": "/tmp/" + }, + "mgtSvr": [ + { + "mgtSvrIp": "192.168.22.1", + "port": 8096 + } + ], + "dbSvr": { + "dbSvr": "127.0.0.1", + "port": 3306, + "user": "cloud", + "passwd": "cloud", + "db": "cloud" + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/binary-installation-advanced/Berksfile ---------------------------------------------------------------------- diff --git a/tools/devcloud4/binary-installation-advanced/Berksfile b/tools/devcloud4/binary-installation-advanced/Berksfile new file mode 100644 index 0000000..7ad09e1 --- /dev/null +++ b/tools/devcloud4/binary-installation-advanced/Berksfile @@ -0,0 +1,26 @@ +# +# 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. +# + +source "https://api.berkshelf.com" + +cookbook 'hostname' +cookbook 'selinux' +cookbook 'nat-router', git: 'http://github.com/imduffy15/cookbook_nat-router' +cookbook 'cloudstack', git: 'https://github.com/imduffy15/cookbook_cloudstack-1' +cookbook 'binary-installation', path: '../common/binary-installation' \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/binary-installation-advanced/Vagrantfile ---------------------------------------------------------------------- diff --git a/tools/devcloud4/binary-installation-advanced/Vagrantfile b/tools/devcloud4/binary-installation-advanced/Vagrantfile new file mode 100644 index 0000000..255efc0 --- /dev/null +++ b/tools/devcloud4/binary-installation-advanced/Vagrantfile @@ -0,0 +1,119 @@ +# -*- mode: ruby -*- +# vi: set ft=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. +# + +xenserver_networking_script = File.join(File.dirname(__FILE__), '../common/', 'configure-network.sh') + +is_windows = (RUBY_PLATFORM =~ /mswin|mingw|cygwin/) + +virtualbox_interface_0 = if is_windows then 'VirtualBox Host-Only Ethernet Adapter' else 'vboxnet0' end +virtualbox_interface_1 = if is_windows then 'VirtualBox Host-Only Ethernet Adapter #2' else 'vboxnet1' end +virtualbox_interface_2 = if is_windows then 'VirtualBox Host-Only Ethernet Adapter #3' else 'vboxnet2' end + +VAGRANTFILE_API_VERSION = '2' +Vagrant.require_version '>= 1.5.0' + +unless Vagrant.has_plugin?('vagrant-berkshelf') + raise 'vagrant-berkshelf is not installed!' +end + +unless Vagrant.has_plugin?('vagrant-omnibus') + raise 'vagrant-omnibus is not installed!' +end + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + config.vm.define 'xenserver' do |xenserver| + xenserver.vm.box = 'duffy/xenserver' + + # Public Network (IP address is ignored.) + xenserver.vm.network :private_network, :auto_config => false, :ip => '192.168.23.10' + + # Guest Network (IP address is ignored.) + xenserver.vm.network :private_network, :auto_config => false, :ip => '192.168.24.10' + + ## Configure Management Interface + xenserver.vm.provision 'shell' do |s| + s.path = xenserver_networking_script + s.args = %w(eth1 192.168.22.10 255.255.255.0 MGMT) + end + + ## Configure Public Interface + xenserver.vm.provision 'shell' do |s| + s.path = xenserver_networking_script + s.args = %w(eth2 na na PUBLIC) + end + + ## Configure Guest Interface + xenserver.vm.provision 'shell' do |s| + s.path = xenserver_networking_script + s.args = %w(eth3 na na GUEST) + end + + ## Map host only networks and the adapters + xenserver.vm.provider 'virtualbox' do |v| + v.customize ['modifyvm', :id, '--nicpromisc2', 'allow-all'] + v.customize ['modifyvm', :id, '--nicpromisc3', 'allow-all'] + v.customize ['modifyvm', :id, '--nicpromisc4', 'allow-all'] + v.customize ['modifyvm', :id, '--hostonlyadapter2', virtualbox_interface_0] + v.customize ['modifyvm', :id, '--hostonlyadapter3', virtualbox_interface_1] + v.customize ['modifyvm', :id, '--hostonlyadapter4', virtualbox_interface_2] + v.customize ['modifyvm', :id, '--memory', 6144] + end + + ## Tweak kernel + xenserver.vm.provision "shell", inline: "sed -i -e 's/net.bridge.bridge-nf-call-iptables = 1/net.bridge.bridge-nf-call-iptables = 0/g' -e 's/net.bridge.bridge-nf-call-arptables = 1/net.bridge.bridge-nf-call-arptables = 0/g' /etc/sysctl.conf && /sbin/sysctl -p /etc/sysctl.conf" + end + + config.vm.define 'management' do |management| + management.vm.box = 'chef/centos-6.5' + + management.vm.network :private_network, :auto_config => true, :ip => '192.168.22.5' + management.vm.network :private_network, :auto_config => true, :ip => '192.168.23.5' + + management.vm.network 'forwarded_port', guest: 3306, host: 3306 + management.vm.network 'forwarded_port', guest: 8080, host: 8080 + + management.vm.provider 'virtualbox' do |v| + v.customize ['modifyvm', :id, '--memory', 2048] + v.customize ['modifyvm', :id, '--hostonlyadapter2', virtualbox_interface_0] + v.customize ['modifyvm', :id, '--hostonlyadapter3', virtualbox_interface_1] + end + + if Vagrant.has_plugin?('vagrant-cachier') + management.cache.scope = :box + management.cache.auto_detect = true + management.omnibus.cache_packages = true + end + + management.omnibus.chef_version = "11.16.4" + management.berkshelf.berksfile_path = File.join(File.dirname(__FILE__), 'Berksfile') + management.berkshelf.enabled = true + + + CHEF_CONFIGURATION = JSON.parse(Pathname(__FILE__).dirname.join('chef_configuration.json').read) + + management.vm.provision :chef_solo do |chef| + chef.log_level = :debug + chef.run_list = CHEF_CONFIGURATION.delete('run_list') + chef.json = CHEF_CONFIGURATION + end + end +end http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/binary-installation-advanced/chef_configuration.json ---------------------------------------------------------------------- diff --git a/tools/devcloud4/binary-installation-advanced/chef_configuration.json b/tools/devcloud4/binary-installation-advanced/chef_configuration.json new file mode 100644 index 0000000..ceae5d4 --- /dev/null +++ b/tools/devcloud4/binary-installation-advanced/chef_configuration.json @@ -0,0 +1,37 @@ +{ + "run_list": [ + "recipe[binary-installation]", + "recipe[nat-router]" + ], + "set_fqdn": "*.localdomain", + "selinux": { + "state": "permissive" + }, + "cloudstack": { + "db": { + "user": "cloud", + "password": "cloud", + "rootusername": "root", + "rootpassword": "password", + "management_server_key": "password", + "database_key": "password", + "prefill": "/vagrant/prefill.sql" + }, + "secondary": { + "path": "/exports/secondary" + }, + "primary": { + "path": "/exports/primary" + }, + "hypervisor_tpl": { + "xenserver": "http://packages.shapeblue.com/systemvmtemplate/4.5/systemvm64template-4.5-xen.vhd.bz2" + }, + "configuration": "/vagrant/marvin.cfg.erb", + "yum_repo": "http://packages.shapeblue.com/cloudstack/testing/centos/4.5/", + "apt_repo": "http://packages.shapeblue.com/cloudstack/testing/debian/4.5/", + "version": "4.5.0" + }, + "iptables": { + "lans": ["eth1", "eth2"] + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/binary-installation-advanced/marvin.cfg.erb ---------------------------------------------------------------------- diff --git a/tools/devcloud4/binary-installation-advanced/marvin.cfg.erb b/tools/devcloud4/binary-installation-advanced/marvin.cfg.erb new file mode 100644 index 0000000..6c847fb --- /dev/null +++ b/tools/devcloud4/binary-installation-advanced/marvin.cfg.erb @@ -0,0 +1,123 @@ +# 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. +# + +{ + "zones": [ + { + "name": "DevCloud-Advanced-01", + "guestcidraddress": "10.1.1.0/24", + "localstorageenabled": true, + "dns1": "8.8.8.8", + "physical_networks": [ + { + "broadcastdomainrange": "Zone", + "vlan": "100-200", + "name": "DevCloud-Network-01", + "traffictypes": [ + { + "xen": "GUEST", + "typ": "Guest" + }, + { + "xen": "MGMT", + "typ": "Management" + }, + { + "xen": "PUBLIC", + "typ": "Public" + } + ], + "providers": [ + { + "broadcastdomainrange": "ZONE", + "name": "VirtualRouter" + }, + { + "broadcastdomainrange": "ZONE", + "name": "VpcVirtualRouter" + }, + { + "broadcastdomainrange": "ZONE", + "name": "InternalLbVm" + } + ], + "isolationmethods": [ + "VLAN" + ] + } + ], + "ipranges": [ + { + "startip": "192.168.23.100", + "endip": "192.168.23.120", + "netmask": "255.255.255.0", + "vlan": "untagged", + "gateway": "192.168.23.5" + } + ], + "networktype": "Advanced", + "pods": [ + { + "startip": "192.168.22.100", + "endip": "192.168.22.120", + "name": "DevCloud-POD-01", + "netmask": "255.255.255.0", + "clusters": [ + { + "clustername": "DevCloud-CLUSTER-01", + "hypervisor": "XenServer", + "hosts": [ + { + "username": "root", + "url": "http://192.168.22.10/", + "password": "password" + } + ], + "clustertype": "CloudManaged" + } + ], + "gateway": "192.168.22.5" + } + ], + "internaldns1": "8.8.8.8", + "secondaryStorages": [ + { + "url": "nfs://192.168.22.5/exports/secondary", + "provider": "NFS", + "details": [ ] + } + ] + } + ], + "logger": { + "LogFolderPath": "/tmp/" + }, + "mgtSvr": [ + { + "mgtSvrIp": "<%= @management_server_ip %>", + "port": <%= @management_server_port %> + } + ], + "dbSvr": { + "dbSvr": "<%= @database_server_ip %>", + "port": <%= @database_server_port %>, + "user": "<%= @database_user %>", + "passwd": "<%= @database_password %>", + "db": "<%= @database %>" + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/binary-installation-basic/Berksfile ---------------------------------------------------------------------- diff --git a/tools/devcloud4/binary-installation-basic/Berksfile b/tools/devcloud4/binary-installation-basic/Berksfile new file mode 100644 index 0000000..7ad09e1 --- /dev/null +++ b/tools/devcloud4/binary-installation-basic/Berksfile @@ -0,0 +1,26 @@ +# +# 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. +# + +source "https://api.berkshelf.com" + +cookbook 'hostname' +cookbook 'selinux' +cookbook 'nat-router', git: 'http://github.com/imduffy15/cookbook_nat-router' +cookbook 'cloudstack', git: 'https://github.com/imduffy15/cookbook_cloudstack-1' +cookbook 'binary-installation', path: '../common/binary-installation' \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/binary-installation-basic/Vagrantfile ---------------------------------------------------------------------- diff --git a/tools/devcloud4/binary-installation-basic/Vagrantfile b/tools/devcloud4/binary-installation-basic/Vagrantfile new file mode 100644 index 0000000..acc9be7 --- /dev/null +++ b/tools/devcloud4/binary-installation-basic/Vagrantfile @@ -0,0 +1,83 @@ +# -*- mode: ruby -*- +# vi: set ft=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. +# + +xenserver_networking_script = File.join(File.dirname(__FILE__), '../common/', 'configure-network.sh') + +is_windows = (RUBY_PLATFORM =~ /mswin|mingw|cygwin/) + +virtualbox_interface_0 = if is_windows then 'VirtualBox Host-Only Ethernet Adapter' else 'vboxnet0' end + +VAGRANTFILE_API_VERSION = '2' +Vagrant.require_version '>= 1.5.0' + +unless Vagrant.has_plugin?('vagrant-berkshelf') + raise 'vagrant-berkshelf is not installed!' +end + +unless Vagrant.has_plugin?('vagrant-omnibus') + raise 'vagrant-omnibus is not installed!' +end + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + config.vm.define 'xenserver' do |xenserver| + xenserver.vm.box = 'duffy/xenserver' + + ## Configure Management Interface + xenserver.vm.provision 'shell' do |s| + s.path = xenserver_networking_script + s.args = %w(eth1 192.168.22.10 255.255.255.0 MGMT) + end + + ## Map host only networks and the adapters + xenserver.vm.provider 'virtualbox' do |v| + v.customize ['modifyvm', :id, '--nicpromisc2', 'allow-all'] + v.customize ['modifyvm', :id, '--hostonlyadapter2', virtualbox_interface_0] + v.customize ['modifyvm', :id, '--memory', 6144] + end + end + + config.vm.define 'management' do |management| + management.vm.box = 'chef/centos-6.5' + + management.vm.network :private_network, :auto_config => true, :ip => '192.168.22.5' + + management.vm.network 'forwarded_port', guest: 3306, host: 3306 + management.vm.network 'forwarded_port', guest: 8080, host: 8080 + + management.vm.provider 'virtualbox' do |v| + v.customize ['modifyvm', :id, '--memory', 2048] + v.customize ['modifyvm', :id, '--hostonlyadapter2', virtualbox_interface_0] + end + + management.omnibus.chef_version = "11.16.4" + management.berkshelf.berksfile_path = File.join(File.dirname(__FILE__), 'Berksfile') + management.berkshelf.enabled = true + + + CHEF_CONFIGURATION = JSON.parse(Pathname(__FILE__).dirname.join('chef_configuration.json').read) + + management.vm.provision :chef_solo do |chef| + chef.run_list = CHEF_CONFIGURATION.delete('run_list') + chef.json = CHEF_CONFIGURATION + end + end +end http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/binary-installation-basic/chef_configuration.json ---------------------------------------------------------------------- diff --git a/tools/devcloud4/binary-installation-basic/chef_configuration.json b/tools/devcloud4/binary-installation-basic/chef_configuration.json new file mode 100644 index 0000000..87464bf --- /dev/null +++ b/tools/devcloud4/binary-installation-basic/chef_configuration.json @@ -0,0 +1,34 @@ +{ + "run_list": [ + "recipe[binary-installation]", + "recipe[nat-router]" + ], + "set_fqdn": "*.localdomain", + "selinux": { + "state": "permissive" + }, + "cloudstack": { + "db": { + "user": "cloud", + "password": "cloud", + "rootusername": "root", + "rootpassword": "password", + "management_server_key": "password", + "database_key": "password", + "prefill": "/vagrant/prefill.sql" + }, + "secondary": { + "path": "/exports/secondary" + }, + "primary": { + "path": "/exports/primary" + }, + "hypervisor_tpl": { + "xenserver": "http://packages.shapeblue.com/systemvmtemplate/4.5/systemvm64template-4.5-xen.vhd.bz2" + }, + "configuration": "/vagrant/marvin.cfg.erb", + "yum_repo": "http://packages.shapeblue.com/cloudstack/testing/centos/4.5/", + "apt_repo": "http://packages.shapeblue.com/cloudstack/testing/debian/4.5/", + "version": "4.5.0" + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/binary-installation-basic/marvin.cfg.erb ---------------------------------------------------------------------- diff --git a/tools/devcloud4/binary-installation-basic/marvin.cfg.erb b/tools/devcloud4/binary-installation-basic/marvin.cfg.erb new file mode 100644 index 0000000..62415c9 --- /dev/null +++ b/tools/devcloud4/binary-installation-basic/marvin.cfg.erb @@ -0,0 +1,109 @@ +# 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. +# + +{ + "zones": [ + { + "name": "DevCloud-Basic-01", + "enabled": "True", + "physical_networks": [ + { + "broadcastdomainrange": "Zone", + "name": "Devcloud-Network-01", + "traffictypes": [ + { + "typ": "Guest" + }, + { + "typ": "Management" + } + ], + "providers": [ + { + "broadcastdomainrange": "ZONE", + "name": "VirtualRouter" + }, + { + "broadcastdomainrange": "Pod", + "name": "SecurityGroupProvider" + } + ] + } + ], + "dns2": "8.8.4.4", + "dns1": "8.8.8.8", + "securitygroupenabled": "true", + "localstorageenabled": "true", + "networktype": "Basic", + "pods": [ + { + "endip": "192.168.22.220", + "name": "DevCloud-POD-01", + "startip": "192.168.22.200", + "guestIpRanges": [ + { + "startip": "192.168.22.100", + "endip": "192.168.22.199", + "netmask": "255.255.255.0", + "gateway": "192.168.22.5" + } + ], + "netmask": "255.255.255.0", + "clusters": [ + { + "clustername": "DevCloud-CLUSTER-01", + "hypervisor": "XenServer", + "hosts": [ + { + "username": "root", + "url": "http://192.168.22.10/", + "password": "password" + } + ], + "clustertype": "CloudManaged" + } + ], + "gateway": "192.168.22.5" + } + ], + "internaldns1": "8.8.8.8", + "secondaryStorages": [ + { + "url": "nfs://192.168.22.5/exports/secondary", + "provider": "NFS" + } + ] + } + ], + "logger": { + "LogFolderPath": "/tmp/" + }, + "mgtSvr": [ + { + "mgtSvrIp": "<%= @management_server_ip %>", + "port": <%= @management_server_port %> + } + ], + "dbSvr": { + "dbSvr": "<%= @database_server_ip %>", + "port": <%= @database_server_port %>, + "user": "<%= @database_user %>", + "passwd": "<%= @database_password %>", + "db": "<%= @database %>" + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/binary-installation/README.md ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/binary-installation/README.md b/tools/devcloud4/common/binary-installation/README.md new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/binary-installation/attributes/database_server.rb ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/binary-installation/attributes/database_server.rb b/tools/devcloud4/common/binary-installation/attributes/database_server.rb new file mode 100644 index 0000000..35a388f --- /dev/null +++ b/tools/devcloud4/common/binary-installation/attributes/database_server.rb @@ -0,0 +1,22 @@ +# +# 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. +# + +default['mysql']['server_root_password'] = node['cloudstack']['db']['rootpassword'] +default['mysql']['allow_remote_root'] = true +default['mysql']['data_dir'] = '/data/mysql' http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/binary-installation/attributes/default.rb ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/binary-installation/attributes/default.rb b/tools/devcloud4/common/binary-installation/attributes/default.rb new file mode 100644 index 0000000..3b3eba0 --- /dev/null +++ b/tools/devcloud4/common/binary-installation/attributes/default.rb @@ -0,0 +1,38 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +default['cloudstack']['db']['host'] = '127.0.0.1' +default['cloudstack']['db']['user'] = 'cloud' +default['cloudstack']['db']['password'] = 'password' +default['cloudstack']['db']['rootusername'] = 'root' +default['cloudstack']['db']['rootpassword'] = 'cloud' +default['cloudstack']['db']['management_server_key'] = 'password' +default['cloudstack']['db']['database_key'] = 'password' +default['cloudstack']['db']['prefill'] = '/vagrant/prefill.sql' + +default['cloudstack']['secondary']['host'] = node['ipaddress'] +default['cloudstack']['secondary']['path'] = '/data/secondary' +default['cloudstack']['secondary']['mgt_path'] = node['cloudstack']['secondary']['path'] + +default['cloudstack']['primary']['host'] = node['ipaddress'] +default['cloudstack']['primary']['path'] = '/data/primary' +default['cloudstack']['primary']['mgt_path'] = node['cloudstack']['primary']['path'] + + +default['cloudstack']['configuration'] = '/vagrant/marvin.cfg.erb' \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/binary-installation/metadata.rb ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/binary-installation/metadata.rb b/tools/devcloud4/common/binary-installation/metadata.rb new file mode 100644 index 0000000..bc2f515 --- /dev/null +++ b/tools/devcloud4/common/binary-installation/metadata.rb @@ -0,0 +1,42 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +name 'binary-installation' +maintainer 'Ian Duffy' +maintainer_email 'i...@ianduffy.ie' +license 'Apache 2' +description 'Wrapper around several different cookbooks.' +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +version '0.1.0' + +depends 'mysql', '= 5.6.1' +depends 'cloudstack', '>= 3.0.0' +depends 'nfs', '>= 2.0.0' + +supports 'centos' +supports 'redhat' +supports 'debian' +supports 'ubuntu' +supports 'fedora' +supports 'oracle' + +provides 'binary-installation::default' +provides 'binary-installation::management_server' +provides 'binary-installation::database_server' +provides 'binary-installation::nfs_server' http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/binary-installation/recipes/database_server.rb ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/binary-installation/recipes/database_server.rb b/tools/devcloud4/common/binary-installation/recipes/database_server.rb new file mode 100644 index 0000000..28a374c --- /dev/null +++ b/tools/devcloud4/common/binary-installation/recipes/database_server.rb @@ -0,0 +1,24 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +include_recipe 'mysql::server' +include_recipe 'mysql::client' + +include_recipe 'cloudstack::mysql_conf' + http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/binary-installation/recipes/default.rb ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/binary-installation/recipes/default.rb b/tools/devcloud4/common/binary-installation/recipes/default.rb new file mode 100644 index 0000000..6dcd47c --- /dev/null +++ b/tools/devcloud4/common/binary-installation/recipes/default.rb @@ -0,0 +1,27 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +service 'iptables' do + action [:disable, :stop] + only_if { platform?(%w{redhat centos fedora oracle}) } +end + +include_recipe 'binary-installation::nfsshares' +include_recipe 'binary-installation::database_server' +include_recipe 'binary-installation::management_server' \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/binary-installation/recipes/management_server.rb ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/binary-installation/recipes/management_server.rb b/tools/devcloud4/common/binary-installation/recipes/management_server.rb new file mode 100644 index 0000000..742f35f --- /dev/null +++ b/tools/devcloud4/common/binary-installation/recipes/management_server.rb @@ -0,0 +1,57 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +include_recipe 'cloudstack::marvin' +include_recipe 'cloudstack::management_server' + +cloudstack_setup_database node['cloudstack']['db']['host'] do + root_user node['cloudstack']['db']['rootusername'] + root_password node['cloudstack']['db']['rootpassword'] + user node['cloudstack']['db']['username'] + password node['cloudstack']['db']['password'] + action :create +end + +cloudstack_prefill_database node['cloudstack']['db']['prefill'] do + ip node['cloudstack']['db']['host'] + user node['cloudstack']['db']['username'] + password node['cloudstack']['db']['password'] +end + +cloudstack_system_template 'xenserver' do + nfs_path node['cloudstack']['secondary']['path'] + nfs_server node['cloudstack']['secondary']['host'] + db_user node['cloudstack']['db']['username'] + url node['cloudstack']['hypervisor_tpl']['xenserver'] + db_password node['cloudstack']['db']['password'] + db_host node['cloudstack']['db']['host'] + action :create +end + +cloudstack_setup_management node.name + +service 'cloudstack-management' do + action [:enable, :start] +end + +cloudstack_configure_cloud node['cloudstack']['configuration'] do + database_server_ip node['cloudstack']['db']['host'] + database_user node['cloudstack']['db']['username'] + database_password node['cloudstack']['db']['password'] +end http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/binary-installation/recipes/nfsshares.rb ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/binary-installation/recipes/nfsshares.rb b/tools/devcloud4/common/binary-installation/recipes/nfsshares.rb new file mode 100644 index 0000000..100eab9 --- /dev/null +++ b/tools/devcloud4/common/binary-installation/recipes/nfsshares.rb @@ -0,0 +1,48 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +include_recipe 'nfs::server' + +directory node['cloudstack']['secondary']['path'] do + owner 'root' + group 'root' + action :create + recursive true +end + +nfs_export node['cloudstack']['secondary']['path'] do + network '*' + writeable true + sync false + options %w(no_root_squash no_subtree_check) +end + +directory node['cloudstack']['primary']['path'] do + owner 'root' + group 'root' + action :create + recursive true +end + +nfs_export node['cloudstack']['primary']['path'] do + network '*' + writeable true + sync false + options %w(no_root_squash no_subtree_check) +end http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/configure-network.sh ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/configure-network.sh b/tools/devcloud4/common/configure-network.sh new file mode 100644 index 0000000..dde115d --- /dev/null +++ b/tools/devcloud4/common/configure-network.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# Usage ./reset-network.sh interface ip netmask +# +# 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. +# + +[ $# -lt 3 ] && { echo -e "Missing arguments\nUsage: ./reset-network interface ip netmask label"; exit 1; } + +. /etc/xensource-inventory + +PIF=$(/usr/bin/xe pif-introduce device=$1 host-uuid=${INSTALLATION_UUID}) + +NETWORKPIF=$(/usr/bin/xe pif-list uuid=${PIF} params="network-uuid" --minimal) +/usr/bin/xe network-param-set uuid=${NETWORKPIF} name-label=${4} + +if [ ${4} == "MGMT" ] +then + /usr/bin/xe pif-reconfigure-ip uuid=${PIF} mode=static ip=${2} netmask=${3} + /usr/bin/xe host-management-reconfigure pif-uuid=${PIF} +else + /usr/bin/xe pif-plug uuid=${PIF} +fi http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/development-installation/README.md ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/development-installation/README.md b/tools/devcloud4/common/development-installation/README.md new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/development-installation/attributes/database_server.rb ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/development-installation/attributes/database_server.rb b/tools/devcloud4/common/development-installation/attributes/database_server.rb new file mode 100644 index 0000000..314f9c1 --- /dev/null +++ b/tools/devcloud4/common/development-installation/attributes/database_server.rb @@ -0,0 +1,22 @@ +# +# 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. +# + +default['mysql']['server_root_password'] = '' +default['mysql']['allow_remote_root'] = true +default['mysql']['data_dir'] = '/data/mysql' http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/development-installation/attributes/default.rb ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/development-installation/attributes/default.rb b/tools/devcloud4/common/development-installation/attributes/default.rb new file mode 100644 index 0000000..705423b --- /dev/null +++ b/tools/devcloud4/common/development-installation/attributes/default.rb @@ -0,0 +1,29 @@ +# +# 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. +# + +default['cloudstack']['secondary']['host'] = node['ipaddress'] +default['cloudstack']['secondary']['path'] = '/data/secondary' +default['cloudstack']['secondary']['mgt_path'] = node['cloudstack']['secondary']['path'] + +default['cloudstack']['primary']['host'] = node['ipaddress'] +default['cloudstack']['primary']['path'] = '/data/primary' +default['cloudstack']['primary']['mgt_path'] = node['cloudstack']['primary']['path'] + +default['cloudstack']['cloud-install-sys-tmplt'] = "#{Chef::Config['file_cache_path']}/cloud-install-sys-tmplt" +default['cloudstack']['createtmplt'] = "#{Chef::Config['file_cache_path']}/createtmplt.sh" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/66cded75/tools/devcloud4/common/development-installation/files/default/cloud-install-sys-tmplt ---------------------------------------------------------------------- diff --git a/tools/devcloud4/common/development-installation/files/default/cloud-install-sys-tmplt b/tools/devcloud4/common/development-installation/files/default/cloud-install-sys-tmplt new file mode 100755 index 0000000..313b599 --- /dev/null +++ b/tools/devcloud4/common/development-installation/files/default/cloud-install-sys-tmplt @@ -0,0 +1,288 @@ +#!/usr/bin/env bash +# $Id: installrtng.sh 11251 2010-07-23 23:40:44Z abhishek $ $HeadURL: svn://svn.lab.vmops.com/repos/vmdev/java/scripts/storage/secondary/installrtng.sh $ + +# 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. + + +usage() { + printf "Usage: %s: -m <secondary storage mount point> -f <system vm template file> [-h <hypervisor name: kvm|vmware|xenserver|hyperv> ] [ -s <mgmt server secret key, if you specified any when running cloudstack-setup-database, default is password>][-u <Url to system vm template>] [-F <clean up system templates of specified hypervisor>] [-e <Template suffix, e.g vhd, ova, qcow2>] [-o <Database server hostname or ip, e.g localhost>] [-r <Database user name, e.g root>] [-d <Database password. Fllowed by nothing if the password is empty>]\n" $(basename $0) >&2 + printf "or\n" >&2 + printf "%s: -m <secondary storage mount point> -u <http url for system vm template> [-h <hypervisor name: kvm|vmware|xenserver|hyperv> ] [ -s <mgmt server secret key>]\n" $(basename $0) >&2 +} + +failed() { + echo "Installation failed" + exit $1 +} +#set -x +mflag= +fflag= +ext="vhd" +templateId= +hyper= +msKey=password +DISKSPACE=5120000 #free disk space required in kilobytes +dbHost= +dbUser= +dbPassword= +name= +jasypt='/usr/share/cloudstack-common/lib/jasypt-1.9.0.jar' +while getopts 'm:h:f:u:Ft:e:s:o:r:d:n:' OPTION +do + case $OPTION in + m) mflag=1 + mntpoint="$OPTARG" + ;; + f) fflag=1 + tmpltimg="$OPTARG" + ;; + u) uflag=1 + url="$OPTARG" + ;; + F) Fflag=1 ;; + t) templateId="$OPTARG" + ;; + e) ext="$OPTARG" + ;; + h) hyper="$OPTARG" + ;; + s) sflag=1 + msKey="$OPTARG" + ;; + o) oflag=1 + dbHost="$OPTARG" + ;; + r) rflag=1 + dbUser="$OPTARG" + ;; + d) dflag=1 + dbPassword="$OPTARG" + ;; + n) nflag=1 + name="$OPTARG" + ;; + ?) usage + failed 2 + ;; + esac +done + +if [[ "$mflag$fflag" != "11" && "$mflag$uflag" != "11" ]] +then + usage + failed 2 +fi + +if [ -z "$hyper" ] +then + usage + failed 2 +fi + +if [ ! -d $mntpoint ] +then + echo "mount point $mntpoint doesn't exist\n" + failed 4 +fi + +if [[ "$fflag" == "1" && ! -f $tmpltimg ]] +then + echo "template image file $tmpltimg doesn't exist" + failed 3 +fi + + +if [ "$oflag" != 1 ]; then + dbHost=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.host' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') +fi +if [ "$rflag" != 1 ]; then + dbUser=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.username' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') +fi + +if [ -f /etc/cloudstack/management/db.properties ]; then + encType=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.encryption.type' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') + if [ "$encType" == "file" ] + then + msKey=$(cat /etc/cloudstack/management/key) + elif [ "$encType" == "web" ] + then + if [ ! "$sflag" == "1" ] + then + echo "Encryption type web requires mgmt secret key using -s option" + failed 9 + fi + fi +fi + +if [[ "$encType" == "file" || "$encType" == "web" ]] +then + encPassword=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'i | sed 's/^ENC(\(.*\))/\1/') + if [ ! $encPassword == "" ] + then + dbPassword=(`java -classpath $jasypt org.jasypt.intf.cli.JasyptPBEStringDecryptionCLI decrypt.sh input=$encPassword password=$msKey verbose=false`) + if [ ! $dbPassword ] + then + echo "Failed to decrypt DB password from db.properties" + failed 9 + fi + fi +else + if [ "$dflag" != 1 ]; then + dbPassword=$(sed '/^\#/d' /etc/cloudstack/management/db.properties | grep 'db.cloud.password' | tail -n 1 | cut -d "=" -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'i ) + fi +fi + +if [ "$templateId" == "" ] +then + if [ "$hyper" == "kvm" ] + then + ext="qcow2" + templateId=(`mysql -h $dbHost --user=$dbUser --password=$dbPassword --skip-column-names -U cloud -e "select max(id) from cloud.vm_template where type = \"SYSTEM\" and hypervisor_type = \"KVM\" and removed is null"`) + elif [ "$hyper" == "xenserver" ] + then + ext="vhd" + templateId=(`mysql -h $dbHost --user=$dbUser --password=$dbPassword --skip-column-names -U cloud -e "select max(id) from cloud.vm_template where type = \"SYSTEM\" and hypervisor_type = \"XenServer\" and removed is null"`) + elif [ "$hyper" == "vmware" ] + then + ext="ova" + templateId=(`mysql -h $dbHost --user=$dbUser --password=$dbPassword --skip-column-names -U cloud -e "select max(id) from cloud.vm_template where type = \"SYSTEM\" and hypervisor_type = \"VMware\" and removed is null"`) + elif [ "$hyper" == "lxc" ] + then + ext="qcow2" + templateId=(`mysql -h $dbHost --user=$dbUser --password=$dbPassword --skip-column-names -U cloud -e "select max(id) from cloud.vm_template where type = \"SYSTEM\" and hypervisor_type = \"LXC\" and removed is null"`) + elif [ "$hyper" == "hyperv" ] + then + ext="vhd" + templateId=(`mysql -h $dbHost --user=$dbUser --password=$dbPassword --skip-column-names -U cloud -e "select max(id) from cloud.vm_template where type = \"SYSTEM\" and hypervisor_type = \"Hyperv\" and removed is null"`) + else + usage + failed 2 + fi +fi + +if [ ! $templateId ] +then + echo "Unable to get template Id from database" + failed 8 +fi + +localfile=$(uuidgen).$ext + +mntpoint=`echo "$mntpoint" | sed 's|/*$||'` + +destdir=$mntpoint/template/tmpl/1/$templateId/ + +mkdir -p $destdir +if [ $? -ne 0 ] +then + printf "Failed to write to mount point $mntpoint -- is it mounted?\n" + failed 3 +fi + +if [ "$Fflag" == "1" ] +then + rm -rf $destdir/* + if [ $? -ne 0 ] + then + echo "Failed to clean up template directory $destdir -- check permissions?" + failed 2 + fi +fi + +if [ -f $destdir/template.properties ] +then + echo "Data already exists at destination $destdir -- use -F to force cleanup of old template" + echo "IF YOU ARE ATTEMPTING AN UPGRADE, YOU MAY NEED TO SPECIFY A TEMPLATE ID USING THE -t FLAG" + failed 4 +fi + +destvhdfiles=$(find $destdir -name \*.$ext) +if [ "$destvhdfiles" != "" ] +then + echo "Data already exists at destination $destdir -- use -F to force cleanup of old template" + failed 5 +fi + +tmpfile=$(dirname $0)/$localfile + +touch $tmpfile +if [ $? -ne 0 ] +then + printf "Failed to create temporary file in directory $(dirname $0) -- is it read-only or full?\n" + failed 4 +fi + +destcap=$(df -P $destdir | awk '{print $4}' | tail -1 ) +[ $destcap -lt $DISKSPACE ] && echo "Insufficient free disk space for target folder $destdir: avail=${destcap}k req=${DISKSPACE}k" && failed 4 + +localcap=$(df -P $(dirname $0) | awk '{print $4}' | tail -1 ) +[ $localcap -lt $DISKSPACE ] && echo "Insufficient free disk space for local temporary folder $(dirname $0): avail=${localcap}k req=${DISKSPACE}k" && failed 4 + +if [ "$uflag" == "1" ] +then + wget -O $tmpfile $url + if [ $? -ne 0 ] + then + echo "Failed to fetch system vm template from $url" + failed 5 + fi +fi + + +if [ "$fflag" == "1" ] +then + cp $tmpltimg $tmpfile + if [ $? -ne 0 ] + then + printf "Failed to create temporary file in directory $(dirname $0) -- is it read-only or full?\n" + failed 6 + fi +fi + + +installrslt=$($(dirname $0)/createtmplt.sh -s 2 -d 'SystemVM Template' -n $localfile -t $destdir/ -f $tmpfile -u -v) + +if [ $? -ne 0 ] +then + echo "Failed to install system vm template $tmpltimg to $destdir: $installrslt" + failed 7 +fi + +if [ "$nflag" != "1" ] +then + uniquename=routing-$templateId +fi + +if [ "$ext" == "ova" ] +then + tar xvf $destdir/$localfile -C $destdir &> /dev/null +fi + +tmpltfile=$destdir/$localfile +tmpltsize=$(ls -l $tmpltfile| awk -F" " '{print $5}') + +echo "$ext=true" >> $destdir/template.properties +echo "id=$templateId" >> $destdir/template.properties +echo "public=true" >> $destdir/template.properties +echo "$ext.filename=$localfile" >> $destdir/template.properties +echo "uniquename=$uniquename" >> $destdir/template.properties +echo "$ext.virtualsize=$tmpltsize" >> $destdir/template.properties +echo "virtualsize=$tmpltsize" >> $destdir/template.properties +echo "$ext.size=$tmpltsize" >> $destdir/template.properties + +echo "Successfully installed system VM template $tmpltimg to $destdir"