vagrant-invade 0.0.1 → 0.2.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 (89) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +17 -0
  3. data/.gitignore +4 -0
  4. data/Gemfile +10 -0
  5. data/Gemfile.lock +106 -0
  6. data/LICENSE +339 -0
  7. data/README.md +4 -0
  8. data/Rakefile +3 -0
  9. data/images/logo-128.png +0 -0
  10. data/images/logo-256.png +0 -0
  11. data/images/logo-512.png +0 -0
  12. data/invade.yml.dist +56 -0
  13. data/lib/vagrant-invade/action/config.rb +73 -0
  14. data/lib/vagrant-invade/action/create.rb +97 -0
  15. data/lib/vagrant-invade/action/generate.rb +95 -0
  16. data/lib/vagrant-invade/action/validate.rb +156 -0
  17. data/lib/vagrant-invade/action.rb +34 -0
  18. data/lib/vagrant-invade/builder/definition.rb +43 -0
  19. data/lib/vagrant-invade/builder/network/forwarded_port.rb +47 -0
  20. data/lib/vagrant-invade/builder/network/private_network.rb +41 -0
  21. data/lib/vagrant-invade/builder/network/public_network.rb +43 -0
  22. data/lib/vagrant-invade/builder/network.rb +13 -0
  23. data/lib/vagrant-invade/builder/provider/virtualbox.rb +47 -0
  24. data/lib/vagrant-invade/builder/provider/vmware.rb +44 -0
  25. data/lib/vagrant-invade/builder/provider.rb +12 -0
  26. data/lib/vagrant-invade/builder/provision/puppet.rb +47 -0
  27. data/lib/vagrant-invade/builder/provision/shell.rb +45 -0
  28. data/lib/vagrant-invade/builder/provision/shell_inline.rb +45 -0
  29. data/lib/vagrant-invade/builder/provision.rb +12 -0
  30. data/lib/vagrant-invade/builder/synced_folder/nfs.rb +48 -0
  31. data/lib/vagrant-invade/builder/synced_folder/virtualbox.rb +48 -0
  32. data/lib/vagrant-invade/builder/synced_folder.rb +12 -0
  33. data/lib/vagrant-invade/builder/vagrantfile.rb +35 -0
  34. data/lib/vagrant-invade/builder/vm.rb +41 -0
  35. data/lib/vagrant-invade/builder.rb +17 -0
  36. data/lib/vagrant-invade/command/base.rb +19 -0
  37. data/lib/vagrant-invade/command/build.rb +37 -0
  38. data/lib/vagrant-invade/command/root.rb +73 -0
  39. data/lib/vagrant-invade/command/validate.rb +37 -0
  40. data/lib/vagrant-invade/generator/definition.rb +25 -0
  41. data/lib/vagrant-invade/generator/section/network.rb +38 -0
  42. data/lib/vagrant-invade/generator/section/plugin.rb +0 -0
  43. data/lib/vagrant-invade/generator/section/provider.rb +36 -0
  44. data/lib/vagrant-invade/generator/section/provision.rb +38 -0
  45. data/lib/vagrant-invade/generator/section/synced_folder.rb +36 -0
  46. data/lib/vagrant-invade/generator/section/vm.rb +27 -0
  47. data/lib/vagrant-invade/generator/section.rb +15 -0
  48. data/lib/vagrant-invade/generator/vagrantfile.rb +24 -0
  49. data/lib/vagrant-invade/generator.rb +11 -0
  50. data/lib/vagrant-invade/plugin.rb +28 -0
  51. data/lib/vagrant-invade/template/definition.erb +19 -0
  52. data/lib/vagrant-invade/template/network/forwarded_port.erb +8 -0
  53. data/lib/vagrant-invade/template/network/private_network.erb +1 -0
  54. data/lib/vagrant-invade/template/network/public_network.erb +5 -0
  55. data/lib/vagrant-invade/template/provider/virtualbox.erb +11 -0
  56. data/lib/vagrant-invade/template/provider/vmware.erb +5 -0
  57. data/lib/vagrant-invade/template/provision/puppet.erb +0 -0
  58. data/lib/vagrant-invade/template/provision/shell.erb +2 -0
  59. data/lib/vagrant-invade/template/provision/shell_inline.erb +2 -0
  60. data/lib/vagrant-invade/template/synced_folder/nfs.erb +12 -0
  61. data/lib/vagrant-invade/template/synced_folder/virtualbox.erb +1 -0
  62. data/lib/vagrant-invade/template/v2.erb +9 -0
  63. data/lib/vagrant-invade/template/vm/vm.erb +7 -0
  64. data/lib/vagrant-invade/validator/invade.rb +39 -0
  65. data/lib/vagrant-invade/validator/network/forwarded_port.rb +68 -0
  66. data/lib/vagrant-invade/validator/network/private_network.rb +44 -0
  67. data/lib/vagrant-invade/validator/network/public_network.rb +56 -0
  68. data/lib/vagrant-invade/validator/network.rb +13 -0
  69. data/lib/vagrant-invade/validator/plugin/hostmanager.rb +57 -0
  70. data/lib/vagrant-invade/validator/plugin/winnfsd.rb +52 -0
  71. data/lib/vagrant-invade/validator/plugin.rb +12 -0
  72. data/lib/vagrant-invade/validator/provider/virtualbox.rb +46 -0
  73. data/lib/vagrant-invade/validator/provider/vmware.rb +27 -0
  74. data/lib/vagrant-invade/validator/provider.rb +39 -0
  75. data/lib/vagrant-invade/validator/provision/puppet.rb +70 -0
  76. data/lib/vagrant-invade/validator/provision/shell.rb +52 -0
  77. data/lib/vagrant-invade/validator/provision/shell_inline.rb +52 -0
  78. data/lib/vagrant-invade/validator/provision.rb +22 -0
  79. data/lib/vagrant-invade/validator/ssh.rb +38 -0
  80. data/lib/vagrant-invade/validator/synced_folder/nfs.rb +46 -0
  81. data/lib/vagrant-invade/validator/synced_folder/vb.rb +52 -0
  82. data/lib/vagrant-invade/validator/synced_folder.rb +36 -0
  83. data/lib/vagrant-invade/validator/vm.rb +45 -0
  84. data/lib/vagrant-invade/validator.rb +113 -0
  85. data/lib/vagrant-invade/version.rb +5 -0
  86. data/lib/vagrant-invade.rb +41 -0
  87. data/pkg/vagrant-invade-0.0.1.gem +0 -0
  88. data/vagrant-invade.gemspec +17 -0
  89. metadata +94 -7
@@ -0,0 +1,97 @@
1
+ module VagrantPlugins
2
+ module Invade
3
+ module Action
4
+
5
+ include Vagrant::Action::Builtin
6
+
7
+ class Create
8
+
9
+ def initialize(app, env)
10
+ @app = app
11
+ @env = env
12
+ @logger = Log4r::Logger.new('vagrant::invade::action::create')
13
+ end
14
+
15
+ def call(env)
16
+
17
+ # Get project root and default vagrantfile filename
18
+ ENV['VAGRANT_VAGRANTFILE'] ? vagrantfile_name = ENV['VAGRANT_VAGRANTFILE'] : vagrantfile_name = "Vagrantfile"
19
+ root_path = @env[:root_path]
20
+
21
+ # Get generated Vagrantfile from environment
22
+ generated_vagrantfile = @env[:invade]['vagrantfile']
23
+
24
+ # Get auto_mode from env
25
+ auto_mode = @env[:invade]['invade']['auto']
26
+
27
+ # Write new Vagrantfile if checksum is not equal and auto mode is enabled
28
+ unless check_md5_checksum(@env[:ui], root_path, vagrantfile_name, generated_vagrantfile)
29
+
30
+ # Write Vagrantfile
31
+ auto_mode ?
32
+ write_vagrantfile(@env[:ui], root_path, generated_vagrantfile, vagrantfile_name, true) :
33
+ write_vagrantfile(@env[:ui], root_path, generated_vagrantfile, vagrantfile_name, false)
34
+
35
+ # Reload
36
+ reload(@env[:ui]) if auto_mode
37
+ end
38
+ end
39
+
40
+ private
41
+
42
+ # Compare md5 strings to replace Vagrantfile
43
+ def check_md5_checksum(ui, root_path, vagrantfile_name, generated_vagrantfile)
44
+
45
+ require 'digest'
46
+
47
+ md5_new = Digest::MD5.hexdigest(generated_vagrantfile)
48
+ md5_current = Digest::MD5.file("#{root_path}/#{vagrantfile_name}").hexdigest
49
+
50
+ ui.success "[Invade] Checking Vagrantfile (#{md5_current})..."
51
+ (md5_new.eql? md5_current) ? md5_check = true : md5_check = false
52
+
53
+ unless md5_check
54
+ ui.warn "[Invade] Vagrantfile (#{md5_current}) not equal with configuration (#{md5_new})."
55
+ return false
56
+ end
57
+
58
+ ui.success "[Invade] Vagrantfile is valid."
59
+
60
+ true
61
+ end
62
+
63
+ def reload(ui)
64
+
65
+ # Get corrent command whether in development mode or using Vagrant for real
66
+ unless Vagrant.in_installer? && Vagrant.very_quiet?
67
+ command = 'bundle exec vagrant reload'
68
+ else
69
+ command = 'vagrant reload'
70
+ end
71
+
72
+ ui.warn '[Invade] Auto reload Vagrant with new Vagrantfile...'
73
+ sleep 2
74
+
75
+ Kernel.exec(command)
76
+ end
77
+
78
+ def write_vagrantfile(ui, root_path, vagrantfile, vagrantfile_name, overwrite)
79
+
80
+ overwrite ?
81
+ vagrantfile_path = "#{root_path}/#{vagrantfile_name}" :
82
+ vagrantfile_path = "#{root_path}/#{vagrantfile_name}.new"
83
+
84
+ # Write new Vagrantfile
85
+ open(vagrantfile_path, "w+") do |f|
86
+ f.puts vagrantfile
87
+ end
88
+
89
+ overwrite ?
90
+ ui.warn('[Invade] Replaced old Vagrantfile.') :
91
+ ui.warn("[Invade] Saved new Vagrantfile as #{root_path}/#{vagrantfile_name}.new")
92
+ end
93
+ end
94
+
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,95 @@
1
+ module VagrantPlugins
2
+ module Invade
3
+ module Action
4
+
5
+ include Vagrant::Action::Builtin
6
+
7
+ class Generate
8
+
9
+ def initialize(app, env)
10
+ @app = app
11
+ @env = env
12
+ @logger = Log4r::Logger.new('vagrant::invade::action::generate')
13
+ end
14
+
15
+ def call(env)
16
+
17
+ # Define invade config
18
+ config = @env[:invade]
19
+
20
+ # Iterate over each machine configuration
21
+ machines = config['machines']
22
+
23
+ unless machines == nil
24
+
25
+ part = Hash.new
26
+ definition = Hash.new
27
+
28
+ machines.each_with_index do |(machine, section), index|
29
+
30
+ # VM
31
+ unless section['vm'] == nil
32
+ part['vm'] = Generator::Section::VM.new(machine, section['vm']).generate
33
+ end
34
+
35
+ # NETWORK
36
+ unless section['network'] == nil
37
+ part['network'] = ''
38
+
39
+ section['network'].each do |type, data|
40
+ part['network'].concat(Generator::Section::Network.new(machine, type, data).generate)
41
+ end
42
+ end
43
+
44
+ # PROVIDER
45
+ unless section['provider'] == nil
46
+ part['provider'] = ''
47
+
48
+ section['provider'].each do |type, data|
49
+ parts = Generator::Section::Provider.new(machine, type, data).generate
50
+ part['provider'].concat(parts)
51
+ end
52
+ end
53
+
54
+ # SYNCED FOLDER
55
+ unless section['synced_folder'] == nil
56
+ part['synced_folder'] = ''
57
+
58
+ section['synced_folder'].each do |type, data|
59
+ parts = Generator::Section::SyncedFolder.new(machine, type, data).generate
60
+ part['synced_folder'].concat(parts)
61
+ end
62
+ end
63
+
64
+ unless section['provision'] == nil
65
+ part['provision'] = ''
66
+
67
+ section['provision'].each do |type, data|
68
+ parts = Generator::Section::Provision.new(machine, type, data).generate
69
+ part['provision'].concat(parts)
70
+ end
71
+ end
72
+
73
+ # # SSH
74
+ # unless section['ssh'] == nil
75
+ # part['ssh'] = Generator::Section::SSH.new(machine, section['ssh']).generate
76
+ # end
77
+
78
+ # Add as definition
79
+ definition[machine] = Generator::Definition.new(machine, part).generate
80
+ end
81
+
82
+ # Finally generate Vagrantfile from generated definitions and add it to Vagrant environment
83
+ @env[:invade]['vagrantfile'] = Generator::Vagrantfile.new(env, definition).generate
84
+
85
+ # Finally done with generating. Delete machines from Vagrant environment
86
+ @env[:invade].delete("machines")
87
+
88
+ @app.call(env)
89
+ end
90
+ end
91
+
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,156 @@
1
+ module VagrantPlugins
2
+ module Invade
3
+ module Action
4
+
5
+ include Vagrant::Action::Builtin
6
+
7
+ class Validate
8
+
9
+ def initialize(app, env)
10
+ @app = app
11
+ @env = env
12
+ @logger = Log4r::Logger.new('vagrant::invade::action::validate')
13
+ end
14
+
15
+ def call(env)
16
+
17
+ config = env[:invade]
18
+
19
+ Validator.set_env(@env)
20
+ Validator.set_invade(@env)
21
+
22
+ ###############################################################
23
+ # Validate the settings and set default variables if needed
24
+ ###############################################################
25
+
26
+ # INVADE
27
+ config['invade'] = Validator::Invade.new(env, config['invade']).validate
28
+
29
+ # Iterate over each machine configuration
30
+ machines = config['machines']
31
+ unless machines == nil
32
+ machines.each_with_index do |(machine, sections), index|
33
+
34
+ # VM
35
+ unless sections['vm'] == nil
36
+ @env[:ui].info("\n[Invade] #{machine.upcase}: Validating VM configuration...")
37
+ sleep 1 unless @env[:invade_command_quiet]
38
+
39
+ sections['vm'] = Validator::VM.new(env, sections['vm']).validate
40
+ end
41
+
42
+ # NETWORK
43
+ unless sections['network'] == nil
44
+ @env[:ui].info("\n[Invade] #{machine.upcase}: Validating network configuration...")
45
+ sleep 1 unless @env[:invade_command_quiet]
46
+
47
+ sections['network'].each do |type, network|
48
+ @env[:ui].info("\tNetwork: #{type}")
49
+ case type
50
+ when 'private', 'private_network', 'privatenetwork', 'private-network'
51
+ network = Validator::Network::PrivateNetwork.new(env, network).validate
52
+ when 'forwarded', 'forwarded_port', 'forwarded-port', 'forwardedport', 'port'
53
+ network = Validator::Network::ForwardedPort.new(@machine_name, network).validate
54
+ when 'public', 'puplic_network', 'publicnetwork', 'public-network'
55
+ network = Validator::Network::PublicNetwork.new(@machine_name, network).validate
56
+ else
57
+ raise StandardError, "Network type unknown or not set. Please check the network configuration."
58
+ end
59
+ end
60
+ end
61
+
62
+ # PROVIDER
63
+ unless sections['provider'] == nil
64
+ @env[:ui].info("\n[Invade] #{machine.upcase}: Validating provider configuration...")
65
+ sleep 1 unless @env[:invade_command_quiet]
66
+
67
+ sections['provider'].each do |type, provider|
68
+ @env[:ui].info("\tProvider: #{type}")
69
+ case type
70
+ when 'virtualbox'
71
+ provider = Validator::Provider::VirtualBox.new(env, provider).validate
72
+ when 'vmware'
73
+ provider = Validator::Provider::VMware.new(env, provider).validate
74
+ else
75
+ raise StandardError, "Provider unknown or not set. Please check configuration file."
76
+ end
77
+ end
78
+ end
79
+
80
+ # SYNCED FOLDER
81
+ unless sections['synced_folder'] == nil
82
+ @env[:ui].info("\n[Invade] #{machine.upcase}: Validating synced folder configuration...")
83
+ sleep 1 unless @env[:invade_command_quiet]
84
+
85
+ sections['synced_folder'].each do |type, sf|
86
+ @env[:ui].info("\tSynced Folder: #{type}")
87
+ case type
88
+ when 'nfs'
89
+ sf = Validator::SyncedFolder::NFS.new(env, sf).validate
90
+ when 'vb'
91
+ sf = Validator::SyncedFolder::VB.new(env, sf).validate
92
+ else
93
+ raise StandardError, "Synced Folder type unknown or not set. Please check configuration file."
94
+ end
95
+ end
96
+ end
97
+
98
+ # PROVISION
99
+ unless sections['provision'] == nil
100
+ @env[:ui].info("\n[Invade] #{machine.upcase}: Validating provision configuration...")
101
+ sleep 1 unless @env[:invade_command_quiet]
102
+
103
+ sections['provision'].each do |type, provision|
104
+ @env[:ui].info("\tProvision: #{type}")
105
+ case type
106
+ when 'shell'
107
+ provision = Validator::Provision::Shell.new(env, provision).validate
108
+ when 'puppet'
109
+ provision = Validator::Provision::Puppet.new(env, provision).validate
110
+ else
111
+ raise StandardError, "Provision type unknown or not set. Please check configuration file."
112
+ end
113
+ end
114
+ end
115
+
116
+ # SSH
117
+ unless sections['ssh'] == nil
118
+ @env[:ui].info("\n[Invade] #{machine.upcase}: Validating SSH configuration...")
119
+ sleep 1 unless @env[:invade_command_quiet]
120
+
121
+ sections['ssh'] = Validator::SSH.new(env, sections['ssh']).validate
122
+ end
123
+
124
+ unless sections['plugin'] == nil
125
+ @env[:ui].info("\n[Invade] #{machine.upcase}: Validating plugin configuration...")
126
+ sleep 1 unless @env[:invade_command_quiet]
127
+
128
+ sections['plugin'].each do |type, plugin|
129
+ @env[:ui].info("\tPlugin: #{type}")
130
+ case type
131
+ when 'hostmanager'
132
+ plugin = Validator::Plugin::HostManager.new(env, plugin).validate
133
+ when 'winnfsd'
134
+ plugin = Validator::Plugin::WinNFSd.new(env, plugin).validate
135
+ else
136
+ raise StandardError, "Plugin type unknown or not set. Please check configuration file."
137
+ end
138
+ end
139
+ end
140
+
141
+ end
142
+ end
143
+
144
+ if Validator::VALIDATION_ERRORS > 0
145
+ @env[:ui].warn('[Invade] Configuration has validation warnings. Use debug mode to see details.')
146
+ else
147
+ @env[:ui].success('[Invade] Configuration validated successfully.')
148
+ end
149
+
150
+ @app.call(env)
151
+ end
152
+
153
+ end
154
+ end
155
+ end
156
+ end
@@ -0,0 +1,34 @@
1
+ require 'pathname'
2
+ require 'vagrant/action/builder'
3
+
4
+ module VagrantPlugins
5
+ module Invade
6
+ module Action
7
+
8
+ # This middleware sequence will only validate the invade configuration file
9
+ def self.validate
10
+ Vagrant::Action::Builder.new.tap do |builder|
11
+ builder.use Config
12
+ builder.use Validate
13
+ end
14
+ end
15
+
16
+ # This middleware sequence will validate and build the Vagrantfile
17
+ def self.build
18
+ Vagrant::Action::Builder.new.tap do |builder|
19
+ builder.use Config
20
+ builder.use Validate
21
+ builder.use Generate
22
+ builder.use Create
23
+ end
24
+ end
25
+
26
+ # The autoload farm
27
+ action_root = Pathname.new(File.expand_path("../action", __FILE__))
28
+ autoload :Config, action_root.join("config")
29
+ autoload :Validate, action_root.join("validate")
30
+ autoload :Generate, action_root.join("generate")
31
+ autoload :Create, action_root.join("create")
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,43 @@
1
+ module VagrantPlugins
2
+ module Invade
3
+ module Builder
4
+
5
+ require 'erubis'
6
+
7
+ class Definition
8
+
9
+ attr_reader :result
10
+ attr_accessor :definition_data
11
+
12
+ def initialize(machine_name, definition_data, result: nil)
13
+ @machine_name = machine_name
14
+ @definition_data = definition_data
15
+ @result = result
16
+ end
17
+
18
+ def build
19
+ b = binding
20
+ template_file = "#{TEMPLATE_PATH}/definition.erb"
21
+
22
+ begin
23
+
24
+ # Machine name
25
+ machine_name = @machine_name
26
+
27
+ # Data to build definition entry
28
+ vm = @definition_data['vm']
29
+ network = @definition_data['network']
30
+ provider = @definition_data['provider']
31
+ synced_folder = @definition_data['synced_folder']
32
+ # provision = @definition_data['provision']
33
+
34
+ eruby = Erubis::Eruby.new(File.read(template_file))
35
+ @result = eruby.result b
36
+ rescue TypeError, SyntaxError, SystemCallError => e
37
+ raise(e)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,47 @@
1
+ module VagrantPlugins
2
+ module Invade
3
+ module Builder
4
+ module Network
5
+ require 'erubis'
6
+
7
+ class ForwardedPort
8
+
9
+ attr_reader :result
10
+ attr_accessor :machine_name, :forwarded_port_data
11
+
12
+ def initialize(machine_name, forwarded_port_data, result: nil)
13
+ @machine_name = machine_name
14
+ @forwarded_port_data = forwarded_port_data
15
+ @result = result
16
+ end
17
+
18
+ def build
19
+ b = binding
20
+ template_file = "#{TEMPLATE_PATH}/network/forwarded_port.erb"
21
+
22
+ begin
23
+
24
+ # Get machine name
25
+ machine_name = @machine_name
26
+
27
+ # Values for network section
28
+ ip = @forwarded_port_data['ip']
29
+ dhcp = @forwarded_port_data['dhcp']
30
+ guest = @forwarded_port_data['guest']
31
+ guest_ip = @forwarded_port_data['guest_ip']
32
+ host = @forwarded_port_data['host']
33
+ host_ip = @forwarded_port_data['host_ip']
34
+ protocol = @forwarded_port_data['protocol']
35
+ auto_correct = @forwarded_port_data['auto_correct']
36
+
37
+ eruby = Erubis::Eruby.new(File.read(template_file))
38
+ @result = eruby.result b
39
+ rescue TypeError, SyntaxError, SystemCallError => e
40
+ raise(e)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,41 @@
1
+ module VagrantPlugins
2
+ module Invade
3
+ module Builder
4
+ module Network
5
+ require 'erubis'
6
+
7
+ class PrivateNetwork
8
+
9
+ attr_reader :result
10
+ attr_accessor :machine_name, :private_network_data
11
+
12
+ def initialize(machine_name, private_network_data, result: nil)
13
+ @machine_name = machine_name
14
+ @private_network_data = private_network_data
15
+ @result = result
16
+ end
17
+
18
+ def build
19
+ b = binding
20
+ template_file = "#{TEMPLATE_PATH}/network/private_network.erb"
21
+
22
+ begin
23
+ # Get machine name
24
+ machine_name = @machine_name
25
+
26
+ # Values for network section
27
+ ip = @private_network_data['ip']
28
+ ip ? dhcp = nil : dhcp = @private_network_data['dhcp']
29
+ auto_config = @private_network_data['auto_config']
30
+
31
+ eruby = Erubis::Eruby.new(File.read(template_file))
32
+ @result = eruby.result b
33
+ rescue TypeError, SyntaxError, SystemCallError => e
34
+ raise(e)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,43 @@
1
+ module VagrantPlugins
2
+ module Invade
3
+ module Builder
4
+ module Network
5
+ require 'erubis'
6
+
7
+ class PublicNetwork
8
+
9
+ attr_reader :result
10
+ attr_accessor :machine_name, :public_network_data
11
+
12
+ def initialize(machine_name, public_network_data, result: nil)
13
+ @machine_name = machine_name
14
+ @public_network_data = public_network_data
15
+ @result = result
16
+ end
17
+
18
+ def build
19
+ b = binding
20
+ template_file = "#{TEMPLATE_PATH}/network/public_network.erb"
21
+
22
+ begin
23
+
24
+ # Get machine name
25
+ machine_name = @machine_name
26
+
27
+ # Values for network section
28
+ ip = @public_network_data['ip']
29
+ dhcp = @public_network_data['dhcp']
30
+ bridge = @public_network_data['bridge']
31
+ auto_config = @public_network_data['auto_config']
32
+
33
+ eruby = Erubis::Eruby.new(File.read(template_file))
34
+ @result = eruby.result b
35
+ rescue StandardError => e
36
+ raise(e)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,13 @@
1
+ module VagrantPlugins
2
+ module Invade
3
+ module Builder
4
+ module Network
5
+
6
+ autoload :ForwardedPort, 'vagrant-invade/builder/network/forwarded_port.rb'
7
+ autoload :PrivateNetwork, 'vagrant-invade/builder/network/private_network.rb'
8
+ autoload :PublicNetwork, 'vagrant-invade/builder/network/public_network.rb'
9
+
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,47 @@
1
+ module VagrantPlugins
2
+ module Invade
3
+ module Builder
4
+ module Provider
5
+
6
+ require 'erubis'
7
+
8
+ class VirtualBox
9
+
10
+ attr_reader :result
11
+ attr_accessor :machine_name, :virtualbox_data
12
+
13
+ def initialize(machine_name, virtualbox_data, result: nil)
14
+ @machine_name = machine_name
15
+ @virtualbox_data = virtualbox_data
16
+ @result = result
17
+ end
18
+
19
+ def build
20
+ b = binding
21
+ template_file = "#{TEMPLATE_PATH}/provider/virtualbox.erb"
22
+
23
+ begin
24
+
25
+ # Get machine name
26
+ machine_name = @machine_name
27
+
28
+ # Values for provider section
29
+ @virtualbox_data['name'] ? name = @virtualbox_data['name'] : name = @machine_name
30
+ type = @virtualbox_data['type']
31
+ cpus = @virtualbox_data['cores']
32
+ memory = @virtualbox_data['memory']
33
+ nicspeed = @virtualbox_data['nicspeed']
34
+ natdns = @virtualbox_data['natdns']
35
+
36
+ eruby = Erubis::Eruby.new(File.read(template_file))
37
+ @result = eruby.result b
38
+ rescue TypeError, SyntaxError, SystemCallError => e
39
+ raise(e)
40
+ end
41
+ end
42
+ end
43
+
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,44 @@
1
+ module VagrantPlugins
2
+ module Invade
3
+ module Builder
4
+ module Provider
5
+
6
+ require 'erubis'
7
+
8
+ class VMware
9
+
10
+ attr_reader :result
11
+ attr_accessor :machine_name, :vmware_data
12
+
13
+ def initialize(machine_name, vmware_data, result: nil)
14
+ @machine_name = machine_name
15
+ @vmware_data = vmware_data
16
+ @result = result
17
+ end
18
+
19
+ def build
20
+ b = binding
21
+ template_file = "#{TEMPLATE_PATH}/provider/vmware.erb"
22
+
23
+ begin
24
+
25
+ # Get machine name
26
+ machine_name = @machine_name
27
+
28
+ # Values for provider section
29
+ @vmware_data['name'] ? name = @vmware_data['name'] : name = @machine_name
30
+ cpus = @vmware_data['cores']
31
+ memory = @vmware_data['memory']
32
+
33
+ eruby = Erubis::Eruby.new(File.read(template_file))
34
+ @result = eruby.result b
35
+ rescue TypeError, SyntaxError, SystemCallError => e
36
+ raise(e)
37
+ end
38
+ end
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,12 @@
1
+ module VagrantPlugins
2
+ module Invade
3
+ module Builder
4
+ module Provider
5
+
6
+ autoload :VirtualBox, 'vagrant-invade/builder/provider/virtualbox.rb'
7
+ autoload :VMware, 'vagrant-invade/builder/provider/vmware.rb'
8
+
9
+ end
10
+ end
11
+ end
12
+ end