vagrant-cloudstack 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +18 -19
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +19 -19
  5. data/CHANGELOG.md +179 -171
  6. data/Docker/.dockerignore +2 -0
  7. data/Docker/Dockerfile +51 -0
  8. data/Docker/Dockerfile.chefdk_0_17 +49 -0
  9. data/Docker/Dockerfile.latest_dependencies +49 -0
  10. data/Docker/README.md +67 -0
  11. data/Docker/vac.ps1 +29 -0
  12. data/Docker/vac.sh +30 -0
  13. data/Gemfile +20 -20
  14. data/LICENSE +8 -8
  15. data/README.md +416 -416
  16. data/Rakefile +106 -99
  17. data/bootstrap.key +27 -0
  18. data/build_rpm.sh +7 -7
  19. data/functional-tests/basic/Vagrantfile.basic_networking +45 -45
  20. data/functional-tests/basic/basic_spec.rb +21 -21
  21. data/functional-tests/networking/Vagrantfile.advanced_networking +119 -102
  22. data/functional-tests/networking/networking_spec.rb +14 -0
  23. data/functional-tests/rsync/Vagrantfile.advanced_networking +39 -56
  24. data/functional-tests/rsync/rsync_spec.rb +9 -9
  25. data/functional-tests/vmlifecycle/Vagrantfile.advanced_networking +66 -82
  26. data/functional-tests/vmlifecycle/vmlifecycle_spec.rb +13 -13
  27. data/lib/vagrant-cloudstack/action/connect_cloudstack.rb +47 -47
  28. data/lib/vagrant-cloudstack/action/is_created.rb +18 -18
  29. data/lib/vagrant-cloudstack/action/is_stopped.rb +18 -18
  30. data/lib/vagrant-cloudstack/action/message_already_created.rb +16 -16
  31. data/lib/vagrant-cloudstack/action/message_not_created.rb +16 -16
  32. data/lib/vagrant-cloudstack/action/message_will_not_destroy.rb +16 -16
  33. data/lib/vagrant-cloudstack/action/read_rdp_info.rb +76 -76
  34. data/lib/vagrant-cloudstack/action/read_ssh_info.rb +104 -87
  35. data/lib/vagrant-cloudstack/action/read_state.rb +38 -38
  36. data/lib/vagrant-cloudstack/action/read_winrm_info.rb +103 -103
  37. data/lib/vagrant-cloudstack/action/run_instance.rb +798 -703
  38. data/lib/vagrant-cloudstack/action/start_instance.rb +81 -81
  39. data/lib/vagrant-cloudstack/action/stop_instance.rb +28 -28
  40. data/lib/vagrant-cloudstack/action/terminate_instance.rb +269 -224
  41. data/lib/vagrant-cloudstack/action/timed_provision.rb +21 -21
  42. data/lib/vagrant-cloudstack/action/wait_for_state.rb +41 -41
  43. data/lib/vagrant-cloudstack/action/warn_networks.rb +19 -19
  44. data/lib/vagrant-cloudstack/action.rb +210 -210
  45. data/lib/vagrant-cloudstack/capabilities/rdp.rb +12 -12
  46. data/lib/vagrant-cloudstack/capabilities/winrm.rb +12 -12
  47. data/lib/vagrant-cloudstack/config.rb +566 -548
  48. data/lib/vagrant-cloudstack/errors.rb +27 -27
  49. data/lib/vagrant-cloudstack/exceptions/exceptions.rb +10 -10
  50. data/lib/vagrant-cloudstack/model/cloudstack_resource.rb +51 -33
  51. data/lib/vagrant-cloudstack/plugin.rb +82 -82
  52. data/lib/vagrant-cloudstack/provider.rb +58 -58
  53. data/lib/vagrant-cloudstack/service/cloudstack_resource_service.rb +64 -58
  54. data/lib/vagrant-cloudstack/util/timer.rb +17 -17
  55. data/lib/vagrant-cloudstack/version.rb +5 -5
  56. data/lib/vagrant-cloudstack.rb +17 -17
  57. data/locales/en.yml +131 -123
  58. data/spec/spec_helper.rb +8 -6
  59. data/spec/vagrant-cloudstack/action/read_ssh_info_spec.rb +80 -0
  60. data/spec/vagrant-cloudstack/config_spec.rb +355 -355
  61. data/spec/vagrant-cloudstack/model/cloudstack_resource_spec.rb +95 -73
  62. data/spec/vagrant-cloudstack/service/cloudstack_resource_service_spec.rb +43 -43
  63. data/spec/vagrant-cloudstack/support/be_a_resource.rb +6 -0
  64. data/vagrant-cloudstack.gemspec +59 -59
  65. data/vagrant-cloudstack.spec +42 -42
  66. metadata +14 -7
  67. data/dummy.box +0 -0
  68. data/example_box/README.md +0 -13
  69. data/example_box/metadata.json +0 -3
  70. data/functional-tests/networking/rsync_spec.rb +0 -12
data/Docker/Dockerfile ADDED
@@ -0,0 +1,51 @@
1
+ FROM debian:8
2
+
3
+ MAINTAINER Bob van den Heuvel <bvandenheuvel@schubergphilis.com>
4
+
5
+ # Specific older chef-dk required due to bundler version, only available as Debian 6 package
6
+ ENV CHEFDK_VERSION 0.10.0
7
+ ENV CHEFDK_DEB_VERSION 6
8
+
9
+ # Currently the latest version of the plugin has been tested with Vagrant 1.8.1
10
+ ENV VAGRANT_VERSION 1.8.1
11
+
12
+ # The plugin currently depends on existence of the USER variable...
13
+ ENV USER VAC
14
+
15
+ # Update before all package installations
16
+ RUN apt-get update -y && \
17
+ apt-get install -y build-essential liblzma-dev zlib1g-dev git openssh-client curl && \
18
+ ln -sf bash /bin/sh
19
+
20
+ # Set the locale, seems to be required for all things gem
21
+ RUN apt-get install -y locales && \
22
+ dpkg-reconfigure -f noninteractive tzdata && \
23
+ sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
24
+ echo 'LANG="en_US.UTF-8"'>/etc/default/locale && \
25
+ dpkg-reconfigure --frontend=noninteractive locales && \
26
+ update-locale LANG=en_US.UTF-8
27
+ # Set environment variables AFTER configuration, else breaks
28
+ ENV LANG en_US.UTF-8
29
+ ENV LANGUAGE en_US:en
30
+ ENV LC_ALL en_US.UTF-8
31
+ #
32
+
33
+ # install vagrant and the vagrant-cloudstack plugin
34
+ RUN curl -L https://releases.hashicorp.com/vagrant/${VAGRANT_VERSION}/vagrant_${VAGRANT_VERSION}_x86_64.deb > /tmp/vagrant_x86_64.deb && \
35
+ dpkg -i /tmp/vagrant_x86_64.deb && \
36
+ rm -f /tmp/vagrant_x86_64.deb && \
37
+ vagrant plugin install vagrant-cloudstack && \
38
+ vagrant plugin install vagrant-winrm
39
+
40
+ RUN curl -L https://packages.chef.io/stable/debian/${CHEFDK_DEB_VERSION}/chefdk_${CHEFDK_VERSION}-1_amd64.deb > /tmp/chef_dk.deb && \
41
+ dpkg -i /tmp/chef_dk.deb && rm /tmp/chef_dk.deb && \
42
+ rm -f /tmp/chef_dk.deb && \
43
+ echo 'eval "$(chef shell-init bash)"' >> ~/.bashrc && \
44
+ /opt/chefdk/embedded/bin/bundler config --global path vendor/bundle && \
45
+ /opt/chefdk/embedded/bin/bundler config --global bin vendor/bin && \
46
+ /opt/chefdk/embedded/bin/gem install kitchen-vagrant
47
+
48
+
49
+ WORKDIR "/work"
50
+
51
+ VOLUME ["/work"]
@@ -0,0 +1,49 @@
1
+ FROM debian:8
2
+
3
+ MAINTAINER Bob van den Heuvel <bvandenheuvel@schubergphilis.com>
4
+
5
+ # Specify the ChefDK version and channel
6
+ ENV CHEFDK_VERSION 0.17
7
+ ENV CHEFDK_CHANNEL stable
8
+
9
+ # Currently the latest version of the plugin has been tested with Vagrant 1.8.1
10
+ ENV VAGRANT_VERSION 1.8.1
11
+
12
+ # The plugin currently depends on existence of the USER variable...
13
+ ENV USER VAC
14
+
15
+ # Update before all package installations
16
+ RUN apt-get update -y && \
17
+ apt-get install -y build-essential liblzma-dev zlib1g-dev git openssh-client curl && \
18
+ ln -sf bash /bin/sh
19
+
20
+ # Set the locale, seems to be required for all things gem
21
+ RUN apt-get install -y locales && \
22
+ dpkg-reconfigure -f noninteractive tzdata && \
23
+ sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
24
+ echo 'LANG="en_US.UTF-8"'>/etc/default/locale && \
25
+ dpkg-reconfigure --frontend=noninteractive locales && \
26
+ update-locale LANG=en_US.UTF-8
27
+ # Set environment variables AFTER configuration, else breaks
28
+ ENV LANG en_US.UTF-8
29
+ ENV LANGUAGE en_US:en
30
+ ENV LC_ALL en_US.UTF-8
31
+ #
32
+
33
+ # Install vagrant and the vagrant-cloudstack plugin
34
+ RUN curl -L https://releases.hashicorp.com/vagrant/${VAGRANT_VERSION}/vagrant_${VAGRANT_VERSION}_x86_64.deb > /tmp/vagrant_x86_64.deb && \
35
+ dpkg -i /tmp/vagrant_x86_64.deb && \
36
+ rm -f /tmp/vagrant_x86_64.deb && \
37
+ vagrant plugin install vagrant-cloudstack && \
38
+ vagrant plugin install vagrant-winrm
39
+
40
+ # Install ChefDK
41
+ RUN curl https://omnitruck.chef.io/install.sh | bash -s -- -c ${CHEFDK_CHANNEL} -P chefdk -v ${CHEFDK_VERSION} && \
42
+ echo 'eval "$(chef shell-init bash)"' >> ~/.bashrc && \
43
+ /opt/chefdk/embedded/bin/bundler config --global path vendor/bundle && \
44
+ /opt/chefdk/embedded/bin/bundler config --global bin vendor/bin && \
45
+ /opt/chefdk/embedded/bin/gem install kitchen-vagrant
46
+
47
+ WORKDIR "/work"
48
+
49
+ VOLUME ["/work"]
@@ -0,0 +1,49 @@
1
+ FROM debian:8
2
+
3
+ MAINTAINER Bob van den Heuvel <bvandenheuvel@schubergphilis.com>
4
+
5
+ # Specify the ChefDK version and channel
6
+ ENV CHEFDK_VERSION 0.19
7
+ ENV CHEFDK_CHANNEL stable
8
+
9
+ # Currently the latest version of the plugin has been tested with Vagrant 1.8.1
10
+ ENV VAGRANT_VERSION 1.8.1
11
+
12
+ # The plugin currently depends on existence of the USER variable...
13
+ ENV USER VAC
14
+
15
+ # Update before all package installations
16
+ RUN apt-get update -y && \
17
+ apt-get install -y build-essential liblzma-dev zlib1g-dev git openssh-client curl && \
18
+ ln -sf bash /bin/sh
19
+
20
+ # Set the locale, seems to be required for all things gem
21
+ RUN apt-get install -y locales && \
22
+ dpkg-reconfigure -f noninteractive tzdata && \
23
+ sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
24
+ echo 'LANG="en_US.UTF-8"'>/etc/default/locale && \
25
+ dpkg-reconfigure --frontend=noninteractive locales && \
26
+ update-locale LANG=en_US.UTF-8
27
+ # Set environment variables AFTER configuration, else breaks
28
+ ENV LANG en_US.UTF-8
29
+ ENV LANGUAGE en_US:en
30
+ ENV LC_ALL en_US.UTF-8
31
+ #
32
+
33
+ # Install vagrant and the vagrant-cloudstack plugin
34
+ RUN curl -L https://releases.hashicorp.com/vagrant/${VAGRANT_VERSION}/vagrant_${VAGRANT_VERSION}_x86_64.deb > /tmp/vagrant_x86_64.deb && \
35
+ dpkg -i /tmp/vagrant_x86_64.deb && \
36
+ rm -f /tmp/vagrant_x86_64.deb && \
37
+ vagrant plugin install vagrant-cloudstack && \
38
+ vagrant plugin install vagrant-winrm
39
+
40
+ # Install ChefDK
41
+ RUN curl https://omnitruck.chef.io/install.sh | bash -s -- -c ${CHEFDK_CHANNEL} -P chefdk -v ${CHEFDK_VERSION} && \
42
+ echo 'eval "$(chef shell-init bash)"' >> ~/.bashrc && \
43
+ /opt/chefdk/embedded/bin/bundler config --global path vendor/bundle && \
44
+ /opt/chefdk/embedded/bin/bundler config --global bin vendor/bin && \
45
+ /opt/chefdk/embedded/bin/gem install kitchen-vagrant
46
+
47
+ WORKDIR "/work"
48
+
49
+ VOLUME ["/work"]
data/Docker/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # Vagrant Cloudstack Container
2
+
3
+ This container contains some tools commonly used with the vagrant-cloudstack plugin
4
+ ## latest
5
+ The versions have been specifically tuned to provide a working set for development of the plugin. To this end also developer tools (e.g. make, g++) are installed to enable bundler to pull in and compile required gems.
6
+ So this one is _required_ for developing and testing the plugin from (latest, master) source.
7
+ * [Vagrant](http://www.vagrantup.com) 1.8.1
8
+ * [Vagrant-cloudstack](https://github.com/missioncriticalcloud/vagrant-cloudstack) plugin latest
9
+ * [Vagrant-winrm](https://github.com/criteo/vagrant-winrm) latest
10
+ * [Chef-DK](https://downloads.chef.io/chef-dk/) 0.10.0
11
+ * [Kitchen-Vagrant](https://github.com/test-kitchen/kitchen-vagrant) latest
12
+ _As the container is build automatically on triggers, latest versions are latest at time of (re)build_
13
+
14
+
15
+ ## latest_dependencies
16
+ This may not work for everyone as we try to use latest, but also stable combination of versions.
17
+ * [Vagrant](http://www.vagrantup.com) 1.8.1
18
+ * [Vagrant-cloudstack](https://github.com/missioncriticalcloud/vagrant-cloudstack) plugin latest
19
+ * [Vagrant-winrm](https://github.com/criteo/vagrant-winrm) latest
20
+ * [Chef-DK](https://downloads.chef.io/chef-dk/) 0.19
21
+ * [Kitchen-Vagrant](https://github.com/test-kitchen/kitchen-vagrant) latest
22
+ _As the container is build automatically on triggers, latest versions are latest at time of (re)build_
23
+
24
+
25
+ ## chefdk_0_17
26
+ This will install chef-client 12.13.37 which is needed for some compatibilty reasons.
27
+ * [Vagrant](http://www.vagrantup.com) 1.8.1
28
+ * [Vagrant-cloudstack](https://github.com/missioncriticalcloud/vagrant-cloudstack) plugin latest
29
+ * [Vagrant-winrm](https://github.com/criteo/vagrant-winrm) latest
30
+ * [Chef-DK](https://downloads.chef.io/chef-dk/) 0.17
31
+ * [Kitchen-Vagrant](https://github.com/test-kitchen/kitchen-vagrant) latest
32
+ _As the container is build automatically on triggers, latest versions are latest at time of (re)build_
33
+
34
+
35
+ Links to the respective Dockerfiles:
36
+ * [latest](https://raw.githubusercontent.com/MissionCriticalCloud/vagrant-cloudstack/master/Docker/Dockerfile)
37
+ * [latest_dependencies](https://raw.githubusercontent.com/MissionCriticalCloud/vagrant-cloudstack/master/Docker/Dockerfile.latest_dependencies)
38
+ * [chefdk_0_17](https://raw.githubusercontent.com/MissionCriticalCloud/vagrant-cloudstack/master/Docker/Dockerfile.chefdk_0_17)
39
+
40
+ ## Features
41
+ * Run Vagrant with the plugin
42
+ * Run Test-Kitchen with the plugin
43
+ * Using Bundler, run Vagrant/Test-Kitchen with vagrant-cloudstack from source
44
+
45
+ ## Usage
46
+ Retrieve the docker container:
47
+ ```
48
+ docker pull missioncriticalcloud/vagrant-cloudstack
49
+ ```
50
+ Change into the directory containing your project (Vagrantfile, .kitchen.yml), and execute:
51
+ ```
52
+ docker run -ti --rm -v $(pwd):/work missioncriticalcloud/vagrant-cloudstack /bin/bash
53
+ ```
54
+ This provides a bash shell (in the container) where you can execute e.g. Vagrant, Test-Kitchen, Bundler.
55
+
56
+ For use of Vagrantfile or .kitchen.yml files containing environment variables, environment variables need to be specified in the docker run, e.g.:
57
+ ```
58
+ docker run \
59
+ -e USER=${USER} \
60
+ -e CLOUDSTACK_API_KEY=${CLOUDSTACK_API_KEY} \
61
+ -e CLOUDSTACK_SECRET_KEY=${CLOUDSTACK_SECRET_KEY} \
62
+ -ti --rm -v $(pwd):/work missioncriticalcloud/vagrant-cloudstack /bin/bash
63
+ ```
64
+
65
+ For actual development of the plugin, a lot more variables are required. To this end you can use the [bash script `vac.sh`](https://raw.githubusercontent.com/MissionCriticalCloud/vagrant-cloudstack/master/Docker/vac.sh) or [PowerShell script `vac.ps1`](https://raw.githubusercontent.com/MissionCriticalCloud/vagrant-cloudstack/master/Docker/vac.ps1) in the git repo.
66
+
67
+ _Note on usage of SSH keyfile_: As the container is mounted on a specific folder (`$(pwd)`), the keyfile must be specified (by `SSH_KEY`) relative to, __and within__, the specified folder!
data/Docker/vac.ps1 ADDED
@@ -0,0 +1,29 @@
1
+ docker run `
2
+ -e USER=$env:USERNAME `
3
+ -e CLOUDSTACK_API_KEY=$env:CLOUDSTACK_API_KEY `
4
+ -e CLOUDSTACK_SECRET_KEY=$env:CLOUDSTACK_SECRET_KEY `
5
+ -e CLOUDSTACK_HOST=$env:CLOUDSTACK_HOST `
6
+ -e ZONE_NAME=$env:ZONE_NAME `
7
+ -e SERVICE_OFFERING_NAME=$env:SERVICE_OFFERING_NAME `
8
+ -e VPC_PUBLIC_IP=$env:VPC_PUBLIC_IP `
9
+ -e VPC_TIER_NAME=$env:VPC_TIER_NAME `
10
+ -e VR_PUBLIC_IP=$env:VR_PUBLIC_IP `
11
+ -e VR_NETWORK_NAME=$env:VR_NETWORK_NAME `
12
+ -e NETWORK_NAME=$env:NETWORK_NAME `
13
+ -e PUBLIC_SOURCE_NAT_IP=$env:PUBLIC_SOURCE_NAT_IP `
14
+ -e OPEN_FIREWALL=$env:OPEN_FIREWALL `
15
+ -e PUBLIC_SSH_PORT=$env:PUBLIC_SSH_PORT `
16
+ -e PRIVATE_SSH_PORT=$env:PRIVATE_SSH_PORT `
17
+ -e PUBLIC_WINRM_PORT=$env:PUBLIC_WINRM_PORT `
18
+ -e PRIVATE_WINRM_PORT=$env:PRIVATE_WINRM_PORT `
19
+ -e SSH_USER=$env:SSH_USER `
20
+ -e SSH_KEY=/work/$env:SSH_KEY `
21
+ -e WINDOWS_USER=$env:WINDOWS_USER `
22
+ -e LINUX_TEMPLATE_NAME=$env:LINUX_TEMPLATE_NAME `
23
+ -e WINDOWS_TEMPLATE_NAME=$env:WINDOWS_TEMPLATE_NAME `
24
+ -e SOURCE_CIDR=$env:SOURCE_CIDR `
25
+ -e TRUSTED_NETWORKS=$env:TRUSTED_NETWORKS `
26
+ -e KITCHEN_LOCAL_YAML=$env:KITCHEN_LOCAL_YAML `
27
+ -e DISK_OFFERING_NAME=$env:DISK_OFFERING_NAME `
28
+ -e EXPUNGE_ON_DESTROY=$env:EXPUNGE_ON_DESTROY `
29
+ -ti --rm -v "$( $(pwd) -replace '\\', '/'):/work" missioncriticalcloud/vagrant-cloudstack /bin/bash
data/Docker/vac.sh ADDED
@@ -0,0 +1,30 @@
1
+ #!/bin/sh
2
+ docker run \
3
+ -e USER=${USER} \
4
+ -e CLOUDSTACK_API_KEY=${CLOUDSTACK_API_KEY} \
5
+ -e CLOUDSTACK_SECRET_KEY=${CLOUDSTACK_SECRET_KEY} \
6
+ -e CLOUDSTACK_HOST=${CLOUDSTACK_HOST} \
7
+ -e ZONE_NAME=${ZONE_NAME} \
8
+ -e SERVICE_OFFERING_NAME=${SERVICE_OFFERING_NAME} \
9
+ -e VPC_PUBLIC_IP=${VPC_PUBLIC_IP} \
10
+ -e VPC_TIER_NAME=${VPC_TIER_NAME} \
11
+ -e VR_PUBLIC_IP=${VR_PUBLIC_IP} \
12
+ -e VR_NETWORK_NAME=${VR_NETWORK_NAME} \
13
+ -e NETWORK_NAME=${NETWORK_NAME} \
14
+ -e PUBLIC_SOURCE_NAT_IP=${PUBLIC_SOURCE_NAT_IP} \
15
+ -e OPEN_FIREWALL=${OPEN_FIREWALL} \
16
+ -e PUBLIC_SSH_PORT=${PUBLIC_SSH_PORT} \
17
+ -e PRIVATE_SSH_PORT=${PRIVATE_SSH_PORT} \
18
+ -e PUBLIC_WINRM_PORT=${PUBLIC_WINRM_PORT} \
19
+ -e PRIVATE_WINRM_PORT=${PRIVATE_WINRM_PORT} \
20
+ -e SSH_USER=${SSH_USER} \
21
+ -e SSH_KEY=/work/${SSH_KEY} \
22
+ -e WINDOWS_USER=${WINDOWS_USER} \
23
+ -e LINUX_TEMPLATE_NAME=${LINUX_TEMPLATE_NAME} \
24
+ -e WINDOWS_TEMPLATE_NAME=${WINDOWS_TEMPLATE_NAME} \
25
+ -e SOURCE_CIDR=${SOURCE_CIDR} \
26
+ -e TRUSTED_NETWORKS=${TRUSTED_NETWORKS} \
27
+ -e KITCHEN_LOCAL_YAML=${KITCHEN_LOCAL_YAML} \
28
+ -e DISK_OFFERING_NAME=${DISK_OFFERING_NAME} \
29
+ -e EXPUNGE_ON_DESTROY=${EXPUNGE_ON_DESTROY} \
30
+ -ti --rm -v $(pwd):/work missioncriticalcloud/vagrant-cloudstack /bin/bash
data/Gemfile CHANGED
@@ -1,20 +1,20 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- group :development do
6
- # We depend on Vagrant for development, but we don't add it as a
7
- # gem dependency because we expect to be installed within the
8
- # Vagrant environment itself using `vagrant plugin`.
9
- gem 'vagrant', git: 'git://github.com/mitchellh/vagrant.git', tag: 'v1.8.1'
10
- gem 'coveralls', require: false
11
- gem 'simplecov', require: false
12
- gem 'rspec-core'
13
- gem 'rspec-expectations'
14
- gem 'rspec-its'
15
- gem 'rspec-mocks'
16
- end
17
-
18
- group :plugins do
19
- gem 'vagrant-cloudstack', path: '.'
20
- end
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ # We depend on Vagrant for development, but we don't add it as a
7
+ # gem dependency because we expect to be installed within the
8
+ # Vagrant environment itself using `vagrant plugin`.
9
+ gem 'vagrant', git: 'git://github.com/mitchellh/vagrant.git', tag: 'v1.8.1'
10
+ gem 'coveralls', require: false
11
+ gem 'simplecov', require: false
12
+ gem 'rspec-core'
13
+ gem 'rspec-expectations'
14
+ gem 'rspec-its'
15
+ gem 'rspec-mocks'
16
+ end
17
+
18
+ group :plugins do
19
+ gem 'vagrant-cloudstack', path: '.'
20
+ end
data/LICENSE CHANGED
@@ -1,8 +1,8 @@
1
- The MIT License (MIT)
2
- Copyright (c) 2013 Mitchell Hashimoto
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
-
6
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
-
8
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ The MIT License (MIT)
2
+ Copyright (c) 2013 Mitchell Hashimoto
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,416 +1,416 @@
1
- # Vagrant Cloudstack Provider
2
-
3
- [![Build Status](https://travis-ci.org/schubergphilis/vagrant-cloudstack.png?branch=master)](https://travis-ci.org/schubergphilis/vagrant-cloudstack)
4
- [![Gem Version](https://badge.fury.io/rb/vagrant-cloudstack.png)](http://badge.fury.io/rb/vagrant-cloudstack)
5
- [![Code climate](https://codeclimate.com/github/schubergphilis/vagrant-cloudstack.png)](https://codeclimate.com/github/schubergphilis/vagrant-cloudstack)
6
- [![Coverage Status](https://coveralls.io/repos/schubergphilis/vagrant-cloudstack/badge.svg?branch=master)](https://coveralls.io/r/schubergphilis/vagrant-cloudstack?branch=master)
7
- [![Gem Version](https://badge.fury.io/rb/vagrant-cloudstack.svg)](http://badge.fury.io/rb/vagrant-cloudstack)
8
-
9
- This is a fork of [mitchellh AWS Provider](https://github.com/mitchellh/vagrant-aws/).
10
-
11
- This is a [Vagrant](http://www.vagrantup.com) 1.5+ plugin that adds a [Cloudstack](http://cloudstack.apache.org)
12
- provider to Vagrant.
13
-
14
- ## Features
15
-
16
- * SSH into the instances.
17
- * Provision the instances with any built-in Vagrant provisioner.
18
- * Minimal synced folder support via `rsync`/`winrm`.
19
-
20
- ## Usage
21
-
22
- Install using standard Vagrant 1.1+ plugin installation methods. After
23
- installing, `vagrant up` and specify the `cloudstack` provider. An example is
24
- shown below.
25
-
26
- ```
27
- $ vagrant plugin install vagrant-cloudstack
28
- ...
29
- $ vagrant up --provider=cloudstack
30
- ...
31
- ```
32
-
33
- Of course prior to doing this, you'll need to obtain an Cloudstack-compatible
34
- box file for Vagrant.
35
-
36
- ## Quick Start
37
-
38
- After installing the plugin (instructions above), the quickest way to get
39
- started is to actually make a Vagrantfile that looks like the following, filling in
40
- your information where necessary.
41
-
42
- ```
43
- Vagrant.configure("2") do |config|
44
- config.vm.box = "${cloudstack.template_name}"
45
-
46
- config.vm.provider :cloudstack do |cloudstack, override|
47
- cloudstack.host = "cloudstack.local"
48
- cloudstack.path = "/client/api"
49
- cloudstack.port = "8080"
50
- cloudstack.scheme = "http"
51
- cloudstack.api_key = "AAAAAAAAAAAAAAAAAAA"
52
- cloudstack.secret_key = "AAAAAAAAAAAAAAAAAAA"
53
-
54
- cloudstack.service_offering_id = "AAAAAAAAAAAAAAAAAAA"
55
- cloudstack.disk_offering_id = "AAAAAAAAAAAAAAAAAAA"
56
- cloudstack.network_id = "AAAAAAAAAAAAAAAAAAA"
57
- cloudstack.zone_id = "AAAAAAAAAAAAAAAAAAA"
58
- cloudstack.project_id = "AAAAAAAAAAAAAAAAAAA"
59
- end
60
- end
61
- ```
62
-
63
- Or with names instead of ids:
64
-
65
- ```
66
- Vagrant.configure("2") do |config|
67
- config.vm.box = "${cloudstack.template_name}"
68
-
69
- config.vm.provider :cloudstack do |cloudstack, override|
70
- cloudstack.host = "cloudstack.local"
71
- cloudstack.path = "/client/api"
72
- cloudstack.port = "8080"
73
- cloudstack.scheme = "http"
74
- cloudstack.api_key = "AAAAAAAAAAAAAAAAAAA"
75
- cloudstack.secret_key = "AAAAAAAAAAAAAAAAAAA"
76
-
77
- cloudstack.service_offering_name = "THE-BESTEST"
78
- cloudstack.disk_offering_name = "THE-LARGEST-OFFER-AVAILABLE"
79
- cloudstack.network_name = "WOW-SUCH-FAST-OFFERING"
80
- cloudstack.zone_name = "District-9"
81
- cloudstack.name = "doge-is-a-hostname-now"
82
- # Sadly there is currently no support for the project api in fog.
83
- cloudstack.project_id = "AAAAAAAAAAAAAAAAAAA"
84
- end
85
- end
86
- ```
87
-
88
-
89
- Note that normally a lot of this boilerplate is encoded within the box
90
- file, but the box file used for the quick start, the "dummy" box, has
91
- no preconfigured defaults.
92
-
93
- And then run `vagrant up --provider=cloudstack`.
94
-
95
- This will start an instance in Cloudstack. And assuming your template
96
- on Cloudstack is Vagrant compatible _(vagrant user with official
97
- vagrant pub key in authorized_keys)_ SSH and provisioning will work as
98
- well.
99
-
100
- ## Box Format
101
-
102
- Every provider in Vagrant must introduce a custom box format. This
103
- provider introduces `cloudstack` boxes. You can view an example box in
104
- the [example_box/ directory](https://github.com/schubergphilis/vagrant-cloudstack/tree/master/example_box).
105
- That directory also contains instructions on how to build a box.
106
-
107
- The box format is basically just the required `metadata.json` file
108
- along with a `Vagrantfile` that does default settings for the
109
- provider-specific configuration for this provider.
110
-
111
- ## Configuration
112
-
113
- This provider exposes quite a few provider-specific configuration options. Most of the settings
114
- have both an id and a name setting and you can chose to use either (i.e network_id or network_name).
115
- This gives the possibility to use the easier to remember name instead of the UUID,
116
- this will also enable you to upgrade the different settings in your cloud without having
117
- to update UUIDs in your Vagrantfile. If both are specified, the id parameter takes precedence.
118
-
119
- * `name` - Hostname of the created machine
120
- * `host` - Cloudstack api host
121
- * `path` - Cloudstack api path
122
- * `port` - Cloudstack api port
123
- * `scheme` - Cloudstack api scheme _(defaults: https (thanks to the resolution order in fog))_
124
- * `api_key` - The api key for accessing Cloudstack
125
- * `secret_key` - The secret key for accessing Cloudstack
126
- * `instance_ready_timeout` - The number of seconds to wait for the instance
127
- to become "ready" in Cloudstack. Defaults to 120 seconds.
128
- * `domain_id` - Domain id to launch the instance into
129
- * `network_id` - Network uuid that the instance should use
130
- * `network_name` - Network name that the instance should use
131
- * `project_id` - Project uuid that the instance should belong to
132
- * `service_offering_id`- Service offering uuid to use for the instance
133
- * `service_offering_name`- Service offering name to use for the instance
134
- * `template_id` - Template uuid to use for the instance
135
- * `template_name` - Template name to use for the instance, defaults to Vagrants config.vm.box
136
- * `zone_id` - Zone uuid to launch the instance into
137
- * `zone_name` - Zone uuid to launch the instance into
138
- * `keypair` - SSH keypair name, if neither'keypair' nor 'ssh_key' have been specified, a temporary keypair will be created
139
- * `static_nat` - static nat for the virtual machine
140
- * `pf_ip_address_id` - IP address ID for port forwarding rule
141
- * `pf_ip_address` - IP address for port forwarding rule
142
- * `pf_public_port` - Public Communicator port for port forwarding rule
143
- * `pf_public_rdp_port` - Public RDP port for port forwarding rule
144
- * `pf_public_port_randomrange` - If public port is omited, a port from this range wll be used (default `{:start=>49152, :end=>65535}`)
145
- * `pf_private_port` - Private port for port forwarding rule (defaults to respective Communicator protocol)
146
- * `pf_open_firewall` - Flag to enable/disable automatic open firewall rule (by CloudStack)
147
- * `pf_trusted_networks` - Array of CIDRs or (array of) comma-separated string of CIDRs to network(s) to
148
- - automatically (by plugin) generate firewall rules for, ignored if `pf_open_firewall` set `true`
149
- - use as default for firewall rules where source CIDR is missing
150
- * `port_forwarding_rules` - Port forwarding rules for the virtual machine
151
- * `firewall_rules` - Firewall rules
152
- * `display_name` - Display name for the instance
153
- * `group` - Group for the instance
154
- * `ssh_key` - Path to a private key to be used with ssh _(defaults to Vagrant's `config.ssh.private_key_path`)_
155
- * `ssh_user` - User name to be used with ssh _(defaults to Vagrant's `config.ssh.username`)_
156
- * `vm_user` - User name to be used with winrm _(defaults to Vagrant's `config.winrm.username`)_
157
- * `vm_password` - Password to be used with winrm. _(If the CloudStack template is "Password Enabled", leaving this unset will trigger the plugin to retrieve and use it.)_
158
- * `private_ip_address` - private (static)ip address to be used by the virtual machine
159
- * `expunge_on_destroy` - Flag to enable/disable expunge vm on destroy
160
-
161
- These can be set like typical provider-specific configuration:
162
-
163
- ```ruby
164
- Vagrant.configure("2") do |config|
165
- # ... other stuff
166
-
167
- config.vm.provider :cloudstack do |cloudstack|
168
- cloudstack.api_key = "foo"
169
- cloudstack.secret_key = "bar"
170
- end
171
- end
172
- ```
173
-
174
- In addition to the above top-level configs, you can use the `region_config`
175
- method to specify region-specific overrides within your Vagrantfile. Note
176
- that the top-level `region` config must always be specified to choose which
177
- region you want to actually use, however. This looks like this:
178
-
179
- ```ruby
180
- Vagrant.configure("2") do |config|
181
- # ... other stuff
182
-
183
- config.vm.provider :cloudstack do |cloudstack|
184
- cloudstack.api_key = "foo"
185
- cloudstack.secret_key = "bar"
186
- cloudstack.domain = "internal"
187
-
188
- # Simple domain config
189
- cloudstack.domain_config "internal", :network_id => "AAAAAAAAAAAAAAAAAAA"
190
-
191
- # More comprehensive region config
192
- cloudstack.domain_config "internal" do |domain|
193
- domain.network_id = "AAAAAAAAAAAAAAAAAAA"
194
- domain.service_offering_id = "AAAAAAAAAAAAAAAAAAA"
195
- end
196
- end
197
- end
198
- ```
199
-
200
- The domain-specific configurations will override the top-level
201
- configurations when that domain is used. They otherwise inherit
202
- the top-level configurations, as you would probably expect.
203
-
204
- ## Networks
205
-
206
- Networking features in the form of `config.vm.network` are not
207
- supported with `vagrant-cloudstack`, currently. If any of these are
208
- specified, Vagrant will emit a warning, but will otherwise boot
209
- the Cloudstack machine.
210
-
211
- ### Basic networking versus Advanced networking
212
-
213
- The plugin will determine this network type dynamically from the zone.
214
- The setting `network_type` in the Vagrant file has been deprecated,
215
- and is silently ignored.
216
-
217
- ### Basic Networking
218
-
219
- If the network type of your zone is `basic`, you can use Security
220
- Groups and associate rules in your Vagrantfile.
221
-
222
- If you already have Security Groups, you can associate them to your
223
- instance, with their IDs:
224
-
225
- ```ruby
226
- Vagrant.configure("2") do |config|
227
- # ... other stuff
228
-
229
- config.vm.provider :cloudstack do |cloudstack|
230
- cloudstack.api_key = "foo"
231
- cloudstack.secret_key = "bar"
232
- cloudstack.security_group_ids = ['aaaa-bbbb-cccc-dddd', '1111-2222-3333-4444']
233
- end
234
- end
235
- ```
236
-
237
- or their names:
238
-
239
- ```ruby
240
- Vagrant.configure("2") do |config|
241
- # ... other stuff
242
-
243
- config.vm.provider :cloudstack do |cloudstack|
244
- cloudstack.api_key = "foo"
245
- cloudstack.secret_key = "bar"
246
- cloudstack.security_group_names = ['
247
- min_fantastiska_security_group', 'another_security_grupp']
248
- end
249
- end
250
- ```
251
-
252
- But you can also create your Security Groups in the Vagrantfile:
253
-
254
- ```ruby
255
- Vagrant.configure("2") do |config|
256
- # ... other stuff
257
-
258
- config.vm.provider :cloudstack do |cloudstack|
259
- cloudstack.api_key = "foo"
260
- cloudstack.secret_key = "bar"
261
- cloudstack.security_groups = [
262
- {
263
- :name => "Awesome_security_group",
264
- :description => "Created from the Vagrantfile",
265
- :rules => [
266
- {:type => "ingress", :protocol => "TCP", :startport => 22, :endport => 22, :cidrlist => "0.0.0.0/0"},
267
- {:type => "ingress", :protocol => "TCP", :startport => 80, :endport => 80, :cidrlist => "0.0.0.0/0"},
268
- {:type => "egress", :protocol => "TCP", :startport => 81, :endport => 82, :cidrlist => "1.2.3.4/24"},
269
- ]
270
- }
271
- ]
272
- end
273
- end
274
- ```
275
-
276
- ### Static NAT, Firewall, Port forwarding
277
-
278
- You can create your static nat, firewall and port forwarding rules in the Vagrantfile.
279
- You can use this rule to access virtual machine from an external machine.
280
-
281
- The rules created in Vagrantfile are removed when the virtual machine is destroyed.
282
-
283
- ```ruby
284
- Vagrant.configure("2") do |config|
285
- # ... other stuff
286
-
287
- config.vm.provider :cloudstack do |cloudstack|
288
-
289
- override.ssh.host = "X.X.X.X"
290
-
291
- cloudstack.static_nat = [
292
- { :ipaddress => "A.A.A.A"}
293
- ]
294
-
295
- cloudstack.port_forwarding_rules = [
296
- { :ipaddress => "X.X.X.X", :protocol => "tcp", :publicport => 22, :privateport => 22, :openfirewall => false },
297
- { :ipaddress => "X.X.X.X", :protocol => "tcp", :publicport => 80, :privateport => 80, :openfirewall => false }
298
- ]
299
-
300
- cloudstack.firewall_rules = [
301
- { :ipaddress => "A.A.A.A", :cidrlist => "1.2.3.4/24", :protocol => "icmp", :icmptype => 8, :icmpcode => 0 },
302
- { :ipaddress => "X.X.X.X", :cidrlist => "1.2.3.4/24", :protocol => "tcp", :startport => 22, :endport => 22 },
303
- { :ipaddress => "X.X.X.X", :cidrlist => "1.2.3.4/24", :protocol => "tcp", :startport => 80, :endport => 80 }
304
- ]
305
-
306
- end
307
- end
308
- ```
309
- Most values in the firewall and portforwarding rules are not mandatory, except either startport/endport or privateport/publicport
310
- * `:ipaddress` - defaults to `pf_ip_address`
311
- * `:protocol` - defaults to `'tcp'`
312
- * `:publicport` - defaults to `:privateport`
313
- * `:privateport` - defaults to `:publicport`
314
- * `:openfirewall` - defaults to `pf_open_firewall`
315
- * `:cidrlist` - defaults to `pf_trusted_networks`
316
- * `:startport` - defaults to `:endport`
317
- * `:endport` - not required by CloudStack
318
-
319
-
320
- For only allowing Vagrant to access the box for further provisioning (SSH/WinRM), and opening the Firewall for some subnets, the following config is sufficient:
321
- ```ruby
322
- Vagrant.configure("2") do |config|
323
- # ... other stuff
324
-
325
- config.vm.provider :cloudstack do |cloudstack|
326
- cloudstack.pf_open_firewall = "false"
327
- cloudstack.pf_ip_address = X.X.X.X
328
- cloudstack.pf_trusted_networks = [ "1.2.3.4/24" , "11.22.33.44/32" ]
329
- end
330
- end
331
- ```
332
- Where X.X.X.X is the ip of the respective CloudStack network, this will automatically map the port of the used Communicator (SSH/Winrm) via a random public port, open the Firewall and set Vagrant to use it.
333
-
334
- The plugin can also automatically generate firewall rules off of the portforwarding rules:
335
- ```ruby
336
- Vagrant.configure("2") do |config|
337
- # ... other stuff
338
-
339
- config.vm.provider :cloudstack do |cloudstack|
340
-
341
- cloudstack.pf_trusted_networks = "1.2.3.4/24,11.22.33.44/32"
342
- cloudstack.port_forwarding_rules = [
343
- { :privateport => 22, :generate_firewall => true },
344
- { :privateport => 80, :generate_firewall => true }
345
- ]
346
-
347
- end
348
- end
349
- ```
350
-
351
- ## Synced Folders
352
-
353
- There is minimal support for synced folders. Upon `vagrant up`, `vagrant reload`, and `vagrant provision`, the Cloudstack provider will use `rsync` (if available) to uni-directionally sync the folder to the remote machine over SSH, and use Vagrant plugin `vagrant-winrm-syncedfolders` (if available) to uni-directionally sync the folder to the remote machine over WinRM.
354
-
355
- This is good enough for all built-in Vagrant provisioners (shell,
356
- chef, and puppet) to work!
357
-
358
- ### User data
359
-
360
- You can specify user data for the instance being booted.
361
-
362
- ```ruby
363
- Vagrant.configure("2") do |config|
364
- # ... other stuff
365
-
366
- config.vm.provider :cloudstack do |cloudstack|
367
- # Option 1: a single string
368
- cloudstack.user_data = "#!/bin/bash\necho 'got user data' > /tmp/user_data.log\necho"
369
-
370
- # Option 2: use a file
371
- cloudstack.user_data = File.read("user_data.txt")
372
- end
373
- end
374
- ```
375
-
376
- The maximum length of user_data is around 1500 bytes with Cloudstack API < 4.2 ( base64 encoded user_data must be < 2048 bytes)
377
-
378
- ## Development
379
-
380
- To work on the `vagrant-cloudstack` plugin, clone this repository out, and use
381
- [Bundler](http://gembundler.com) to get the dependencies:
382
-
383
- ```
384
- $ bundle
385
- ```
386
-
387
- Once you have the dependencies, verify the unit tests pass with `rake`:
388
-
389
- ```
390
- $ bundle exec rake
391
- ```
392
-
393
- If the unit-tests pass, verify the plugin is functionaly good by running the functional tests with bats.
394
- Before running the tests you need to export a set of variables that are used in the tests. Look at the
395
- Rake file for the required variables, or run the following Rake command to check:
396
- ```
397
- bundle exec rake functional_tests:check_environment
398
- ```
399
-
400
- Run all functional tests by executing:
401
- ```
402
- bundle exec rake functional_tests:all
403
- ```
404
-
405
- If those pass, you're ready to start developing the plugin. You can test
406
- the plugin without installing it into your Vagrant environment by just
407
- creating a `Vagrantfile` in the top level of this directory (it is gitignored)
408
- and add the following line to your `Vagrantfile`
409
- ```ruby
410
- Vagrant.require_plugin "vagrant-cloudstack"
411
- ```
412
- Use bundler to execute Vagrant:
413
-
414
- ```
415
- $ bundle exec vagrant up --provider=cloudstack
416
- ```
1
+ # Vagrant Cloudstack Provider
2
+
3
+ [![Build Status](https://travis-ci.org/MissionCriticalCloud/vagrant-cloudstack.png?branch=master)](https://travis-ci.org/missioncriticalcloud/vagrant-cloudstack)
4
+ [![Gem Version](https://badge.fury.io/rb/vagrant-cloudstack.png)](http://badge.fury.io/rb/vagrant-cloudstack)
5
+ [![Code climate](https://codeclimate.com/github/MissionCriticalCloud/vagrant-cloudstack.png)](https://codeclimate.com/github/missioncriticalcloud/vagrant-cloudstack)
6
+ [![Coverage Status](https://coveralls.io/repos/github/MissionCriticalCloud/vagrant-cloudstack/badge.svg?branch=master)](https://coveralls.io/github/MissionCriticalCloud/vagrant-cloudstack?branch=master)
7
+ [![Gem Version](https://badge.fury.io/rb/vagrant-cloudstack.svg)](http://badge.fury.io/rb/vagrant-cloudstack)
8
+
9
+ This is a fork of [mitchellh AWS Provider](https://github.com/mitchellh/vagrant-aws/).
10
+
11
+ This is a [Vagrant](http://www.vagrantup.com) 1.5+ plugin that adds a [Cloudstack](http://cloudstack.apache.org)
12
+ provider to Vagrant for use with either [Cosmic](https://github.com/MissionCriticalCloud/cosmic) or [Cloudstack](http://cloudstack.apache.org).
13
+
14
+ ## Features
15
+
16
+ * SSH into the instances.
17
+ * Provision the instances with any built-in Vagrant provisioner.
18
+ * Minimal synced folder support via `rsync`/`winrm`.
19
+
20
+ ## Usage
21
+
22
+ Install using standard Vagrant 1.1+ plugin installation methods. After
23
+ installing, `vagrant up` and specify the `cloudstack` provider. An example is
24
+ shown below.
25
+
26
+ ```
27
+ $ vagrant plugin install vagrant-cloudstack
28
+ ...
29
+ $ vagrant up --provider=cloudstack
30
+ ...
31
+ ```
32
+
33
+ ## Quick Start
34
+
35
+ After installing the plugin (instructions above), the quickest way to get
36
+ started is to actually make a Vagrantfile that looks like the following, filling in
37
+ your information where necessary.
38
+
39
+ ```
40
+ Vagrant.configure("2") do |config|
41
+ config.vm.box = "${cloudstack.template_name}"
42
+
43
+ config.vm.provider :cloudstack do |cloudstack, override|
44
+ cloudstack.host = "cloudstack.local"
45
+ cloudstack.path = "/client/api"
46
+ cloudstack.port = "8080"
47
+ cloudstack.scheme = "http"
48
+ cloudstack.api_key = "AAAAAAAAAAAAAAAAAAA"
49
+ cloudstack.secret_key = "AAAAAAAAAAAAAAAAAAA"
50
+
51
+ cloudstack.service_offering_id = "AAAAAAAAAAAAAAAAAAA"
52
+ cloudstack.disk_offering_id = "AAAAAAAAAAAAAAAAAAA"
53
+ cloudstack.network_id = "AAAAAAAAAAAAAAAAAAA"
54
+ cloudstack.zone_id = "AAAAAAAAAAAAAAAAAAA"
55
+ cloudstack.project_id = "AAAAAAAAAAAAAAAAAAA"
56
+ end
57
+ end
58
+ ```
59
+
60
+ Or with names instead of ids:
61
+
62
+ ```
63
+ Vagrant.configure("2") do |config|
64
+ config.vm.box = "${cloudstack.template_name}"
65
+
66
+ config.vm.provider :cloudstack do |cloudstack, override|
67
+ cloudstack.host = "cloudstack.local"
68
+ cloudstack.path = "/client/api"
69
+ cloudstack.port = "8080"
70
+ cloudstack.scheme = "http"
71
+ cloudstack.api_key = "AAAAAAAAAAAAAAAAAAA"
72
+ cloudstack.secret_key = "AAAAAAAAAAAAAAAAAAA"
73
+
74
+ cloudstack.service_offering_name = "THE-BESTEST"
75
+ cloudstack.disk_offering_name = "THE-LARGEST-OFFER-AVAILABLE"
76
+ cloudstack.network_name = "WOW-SUCH-FAST-OFFERING"
77
+ cloudstack.zone_name = "District-9"
78
+ cloudstack.name = "doge-is-a-hostname-now"
79
+ # Sadly there is currently no support for the project api in fog.
80
+ cloudstack.project_id = "AAAAAAAAAAAAAAAAAAA"
81
+ end
82
+ end
83
+ ```
84
+
85
+ And then run `vagrant up --provider=cloudstack`.
86
+
87
+ This will start an instance in Cloudstack. And assuming your template
88
+ on Cloudstack is Vagrant compatible _(vagrant user with official
89
+ vagrant pub key in authorized_keys)_ SSH and provisioning will work as
90
+ well.
91
+
92
+ ## Configuration
93
+
94
+ This provider exposes quite a few provider-specific configuration options. Most of the settings
95
+ have both an id and a name setting and you can chose to use either (i.e network_id or network_name).
96
+ This gives the possibility to use the easier to remember name instead of the UUID,
97
+ this will also enable you to upgrade the different settings in your cloud without having
98
+ to update UUIDs in your Vagrantfile. If both are specified, the id parameter takes precedence.
99
+
100
+ * `name` - Hostname of the created machine
101
+ * `host` - Cloudstack api host
102
+ * `path` - Cloudstack api path
103
+ * `port` - Cloudstack api port
104
+ * `scheme` - Cloudstack api scheme _(defaults: https (thanks to the resolution order in fog))_
105
+ * `api_key` - The api key for accessing Cloudstack
106
+ * `secret_key` - The secret key for accessing Cloudstack
107
+ * `instance_ready_timeout` - The number of seconds to wait for the instance
108
+ to become "ready" in Cloudstack. Defaults to 120 seconds.
109
+ * `domain_id` - Domain id to launch the instance into
110
+ * `network_id` - Network uuid(s) that the instance should use
111
+ - `network_id` is single value (e.g. `"AAAA"`) or multiple values (e.g. `["AAAA", "BBBB"]`)
112
+ * `network_name` - Network name(s) that the instance should use
113
+ - `network_name` is single value (e.g. `"AAAA"`) or multiple values (e.g. `["AAAA", "BBBB"]`)
114
+ * `project_id` - Project uuid that the instance should belong to
115
+ * `service_offering_id`- Service offering uuid to use for the instance
116
+ * `service_offering_name`- Service offering name to use for the instance
117
+ * `template_id` - Template uuid to use for the instance
118
+ * `template_name` - Template name to use for the instance, defaults to Vagrants config.vm.box
119
+ * `zone_id` - Zone uuid to launch the instance into
120
+ * `zone_name` - Zone uuid to launch the instance into
121
+ * `keypair` - SSH keypair name, if neither'keypair' nor 'ssh_key' have been specified, a temporary keypair will be created
122
+ * `static_nat` - static nat for the virtual machine
123
+ * `pf_ip_address_id` - IP address ID for port forwarding rule
124
+ * `pf_ip_address` - IP address for port forwarding rule
125
+ * `pf_public_port` - Public Communicator port for port forwarding rule
126
+ * `pf_public_rdp_port` - Public RDP port for port forwarding rule
127
+ * `pf_public_port_randomrange` - If public port is omited, a port from this range wll be used (default `{:start=>49152, :end=>65535}`)
128
+ * `pf_private_port` - Private port for port forwarding rule (defaults to respective Communicator protocol)
129
+ * `pf_open_firewall` - Flag to enable/disable automatic open firewall rule (by CloudStack)
130
+ * `pf_trusted_networks` - Array of CIDRs or (array of) comma-separated string of CIDRs to network(s) to
131
+ - automatically (by plugin) generate firewall rules for, ignored if `pf_open_firewall` set `true`
132
+ - use as default for firewall rules where source CIDR is missing
133
+ * `port_forwarding_rules` - Port forwarding rules for the virtual machine
134
+ * `firewall_rules` - Firewall rules
135
+ * `display_name` - Display name for the instance
136
+ * `group` - Group for the instance
137
+ * `ssh_key` - Path to a private key to be used with ssh _(defaults to Vagrant's `config.ssh.private_key_path`)_
138
+ * `ssh_user` - User name to be used with ssh _(defaults to Vagrant's `config.ssh.username`)_
139
+ * `ssh_network_id` - The network_id to be used when loging in to the vm via ssh _(defaults to first nic)_
140
+ * `ssh_network_name` - The network_name to be used when loging in to the vm via ssh _(defaults to first nic)_
141
+ - Use either `ssh_network_id` or `ssh_network_name`. If specified both , use `ssh_network_id`
142
+ * `vm_user` - User name to be used with winrm _(defaults to Vagrant's `config.winrm.username`)_
143
+ * `vm_password` - Password to be used with winrm. _(If the CloudStack template is "Password Enabled", leaving this unset will trigger the plugin to retrieve and use it.)_
144
+ * `private_ip_address` - private (static)ip address to be used by the virtual machine
145
+ * `expunge_on_destroy` - Flag to enable/disable expunge vm on destroy
146
+
147
+ These can be set like typical provider-specific configuration:
148
+
149
+ ```ruby
150
+ Vagrant.configure("2") do |config|
151
+ # ... other stuff
152
+
153
+ config.vm.provider :cloudstack do |cloudstack|
154
+ cloudstack.api_key = "foo"
155
+ cloudstack.secret_key = "bar"
156
+ end
157
+ end
158
+ ```
159
+
160
+ In addition to the above top-level configs, you can use the `region_config`
161
+ method to specify region-specific overrides within your Vagrantfile. Note
162
+ that the top-level `region` config must always be specified to choose which
163
+ region you want to actually use, however. This looks like this:
164
+
165
+ ```ruby
166
+ Vagrant.configure("2") do |config|
167
+ # ... other stuff
168
+
169
+ config.vm.provider :cloudstack do |cloudstack|
170
+ cloudstack.api_key = "foo"
171
+ cloudstack.secret_key = "bar"
172
+ cloudstack.domain = "internal"
173
+
174
+ # Simple domain config
175
+ cloudstack.domain_config "internal", :network_id => "AAAAAAAAAAAAAAAAAAA"
176
+
177
+ # More comprehensive region config
178
+ cloudstack.domain_config "internal" do |domain|
179
+ domain.network_id = "AAAAAAAAAAAAAAAAAAA"
180
+ domain.service_offering_id = "AAAAAAAAAAAAAAAAAAA"
181
+ end
182
+ end
183
+ end
184
+ ```
185
+
186
+ The domain-specific configurations will override the top-level
187
+ configurations when that domain is used. They otherwise inherit
188
+ the top-level configurations, as you would probably expect.
189
+
190
+ ## Networks
191
+
192
+ Networking features in the form of `config.vm.network` are not
193
+ supported with `vagrant-cloudstack`, currently. If any of these are
194
+ specified, Vagrant will emit a warning, but will otherwise boot
195
+ the Cloudstack machine.
196
+
197
+ ### Basic networking versus Advanced networking
198
+
199
+ The plugin will determine this network type dynamically from the zone.
200
+ The setting `network_type` in the Vagrant file has been deprecated,
201
+ and is silently ignored.
202
+
203
+ ### Basic Networking
204
+
205
+ If the network type of your zone is `basic`, you can use Security
206
+ Groups and associate rules in your Vagrantfile.
207
+
208
+ If you already have Security Groups, you can associate them to your
209
+ instance, with their IDs:
210
+
211
+ ```ruby
212
+ Vagrant.configure("2") do |config|
213
+ # ... other stuff
214
+
215
+ config.vm.provider :cloudstack do |cloudstack|
216
+ cloudstack.api_key = "foo"
217
+ cloudstack.secret_key = "bar"
218
+ cloudstack.security_group_ids = ['aaaa-bbbb-cccc-dddd', '1111-2222-3333-4444']
219
+ end
220
+ end
221
+ ```
222
+
223
+ or their names:
224
+
225
+ ```ruby
226
+ Vagrant.configure("2") do |config|
227
+ # ... other stuff
228
+
229
+ config.vm.provider :cloudstack do |cloudstack|
230
+ cloudstack.api_key = "foo"
231
+ cloudstack.secret_key = "bar"
232
+ cloudstack.security_group_names = ['
233
+ min_fantastiska_security_group', 'another_security_grupp']
234
+ end
235
+ end
236
+ ```
237
+
238
+ But you can also create your Security Groups in the Vagrantfile:
239
+
240
+ ```ruby
241
+ Vagrant.configure("2") do |config|
242
+ # ... other stuff
243
+
244
+ config.vm.provider :cloudstack do |cloudstack|
245
+ cloudstack.api_key = "foo"
246
+ cloudstack.secret_key = "bar"
247
+ cloudstack.security_groups = [
248
+ {
249
+ :name => "Awesome_security_group",
250
+ :description => "Created from the Vagrantfile",
251
+ :rules => [
252
+ {:type => "ingress", :protocol => "TCP", :startport => 22, :endport => 22, :cidrlist => "0.0.0.0/0"},
253
+ {:type => "ingress", :protocol => "TCP", :startport => 80, :endport => 80, :cidrlist => "0.0.0.0/0"},
254
+ {:type => "egress", :protocol => "TCP", :startport => 81, :endport => 82, :cidrlist => "1.2.3.4/24"},
255
+ ]
256
+ }
257
+ ]
258
+ end
259
+ end
260
+ ```
261
+
262
+ ### Static NAT, Firewall, Port forwarding
263
+
264
+ You can create your static nat, firewall and port forwarding rules in the Vagrantfile.
265
+ You can use this rule to access virtual machine from an external machine.
266
+
267
+ The rules created in Vagrantfile are removed when the virtual machine is destroyed.
268
+
269
+ ```ruby
270
+ Vagrant.configure("2") do |config|
271
+ # ... other stuff
272
+
273
+ config.vm.provider :cloudstack do |cloudstack|
274
+
275
+ override.ssh.host = "X.X.X.X"
276
+
277
+ cloudstack.static_nat = [
278
+ { :ipaddress => "A.A.A.A"}
279
+ ]
280
+
281
+ cloudstack.port_forwarding_rules = [
282
+ { :ipaddress => "X.X.X.X", :protocol => "tcp", :publicport => 22, :privateport => 22, :openfirewall => false },
283
+ { :ipaddress => "X.X.X.X", :protocol => "tcp", :publicport => 80, :privateport => 80, :openfirewall => false }
284
+ ]
285
+
286
+ cloudstack.firewall_rules = [
287
+ { :ipaddress => "A.A.A.A", :cidrlist => "1.2.3.4/24", :protocol => "icmp", :icmptype => 8, :icmpcode => 0 },
288
+ { :ipaddress => "X.X.X.X", :cidrlist => "1.2.3.4/24", :protocol => "tcp", :startport => 22, :endport => 22 },
289
+ { :ipaddress => "X.X.X.X", :cidrlist => "1.2.3.4/24", :protocol => "tcp", :startport => 80, :endport => 80 }
290
+ ]
291
+
292
+ end
293
+ end
294
+ ```
295
+ Most values in the firewall and portforwarding rules are not mandatory, except either startport/endport or privateport/publicport
296
+ * `:ipaddress` - defaults to `pf_ip_address`
297
+ * `:protocol` - defaults to `'tcp'`
298
+ * `:publicport` - defaults to `:privateport`
299
+ * `:privateport` - defaults to `:publicport`
300
+ * `:openfirewall` - defaults to `pf_open_firewall`
301
+ * `:cidrlist` - defaults to `pf_trusted_networks`
302
+ * `:startport` - defaults to `:endport`
303
+ * `:endport` - not required by CloudStack
304
+
305
+
306
+ For only allowing Vagrant to access the box for further provisioning (SSH/WinRM), and opening the Firewall for some subnets, the following config is sufficient:
307
+ ```ruby
308
+ Vagrant.configure("2") do |config|
309
+ # ... other stuff
310
+
311
+ config.vm.provider :cloudstack do |cloudstack|
312
+ cloudstack.pf_open_firewall = "false"
313
+ cloudstack.pf_ip_address = X.X.X.X
314
+ cloudstack.pf_trusted_networks = [ "1.2.3.4/24" , "11.22.33.44/32" ]
315
+ end
316
+ end
317
+ ```
318
+ Where X.X.X.X is the ip of the respective CloudStack network, this will automatically map the port of the used Communicator (SSH/Winrm) via a random public port, open the Firewall and set Vagrant to use it.
319
+
320
+ The plugin can also automatically generate firewall rules off of the portforwarding rules:
321
+ ```ruby
322
+ Vagrant.configure("2") do |config|
323
+ # ... other stuff
324
+
325
+ config.vm.provider :cloudstack do |cloudstack|
326
+
327
+ cloudstack.pf_trusted_networks = "1.2.3.4/24,11.22.33.44/32"
328
+ cloudstack.port_forwarding_rules = [
329
+ { :privateport => 22, :generate_firewall => true },
330
+ { :privateport => 80, :generate_firewall => true }
331
+ ]
332
+
333
+ end
334
+ end
335
+ ```
336
+
337
+ ### Virtual Router versus VPC
338
+ Both Virtual Routers and VPCs are supported when using port-forwarding and firewall. This is automatically determined by the specific `pf_ip_address`.
339
+
340
+ Note that there are architectural differences in CloudStack which the configuration must adhere to.
341
+
342
+ For VPC:
343
+ * `pf_open_firewall` will be ignored as global setting and (specifically) in `port_forwarding_rules`
344
+ * for `firewall_rules` to open access for `port_forwarding_rules`, the firewall rule should allow traffic for the `:privateport` port.
345
+
346
+ For Virtual Router:
347
+ * for `firewall_rules` to open access for `port_forwarding_rules`, the firewall rule should allow traffic for the `:publicport` port.
348
+
349
+ Usage of other attributes and features work with both network types. Such as `:generate_firewall` for portforwarding rules, or `pf_trusted_networks` to automatically generate rules for the Communicator.
350
+
351
+ ## Synced Folders
352
+
353
+ There is minimal support for synced folders. Upon `vagrant up`, `vagrant reload`, and `vagrant provision`, the Cloudstack provider will use `rsync` (if available) to uni-directionally sync the folder to the remote machine over SSH, and use Vagrant plugin `vagrant-winrm-syncedfolders` (if available) to uni-directionally sync the folder to the remote machine over WinRM.
354
+
355
+ This is good enough for all built-in Vagrant provisioners (shell,
356
+ chef, and puppet) to work!
357
+
358
+ ### User data
359
+
360
+ You can specify user data for the instance being booted.
361
+
362
+ ```ruby
363
+ Vagrant.configure("2") do |config|
364
+ # ... other stuff
365
+
366
+ config.vm.provider :cloudstack do |cloudstack|
367
+ # Option 1: a single string
368
+ cloudstack.user_data = "#!/bin/bash\necho 'got user data' > /tmp/user_data.log\necho"
369
+
370
+ # Option 2: use a file
371
+ cloudstack.user_data = File.read("user_data.txt")
372
+ end
373
+ end
374
+ ```
375
+
376
+ The maximum length of user_data is around 1500 bytes with Cloudstack API < 4.2 (base64 encoded user_data must be < 2048 bytes)
377
+
378
+ ## Development
379
+
380
+ To work on the `vagrant-cloudstack` plugin, clone this repository out, and use
381
+ [Bundler](http://gembundler.com) to get the dependencies:
382
+
383
+ ```
384
+ $ bundle
385
+ ```
386
+
387
+ Once you have the dependencies, verify the unit tests pass with `rake`:
388
+
389
+ ```
390
+ $ bundle exec rake
391
+ ```
392
+
393
+ If the unit-tests pass, verify the plugin is functionaly good by running the functional tests with bats.
394
+ Before running the tests you need to export a set of variables that are used in the tests. Look at the
395
+ Rake file for the required variables, or run the following Rake command to check:
396
+ ```
397
+ bundle exec rake functional_tests:check_environment
398
+ ```
399
+
400
+ Run all functional tests by executing:
401
+ ```
402
+ bundle exec rake functional_tests:all
403
+ ```
404
+
405
+ If those pass, you're ready to start developing the plugin. You can test
406
+ the plugin without installing it into your Vagrant environment by just
407
+ creating a `Vagrantfile` in the top level of this directory (it is gitignored)
408
+ and add the following line to your `Vagrantfile`
409
+ ```ruby
410
+ Vagrant.require_plugin "vagrant-cloudstack"
411
+ ```
412
+ Use bundler to execute Vagrant:
413
+
414
+ ```
415
+ $ bundle exec vagrant up --provider=cloudstack
416
+ ```