vagrant-vcenter 0.0.2.pre.dev

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/.rubocop.yml +34 -0
  4. data/Gemfile +7 -0
  5. data/LICENSE +20 -0
  6. data/README.md +5 -0
  7. data/Rakefile +17 -0
  8. data/example_box/README.md +13 -0
  9. data/example_box/Vagrantfile +6 -0
  10. data/example_box/metadata.json +1 -0
  11. data/lib/vagrant-vcenter.rb +18 -0
  12. data/lib/vagrant-vcenter/action.rb +232 -0
  13. data/lib/vagrant-vcenter/action/announce_ssh_exec.rb +19 -0
  14. data/lib/vagrant-vcenter/action/build_vm.rb +130 -0
  15. data/lib/vagrant-vcenter/action/connect_vcenter.rb +37 -0
  16. data/lib/vagrant-vcenter/action/destroy.rb +29 -0
  17. data/lib/vagrant-vcenter/action/disconnect_vcenter.rb +29 -0
  18. data/lib/vagrant-vcenter/action/inventory_check.rb +132 -0
  19. data/lib/vagrant-vcenter/action/is_created.rb +26 -0
  20. data/lib/vagrant-vcenter/action/is_paused.rb +23 -0
  21. data/lib/vagrant-vcenter/action/is_running.rb +23 -0
  22. data/lib/vagrant-vcenter/action/message_already_running.rb +17 -0
  23. data/lib/vagrant-vcenter/action/message_cannot_suspend.rb +19 -0
  24. data/lib/vagrant-vcenter/action/message_not_created.rb +17 -0
  25. data/lib/vagrant-vcenter/action/message_will_not_destroy.rb +18 -0
  26. data/lib/vagrant-vcenter/action/power_off.rb +30 -0
  27. data/lib/vagrant-vcenter/action/power_on.rb +30 -0
  28. data/lib/vagrant-vcenter/action/read_ssh_info.rb +37 -0
  29. data/lib/vagrant-vcenter/action/read_state.rb +52 -0
  30. data/lib/vagrant-vcenter/action/resume.rb +30 -0
  31. data/lib/vagrant-vcenter/action/suspend.rb +30 -0
  32. data/lib/vagrant-vcenter/action/sync_folders.rb +135 -0
  33. data/lib/vagrant-vcenter/config.rb +92 -0
  34. data/lib/vagrant-vcenter/errors.rb +88 -0
  35. data/lib/vagrant-vcenter/plugin.rb +67 -0
  36. data/lib/vagrant-vcenter/provider.rb +46 -0
  37. data/lib/vagrant-vcenter/version.rb +6 -0
  38. data/locales/en.yml +50 -0
  39. data/vagrant-vcenter.gemspec +29 -0
  40. metadata +194 -0
@@ -0,0 +1,67 @@
1
+ begin
2
+ require 'vagrant'
3
+ rescue LoadError
4
+ raise 'The Vagrant vCenter plugin must be run within Vagrant.'
5
+ end
6
+
7
+ if Vagrant::VERSION < '1.5.0'
8
+ fail 'The Vagrant vCenter plugin is only compatible with Vagrant 1.5+'
9
+ end
10
+
11
+ module VagrantPlugins
12
+ module VCenter
13
+ # Initialize Vagrant Plugin
14
+ class Plugin < Vagrant.plugin('2')
15
+ name 'vCenter'
16
+ description 'Allows Vagrant to manage machines with VMware vCenter (R)'
17
+
18
+ config(:vcenter, :provider) do
19
+ require_relative 'config'
20
+ Config
21
+ end
22
+
23
+ provider(:vcenter) do
24
+ setup_logging
25
+ setup_i18n
26
+
27
+ # Return the provider
28
+ require_relative 'provider'
29
+ Provider
30
+ end
31
+
32
+ def self.setup_i18n
33
+ I18n.load_path << File.expand_path('locales/en.yml',
34
+ VCenter.source_root)
35
+ I18n.reload!
36
+ end
37
+
38
+ # This sets up our log level to be whatever VAGRANT_LOG is.
39
+ def self.setup_logging
40
+ require 'log4r'
41
+
42
+ level = nil
43
+ begin
44
+ level = Log4r.const_get(ENV['VAGRANT_LOG'].upcase)
45
+ rescue NameError
46
+ # This means that the logging constant wasn't found,
47
+ # which is fine. We just keep `level` as `nil`. But
48
+ # we tell the user.
49
+ level = nil
50
+ end
51
+
52
+ # Some constants, such as 'true' resolve to booleans, so the
53
+ # above error checking doesn't catch it. This will check to make
54
+ # sure that the log level is an integer, as Log4r requires.
55
+ level = nil unless level.is_a?(Integer)
56
+
57
+ # Set the logging level on all 'vagrant' namespaced
58
+ # logs as long as we have a valid level.
59
+ if level
60
+ logger = Log4r::Logger.new('vagrant_vcenter')
61
+ logger.outputters = Log4r::Outputter.stderr
62
+ logger.level = level
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,46 @@
1
+ require 'log4r'
2
+ require 'vagrant'
3
+
4
+ module VagrantPlugins
5
+ module VCenter
6
+ # Initialize Vagrant Provider.
7
+ class Provider < Vagrant.plugin('2', :provider)
8
+ def initialize(machine)
9
+ @machine = machine
10
+ end
11
+
12
+ def action(name)
13
+ action_method = "action_#{name}"
14
+ return Action.send(action_method) if Action.respond_to?(action_method)
15
+ nil
16
+ end
17
+
18
+ # Read and return SSH info
19
+ def ssh_info
20
+ env = @machine.action('read_ssh_info')
21
+ env[:machine_ssh_info]
22
+ end
23
+
24
+ # Read state and return the current MachineState object
25
+ #
26
+ # @return [Vagrant::MachineState]
27
+ def state
28
+ env = @machine.action('read_state')
29
+
30
+ state_id = env[:machine_state_id]
31
+
32
+ # Translate into short/long descriptions
33
+ short = state_id.to_s.gsub('_', ' ')
34
+ long = I18n.t("vagrant_vcenter.states.#{state_id}")
35
+
36
+ # Return the MachineState object
37
+ Vagrant::MachineState.new(state_id, short, long)
38
+ end
39
+
40
+ def to_s
41
+ id = @machine.id.nil? ? 'new' : @machine.id
42
+ "vCenter (#{id})"
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,6 @@
1
+ module VagrantPlugins
2
+ # Set version for vagrant-vcenter gem.
3
+ module VCenter
4
+ VERSION = '0.0.2-dev'
5
+ end
6
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,50 @@
1
+ en:
2
+ vagrant_vcenter:
3
+ power:
4
+ vm_not_created: |-
5
+ The VM has not been created
6
+ will_not_destroy: |-
7
+ VM will not be destroyed
8
+ vm_already_running: |-
9
+ VM is already running
10
+ vm_halted_cannot_suspend: |-
11
+ VM is not running or already suspended, cannot suspend it.
12
+ sync:
13
+ rsync_not_found_warning: |-
14
+ Warning! Folder sync disabled because the rsync binary is missing.
15
+ Make sure rsync is installed and the binary can be found in the PATH.
16
+ rsync_folder: |-
17
+ Rsyncing folder: %{hostpath} => %{guestpath}
18
+ config:
19
+ hostname: |-
20
+ Configuration must specify a vCenter hostname
21
+ username: |-
22
+ Configuration must specify a vCenter username
23
+ password: |-
24
+ Configuration must specify a vCenter password
25
+ datastore_name: |-
26
+ Configuration must specify a Datastore (for the VM templates images)
27
+ datacenter_name: |-
28
+ Configuration must specify a vCenter Datacenter
29
+ computer_name: |-
30
+ Configuration must specify a compute resource name
31
+ network_name: |-
32
+ Configuration must specify a resource pool name
33
+ resourcepool_name: |-
34
+ Configuration must specify a resource pool name
35
+ states:
36
+ not_created: |-
37
+ The environment has not yet been created. Run `vagrant up` to
38
+ create the environment. If a machine is not created, only the
39
+ default provider will be shown. So if a provider is not listed,
40
+ then the machine is not created for that environment.
41
+ suspended: |-
42
+ The VM is paused. To resume the VM, simply run `vagrant up`
43
+ or `vagrant resume`
44
+ stopped: |-
45
+ The VM is powered off. To restart the VM, simply run `vagrant up`
46
+ running: |-
47
+ The VM is running. To stop this VM, you can run `vagrant halt` to
48
+ shut it down forcefully, or you can run `vagrant suspend` to simply
49
+ suspend the virtual machine. In either case, to restart it again,
50
+ simply run `vagrant up`.
@@ -0,0 +1,29 @@
1
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
2
+ require 'vagrant-vcenter/version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'vagrant-vcenter'
6
+ s.version = VagrantPlugins::VCenter::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = 'Fabio Rapposelli'
9
+ s.email = 'fabio@gosddc.com'
10
+ s.homepage = 'https://github.com/gosddc/vagrant-vcenter'
11
+ s.license = 'MIT'
12
+ s.summary = 'VMware vCenter® Vagrant provider'
13
+ s.description = 'Enables Vagrant to manage machines with VMware vCenter®.'
14
+
15
+ s.add_runtime_dependency 'vagrant-rbvmomi', '~> 1.8.1'
16
+ s.add_runtime_dependency 'log4r', '~> 1.1.10'
17
+ s.add_runtime_dependency 'nokogiri', '1.5.5'
18
+ s.add_runtime_dependency 'pry'
19
+
20
+ s.add_development_dependency 'rake'
21
+ s.add_development_dependency 'rspec-core', '~> 2.12.2'
22
+ s.add_development_dependency 'rspec-expectations', '~> 2.12.1'
23
+ s.add_development_dependency 'rspec-mocks', '~> 2.12.1'
24
+
25
+ s.files = `git ls-files`.split($RS)
26
+ s.executables = s.files.grep(/^bin/) { |f| File.basename(f) }
27
+ s.test_files = s.files.grep(/^(test|spec|features)/)
28
+ s.require_path = 'lib'
29
+ end
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-vcenter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2.pre.dev
5
+ platform: ruby
6
+ authors:
7
+ - Fabio Rapposelli
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: vagrant-rbvmomi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 1.8.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 1.8.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: log4r
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.10
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.1.10
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.5.5
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.5.5
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec-core
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 2.12.2
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 2.12.2
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-expectations
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 2.12.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 2.12.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-mocks
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 2.12.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: 2.12.1
125
+ description: Enables Vagrant to manage machines with VMware vCenter®.
126
+ email: fabio@gosddc.com
127
+ executables: []
128
+ extensions: []
129
+ extra_rdoc_files: []
130
+ files:
131
+ - .gitignore
132
+ - .rubocop.yml
133
+ - Gemfile
134
+ - LICENSE
135
+ - README.md
136
+ - Rakefile
137
+ - example_box/README.md
138
+ - example_box/Vagrantfile
139
+ - example_box/metadata.json
140
+ - lib/vagrant-vcenter.rb
141
+ - lib/vagrant-vcenter/action.rb
142
+ - lib/vagrant-vcenter/action/announce_ssh_exec.rb
143
+ - lib/vagrant-vcenter/action/build_vm.rb
144
+ - lib/vagrant-vcenter/action/connect_vcenter.rb
145
+ - lib/vagrant-vcenter/action/destroy.rb
146
+ - lib/vagrant-vcenter/action/disconnect_vcenter.rb
147
+ - lib/vagrant-vcenter/action/inventory_check.rb
148
+ - lib/vagrant-vcenter/action/is_created.rb
149
+ - lib/vagrant-vcenter/action/is_paused.rb
150
+ - lib/vagrant-vcenter/action/is_running.rb
151
+ - lib/vagrant-vcenter/action/message_already_running.rb
152
+ - lib/vagrant-vcenter/action/message_cannot_suspend.rb
153
+ - lib/vagrant-vcenter/action/message_not_created.rb
154
+ - lib/vagrant-vcenter/action/message_will_not_destroy.rb
155
+ - lib/vagrant-vcenter/action/power_off.rb
156
+ - lib/vagrant-vcenter/action/power_on.rb
157
+ - lib/vagrant-vcenter/action/read_ssh_info.rb
158
+ - lib/vagrant-vcenter/action/read_state.rb
159
+ - lib/vagrant-vcenter/action/resume.rb
160
+ - lib/vagrant-vcenter/action/suspend.rb
161
+ - lib/vagrant-vcenter/action/sync_folders.rb
162
+ - lib/vagrant-vcenter/config.rb
163
+ - lib/vagrant-vcenter/errors.rb
164
+ - lib/vagrant-vcenter/plugin.rb
165
+ - lib/vagrant-vcenter/provider.rb
166
+ - lib/vagrant-vcenter/version.rb
167
+ - locales/en.yml
168
+ - vagrant-vcenter.gemspec
169
+ homepage: https://github.com/gosddc/vagrant-vcenter
170
+ licenses:
171
+ - MIT
172
+ metadata: {}
173
+ post_install_message:
174
+ rdoc_options: []
175
+ require_paths:
176
+ - lib
177
+ required_ruby_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ required_rubygems_version: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - '>'
185
+ - !ruby/object:Gem::Version
186
+ version: 1.3.1
187
+ requirements: []
188
+ rubyforge_project:
189
+ rubygems_version: 2.1.8
190
+ signing_key:
191
+ specification_version: 4
192
+ summary: VMware vCenter® Vagrant provider
193
+ test_files: []
194
+ has_rdoc: