vagrant-cloudstack 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5d750f86b43aa8348d4e5c9687d83637b9b7997e
4
+ data.tar.gz: f0551d674a64b6478c4a6b44a5dca65010dae7bd
5
+ SHA512:
6
+ metadata.gz: 8e442bbdbfa07e2ae3f44421e3a3191c05352f025c1b41e8a6270e650e51d1ad74ab37f3c200b1ff494bd8fe148bf2a3a7e87d22536e2956836e326cc1392889
7
+ data.tar.gz: d5ebb8c660995a2caa731bf48e953bf029dc5982994f48c48366f8643a6ce74efbef8ba00318d3f6617bc8b28aa085deb58f613af0ee22491858dda5630ebb32
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ # OS-specific
2
+ .DS_Store
3
+
4
+ # Bundler/Rubygems
5
+ *.gem
6
+ .bundle
7
+ pkg/*
8
+ tags
9
+ Gemfile.lock
10
+
11
+ # Vagrant
12
+ .vagrant
13
+ Vagrantfile
14
+ !example_box/Vagrantfile
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ notifications:
3
+ email:
4
+ - carl.loa.odin@klarna.com
5
+ before_install:
6
+ - sudo apt-get update -qq
7
+ - sudo apt-get install -qq -y bsdtar
8
+ rvm:
9
+ - 1.9.3
10
+ script: rake
data/CHANGELOG.md ADDED
@@ -0,0 +1,47 @@
1
+ # 0.0.2 (May 3, 2013)
2
+
3
+ * Renamed module from CloudStack to Cloudstack
4
+ * Renamed configurations to match Cloudstack
5
+ * domain -> domain_id
6
+ * offering_id -> service_offering_id
7
+ * Added specc test for all provider specific configurations
8
+
9
+ # 0.0.1 (April 17, 2013)
10
+
11
+ * Forked into a Cloudstack plugin
12
+
13
+ # 0.2.1 (April 16, 2013)
14
+
15
+ * Got rid of extranneous references to old SSH settings.
16
+
17
+ # 0.2.0 (April 16, 2013)
18
+
19
+ * Add support for `vagrant ssh -c` [GH-42]
20
+ * Ability to specify a timeout for waiting for instances to become ready. [GH-44]
21
+ * Better error message if instance didn't become ready in time.
22
+ * Connection can now be done using IAM profiles. [GH-41]
23
+
24
+ # 0.1.3 (April 9, 2013)
25
+
26
+ * The `AWS_ACCESS_KEY` and `AWS_SECRET_KEY` will be used if available
27
+ and no specific keys are set in the Vagrantfile. [GH-33]
28
+ * Fix issues with SSH on VPCs, the correct IP is used. [GH-30]
29
+ * Exclude the ".vagrant" directory from rsync.
30
+ * Implement `:disabled` flag support for shared folders. [GH-29]
31
+ * `aws.user_data` to specify user data on the instance. [GH-26]
32
+
33
+ # 0.1.2 (March 22, 2013)
34
+
35
+ * Choose the proper region when connecting to AWS. [GH-9]
36
+ * Configurable SSH port. [GH-13]
37
+ * Support other AWS-compatible API endpoints with `config.endpoint`
38
+ and `config.version`. [GH-6]
39
+ * Disable strict host key checking on rsync so known hosts aren't an issue. [GH-7]
40
+
41
+ # 0.1.1 (March 18, 2013)
42
+
43
+ * Up fog dependency for Vagrant 1.1.1
44
+
45
+ # 0.1.0 (March 14, 2013)
46
+
47
+ * Initial release.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
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"
10
+ end
data/LICENSE ADDED
@@ -0,0 +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.
data/README.md ADDED
@@ -0,0 +1,194 @@
1
+ # Vagrant Cloudstack Provider
2
+
3
+ [![Build Status](https://travis-ci.org/klarna/vagrant-cloudstack.png?branch=master)](https://travis-ci.org/klarna/vagrant-cloudstack)
4
+
5
+ This is a fork of [mitchellh AWS Provider](https://github.com/mitchellh/vagrant-aws/).
6
+
7
+ This is a [Vagrant](http://www.vagrantup.com) 1.2+ plugin that adds an [Cloudstack](http://cloudstack.apache.org)
8
+ provider to Vagrant.
9
+
10
+ **NOTE:** This plugin requires Vagrant 1.2+,
11
+
12
+ ## Features
13
+
14
+ * SSH into the instances.
15
+ * Provision the instances with any built-in Vagrant provisioner.
16
+ * Minimal synced folder support via `rsync`.
17
+
18
+ ## Usage
19
+
20
+ Install using standard Vagrant 1.1+ plugin installation methods. After
21
+ installing, `vagrant up` and specify the `cloudstack` provider. An example is
22
+ shown below.
23
+
24
+ ```
25
+ $ vagrant plugin install vagrant-cloudstack
26
+ ...
27
+ $ vagrant up --provider=cloudstack
28
+ ...
29
+ ```
30
+
31
+ Of course prior to doing this, you'll need to obtain an Cloudstack-compatible
32
+ box file for Vagrant.
33
+
34
+ ## Quick Start
35
+
36
+ After installing the plugin (instructions above), the quickest way to get
37
+ started is to actually use a dummy Cloudstack box and specify all the details
38
+ manually within a `config.vm.provider` block. So first, add the dummy
39
+ box using any name you want:
40
+
41
+ ```
42
+ $ vagrant box add dummy https://github.com/klarna/vagrant-cloudstack/raw/master/dummy.box
43
+ ...
44
+ ```
45
+
46
+ And then make a Vagrantfile that looks like the following, filling in
47
+ your information where necessary.
48
+
49
+ ```
50
+ Vagrant.configure("2") do |config|
51
+ config.vm.box = "dummy"
52
+
53
+ config.vm.provider :cloudstack do |cloudstack, override|
54
+ cloudstack.host = "cloudstack.local"
55
+ cloudstack.path = "/client/api"
56
+ cloudstack.port = "8080"
57
+ cloudstack.scheme = "http"
58
+ cloudstack.api_key = "AAAAAAAAAAAAAAAAAAA"
59
+ cloudstack.secret_key = "AAAAAAAAAAAAAAAAAAA"
60
+
61
+ cloudstack.template_id = "AAAAAAAAAAAAAAAAAAA"
62
+ cloudstack.service_offering_id = "AAAAAAAAAAAAAAAAAAA"
63
+ cloudstack.network_id = "AAAAAAAAAAAAAAAAAAA"
64
+ cloudstack.zone_id = "AAAAAAAAAAAAAAAAAAA"
65
+ cloudstack.project_id = "AAAAAAAAAAAAAAAAAAA"
66
+ end
67
+ end
68
+ ```
69
+
70
+ Note that normally a lot of this boilerplate is encoded within the box
71
+ file, but the box file used for the quick start, the "dummy" box, has
72
+ no preconfigured defaults.
73
+
74
+ And then run `vagrant up --provider=cloudstack`.
75
+
76
+ This will start an instance in Cloudstack. And assuming your template on Cloudstack is Vagrant compatible _(vagrant user with official vagrant pub key in authorized_keys)_ SSH and provisioning will work as well.
77
+
78
+ ## Box Format
79
+
80
+ Every provider in Vagrant must introduce a custom box format. This
81
+ provider introduces `cloudstack` boxes. You can view an example box in
82
+ the [example_box/ directory](https://github.com/klarna/vagrant-cloudstack/tree/master/example_box).
83
+ That directory also contains instructions on how to build a box.
84
+
85
+ The box format is basically just the required `metadata.json` file
86
+ along with a `Vagrantfile` that does default settings for the
87
+ provider-specific configuration for this provider.
88
+
89
+ ## Configuration
90
+
91
+ This provider exposes quite a few provider-specific configuration options:
92
+
93
+ * `host` - Cloudstack api host
94
+ * `path` - Cloudstack api path
95
+ * `port` - Cloudstack api port
96
+ * `scheme` - Cloudstack api scheme _(default: http)_
97
+ * `api_key` - The api key for accessing Cloudstack
98
+ * `secret_key` - The secret key for accessing Cloudstack
99
+ * `instance_ready_timeout` - The number of seconds to wait for the instance
100
+ to become "ready" in Cloudstack. Defaults to 120 seconds.
101
+ * `domain_id` - Domain id to launch the instance into
102
+ * `network_id` - Network uuid that the instance should use
103
+ * `project_id` - Project uuid that the instance should belong to
104
+ * `service_offering_id`- Service offering uuid to use for the instance
105
+ * `template_id` - Template uuid to use for the instance
106
+ * `zone_id` - Zone uuid to launch the instance into
107
+
108
+ These can be set like typical provider-specific configuration:
109
+
110
+ ```ruby
111
+ Vagrant.configure("2") do |config|
112
+ # ... other stuff
113
+
114
+ config.vm.provider :cloudstack do |cloudstack|
115
+ cloudstack.api_key = "foo"
116
+ cloudstack.secret_key = "bar"
117
+ end
118
+ end
119
+ ```
120
+
121
+ In addition to the above top-level configs, you can use the `region_config`
122
+ method to specify region-specific overrides within your Vagrantfile. Note
123
+ that the top-level `region` config must always be specified to choose which
124
+ region you want to actually use, however. This looks like this:
125
+
126
+ ```ruby
127
+ Vagrant.configure("2") do |config|
128
+ # ... other stuff
129
+
130
+ config.vm.provider :cloudstack do |cloudstack|
131
+ cloudstack.api_key = "foo"
132
+ cloudstack.secret_key = "bar"
133
+ cloudstack.domain = "internal"
134
+
135
+ # Simple domain config
136
+ cloudstack.domain_config "internal", :network_id => "AAAAAAAAAAAAAAAAAAA"
137
+
138
+ # More comprehensive region config
139
+ cloudstack.domain_config "internal" do |domain|
140
+ domain.network_id = "AAAAAAAAAAAAAAAAAAA"
141
+ domain.service_offering_id = "AAAAAAAAAAAAAAAAAAA"
142
+ end
143
+ end
144
+ end
145
+ ```
146
+
147
+ The domain-specific configurations will override the top-level
148
+ configurations when that domain is used. They otherwise inherit
149
+ the top-level configurations, as you would probably expect.
150
+
151
+ ## Networks
152
+
153
+ Networking features in the form of `config.vm.network` are not
154
+ supported with `vagrant-cloudstack`, currently. If any of these are
155
+ specified, Vagrant will emit a warning, but will otherwise boot
156
+ the Cloudstack machine.
157
+
158
+ ## Synced Folders
159
+
160
+ There is minimal support for synced folders. Upon `vagrant up`,
161
+ `vagrant reload`, and `vagrant provision`, the Cloudstack provider will use
162
+ `rsync` (if available) to uni-directionally sync the folder to
163
+ the remote machine over SSH.
164
+
165
+ This is good enough for all built-in Vagrant provisioners (shell,
166
+ chef, and puppet) to work!
167
+
168
+ ## Development
169
+
170
+ To work on the `vagrant-cloudstack` plugin, clone this repository out, and use
171
+ [Bundler](http://gembundler.com) to get the dependencies:
172
+
173
+ ```
174
+ $ bundle
175
+ ```
176
+
177
+ Once you have the dependencies, verify the unit tests pass with `rake`:
178
+
179
+ ```
180
+ $ bundle exec rake
181
+ ```
182
+
183
+ If those pass, you're ready to start developing the plugin. You can test
184
+ the plugin without installing it into your Vagrant environment by just
185
+ creating a `Vagrantfile` in the top level of this directory (it is gitignored)
186
+ and add the following line to your `Vagrantfile`
187
+ ```ruby
188
+ Vagrant.require_plugin "vagrant-cloudstack"
189
+ ```
190
+ Use bundler to execute Vagrant:
191
+
192
+ ```
193
+ $ bundle exec vagrant up --provider=cloudstack
194
+ ```
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'rspec/core/rake_task'
4
+
5
+ # Immediately sync all stdout so that tools like buildbot can
6
+ # immediately load in the output.
7
+ $stdout.sync = true
8
+ $stderr.sync = true
9
+
10
+ # Change to the directory of this file.
11
+ Dir.chdir(File.expand_path("../", __FILE__))
12
+
13
+ # This installs the tasks that help with gem creation and
14
+ # publishing.
15
+ Bundler::GemHelper.install_tasks
16
+
17
+ # Install the `spec` task so that we can run tests.
18
+ RSpec::Core::RakeTask.new
19
+
20
+ # Default task is to run the unit tests
21
+ task :default => "spec"
data/dummy.box ADDED
Binary file
@@ -0,0 +1,13 @@
1
+ # Vagrant Cloudstack Example Box
2
+
3
+ Vagrant providers each require a custom provider-specific box format.
4
+ This folder shows the example contents of a box for the `aws` provider.
5
+ To turn this into a box:
6
+
7
+ ```
8
+ $ tar cvzf cloudstack.box ./metadata.json ./Vagrantfile
9
+ ```
10
+
11
+ This box works by using Vagrant's built-in Vagrantfile merging to setup
12
+ defaults for Cloudstack. These defaults can easily be overwritten by higher-level
13
+ Vagrantfiles (such as project root Vagrantfiles).
@@ -0,0 +1,3 @@
1
+ {
2
+ "provider": "cloudstack"
3
+ }
@@ -0,0 +1,18 @@
1
+ require "pathname"
2
+
3
+ require "vagrant-cloudstack/plugin"
4
+
5
+ module VagrantPlugins
6
+ module Cloudstack
7
+ lib_path = Pathname.new(File.expand_path("../vagrant-cloudstack", __FILE__))
8
+ autoload :Action, lib_path.join("action")
9
+ autoload :Errors, lib_path.join("errors")
10
+
11
+ # This returns the path to the source of this plugin.
12
+ #
13
+ # @return [Pathname]
14
+ def self.source_root
15
+ @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,121 @@
1
+ require "pathname"
2
+
3
+ require "vagrant/action/builder"
4
+
5
+ module VagrantPlugins
6
+ module Cloudstack
7
+ module Action
8
+ # Include the built-in modules so we can use them as top-level things.
9
+ include Vagrant::Action::Builtin
10
+
11
+ # This action is called to terminate the remote machine.
12
+ def self.action_destroy
13
+ Vagrant::Action::Builder.new.tap do |b|
14
+ b.use ConfigValidate
15
+ b.use ConnectCloudstack
16
+ b.use TerminateInstance
17
+ end
18
+ end
19
+
20
+ # This action is called when `vagrant provision` is called.
21
+ def self.action_provision
22
+ Vagrant::Action::Builder.new.tap do |b|
23
+ b.use ConfigValidate
24
+ b.use Call, IsCreated do |env, b2|
25
+ if !env[:result]
26
+ b2.use MessageNotCreated
27
+ next
28
+ end
29
+
30
+ b2.use Provision
31
+ b2.use SyncFolders
32
+ end
33
+ end
34
+ end
35
+
36
+ # This action is called to read the SSH info of the machine. The
37
+ # resulting state is expected to be put into the `:machine_ssh_info`
38
+ # key.
39
+ def self.action_read_ssh_info
40
+ Vagrant::Action::Builder.new.tap do |b|
41
+ b.use ConfigValidate
42
+ b.use ConnectCloudstack
43
+ b.use ReadSSHInfo
44
+ end
45
+ end
46
+
47
+ # This action is called to read the state of the machine. The
48
+ # resulting state is expected to be put into the `:machine_state_id`
49
+ # key.
50
+ def self.action_read_state
51
+ Vagrant::Action::Builder.new.tap do |b|
52
+ b.use ConfigValidate
53
+ b.use ConnectCloudstack
54
+ b.use ReadState
55
+ end
56
+ end
57
+
58
+ # This action is called to SSH into the machine.
59
+ def self.action_ssh
60
+ Vagrant::Action::Builder.new.tap do |b|
61
+ b.use ConfigValidate
62
+ b.use Call, IsCreated do |env, b2|
63
+ if !env[:result]
64
+ b2.use MessageNotCreated
65
+ next
66
+ end
67
+
68
+ b2.use SSHExec
69
+ end
70
+ end
71
+ end
72
+
73
+ def self.action_ssh_run
74
+ Vagrant::Action::Builder.new.tap do |b|
75
+ b.use ConfigValidate
76
+ b.use Call, IsCreated do |env, b2|
77
+ if !env[:result]
78
+ b2.use MessageNotCreated
79
+ next
80
+ end
81
+
82
+ b2.use SSHRun
83
+ end
84
+ end
85
+ end
86
+
87
+ # This action is called to bring the box up from nothing.
88
+ def self.action_up
89
+ Vagrant::Action::Builder.new.tap do |b|
90
+ b.use ConfigValidate
91
+ b.use ConnectCloudstack
92
+ b.use Call, IsCreated do |env, b2|
93
+ if env[:result]
94
+ b2.use MessageAlreadyCreated
95
+ next
96
+ end
97
+
98
+ b2.use TimedProvision
99
+ b2.use SyncFolders
100
+ b2.use WarnNetworks
101
+ b2.use RunInstance
102
+ end
103
+ end
104
+ end
105
+
106
+ # The autoload farm
107
+ action_root = Pathname.new(File.expand_path("../action", __FILE__))
108
+ autoload :ConnectCloudstack, action_root.join("connect_cloudstack")
109
+ autoload :IsCreated, action_root.join("is_created")
110
+ autoload :MessageAlreadyCreated, action_root.join("message_already_created")
111
+ autoload :MessageNotCreated, action_root.join("message_not_created")
112
+ autoload :ReadSSHInfo, action_root.join("read_ssh_info")
113
+ autoload :ReadState, action_root.join("read_state")
114
+ autoload :RunInstance, action_root.join("run_instance")
115
+ autoload :SyncFolders, action_root.join("sync_folders")
116
+ autoload :TimedProvision, action_root.join("timed_provision")
117
+ autoload :WarnNetworks, action_root.join("warn_networks")
118
+ autoload :TerminateInstance, action_root.join("terminate_instance")
119
+ end
120
+ end
121
+ end