vagrant-vmm 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +18 -0
  3. data/.travis.yml +14 -0
  4. data/Gemfile +12 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +118 -0
  7. data/Rakefile +5 -0
  8. data/example/Berksfile +6 -0
  9. data/example/Vagrantfile +53 -0
  10. data/example/metadata.rb +5 -0
  11. data/lib/vagrant-vmm/action/delete_vm.rb +25 -0
  12. data/lib/vagrant-vmm/action/import.rb +35 -0
  13. data/lib/vagrant-vmm/action/message_will_not_destroy.rb +17 -0
  14. data/lib/vagrant-vmm/action/read_state.rb +39 -0
  15. data/lib/vagrant-vmm/action/resume_vm.rb +25 -0
  16. data/lib/vagrant-vmm/action/start_instance.rb +26 -0
  17. data/lib/vagrant-vmm/action/stop_instance.rb +26 -0
  18. data/lib/vagrant-vmm/action/suspend_vm.rb +25 -0
  19. data/lib/vagrant-vmm/action/wait_for_ip_address.rb +64 -0
  20. data/lib/vagrant-vmm/action.rb +225 -0
  21. data/lib/vagrant-vmm/cap/public_address.rb +15 -0
  22. data/lib/vagrant-vmm/config.rb +44 -0
  23. data/lib/vagrant-vmm/driver.rb +124 -0
  24. data/lib/vagrant-vmm/errors.rb +42 -0
  25. data/lib/vagrant-vmm/plugin.rb +46 -0
  26. data/lib/vagrant-vmm/provider.rb +103 -0
  27. data/lib/vagrant-vmm/scripts/delete_vm.ps1 +32 -0
  28. data/lib/vagrant-vmm/scripts/get_network_config.ps1 +84 -0
  29. data/lib/vagrant-vmm/scripts/get_vm_status.ps1 +40 -0
  30. data/lib/vagrant-vmm/scripts/import_vm.ps1 +107 -0
  31. data/lib/vagrant-vmm/scripts/resume_vm.ps1 +24 -0
  32. data/lib/vagrant-vmm/scripts/start_vm.ps1 +48 -0
  33. data/lib/vagrant-vmm/scripts/stop_vm.ps1 +24 -0
  34. data/lib/vagrant-vmm/scripts/suspend_vm.ps1 +27 -0
  35. data/lib/vagrant-vmm/scripts/sync_folders.ps1 +200 -0
  36. data/lib/vagrant-vmm/scripts/utils/manage_credentials.ps1 +26 -0
  37. data/lib/vagrant-vmm/scripts/utils/vmm_executor.ps1 +30 -0
  38. data/lib/vagrant-vmm/scripts/utils/write_messages.ps1 +20 -0
  39. data/lib/vagrant-vmm/synced_folder.rb +89 -0
  40. data/lib/vagrant-vmm/version.rb +5 -0
  41. data/lib/vagrant-vmm.rb +17 -0
  42. data/locales/en.yml +46 -0
  43. data/vagrant-vmm.gemspec +23 -0
  44. metadata +114 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MjgxMjMxY2I3ZTUxNGRiNjAxNTNmNGQ4MGMxYTIzZTdiZDgwZDY2OA==
5
+ data.tar.gz: !binary |-
6
+ NWYwOGJjNDA2YWFmYWM5ZTkwYzEzNzlmNDQyMDFjNThlNDJhYjcxZg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MGU2OWUzYmFmYjFkMDBkMjc4NGM0MmI1YmM0NWZhNDFhYmJhZDllNjgwNGU2
10
+ YTY1M2UwYzRiZjY5ODU0NzQ0OWQ5ZjFmMmEyOWZiYThiMzA1YzIyYzljN2M4
11
+ ZTVjMzkyOGIzYTdlM2E1Y2Y3NDIxMzU1ZTE1OTgwYzc3Y2U3ODk=
12
+ data.tar.gz: !binary |-
13
+ MTVkOWU2MmQwM2UwMzIyOWFmODY1YzFlZjFkZTU0Y2E0ZjU4ZjVmNGQ0NjIz
14
+ NTY5OWQyNGE3ZTFmZTNjNWNjMzJmZGM5ODZkZWQwYTEwYmYzZGMxM2RlY2Y3
15
+ NTM2MDUxZWYxNWE4MjZlZWM4NzM2OWRhYzJjMDFmMDVkNTNhOTI=
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ /.bundle/
2
+ /.vagrant/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
16
+ /Vagrantfile
17
+ /Berksfile
18
+ /metadata.rb
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ bundler_args: --without doc guard --jobs 7
5
+ script: bundle exec rake build
6
+
7
+ deploy:
8
+ provider: rubygems
9
+ api_key:
10
+ secure: GmhgrfFN24iE/PMenA1muqrZ3QeygA7GEQAjZaz3mLoBekDlZZxEKdZKKRlVO0Ep7evnh8hklhPRHt8QhTqAKBjaYIJXWJanbhcsPuzShEajDgo6qa+SB/YYPiVqqvS+XGYLwHgZcd9iCEqJsw/z72Kov1bf8L0qXtppIqN1Duc=
11
+ gem: vagrant-vmm
12
+ on:
13
+ repo: ivadim/vagrant-vmm
14
+ branch: travis_ci_support
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+
3
+ group :development do
4
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
5
+ gem "rake"
6
+ end
7
+
8
+ group :plugins do
9
+ gem "vagrant-vmm", path: "."
10
+ gem "vagrant-berkshelf"
11
+ gem "vagrant-omnibus"
12
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 jagorjat
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,118 @@
1
+ # Vagrant Virtual Machine Manager (VMM) Plugin
2
+
3
+ **UNDER DEVELOPMENT**
4
+
5
+ Vagrant is a tool for building and distributing development environments.
6
+
7
+ This provider will allow you to create VMs in the remote Virtual Machine Manager.
8
+
9
+ ## Installation
10
+
11
+ Install Vagrant 1.7.1
12
+ ```
13
+ http://www.vagrantup.com/downloads.html
14
+ ```
15
+
16
+ Install plugin:
17
+ ```
18
+ vagrant plugin install vagrant-vmm
19
+ ```
20
+
21
+ ## Prerequisites
22
+
23
+ 1. You should have template in your VMM which has following things setup:
24
+ - WinRM and firewall configured, using:
25
+ ```
26
+ winrm quickconfig
27
+ ```
28
+ - Local user vagrant/vagrant with admin rights.
29
+ Alternatively you can specify other creds using:
30
+ ```
31
+ win64_config.winrm.username = "account_name"
32
+ win64_config.winrm.password = "password"
33
+ ```
34
+ - Once VM created in VMM it should automatically get IP assigned, as well as it should be directly accessible from your machine.
35
+ 2. Run vagrant under Administrator(in admin shell).
36
+
37
+
38
+
39
+ ## Usage
40
+
41
+ Set guest to **:windows**
42
+ ```
43
+ win64_config.vm.guest = :windows
44
+ ```
45
+
46
+ Set communicator to **:winrm**
47
+ ```
48
+ win64_config.vm.communicator = "winrm"
49
+ ```
50
+
51
+ Set you provider to :vmm and specify at least *vmm_server_address*, *vm_host_group_name* and *vm_template_name* parameters.
52
+ ```
53
+ win64_config.vm.provider :vmm do |conf|
54
+ conf.vm_template_name = 'vagrant-template-w8.1-64'
55
+ conf.vm_host_group_name = 'Host-Group-Name'
56
+ conf.vmm_server_address = 'my-vmm-server'
57
+ conf.proxy_server_address = '192.126.18.126' # optional
58
+ end
59
+ ```
60
+
61
+ ## Provider settings
62
+
63
+ ### Template name (required)
64
+
65
+ VMM template name that will be used for VM creation.
66
+
67
+ ```
68
+ conf.vm_template_name = 'vagrant-template-w8.1-64'
69
+ ```
70
+
71
+ ### VM Host group (required)
72
+
73
+ VMM host group where VM will be placed.
74
+ NOTE: Your template should match it as well.
75
+
76
+ ```
77
+ conf.vm_host_group_name = 'Host-Group-Name'
78
+ ```
79
+
80
+ ### Virtual Machine Manager address (required)
81
+
82
+ IP/Hostname of the VMM server where VMs are going to be created.
83
+ ```
84
+ conf.vmm_server_address = '192.124.125.10'
85
+ ```
86
+
87
+ ### Proxy server address (optional)
88
+
89
+ If your local machine do not have direct access to the machine that hosts VMM, but you have proxy server(jump box) you can specify its IP in *proxy_server_address* property.
90
+
91
+ ```
92
+ conf.proxy_server_address = 'my-proxy-to-vmm'
93
+ ```
94
+
95
+ ## Troubleshooting
96
+
97
+ ### Hangs on waiting machine to boot
98
+
99
+ Check that winrm is configured properly in the VM, if default username is used (vagrant/vagrant) then ensure that winrm accepts unencrypted connection and Basic auth.
100
+
101
+ Enable basic auth (in VM)
102
+ ```
103
+ winrm set winrm/config/service/auth @{Basic="true"}
104
+ ```
105
+
106
+ Allow unencrypted connection (in VM)
107
+ ```
108
+ winrm set winrm/config/service @{AllowUnencrypted="true"}
109
+ ```
110
+
111
+
112
+ ## Contributing
113
+
114
+ 1. Fork it ( https://github.com/jarig/vagrant-vmm/fork )
115
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
116
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
117
+ 4. Push to the branch (`git push origin my-new-feature`)
118
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rubygems'
4
+ require 'bundler/setup'
5
+ Bundler::GemHelper.install_tasks
data/example/Berksfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://supermarket.chef.io"
2
+
3
+ group :integration do
4
+ cookbook 'chef-solo-search'
5
+ cookbook 'vim-windows'
6
+ end
@@ -0,0 +1,53 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ data_bags_path = "../data_bags"
5
+ secret_key_path = "~/.chef/encrypted_data_bag_secret"
6
+ validation_key_path = "~/.chef/chef-validator.pem"
7
+
8
+ Vagrant.configure('2') do |config|
9
+
10
+ # Plugins
11
+ config.omnibus.chef_version = "11.12.8"
12
+ config.berkshelf.enabled = true
13
+
14
+ # Windows 8.1 (64-bit)
15
+ config.vm.define :win64 do |win64_config|
16
+ win64_config.vm.hostname = "vmm-test-machine"
17
+ # required
18
+ win64_config.vm.guest = :windows
19
+ # required
20
+ win64_config.vm.communicator = "winrm"
21
+
22
+ win64_config.vm.provider :vmm do |vb|
23
+ # required
24
+ vb.vm_template_name = 'vagrant-template-w8.1-64'
25
+ # required
26
+ vb.vm_host_group_name = 'host-group-name'
27
+ # required
28
+ vb.vmm_server_address = '192.164.25.10'
29
+ # optional
30
+ vb.proxy_server_address = '192.126.48.226'
31
+ end
32
+
33
+ # those 2 not required if vagrant/vagrant used ( defaults anyway )
34
+ win64_config.winrm.username = "vagrant"
35
+ win64_config.winrm.password = "vagrant"
36
+ win64_config.winrm.timeout = 3600
37
+
38
+ win64_config.vm.provision :chef_solo do |chef|
39
+ #chef.log_level = :debug # Default is "info"
40
+ chef.file_cache_path = 'C:/var/chef/cache'
41
+ chef.data_bags_path = data_bags_path if ::File.exist?(File.expand_path(data_bags_path))
42
+ chef.encrypted_data_bag_secret_key_path = secret_key_path if ::File.exist?(File.expand_path(secret_key_path))
43
+
44
+ chef.json = {
45
+ }
46
+
47
+ chef.run_list = [
48
+ 'recipe[chef-solo-search::default]',
49
+ 'recipe[vim-windows::default]'
50
+ ]
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,5 @@
1
+ name 'vmm_provider_example'
2
+ license 'All rights reserved'
3
+ description 'Installs/Configures vmm_provider_example'
4
+ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
5
+ version '0.1.0'
@@ -0,0 +1,25 @@
1
+ module VagrantPlugins
2
+ module VMM
3
+ module Action
4
+ class DeleteVM
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ vmm_server_address = env[:machine].provider_config.vmm_server_address
11
+ # generate options
12
+ options = {
13
+ vmm_server_address: vmm_server_address,
14
+ proxy_server_address: env[:machine].provider_config.proxy_server_address
15
+ }
16
+ env[:ui].info("Deleting the machine...")
17
+ env[:machine].provider.driver.delete_vm(options)
18
+ env[:machine].provider.reset_state
19
+
20
+ @app.call(env)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,35 @@
1
+ require "fileutils"
2
+
3
+ require "log4r"
4
+
5
+ module VagrantPlugins
6
+ module VMM
7
+ module Action
8
+ class Import
9
+ def initialize(app, env)
10
+ @app = app
11
+ @logger = Log4r::Logger.new("vagrant::VMM::import")
12
+ end
13
+
14
+ def call(env)
15
+ vmm_server_address = env[:machine].provider_config.vmm_server_address
16
+ # generate options
17
+ options = {
18
+ vmm_server_address: vmm_server_address,
19
+ proxy_server_address: env[:machine].provider_config.proxy_server_address,
20
+ vm_name: env[:machine].config.vm.hostname,
21
+ vm_template_name: env[:machine].provider_config.vm_template_name,
22
+ vm_host_group_name: env[:machine].provider_config.vm_host_group_name
23
+ }
24
+
25
+ #
26
+ env[:ui].detail("Creating and registering VM in the VMM (#{vmm_server_address})...")
27
+ server = env[:machine].provider.driver.import(options)
28
+ env[:ui].detail("Successfully created the VM with name: #{server['name']}")
29
+ env[:machine].id = server["id"]
30
+ @app.call(env)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,17 @@
1
+ module VagrantPlugins
2
+ module VMM
3
+ module Action
4
+ class MessageWillNotDestroy
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ env[:ui].info I18n.t("vagrant.commands.destroy.will_not_destroy",
11
+ name: env[:machine].name)
12
+ @app.call(env)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,39 @@
1
+
2
+ require "log4r"
3
+
4
+ module VagrantPlugins
5
+ module VMM
6
+ module Action
7
+ class ReadState
8
+ def initialize(app, env)
9
+ @app = app
10
+ @logger = Log4r::Logger.new("vagrant::VMM::connection")
11
+ end
12
+
13
+ def call(env)
14
+ if env[:machine].id
15
+ #
16
+ vmm_server_address = env[:machine].provider_config.vmm_server_address
17
+ # generate options
18
+ options = {
19
+ vmm_server_address: vmm_server_address,
20
+ proxy_server_address: env[:machine].provider_config.proxy_server_address
21
+ }
22
+ env[:ui].detail("Taking a state of VM #{env[:machine].config.vm.hostname} (id: #{env[:machine].id} )...")
23
+ response = env[:machine].provider.driver.get_current_state(options)
24
+ env[:machine_state_id] = response["state"].downcase.to_sym
25
+ #env[:ui].detail("VM status: #{env[:machine_state_id]}")
26
+ # If the machine isn't created, then our ID is stale, so just
27
+ # mark it as not created.
28
+ if env[:machine_state_id] == :not_created
29
+ env[:machine].id = nil
30
+ end
31
+ else
32
+ env[:machine_state_id] = :not_created
33
+ end
34
+ @app.call(env)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,25 @@
1
+ module VagrantPlugins
2
+ module VMM
3
+ module Action
4
+ class ResumeVM
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ vmm_server_address = env[:machine].provider_config.vmm_server_address
11
+ # generate options
12
+ options = {
13
+ vmm_server_address: vmm_server_address,
14
+ proxy_server_address: env[:machine].provider_config.proxy_server_address
15
+ }
16
+ env[:ui].info("Resuming the machine...")
17
+ env[:machine].provider.driver.resume(options)
18
+ env[:machine].provider.reset_state
19
+
20
+ @app.call(env)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ module VagrantPlugins
2
+ module VMM
3
+ module Action
4
+ class StartInstance
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ vmm_server_address = env[:machine].provider_config.vmm_server_address
11
+ # generate options
12
+ options = {
13
+ vmm_server_address: vmm_server_address,
14
+ proxy_server_address: env[:machine].provider_config.proxy_server_address
15
+ }
16
+ env[:ui].output('Starting the machine...')
17
+ env[:machine].provider.driver.start(options)
18
+ env[:machine].provider.reset_state
19
+ env[:ui].output('Machine started')
20
+
21
+ @app.call(env)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ module VagrantPlugins
2
+ module VMM
3
+ module Action
4
+ class StopInstance
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ vmm_server_address = env[:machine].provider_config.vmm_server_address
11
+ # generate options
12
+ options = {
13
+ vmm_server_address: vmm_server_address,
14
+ proxy_server_address: env[:machine].provider_config.proxy_server_address
15
+ }
16
+ env[:ui].info("Stopping the machine...")
17
+ env[:machine].provider.driver.stop(options)
18
+ env[:ui].info("Machine stopped.")
19
+ env[:machine].provider.reset_state
20
+
21
+ @app.call(env)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ module VagrantPlugins
2
+ module VMM
3
+ module Action
4
+ class SuspendVM
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ vmm_server_address = env[:machine].provider_config.vmm_server_address
11
+ # generate options
12
+ options = {
13
+ vmm_server_address: vmm_server_address,
14
+ proxy_server_address: env[:machine].provider_config.proxy_server_address
15
+ }
16
+ env[:ui].info("Suspending the machine...")
17
+ env[:machine].provider.driver.suspend(options)
18
+ env[:machine].provider.reset_state
19
+
20
+ @app.call(env)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,64 @@
1
+ require "ipaddr"
2
+ require "timeout"
3
+
4
+ module VagrantPlugins
5
+ module VMM
6
+ module Action
7
+ class WaitForIPAddress
8
+ def initialize(app, env)
9
+ @app = app
10
+ @logger = Log4r::Logger.new("vagrant::VMM::wait_for_ip_addr")
11
+ end
12
+
13
+ def call(env)
14
+ timeout = env[:machine].provider_config.ip_address_timeout
15
+
16
+ env[:ui].output("Waiting for the machine to report its IP address(might take some time, have a patience)...")
17
+ env[:ui].detail("Timeout: #{timeout} seconds")
18
+
19
+ vmm_server_address = env[:machine].provider_config.vmm_server_address
20
+ # generate options
21
+ options = {
22
+ vmm_server_address: vmm_server_address,
23
+ proxy_server_address: env[:machine].provider_config.proxy_server_address,
24
+ timeout: timeout
25
+ }
26
+ guest_adr = nil
27
+ Timeout.timeout(timeout) do
28
+ while true
29
+ # If a ctrl-c came through, break out
30
+ return if env[:interrupted]
31
+
32
+ # Try to get the IP
33
+ network_info = env[:machine].provider.driver.read_guest_ip(options)
34
+ guest_adr = network_info["address"]
35
+
36
+ if guest_adr
37
+ begin
38
+ IPAddr.new(guest_adr)
39
+ break
40
+ rescue IPAddr::InvalidAddressError
41
+ # Ignore, continue looking.
42
+ @logger.warn("Invalid IP address returned: #{guest_adr}")
43
+ end
44
+ end
45
+
46
+ sleep 1
47
+ end
48
+ end
49
+
50
+ # If we were interrupted then return now
51
+ return if env[:interrupted]
52
+
53
+ env[:ui].detail("VM Address: #{guest_adr}")
54
+ env[:machine].provider_config.vm_address = guest_adr
55
+ env[:machine].config.winrm.host = guest_adr
56
+
57
+ @app.call(env)
58
+ rescue Timeout::Error
59
+ raise Errors::IPAddrTimeout
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end