vagrant-xenserver 0.0.0

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: 3e71a5e7cadb1956653b86df342189d60b6da468
4
+ data.tar.gz: 6f2128e6f3fdea3108dadc8c8f40cb4d0bd3f694
5
+ SHA512:
6
+ metadata.gz: 7c7df81ce4a9603ccc52c8e43913a38a297e8b3993e80ff593f5af43b506439decb9c1a46d8ab12fb26f4f9fd0a892c4af2596abb2ee21168a18d1f99be83f91
7
+ data.tar.gz: a982ff961439ce2c9043fac119fb07288ca348122fec58770df9ace0f6cd4ef49d2de1e24ddac59abac02721cc50ee73314dfa973d770959134248028794b51e
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ # 0.1.0 (Unreleased)
2
+
3
+ * Initial release.
data/Gemfile ADDED
@@ -0,0 +1,14 @@
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
11
+
12
+ group :plugins do
13
+ gem "vagrant-xenserver", :path => "."
14
+ end
data/LICENSE ADDED
@@ -0,0 +1,8 @@
1
+ The MIT License (MIT)
2
+ Copyright (c) 2014 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,251 @@
1
+ # Vagrant AWS Provider
2
+
3
+ <span class="badges">
4
+ [![Gem Version](https://badge.fury.io/rb/vagrant-aws.png)][gem]
5
+ [![Dependency Status](https://gemnasium.com/mitchellh/vagrant-aws.png)][gemnasium]
6
+ </span>
7
+
8
+ [gem]: https://rubygems.org/gems/vagrant-aws
9
+ [gemnasium]: https://gemnasium.com/mitchellh/vagrant-aws
10
+
11
+ This is a [Vagrant](http://www.vagrantup.com) 1.2+ plugin that adds an [AWS](http://aws.amazon.com)
12
+ provider to Vagrant, allowing Vagrant to control and provision machines in
13
+ EC2 and VPC.
14
+
15
+ **NOTE:** This plugin requires Vagrant 1.2+,
16
+
17
+ ## Features
18
+
19
+ * Boot EC2 or VPC instances.
20
+ * SSH into the instances.
21
+ * Provision the instances with any built-in Vagrant provisioner.
22
+ * Minimal synced folder support via `rsync`.
23
+ * Define region-specifc configurations so Vagrant can manage machines
24
+ in multiple regions.
25
+
26
+ ## Usage
27
+
28
+ Install using standard Vagrant 1.1+ plugin installation methods. After
29
+ installing, `vagrant up` and specify the `aws` provider. An example is
30
+ shown below.
31
+
32
+ ```
33
+ $ vagrant plugin install vagrant-aws
34
+ ...
35
+ $ vagrant up --provider=aws
36
+ ...
37
+ ```
38
+
39
+ Of course prior to doing this, you'll need to obtain an AWS-compatible
40
+ box file for Vagrant.
41
+
42
+ ## Quick Start
43
+
44
+ After installing the plugin (instructions above), the quickest way to get
45
+ started is to actually use a dummy AWS box and specify all the details
46
+ manually within a `config.vm.provider` block. So first, add the dummy
47
+ box using any name you want:
48
+
49
+ ```
50
+ $ vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
51
+ ...
52
+ ```
53
+
54
+ And then make a Vagrantfile that looks like the following, filling in
55
+ your information where necessary.
56
+
57
+ ```
58
+ Vagrant.configure("2") do |config|
59
+ config.vm.box = "dummy"
60
+
61
+ config.vm.provider :aws do |aws, override|
62
+ aws.access_key_id = "YOUR KEY"
63
+ aws.secret_access_key = "YOUR SECRET KEY"
64
+ aws.keypair_name = "KEYPAIR NAME"
65
+
66
+ aws.ami = "ami-7747d01e"
67
+
68
+ override.ssh.username = "ubuntu"
69
+ override.ssh.private_key_path = "PATH TO YOUR PRIVATE KEY"
70
+ end
71
+ end
72
+ ```
73
+
74
+ And then run `vagrant up --provider=aws`.
75
+
76
+ This will start an Ubuntu 12.04 instance in the us-east-1 region within
77
+ your account. And assuming your SSH information was filled in properly
78
+ within your Vagrantfile, SSH and provisioning will work as well.
79
+
80
+ Note that normally a lot of this boilerplate is encoded within the box
81
+ file, but the box file used for the quick start, the "dummy" box, has
82
+ no preconfigured defaults.
83
+
84
+ If you have issues with SSH connecting, make sure that the instances
85
+ are being launched with a security group that allows SSH access.
86
+
87
+ ## Box Format
88
+
89
+ Every provider in Vagrant must introduce a custom box format. This
90
+ provider introduces `aws` boxes. You can view an example box in
91
+ the [example_box/ directory](https://github.com/mitchellh/vagrant-aws/tree/master/example_box).
92
+ That directory also contains instructions on how to build a box.
93
+
94
+ The box format is basically just the required `metadata.json` file
95
+ along with a `Vagrantfile` that does default settings for the
96
+ provider-specific configuration for this provider.
97
+
98
+ ## Configuration
99
+
100
+ This provider exposes quite a few provider-specific configuration options:
101
+
102
+ * `access_key_id` - The access key for accessing AWS
103
+ * `ami` - The AMI id to boot, such as "ami-12345678"
104
+ * `availability_zone` - The availability zone within the region to launch
105
+ the instance. If nil, it will use the default set by Amazon.
106
+ * `instance_ready_timeout` - The number of seconds to wait for the instance
107
+ to become "ready" in AWS. Defaults to 120 seconds.
108
+ * `instance_type` - The type of instance, such as "m1.small". The default
109
+ value of this if not specified is "m1.small".
110
+ * `keypair_name` - The name of the keypair to use to bootstrap AMIs
111
+ which support it.
112
+ * `private_ip_address` - The private IP address to assign to an instance
113
+ within a [VPC](http://aws.amazon.com/vpc/)
114
+ * `region` - The region to start the instance in, such as "us-east-1"
115
+ * `secret_access_key` - The secret access key for accessing AWS
116
+ * `security_groups` - An array of security groups for the instance. If this
117
+ instance will be launched in VPC, this must be a list of security group
118
+ IDs.
119
+ * `iam_instance_profile_arn` - The Amazon resource name (ARN) of the IAM Instance
120
+ Profile to associate with the instance
121
+ * `iam_instance_profile_name` - The name of the IAM Instance Profile to associate
122
+ with the instance
123
+ * `subnet_id` - The subnet to boot the instance into, for VPC.
124
+ * `associate_public_ip` - If true, will associate a public IP address to an instance in a VPC.
125
+ * `tags` - A hash of tags to set on the machine.
126
+ * `use_iam_profile` - If true, will use [IAM profiles](http://docs.aws.amazon.com/IAM/latest/UserGuide/instance-profiles.html)
127
+ for credentials.
128
+
129
+ These can be set like typical provider-specific configuration:
130
+
131
+ ```ruby
132
+ Vagrant.configure("2") do |config|
133
+ # ... other stuff
134
+
135
+ config.vm.provider :aws do |aws|
136
+ aws.access_key_id = "foo"
137
+ aws.secret_access_key = "bar"
138
+ end
139
+ end
140
+ ```
141
+
142
+ In addition to the above top-level configs, you can use the `region_config`
143
+ method to specify region-specific overrides within your Vagrantfile. Note
144
+ that the top-level `region` config must always be specified to choose which
145
+ region you want to actually use, however. This looks like this:
146
+
147
+ ```ruby
148
+ Vagrant.configure("2") do |config|
149
+ # ... other stuff
150
+
151
+ config.vm.provider :aws do |aws|
152
+ aws.access_key_id = "foo"
153
+ aws.secret_access_key = "bar"
154
+ aws.region = "us-east-1"
155
+
156
+ # Simple region config
157
+ aws.region_config "us-east-1", :ami => "ami-12345678"
158
+
159
+ # More comprehensive region config
160
+ aws.region_config "us-west-2" do |region|
161
+ region.ami = "ami-87654321"
162
+ region.keypair_name = "company-west"
163
+ end
164
+ end
165
+ end
166
+ ```
167
+
168
+ The region-specific configurations will override the top-level
169
+ configurations when that region is used. They otherwise inherit
170
+ the top-level configurations, as you would probably expect.
171
+
172
+ ## Networks
173
+
174
+ Networking features in the form of `config.vm.network` are not
175
+ supported with `vagrant-aws`, currently. If any of these are
176
+ specified, Vagrant will emit a warning, but will otherwise boot
177
+ the AWS machine.
178
+
179
+ ## Synced Folders
180
+
181
+ There is minimal support for synced folders. Upon `vagrant up`,
182
+ `vagrant reload`, and `vagrant provision`, the AWS provider will use
183
+ `rsync` (if available) to uni-directionally sync the folder to
184
+ the remote machine over SSH.
185
+
186
+ This is good enough for all built-in Vagrant provisioners (shell,
187
+ chef, and puppet) to work!
188
+
189
+ ## Other Examples
190
+
191
+ ### Tags
192
+
193
+ To use tags, simply define a hash of key/value for the tags you want to associate to your instance, like:
194
+
195
+ ```ruby
196
+ Vagrant.configure("2") do |config|
197
+ # ... other stuff
198
+
199
+ config.vm.provider "aws" do |aws|
200
+ aws.tags = {
201
+ 'Name' => 'Some Name',
202
+ 'Some Key' => 'Some Value'
203
+ }
204
+ end
205
+ end
206
+ ```
207
+
208
+ ### User data
209
+
210
+ You can specify user data for the instance being booted.
211
+
212
+ ```ruby
213
+ Vagrant.configure("2") do |config|
214
+ # ... other stuff
215
+
216
+ config.vm.provider "aws" do |aws|
217
+ # Option 1: a single string
218
+ aws.user_data = "#!/bin/bash\necho 'got user data' > /tmp/user_data.log\necho"
219
+
220
+ # Option 2: use a file
221
+ aws.user_data = File.read("user_data.txt")
222
+ end
223
+ end
224
+ ```
225
+
226
+ ## Development
227
+
228
+ To work on the `vagrant-aws` plugin, clone this repository out, and use
229
+ [Bundler](http://gembundler.com) to get the dependencies:
230
+
231
+ ```
232
+ $ bundle
233
+ ```
234
+
235
+ Once you have the dependencies, verify the unit tests pass with `rake`:
236
+
237
+ ```
238
+ $ bundle exec rake
239
+ ```
240
+
241
+ If those pass, you're ready to start developing the plugin. You can test
242
+ the plugin without installing it into your Vagrant environment by just
243
+ creating a `Vagrantfile` in the top level of this directory (it is gitignored)
244
+ and add the following line to your `Vagrantfile`
245
+ ```ruby
246
+ Vagrant.require_plugin "vagrant-aws"
247
+ ```
248
+ Use bundler to execute Vagrant:
249
+ ```
250
+ $ bundle exec vagrant up --provider=aws
251
+ ```
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ # Immediately sync all stdout so that tools like buildbot can
5
+ # immediately load in the output.
6
+ $stdout.sync = true
7
+ $stderr.sync = true
8
+
9
+ # Change to the directory of this file.
10
+ Dir.chdir(File.expand_path("../", __FILE__))
11
+
12
+ # This installs the tasks that help with gem creation and
13
+ # publishing.
14
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,3 @@
1
+ {
2
+ "provider": "xenserver"
3
+ }
@@ -0,0 +1,17 @@
1
+ require "pathname"
2
+
3
+ require "vagrant-xenserver/plugin"
4
+
5
+ module VagrantPlugins
6
+ module XenServer
7
+ lib_path = Pathname.new(File.expand_path("../vagrant-xenserver", __FILE__))
8
+ autoload :Action, lib_path.join("action")
9
+ autoload :Errors, lib_path.join("errors")
10
+ autoload :Util, lib_path.join("util")
11
+
12
+ def self.source_root
13
+ @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,130 @@
1
+ require 'vagrant/action/builder'
2
+ require 'log4r'
3
+
4
+ module VagrantPlugins
5
+ module XenServer
6
+ module Action
7
+ include Vagrant::Action::Builtin
8
+ @logger = Log4r::Logger.new('vagrant::xenserver::action')
9
+
10
+ def self.action_up
11
+ Vagrant::Action::Builder.new.tap do |b|
12
+ b.use HandleBox
13
+ b.use ConfigValidate
14
+ b.use ConnectXS
15
+ b.use Call, IsCreated do |env,b2|
16
+ # Create the VM
17
+ if !env[:result]
18
+ b2.use UploadVHD
19
+ b2.use CloneDisk
20
+ b2.use CreateVM
21
+ b2.use Provision
22
+ b2.use StartVM
23
+ b2.use WaitForCommunicator, ["Running"]
24
+
25
+ # b2.use ForwardPorts
26
+ # b2.use PrepareNFSSettings
27
+ # b2.use ShareFolders
28
+ # b2.use SetHostname
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ def self.action_destroy
35
+ Vagrant::Action::Builder.new.tap do |b|
36
+ b.use ConfigValidate
37
+ b.use Call, IsCreated do |env, b2|
38
+ if !env[:result]
39
+ @logger.info "MessageNotCreated"
40
+ next
41
+ end
42
+
43
+ b2.use ConnectXS
44
+ b2.use DestroyVM
45
+ end
46
+ end
47
+ end
48
+
49
+ def self.action_read_state
50
+ Vagrant::Action::Builder.new.tap do |b|
51
+ b.use ConfigValidate
52
+ b.use ConnectXS
53
+ b.use ReadState
54
+ end
55
+ end
56
+
57
+ def self.action_read_ssh_info
58
+ Vagrant::Action::Builder.new.tap do |b|
59
+ b.use ConfigValidate
60
+ b.use ConnectXS
61
+ b.use ReadSSHInfo
62
+ end
63
+ end
64
+
65
+ def self.action_ssh
66
+ Vagrant::Action::Builder.new.tap do |b|
67
+ @logger.info("XXXXX SSH")
68
+ b.use ConfigValidate
69
+ b.use Call, IsCreated do | env, b2|
70
+ if !env[:result]
71
+ # b2.use MessageNotCreated
72
+ @logger.info("MessageNotCreate")
73
+ next
74
+ end
75
+
76
+ b2.use ConnectXS
77
+ b2.use Call, IsRunning do |env2, b3|
78
+ if !env2[:result]
79
+ #b3.use MessageNotRunning
80
+ @logger.info("MessageNotCreate")
81
+ next
82
+ end
83
+
84
+ b3.use SSHExec
85
+ @logger.info("ssh run")
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ def self.action_provision
92
+ Vagrant::Action::Builder.new.tap do |b|
93
+ @logger.info("XXXXX provision")
94
+ b.use ConfigValidate
95
+ b.use Call, IsCreated do |env, b2|
96
+ if !env[:result]
97
+ @logger.info("MessageNotCreated")
98
+ next
99
+ end
100
+
101
+ b2.use ConnectXS
102
+ b2.use Call, IsRunning do |env2, b3|
103
+ if !env2[:result]
104
+ @logger.info("MessageNotRunning")
105
+ next
106
+ end
107
+
108
+ b3.use Provision
109
+ end
110
+ end
111
+ end
112
+ end
113
+
114
+ action_root = Pathname.new(File.expand_path('../action', __FILE__))
115
+ autoload :ConnectXS, action_root.join("connect_xs")
116
+ autoload :DummyMessage, action_root.join('dummy')
117
+ autoload :ReadState, action_root.join('read_state')
118
+ autoload :IsCreated, action_root.join('is_created')
119
+ autoload :IsRunning, action_root.join('is_running')
120
+ autoload :UploadXVA, action_root.join('upload_xva')
121
+ autoload :UploadVHD, action_root.join('upload_vhd')
122
+ autoload :CloneDisk, action_root.join('clone_disk')
123
+ autoload :CreateVM, action_root.join('create_vm')
124
+ autoload :DestroyVM, action_root.join('destroy_vm')
125
+ autoload :StartVM, action_root.join('start_vm')
126
+ autoload :ReadSSHInfo, action_root.join('read_ssh_info')
127
+ end
128
+ end
129
+ end
130
+