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
@@ -0,0 +1,89 @@
1
+
2
+ require "vagrant/util/platform"
3
+ require "vagrant/util/powershell"
4
+ require "json"
5
+
6
+ # implements:
7
+ # https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/plugin/v2/synced_folder.rb
8
+
9
+ module VagrantPlugins
10
+ module VMM
11
+ class SyncedFolder < Vagrant.plugin("2", :synced_folder)
12
+ #
13
+ def usable?(machine, raise_error=false)
14
+ return false if machine.provider_name != :vmm
15
+
16
+ if !Vagrant::Util::Platform.windows?
17
+ raise Errors::WindowsRequired
18
+ return false
19
+ end
20
+
21
+ if !Vagrant::Util::PowerShell.available?
22
+ raise Errors::PowerShellRequired
23
+ return false
24
+ end
25
+
26
+ true
27
+ end
28
+
29
+ # This is called after the machine is booted and after networks
30
+ # are setup.
31
+ #
32
+ # This might be called with new folders while the machine is running.
33
+ # If so, then this should add only those folders without removing
34
+ # any existing ones.
35
+ #
36
+ # No return value.
37
+ def enable(machine, folders, opts)
38
+ machine.ui.output('Syncing folders with the VM via WinRM')
39
+
40
+ # generate options
41
+ options = {
42
+ vm_address: machine.provider_config.vm_address,
43
+ folders_to_sync: {},
44
+ winrm_vm_username: machine.config.winrm.username,
45
+ winrm_vm_password: machine.config.winrm.password
46
+ }
47
+ #
48
+ folders.each do |id, data|
49
+ if data[:guestpath]
50
+ # record in options
51
+ options[:folders_to_sync][data[:hostpath]] = data[:guestpath]
52
+ else
53
+ # If no guest path is specified, then automounting is disabled
54
+ machine.ui.detail("No guest path specified for: #{data[:hostpath]}")
55
+ end
56
+ end
57
+ # escape quotes
58
+ options[:folders_to_sync] = options[:folders_to_sync].to_json.gsub('"','\\"')
59
+ res = machine.provider.driver.sync_folders(options)
60
+ machine.ui.detail("Files synced.")
61
+ end
62
+
63
+ # This is called to remove the synced folders from a running
64
+ # machine.
65
+ #
66
+ # This is not guaranteed to be called, but this should be implemented
67
+ # by every synced folder implementation.
68
+ #
69
+ # @param [Machine] machine The machine to modify.
70
+ # @param [Hash] folders The folders to remove. This will not contain
71
+ # any folders that should remain.
72
+ # @param [Hash] opts Any options for the synced folders.
73
+ def disable(machine, folders, opts)
74
+ end
75
+
76
+ # This is called after destroying the machine during a
77
+ # `vagrant destroy` and also prior to syncing folders during
78
+ # a `vagrant up`.
79
+ #
80
+ # No return value.
81
+ #
82
+ # @param [Machine] machine
83
+ # @param [Hash] opts
84
+ def cleanup(machine, opts)
85
+ end
86
+
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module VMM
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,17 @@
1
+ require 'pathname'
2
+ require 'vagrant-vmm/plugin'
3
+
4
+ module VagrantPlugins
5
+ module VMM
6
+ lib_path = Pathname.new(File.expand_path("../vagrant-vmm", __FILE__))
7
+ autoload :Action, lib_path.join("action")
8
+ autoload :Errors, lib_path.join("errors")
9
+
10
+ # This returns the path to the source of this plugin.
11
+ #
12
+ # @return [Pathname]
13
+ def self.source_root
14
+ @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
15
+ end
16
+ end
17
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,46 @@
1
+ en:
2
+ vagrant_VMM:
3
+ message_already_running: |-
4
+ VM instance is already running.
5
+ message_not_created: |-
6
+ VM not created. Moving on...
7
+ message_not_running: |-
8
+ VM machine isn't running. Can't SSH in!
9
+
10
+ errors:
11
+ admin_required: |-
12
+ The Hyper-V provider requires that Vagrant be run with
13
+ administrative privileges. This is a limitation of Hyper-V itself.
14
+ Hyper-V requires administrative privileges for management
15
+ commands. Please restart your console with administrative
16
+ privileges and try again.
17
+ ip_addr_timeout: |-
18
+ Hyper-V failed to determine your machine's IP address within the
19
+ configured timeout. Please verify the machine properly booted and
20
+ the network works. To do this, open the Hyper-V manager, find your
21
+ virtual machine, and connect to it.
22
+
23
+ The most common cause for this error is that the running virtual
24
+ machine doesn't have the latest Hyper-V integration drivers. Please
25
+ research for your operating system how to install these in order
26
+ for the VM to properly communicate its IP address to Hyper-V.
27
+ powershell_features_disabled: |-
28
+ The Hyper-V cmdlets for PowerShell are not available! Vagrant
29
+ requires these to control Hyper-V. Please enable them in the
30
+ "Windows Features" control panel and try again.
31
+ powershell_error: |-
32
+ An error occurred while executing a PowerShell script. This error
33
+ is shown below. Please read the error message and see if this is
34
+ a configuration error with your system. If it is not, then please
35
+ report a bug.
36
+
37
+ Script: %{script}
38
+ Error:
39
+
40
+ %{stderr}
41
+ powershell_required: |-
42
+ The Vagrant Hyper-V provider requires PowerShell to be available.
43
+ Please make sure "powershell.exe" is available on your PATH.
44
+ windows_required: |-
45
+ The Hyper-V provider only works on Windows. Please try to
46
+ use another provider.
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-vmm/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-vmm"
8
+ spec.version = VagrantPlugins::VMM::VERSION
9
+ spec.authors = ["jarig"]
10
+ spec.email = ["gjarik@gmail.com"]
11
+ spec.summary = %q{Plugin for running VMs via Virtual Machine Manager.}
12
+ spec.description = %q{Write a longer description. Optional.}
13
+ spec.homepage = "https://github.com/jarig"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-vmm
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - jarig
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Write a longer description. Optional.
42
+ email:
43
+ - gjarik@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - .travis.yml
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - example/Berksfile
55
+ - example/Vagrantfile
56
+ - example/metadata.rb
57
+ - lib/vagrant-vmm.rb
58
+ - lib/vagrant-vmm/action.rb
59
+ - lib/vagrant-vmm/action/delete_vm.rb
60
+ - lib/vagrant-vmm/action/import.rb
61
+ - lib/vagrant-vmm/action/message_will_not_destroy.rb
62
+ - lib/vagrant-vmm/action/read_state.rb
63
+ - lib/vagrant-vmm/action/resume_vm.rb
64
+ - lib/vagrant-vmm/action/start_instance.rb
65
+ - lib/vagrant-vmm/action/stop_instance.rb
66
+ - lib/vagrant-vmm/action/suspend_vm.rb
67
+ - lib/vagrant-vmm/action/wait_for_ip_address.rb
68
+ - lib/vagrant-vmm/cap/public_address.rb
69
+ - lib/vagrant-vmm/config.rb
70
+ - lib/vagrant-vmm/driver.rb
71
+ - lib/vagrant-vmm/errors.rb
72
+ - lib/vagrant-vmm/plugin.rb
73
+ - lib/vagrant-vmm/provider.rb
74
+ - lib/vagrant-vmm/scripts/delete_vm.ps1
75
+ - lib/vagrant-vmm/scripts/get_network_config.ps1
76
+ - lib/vagrant-vmm/scripts/get_vm_status.ps1
77
+ - lib/vagrant-vmm/scripts/import_vm.ps1
78
+ - lib/vagrant-vmm/scripts/resume_vm.ps1
79
+ - lib/vagrant-vmm/scripts/start_vm.ps1
80
+ - lib/vagrant-vmm/scripts/stop_vm.ps1
81
+ - lib/vagrant-vmm/scripts/suspend_vm.ps1
82
+ - lib/vagrant-vmm/scripts/sync_folders.ps1
83
+ - lib/vagrant-vmm/scripts/utils/manage_credentials.ps1
84
+ - lib/vagrant-vmm/scripts/utils/vmm_executor.ps1
85
+ - lib/vagrant-vmm/scripts/utils/write_messages.ps1
86
+ - lib/vagrant-vmm/synced_folder.rb
87
+ - lib/vagrant-vmm/version.rb
88
+ - locales/en.yml
89
+ - vagrant-vmm.gemspec
90
+ homepage: https://github.com/jarig
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.4.5
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Plugin for running VMs via Virtual Machine Manager.
114
+ test_files: []