vagrant-hypervnet 0.1.1

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 (32) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +16 -0
  3. data/README.md +54 -0
  4. data/Rakefile +8 -0
  5. data/Vagrantfile +104 -0
  6. data/lib/vagrant-hypervnet/action/disable_builtin_network_configure.rb +39 -0
  7. data/lib/vagrant-hypervnet/action/network.rb +328 -0
  8. data/lib/vagrant-hypervnet/action/ssh_server.rb +28 -0
  9. data/lib/vagrant-hypervnet/action.rb +31 -0
  10. data/lib/vagrant-hypervnet/cap/linux/nic_mac_addresses.rb +71 -0
  11. data/lib/vagrant-hypervnet/cap/linux/pre_configure_networks.rb +31 -0
  12. data/lib/vagrant-hypervnet/cap/vyos/post_configure_networks.rb +45 -0
  13. data/lib/vagrant-hypervnet/cap/windows/rsync.rb +60 -0
  14. data/lib/vagrant-hypervnet/cap/windows/sshd.rb +151 -0
  15. data/lib/vagrant-hypervnet/cap.rb +15 -0
  16. data/lib/vagrant-hypervnet/config.rb +36 -0
  17. data/lib/vagrant-hypervnet/driver.rb +197 -0
  18. data/lib/vagrant-hypervnet/errors.rb +34 -0
  19. data/lib/vagrant-hypervnet/scripts/add_vm_adapter.ps1 +15 -0
  20. data/lib/vagrant-hypervnet/scripts/connect_vm_adapter.ps1 +12 -0
  21. data/lib/vagrant-hypervnet/scripts/get_switch_by_address.ps1 +22 -0
  22. data/lib/vagrant-hypervnet/scripts/get_switch_by_name.ps1 +17 -0
  23. data/lib/vagrant-hypervnet/scripts/get_vm_adapters.ps1 +11 -0
  24. data/lib/vagrant-hypervnet/scripts/new_switch.ps1 +26 -0
  25. data/lib/vagrant-hypervnet/scripts/remove_vm_adapter.ps1 +9 -0
  26. data/lib/vagrant-hypervnet/scripts/utils/VagrantMessages/VagrantMessages.psm1 +27 -0
  27. data/lib/vagrant-hypervnet/version.rb +7 -0
  28. data/lib/vagrant-hypervnet.rb +89 -0
  29. data/locales/en.yml +69 -0
  30. data/sig/vagrant/hypervnet.rbs +6 -0
  31. data/vagrant-hypervnet.gemspec +26 -0
  32. metadata +73 -0
@@ -0,0 +1,9 @@
1
+ param (
2
+ [parameter (Mandatory=$true)]
3
+ [string]$VmId,
4
+ [parameter (Mandatory=$true)]
5
+ [string]$Id
6
+ )
7
+
8
+ $vm = Get-VM -Id $VmId
9
+ Get-VMNetworkAdapter -VM $vm | Where-Object -Property Id -EQ -Value $Id | Remove-VMNetworkAdapter
@@ -0,0 +1,27 @@
1
+ #-------------------------------------------------------------------------
2
+ # Copyright (c) Microsoft Open Technologies, Inc.
3
+ # All Rights Reserved. Licensed under the MIT License.
4
+ #--------------------------------------------------------------------------
5
+
6
+ function Write-ErrorMessage {
7
+ param (
8
+ [parameter (Mandatory=$true,Position=0)]
9
+ [string] $Message
10
+ )
11
+ $error_message = @{
12
+ error = $Message
13
+ }
14
+ Write-Host "===Begin-Error==="
15
+ Write-Host (ConvertTo-Json $error_message)
16
+ Write-Host "===End-Error==="
17
+ }
18
+
19
+ function Write-OutputMessage {
20
+ param (
21
+ [parameter (Mandatory=$true,Position=0)]
22
+ [string] $Message
23
+ )
24
+ Write-Host "===Begin-Output==="
25
+ Write-Host $Message
26
+ Write-Host "===End-Output==="
27
+ }
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VagrantPlugins
4
+ module HyperVNet
5
+ VERSION = "0.1.1"
6
+ end
7
+ end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require "vagrant"
5
+ rescue LoadError
6
+ raise "The Vagrant Hyper-V network plugin must be run within Vagrant."
7
+ end
8
+
9
+ I18n.load_path << File.expand_path("../../locales/en.yml", __FILE__)
10
+ I18n.reload!
11
+
12
+ module VagrantPlugins
13
+ module HyperVNet
14
+ class Plugin < Vagrant.plugin("2")
15
+ name "Hyper-V network"
16
+ description <<-DESC
17
+ This plugin installs some extensions that allows Vagrant to manage
18
+ network configuration of machines in Hyper-V.
19
+ DESC
20
+
21
+ config(:hypervnet) do
22
+ require_relative "vagrant-hypervnet/config"
23
+ Config
24
+ end
25
+
26
+ provider_capability(:hyperv, :nic_mac_addresses) do
27
+ require_relative "vagrant-hypervnet/cap"
28
+ Cap
29
+ end
30
+
31
+ guest_capability(:linux, :pre_configure_networks) do
32
+ require_relative "vagrant-hypervnet/cap/linux/pre_configure_networks"
33
+ Cap::Linux::PreConfigureNetworks
34
+ end
35
+
36
+ guest_capability(:vyos, :post_configure_networks) do
37
+ require_relative "vagrant-hypervnet/cap/vyos/post_configure_networks"
38
+ Cap::Vyos::PostConfigureNetworks
39
+ end
40
+
41
+ guest_capability(:linux, :nic_mac_addresses) do
42
+ require_relative "vagrant-hypervnet/cap/linux/nic_mac_addresses"
43
+ Cap::Linux::NicMacAddresses
44
+ end
45
+
46
+ guest_capability(:windows, :rsync_installed) do
47
+ require_relative "vagrant-hypervnet/cap/windows/rsync"
48
+ Cap::Windows::RSync
49
+ end
50
+
51
+ guest_capability(:windows, :rsync_install) do
52
+ require_relative "vagrant-hypervnet/cap/windows/rsync"
53
+ Cap::Windows::RSync
54
+ end
55
+
56
+ guest_capability(:windows, :rsync_scrub_guestpath) do
57
+ require_relative "vagrant-hypervnet/cap/windows/rsync"
58
+ Cap::Windows::RSync
59
+ end
60
+
61
+ guest_capability(:windows, :sshd_installed) do
62
+ require_relative "vagrant-hypervnet/cap/windows/sshd"
63
+ Cap::Windows::Sshd
64
+ end
65
+
66
+ guest_capability(:windows, :sshd_install) do
67
+ require_relative "vagrant-hypervnet/cap/windows/sshd"
68
+ Cap::Windows::Sshd
69
+ end
70
+
71
+ guest_capability(:windows, :sshd_reload) do
72
+ require_relative "vagrant-hypervnet/cap/windows/sshd"
73
+ Cap::Windows::Sshd
74
+ end
75
+
76
+ action_hook(:hypervnet) do |hook|
77
+ require_relative 'vagrant-hypervnet/action'
78
+
79
+ if defined?(VagrantPlugins::HyperV::Action::Configure)
80
+ hook.before(VagrantPlugins::HyperV::Action::Configure, Action.disable_builtin_network_configure)
81
+ end
82
+ if defined?(VagrantPlugins::HyperV::Action::StartInstance)
83
+ hook.before(VagrantPlugins::HyperV::Action::StartInstance, Action.network)
84
+ end
85
+ hook.before(Vagrant::Action::Builtin::SyncedFolders, Action.ssh_server)
86
+ end
87
+ end
88
+ end
89
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,69 @@
1
+ en:
2
+ vagrant_hypervnet:
3
+ network_adapter: |-
4
+ Adapter %{adapter}: %{type} %{switch}
5
+ network_config: |-
6
+ network %{network} -> %{interface}: %{type} %{ip}/%{netmask}
7
+ ssh:
8
+ install: |-
9
+ Installing OpenSSH server to the VM...
10
+ reload: |-
11
+ Reloading OpenSSH server in the VM...
12
+ inserted_key: |-
13
+ Key inserted!
14
+ inserting_insecure_detected: |-
15
+ Vagrant insecure key detected. Vagrant will automatically replace
16
+ this with a newly generated keypair for better security.
17
+ inserting_random_key: |-
18
+ Inserting generated public key within guest...
19
+ inserting_remove_key: |-
20
+ Removing insecure key from the guest if it's present...
21
+ rsync:
22
+ install: |-
23
+ Installing MSYS2 to the VM...
24
+ config:
25
+ private_on_bad_type: |-
26
+ HyperV private networks can only be enabled on "private_network"
27
+ network:
28
+ configuring: |-
29
+ Configuring and enabling network interfaces...
30
+ preparing: |-
31
+ Preparing network interfaces based on configuration...
32
+ errors:
33
+ bridge_undefined_in_public_network: |-
34
+ Network settings specified in your Vagrantfile specifies a public
35
+ network without a bridge. Please review the error message below and
36
+ update your Vagrantfile network settings:
37
+
38
+ Error: %{error}
39
+ ip_undefined_in_private_network: |-
40
+ Network settings specified in your Vagrantfile specifies a private
41
+ network without an IP address. Please review the error message below
42
+ and update your Vagrantfile network settings:
43
+
44
+ Error: %{error}
45
+ powershell_error: |-
46
+ An error occurred while executing a PowerShell script. This error
47
+ is shown below. Please read the error message and see if this is
48
+ a configuration error with your system. If it is not, then please
49
+ report a bug.
50
+
51
+ Script: %{script}
52
+ Error:
53
+
54
+ %{stderr}
55
+ network_type_not_supported: |-
56
+ The %{type} network type is not supported for this box or guest.
57
+ network_address_invalid: |-
58
+ Network settings specified in your Vagrantfile define an invalid
59
+ IP address. Please review the error message below and update your
60
+ Vagrantfile network settings:
61
+
62
+ Address: %{address}
63
+ Netmask: %{mask}
64
+ Error: %{error}
65
+ network_not_found: |-
66
+ The specified host network could not be found: '%{name}.'
67
+ If the name specification is removed, Vagrant will create a new
68
+ network for you. Alternatively, please create the
69
+ specified network manually.
@@ -0,0 +1,6 @@
1
+ module Vagrant
2
+ module Hypervnet
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/vagrant-hypervnet/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "vagrant-hypervnet"
7
+ spec.version = VagrantPlugins::HyperVNet::VERSION
8
+ spec.authors = ["Luca Bompani"]
9
+ spec.email = ["luca.bompani@unibo.it"]
10
+
11
+ spec.summary = "Vagrant plugin to configure Hyper-V network."
12
+ spec.description = "Vagrant plugin which extends Hyper-V provider implementing networks creation and configuration."
13
+ spec.homepage = "https://github.com/bompani/vagrant-hyperv"
14
+ spec.required_ruby_version = ">= 2.6.0"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(__dir__) do
19
+ `git ls-files -z`.split("\x0").reject do |f|
20
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
21
+ end
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-hypervnet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Luca Bompani
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-04-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Vagrant plugin which extends Hyper-V provider implementing networks creation
14
+ and configuration.
15
+ email:
16
+ - luca.bompani@unibo.it
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - Gemfile
22
+ - README.md
23
+ - Rakefile
24
+ - Vagrantfile
25
+ - lib/vagrant-hypervnet.rb
26
+ - lib/vagrant-hypervnet/action.rb
27
+ - lib/vagrant-hypervnet/action/disable_builtin_network_configure.rb
28
+ - lib/vagrant-hypervnet/action/network.rb
29
+ - lib/vagrant-hypervnet/action/ssh_server.rb
30
+ - lib/vagrant-hypervnet/cap.rb
31
+ - lib/vagrant-hypervnet/cap/linux/nic_mac_addresses.rb
32
+ - lib/vagrant-hypervnet/cap/linux/pre_configure_networks.rb
33
+ - lib/vagrant-hypervnet/cap/vyos/post_configure_networks.rb
34
+ - lib/vagrant-hypervnet/cap/windows/rsync.rb
35
+ - lib/vagrant-hypervnet/cap/windows/sshd.rb
36
+ - lib/vagrant-hypervnet/config.rb
37
+ - lib/vagrant-hypervnet/driver.rb
38
+ - lib/vagrant-hypervnet/errors.rb
39
+ - lib/vagrant-hypervnet/scripts/add_vm_adapter.ps1
40
+ - lib/vagrant-hypervnet/scripts/connect_vm_adapter.ps1
41
+ - lib/vagrant-hypervnet/scripts/get_switch_by_address.ps1
42
+ - lib/vagrant-hypervnet/scripts/get_switch_by_name.ps1
43
+ - lib/vagrant-hypervnet/scripts/get_vm_adapters.ps1
44
+ - lib/vagrant-hypervnet/scripts/new_switch.ps1
45
+ - lib/vagrant-hypervnet/scripts/remove_vm_adapter.ps1
46
+ - lib/vagrant-hypervnet/scripts/utils/VagrantMessages/VagrantMessages.psm1
47
+ - lib/vagrant-hypervnet/version.rb
48
+ - locales/en.yml
49
+ - sig/vagrant/hypervnet.rbs
50
+ - vagrant-hypervnet.gemspec
51
+ homepage: https://github.com/bompani/vagrant-hyperv
52
+ licenses: []
53
+ metadata: {}
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 2.6.0
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubygems_version: 3.1.6
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: Vagrant plugin to configure Hyper-V network.
73
+ test_files: []