vagrant-vsphere 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/.gitignore +8 -6
  2. data/Gemfile +10 -10
  3. data/LICENSE.txt +23 -23
  4. data/README.md +180 -175
  5. data/Rakefile +16 -16
  6. data/example_box/metadata.json +2 -2
  7. data/lib/vSphere/action.rb +172 -172
  8. data/lib/vSphere/action/clone.rb +131 -127
  9. data/lib/vSphere/action/close_vsphere.rb +23 -23
  10. data/lib/vSphere/action/connect_vsphere.rb +25 -25
  11. data/lib/vSphere/action/destroy.rb +37 -37
  12. data/lib/vSphere/action/get_ssh_info.rb +37 -37
  13. data/lib/vSphere/action/get_state.rb +45 -45
  14. data/lib/vSphere/action/is_created.rb +15 -15
  15. data/lib/vSphere/action/is_running.rb +20 -20
  16. data/lib/vSphere/action/message_already_created.rb +17 -17
  17. data/lib/vSphere/action/message_not_created.rb +17 -17
  18. data/lib/vSphere/action/message_not_running.rb +18 -18
  19. data/lib/vSphere/action/power_off.rb +27 -27
  20. data/lib/vSphere/action/power_on.rb +31 -31
  21. data/lib/vSphere/action/sync_folders.rb +94 -97
  22. data/lib/vSphere/config.rb +37 -37
  23. data/lib/vSphere/errors.rb +14 -11
  24. data/lib/vSphere/plugin.rb +29 -29
  25. data/lib/vSphere/provider.rb +38 -38
  26. data/lib/vSphere/util/machine_helpers.rb +15 -15
  27. data/lib/vSphere/util/vim_helpers.rb +37 -37
  28. data/lib/vSphere/version.rb +5 -5
  29. data/lib/vagrant-vsphere.rb +17 -17
  30. data/locales/en.yml +66 -65
  31. data/spec/action_spec.rb +116 -116
  32. data/spec/clone_spec.rb +31 -31
  33. data/spec/connect_vsphere_spec.rb +23 -23
  34. data/spec/destroy_spec.rb +30 -30
  35. data/spec/get_ssh_info_spec.rb +30 -30
  36. data/spec/get_state_spec.rb +54 -54
  37. data/spec/is_created_spec.rb +28 -28
  38. data/spec/spec_helper.rb +98 -98
  39. data/vSphere.gemspec +29 -28
  40. metadata +14 -8
data/.gitignore CHANGED
@@ -1,6 +1,8 @@
1
- *~
2
- .vagrant/*
3
- Vagrantfile
4
- pkg/*
5
- *.box
6
- Gemfile.lock
1
+ *~
2
+ .vagrant/*
3
+ Vagrantfile
4
+ pkg/*
5
+ *.box
6
+ Gemfile.lock
7
+ .bundle/*
8
+ vendor/*
data/Gemfile CHANGED
@@ -1,10 +1,10 @@
1
- source 'http://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
1
+ source 'http://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.4.3'
10
+ end
data/LICENSE.txt CHANGED
@@ -1,24 +1,24 @@
1
- Copyright (c) 2013 Regents of the University of Colorado
2
-
3
- This software was developed by the National Snow and Ice Data Center with funding from multiple sources.
4
-
5
- MIT License
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining
8
- a copy of this software and associated documentation files (the
9
- "Software"), to deal in the Software without restriction, including
10
- without limitation the rights to use, copy, modify, merge, publish,
11
- distribute, sublicense, and/or sell copies of the Software, and to
12
- permit persons to whom the Software is furnished to do so, subject to
13
- the following conditions:
14
-
15
- The above copyright notice and this permission notice shall be
16
- included in all copies or substantial portions of the Software.
17
-
18
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1
+ Copyright (c) 2013 Regents of the University of Colorado
2
+
3
+ This software was developed by the National Snow and Ice Data Center with funding from multiple sources.
4
+
5
+ MIT License
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
24
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,175 +1,180 @@
1
- # Vagrant vSphere Provider
2
-
3
- This is a [Vagrant](http://www.vagrantup.com) 1.2+ plugin that adds a [vSphere](http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc_50%2Fright-pane.html)
4
- provider to Vagrant, allowing Vagrant to control and provision machines using VMware. New machines are created from virtual machines or templates which must be configured prior to using using this provider.
5
-
6
- This provider is built on top of the [RbVmomi](https://github.com/vmware/rbvmomi) Ruby interface to the vSphere API.
7
-
8
- ## Requirements
9
- * Vagrant 1.2+
10
- * VMware + vSphere API
11
- * Ruby 1.9+
12
- * libxml2, libxml2-dev, libxslt, libxslt-dev
13
-
14
- ## Current Version
15
- **0.6.0**
16
-
17
- vagrant-vsphere (0.6.0) is available from [RubyGems.org](https://rubygems.org/)
18
-
19
- ## Installation
20
-
21
- Install using standard Vagrant plugin method:
22
-
23
- ```
24
- $ vagrant plugin install vagrant-vsphere
25
- ```
26
-
27
- This will install the plugin from RubGems.org.
28
-
29
- Alternatively, you can clone this repository and build the source with `gem build vSphere.gemspec`.
30
- After the gem is built, run the plugin install command from the build directory.
31
-
32
- ### Potential Intallation Problems
33
-
34
- The requirements for [Nokogiri](http://nokogiri.org/) must be installed before the plugin can be installed. See Nokogiri's [tutorial](http://nokogiri.org/tutorials/installing_nokogiri.html) for
35
- detailed instructions.
36
-
37
- The plugin forces use of Nokogiri 1.5.10 to prevent conflicts with older versions of system libraries, specifically zlib.
38
-
39
- ## Usage
40
-
41
- After installing the plugin, you must create a vSphere box. The example_box directory contains a metadata.json file
42
- that can be used to create a dummy box with the command:
43
-
44
- ```
45
- $ tar cvzf dummy.box ./metadata.json
46
- ```
47
-
48
- This can be installed using the standard Vagrant methods or specified in the Vagrantfile.
49
-
50
- After creating the dummy box, make a Vagrantfile that looks like the following:
51
-
52
- ```ruby
53
- Vagrant.configure("2") do |config|
54
- config.vm.box = 'dummy'
55
- config.vm.box_url = './example_box/dummy.box'
56
-
57
- config.vm.provider :vsphere do |vsphere|
58
- vsphere.host = 'HOST NAME OF YOUR VSPHERE INSTANCE'
59
- vsphere.compute_resource_name = 'YOUR COMPUTE RESOURCE'
60
- vsphere.resource_pool_name = 'YOUR RESOURCE POOL'
61
- vsphere.template_name = 'YOUR VM TEMPLATE'
62
- vsphere.name = 'NEW VM NAME'
63
- vsphere.user = 'YOUR VMWARE USER'
64
- vsphere.password = 'YOUR VMWARE PASSWORD'
65
- end
66
- end
67
- ```
68
-
69
- And then run `vagrant up --provider=vsphere`.
70
-
71
- ### Custom Box
72
-
73
- The bulk of this configuration can be included as part of a custom box. See the [Vagrant documentation](http://docs.vagrantup.com/v2/boxes.html)
74
- and the Vagrant [AWS provider](https://github.com/mitchellh/vagrant-aws/tree/master/example_box) for more information and an example.
75
-
76
- ### Supported Commands
77
-
78
- Currently the only implemented actions are `up`, `halt`, `destroy`, and `ssh`.
79
-
80
- `up` supports provisioning of the new VM with the standard Vagrant provisioners.
81
-
82
-
83
- ## Configuration
84
-
85
- This provider has the following settings, all are required unless noted:
86
-
87
- * `host` - IP or name for the vSphere API
88
- * `insecure` - _Optional_ verify SSL certificate from the host
89
- * `user' - user name for connecting to vSphere
90
- * `password` - password for connecting to vSphere
91
- * `data_center_name` - _Optional_ datacenter containing the computed resource, the template and where the new VM will be created, if not specified the first datacenter found will be used
92
- * `compute_resource_name` - _Required if cloning from template_ the name of the host containing the resource pool for the new VM
93
- * `resource_pool_name` - _Required if cloning from template_ the resource pool for the new VM
94
- * `clone_from_vm` - _Optional_ use a virtual machine instead of a template as the source for the cloning operation
95
- * `template_name` - the VM or VM template to clone
96
- * `name` - _Optional_ name of the new VM, if missing the name will be auto generated
97
- * `customization_spec_name` - _Optional_ customization spec for the new VM
98
- * `data_store_name` - _Optional_ the datastore where the VM will be located
99
- * `linked_clone` - _Optional_ link the cloned VM to the parent to share virtual disks
100
-
101
- ### Cloning from a VM rather than a template
102
-
103
- To clone from an existing VM rather than a template, set `clone_from_vm` to true. If this value is set, `compute_resource_name` and `resource_pool_name` are not required.
104
-
105
- ### Setting a static IP address
106
-
107
- To set a static IP, add a private network to your vagrant file:
108
-
109
- ```ruby
110
- config.vm.network 'private_network', ip: '192.168.50.4'
111
- ```
112
-
113
- The IP address will only be set if a customization spec name is given. The customization spec must have network adapter settings configured. For each private network specified, there needs to be a corresponding network adapter in the customization spec. An error will be thrown if there are more networks than adapters.
114
-
115
- ### Auto name generation
116
-
117
- The name for the new VM will be automagically generated from the Vagrant machine name, the current timestamp and a random number to allow for simultaneous executions.
118
-
119
- This is useful if running Vagrant from multiple directories or if multiple machines are defined in the Vagrantfile.
120
-
121
- ## Version History
122
- * 0.0.1
123
- * Initial release
124
- * 0.1.0
125
- * Add folder syncing with guest OS
126
- * Add provisoning
127
- * 0.2.0
128
- * Merge halt action from [catharsis](https://github.com/catharsis)
129
- * 0.3.0
130
- * Lock Nokogiri version at 1.5.10 to prevent library conflicts
131
- * Add support for customization specs
132
- * 0.4.0
133
- * Add support for specifying datastore location for new VMs
134
- * 0.5.0
135
- * Allow setting static ip addresses using Vagrant private networks
136
- * Allow cloning from VM or template
137
- * 0.5.1
138
- * fix rsync on Windows, adapted from [mitchellh/vagrant-aws#77](https://github.com/mitchellh/vagrant-aws/pull/77)
139
- * 0.6.0
140
- * add support for the `vagrant ssh -c` command
141
- * 0.7.0
142
- * handle multiple private key paths
143
- * add auto name generation based on machine name
144
- * add support for linked clones
145
-
146
- ## Versioning
147
-
148
- This plugin follows the principles of [Semantic Versioning 2.0.0](http://semver.org/)
149
-
150
- ## Contributing
151
-
152
- 1. Fork it
153
- 2. Create your feature branch (`git checkout -b my-new-feature`)
154
- 3. Commit your changes (`git commit -am 'Add some feature'`)
155
- 4. Push to the branch (`git push origin my-new-feature`)
156
- 5. Create new Pull Request
157
-
158
- ### Unit Tests
159
-
160
- Please run the unit tests to verify your changes. To do this simply run `rake`.
161
-
162
-
163
- If you don't have rake installed, first install [bundler](http://bundler.io/) and run `bundle install`.
164
-
165
-
166
-
167
- ## License
168
-
169
- GI-Cat Driver is licensed under the MIT license. See [LICENSE.txt][license].
170
-
171
- [license]: https://raw.github.com/nsidc/vagrant-vsphere/master/LICENSE.txt
172
-
173
- ## Credit
174
-
175
- This software was developed by the National Snow and Ice Data Center with funding from multiple sources.
1
+ # Vagrant vSphere Provider
2
+
3
+ This is a [Vagrant](http://www.vagrantup.com) 1.2+ plugin that adds a [vSphere](http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc_50%2Fright-pane.html)
4
+ provider to Vagrant, allowing Vagrant to control and provision machines using VMware. New machines are created from virtual machines or templates which must be configured prior to using using this provider.
5
+
6
+ This provider is built on top of the [RbVmomi](https://github.com/vmware/rbvmomi) Ruby interface to the vSphere API.
7
+
8
+ ## Requirements
9
+ * Vagrant 1.2+
10
+ * VMware + vSphere API
11
+ * Ruby 1.9+
12
+ * libxml2, libxml2-dev, libxslt, libxslt-dev
13
+
14
+ ## Current Version
15
+ **0.7.1**
16
+
17
+ vagrant-vsphere (0.7.1) is available from [RubyGems.org](https://rubygems.org/)
18
+
19
+ ## Installation
20
+
21
+ Install using standard Vagrant plugin method:
22
+
23
+ ```
24
+ $ vagrant plugin install vagrant-vsphere
25
+ ```
26
+
27
+ This will install the plugin from RubyGems.org.
28
+
29
+ Alternatively, you can clone this repository and build the source with `gem build vSphere.gemspec`.
30
+ After the gem is built, run the plugin install command from the build directory.
31
+
32
+ ### Potential Intallation Problems
33
+
34
+ The requirements for [Nokogiri](http://nokogiri.org/) must be installed before the plugin can be installed. See Nokogiri's [tutorial](http://nokogiri.org/tutorials/installing_nokogiri.html) for
35
+ detailed instructions.
36
+
37
+ The plugin forces use of Nokogiri >= 1.5.10 to prevent conflicts with older versions of system libraries, specifically zlib.
38
+
39
+ ## Usage
40
+
41
+ After installing the plugin, you must create a vSphere box. The example_box directory contains a metadata.json file
42
+ that can be used to create a dummy box with the command:
43
+
44
+ ```
45
+ $ tar cvzf dummy.box ./metadata.json
46
+ ```
47
+
48
+ This can be installed using the standard Vagrant methods or specified in the Vagrantfile.
49
+
50
+ After creating the dummy box, make a Vagrantfile that looks like the following:
51
+
52
+ ```ruby
53
+ Vagrant.configure("2") do |config|
54
+ config.vm.box = 'dummy'
55
+ config.vm.box_url = './example_box/dummy.box'
56
+
57
+ config.vm.provider :vsphere do |vsphere|
58
+ vsphere.host = 'HOST NAME OF YOUR VSPHERE INSTANCE'
59
+ vsphere.compute_resource_name = 'YOUR COMPUTE RESOURCE'
60
+ vsphere.resource_pool_name = 'YOUR RESOURCE POOL'
61
+ vsphere.template_name = 'YOUR VM TEMPLATE'
62
+ vsphere.name = 'NEW VM NAME'
63
+ vsphere.user = 'YOUR VMWARE USER'
64
+ vsphere.password = 'YOUR VMWARE PASSWORD'
65
+ end
66
+ end
67
+ ```
68
+
69
+ And then run `vagrant up --provider=vsphere`.
70
+
71
+ ### Custom Box
72
+
73
+ The bulk of this configuration can be included as part of a custom box. See the [Vagrant documentation](http://docs.vagrantup.com/v2/boxes.html)
74
+ and the Vagrant [AWS provider](https://github.com/mitchellh/vagrant-aws/tree/master/example_box) for more information and an example.
75
+
76
+ ### Supported Commands
77
+
78
+ Currently the only implemented actions are `up`, `halt`, `destroy`, and `ssh`.
79
+
80
+ `up` supports provisioning of the new VM with the standard Vagrant provisioners.
81
+
82
+
83
+ ## Configuration
84
+
85
+ This provider has the following settings, all are required unless noted:
86
+
87
+ * `host` - IP or name for the vSphere API
88
+ * `insecure` - _Optional_ verify SSL certificate from the host
89
+ * `user' - user name for connecting to vSphere
90
+ * `password` - password for connecting to vSphere
91
+ * `data_center_name` - _Optional_ datacenter containing the computed resource, the template and where the new VM will be created, if not specified the first datacenter found will be used
92
+ * `compute_resource_name` - _Required if cloning from template_ the name of the host containing the resource pool for the new VM
93
+ * `resource_pool_name` - _Required if cloning from template_ the resource pool for the new VM
94
+ * `clone_from_vm` - _Optional_ use a virtual machine instead of a template as the source for the cloning operation
95
+ * `template_name` - the VM or VM template to clone
96
+ * `name` - _Optional_ name of the new VM, if missing the name will be auto generated
97
+ * `customization_spec_name` - _Optional_ customization spec for the new VM
98
+ * `data_store_name` - _Optional_ the datastore where the VM will be located
99
+ * `linked_clone` - _Optional_ link the cloned VM to the parent to share virtual disks
100
+
101
+ ### Cloning from a VM rather than a template
102
+
103
+ To clone from an existing VM rather than a template, set `clone_from_vm` to true. If this value is set, `compute_resource_name` and `resource_pool_name` are not required.
104
+
105
+ ### Setting a static IP address
106
+
107
+ To set a static IP, add a private network to your vagrant file:
108
+
109
+ ```ruby
110
+ config.vm.network 'private_network', ip: '192.168.50.4'
111
+ ```
112
+
113
+ The IP address will only be set if a customization spec name is given. The customization spec must have network adapter settings configured. For each private network specified, there needs to be a corresponding network adapter in the customization spec. An error will be thrown if there are more networks than adapters.
114
+
115
+ ### Auto name generation
116
+
117
+ The name for the new VM will be automagically generated from the Vagrant machine name, the current timestamp and a random number to allow for simultaneous executions.
118
+
119
+ This is useful if running Vagrant from multiple directories or if multiple machines are defined in the Vagrantfile.
120
+
121
+ ## Version History
122
+ * 0.0.1
123
+ * Initial release
124
+ * 0.1.0
125
+ * Add folder syncing with guest OS
126
+ * Add provisoning
127
+ * 0.2.0
128
+ * Merge halt action from [catharsis](https://github.com/catharsis)
129
+ * 0.3.0
130
+ * Lock Nokogiri version at 1.5.10 to prevent library conflicts
131
+ * Add support for customization specs
132
+ * 0.4.0
133
+ * Add support for specifying datastore location for new VMs
134
+ * 0.5.0
135
+ * Allow setting static ip addresses using Vagrant private networks
136
+ * Allow cloning from VM or template
137
+ * 0.5.1
138
+ * fix rsync on Windows, adapted from [mitchellh/vagrant-aws#77](https://github.com/mitchellh/vagrant-aws/pull/77)
139
+ * 0.6.0
140
+ * add support for the `vagrant ssh -c` command
141
+ * 0.7.0
142
+ * handle multiple private key paths
143
+ * add auto name generation based on machine name
144
+ * add support for linked clones
145
+ * 0.7.1
146
+ * fixes rsync error reporting
147
+ * updates locales yaml
148
+ * restricts rbvmomi dependency
149
+
150
+
151
+ ## Versioning
152
+
153
+ This plugin follows the principles of [Semantic Versioning 2.0.0](http://semver.org/)
154
+
155
+ ## Contributing
156
+
157
+ 1. Fork it
158
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
159
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
160
+ 4. Push to the branch (`git push origin my-new-feature`)
161
+ 5. Create new Pull Request
162
+
163
+ ### Unit Tests
164
+
165
+ Please run the unit tests to verify your changes. To do this simply run `rake`.
166
+
167
+
168
+ If you don't have rake installed, first install [bundler](http://bundler.io/) and run `bundle install`.
169
+
170
+
171
+
172
+ ## License
173
+
174
+ The Vagrant vSphere Provider is licensed under the MIT license. See [LICENSE.txt][license].
175
+
176
+ [license]: https://raw.github.com/nsidc/vagrant-vsphere/master/LICENSE.txt
177
+
178
+ ## Credit
179
+
180
+ This software was developed by the National Snow and Ice Data Center with funding from multiple sources.
data/Rakefile CHANGED
@@ -1,17 +1,17 @@
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
- Bundler::GemHelper.install_tasks
14
-
15
- RSpec::Core::RakeTask.new
16
-
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
+ Bundler::GemHelper.install_tasks
14
+
15
+ RSpec::Core::RakeTask.new
16
+
17
17
  task :default => 'spec'