vagrant-vmware-dhcp 0.0.2 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a870444e4958940d62c99dc53976515823d5626
4
- data.tar.gz: d794239606d79b0c19e9912f9d3c261b1aa25509
3
+ metadata.gz: 627b3ac504a958a623599945dd706121b4e4d558
4
+ data.tar.gz: 0167b871cbd3af221471245097e322d66eb9f12a
5
5
  SHA512:
6
- metadata.gz: a01346653754d4e6109f1fe60b91bb3a0803d92d188a5e297c20d85a9c867d5e862cb1bc8afa4bebbe711b5b330d04714261d4defbca2fd8c7f1b462eb9b7d70
7
- data.tar.gz: 440f762251a8db57d251439b2111bf4ed1c3eaff9f20398793616c847a1d92f752d04b0188c44e4f60f54c4cc8a47db51d5f8ce30245bbc2933eaab1d82e88a4
6
+ metadata.gz: c2fd55f82159162eada877583665ee6094d60e002f715018572c39c2e6599baa5092fa4ac3e1c09129e32f8647afcf86fb44b5c230d43a4926ca878be992d51b
7
+ data.tar.gz: 08b14de6bfc80cc1545c54779e77535cdeceaa7486f5b111d8e83878e1b081d10ea7e0019e49f3db3964626c594c80e42a5981b9e4621a35dd9ad1c3158e7f4e
@@ -16,10 +16,10 @@ module VagrantPlugins
16
16
  @env = env
17
17
 
18
18
  if @env[:machine]
19
- @logger.info("In config_dhcp provider_name is #{@env[:machine].provider_name}")
19
+ @logger.debug("In config_dhcp provider_name is #{@env[:machine].provider_name}")
20
20
 
21
- # or env[:machine].provider_name == :vmware_desktop
22
- if @env[:machine].provider_name == :vmware_fusion
21
+ # or env[:machine].provider_name == :vmware_workstation
22
+ if @env[:machine].provider_name == :vmware_fusion or @env[:machine].provider_name == :vmware_workstation
23
23
  configure_dhcp
24
24
  end
25
25
  end
@@ -101,12 +101,6 @@ module VagrantPlugins
101
101
  network_map
102
102
  end
103
103
 
104
- def guess_dhcpd_conf_location(network)
105
- @logger.debug("Using dhcpd.conf at #{network[:vnet]}")
106
- location = "/Library/Preferences/VMware Fusion/#{network[:vnet]}/dhcpd.conf"
107
- return location
108
- end
109
-
110
104
  def apply_static_dhcp_config(machine, network_map)
111
105
 
112
106
  network_map.each {
@@ -124,32 +118,7 @@ module VagrantPlugins
124
118
 
125
119
  end
126
120
 
127
- def prune_dhcpd_conf(network)
128
- conf_location = guess_dhcpd_conf_location(network)
129
- escaped_conf_location = Vagrant::Util::ShellQuote.escape(conf_location, "'")
130
-
131
- mac = network[:mac]
132
-
133
- command = []
134
- command << "sudo" if !File.writable?(conf_location)
135
- command += [
136
- "sed", "-E", "-e",
137
- "/^# VAGRANT-BEGIN: #{mac}/," +
138
- "/^# VAGRANT-END: #{mac}/ d",
139
- "-ibak",
140
- conf_location
141
- ]
142
-
143
- system(*command)
144
- end
145
-
146
- def write_dhcpd_conf(network)
147
- conf_location = guess_dhcpd_conf_location(network)
148
- escaped_conf_location = Vagrant::Util::ShellQuote.escape(conf_location, "'")
149
-
150
- sudo_command = ""
151
- sudo_command = "sudo " if !File.writable?(conf_location)
152
-
121
+ def get_dhcpd_section(network)
153
122
  netname = [network[:vnet], network[:ip].gsub(/\./, '_')].join('_')
154
123
 
155
124
  output = Vagrant::Util::TemplateRenderer.render('dhcpd_static',
@@ -159,41 +128,24 @@ module VagrantPlugins
159
128
  name: netname,
160
129
  template_root: VagrantPlugins::VagrantVmwareDhcp.source_root().join("templates")
161
130
  )
162
-
163
- @logger.debug("DHCPD template for interface #{network[:vnet]} is #{output}")
164
-
165
- before = File.open(conf_location).read
166
- @logger.debug("Before altering, dhcpd.conf content is #{before}")
167
-
168
- output.split("\n").each do |line|
169
- line = Vagrant::Util::ShellQuote.escape(line, "'")
170
- system(%Q[echo '#{line}' | #{sudo_command}tee -a '#{escaped_conf_location}' >/dev/null])
171
- end
172
-
173
- after = File.open(conf_location).read
174
- @logger.debug("After, dhcpd.conf content is #{after}")
131
+ return output
175
132
  end
176
133
 
177
- def trigger_dhcpd_update
178
- # Per http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1026510
179
-
180
- vmnet_cli = "/Applications/VMware Fusion.app/Contents/Library/vmnet-cli"
181
-
182
- configureCommand = [ "sudo", vmnet_cli, "--configure" ].flatten
183
- stopCommand = [ "sudo", vmnet_cli, "--stop" ].flatten
184
- startCommand = [ "sudo", vmnet_cli, "--start" ].flatten
185
- statusCommand = [ "sudo", vmnet_cli, "--status" ].flatten
186
-
187
- Vagrant::Util::Subprocess.execute(*configureCommand)
188
- Vagrant::Util::Subprocess.execute(*stopCommand)
189
- Vagrant::Util::Subprocess.execute(*startCommand)
190
- r = Vagrant::Util::Subprocess.execute(*statusCommand)
191
-
192
- if r.exit_code != 0
193
- @env[:ui].error("VMNet status exited with code #{r.exit_code} and output:\n#{r.stdout.chomp}")
194
- end
195
-
196
- end
134
+ # def prune_dhcpd_conf(network)
135
+ # raise "This should never happen!"
136
+ # end
137
+ #
138
+ # def dhcpd_conf_location(network)
139
+ # raise "This should never happen!"
140
+ # end
141
+ #
142
+ # def write_dhcpd_conf(network)
143
+ # raise "This should never happen!"
144
+ # end
145
+ #
146
+ # def trigger_dhcpd_update(network)
147
+ # raise "This should never happen!"
148
+ # end
197
149
 
198
150
  end
199
151
  end
@@ -0,0 +1,87 @@
1
+ require "log4r"
2
+ require "digest"
3
+
4
+ # Someone who's had some sleep recently is welcome to come fill in comments here...
5
+ module VagrantPlugins
6
+ module VagrantVmwareDhcp
7
+ module Action
8
+ class ConfigDhcpDarwin < ConfigDhcp
9
+
10
+ protected
11
+
12
+ def dhcpd_conf_location(network)
13
+ # Locations from https://pubs.vmware.com/workstation-9/index.jsp?topic=%2Fcom.vmware.ws.using.doc%2FGUID-04D783E1-3AB9-4D98-9891-2C58215905CC.html
14
+
15
+ location = "/Library/Preferences/VMware Fusion/#{network[:vnet]}/dhcpd.conf"
16
+
17
+ @logger.debug("Using dhcpd.conf at #{location}")
18
+
19
+ return location
20
+ end
21
+
22
+ def prune_dhcpd_conf(network)
23
+ conf_location = dhcpd_conf_location(network)
24
+ escaped_conf_location = Vagrant::Util::ShellQuote.escape(conf_location, "'")
25
+
26
+ mac = network[:mac]
27
+
28
+ command = []
29
+ command << "sudo" if !File.writable?(conf_location)
30
+ command += [
31
+ "sed", "-E", "-e",
32
+ "/^# VAGRANT-BEGIN: #{mac}/," +
33
+ "/^# VAGRANT-END: #{mac}/ d",
34
+ "-ibak",
35
+ conf_location
36
+ ]
37
+
38
+ system(*command)
39
+ end
40
+
41
+ def write_dhcpd_conf(network)
42
+ conf_location = dhcpd_conf_location(network)
43
+ escaped_conf_location = Vagrant::Util::ShellQuote.escape(conf_location, "'")
44
+
45
+ sudo_command = ""
46
+ sudo_command = "sudo " if !File.writable?(conf_location)
47
+
48
+ output = get_dhcpd_section(network)
49
+
50
+ @logger.debug("DHCPD template for interface #{network[:vnet]} is #{output}")
51
+
52
+ before = File.open(conf_location).read
53
+ @logger.debug("Before altering, dhcpd.conf content is #{before}")
54
+
55
+ output.split("\n").each do |line|
56
+ line = Vagrant::Util::ShellQuote.escape(line, "'")
57
+ system(%Q[echo '#{line}' | #{sudo_command}tee -a '#{escaped_conf_location}' >/dev/null])
58
+ end
59
+
60
+ after = File.open(conf_location).read
61
+ @logger.debug("After, dhcpd.conf content is #{after}")
62
+ end
63
+
64
+ def trigger_dhcpd_update
65
+ # Per http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1026510
66
+
67
+ vmnet_cli = "/Applications/VMware Fusion.app/Contents/Library/vmnet-cli"
68
+
69
+ configureCommand = [ "sudo", vmnet_cli, "--configure" ].flatten
70
+ stopCommand = [ "sudo", vmnet_cli, "--stop" ].flatten
71
+ startCommand = [ "sudo", vmnet_cli, "--start" ].flatten
72
+ statusCommand = [ "sudo", vmnet_cli, "--status" ].flatten
73
+
74
+ Vagrant::Util::Subprocess.execute(*configureCommand)
75
+ Vagrant::Util::Subprocess.execute(*stopCommand)
76
+ Vagrant::Util::Subprocess.execute(*startCommand)
77
+ r = Vagrant::Util::Subprocess.execute(*statusCommand)
78
+
79
+ if r.exit_code != 0
80
+ @env[:ui].error("VMNet status exited with code #{r.exit_code} and output:\n#{r.stdout.chomp}")
81
+ end
82
+
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,87 @@
1
+ require "log4r"
2
+ require "digest"
3
+
4
+ # Someone who's had some sleep recently is welcome to come fill in comments here...
5
+ module VagrantPlugins
6
+ module VagrantVmwareDhcp
7
+ module Action
8
+ class ConfigDhcpLinux < ConfigDhcp
9
+
10
+ protected
11
+
12
+ def dhcpd_conf_location(network)
13
+ # Locations from https://pubs.vmware.com/workstation-9/index.jsp?topic=%2Fcom.vmware.ws.using.doc%2FGUID-04D783E1-3AB9-4D98-9891-2C58215905CC.html
14
+
15
+ location = "/etc/vmware/#{network[:vnet]}/dhcp/dhcp.conf"
16
+
17
+ @logger.debug("Using dhcpd.conf at #{location}")
18
+
19
+ return location
20
+ end
21
+
22
+ def prune_dhcpd_conf(network)
23
+ conf_location = dhcpd_conf_location(network)
24
+ escaped_conf_location = Vagrant::Util::ShellQuote.escape(conf_location, "'")
25
+
26
+ mac = network[:mac]
27
+
28
+ command = []
29
+ command << "sudo" if !File.writable?(conf_location)
30
+ command += [
31
+ "sed", "-E", "-e",
32
+ "/^# VAGRANT-BEGIN: #{mac}/," +
33
+ "/^# VAGRANT-END: #{mac}/ d",
34
+ "-ibak",
35
+ conf_location
36
+ ]
37
+
38
+ system(*command)
39
+ end
40
+
41
+ def write_dhcpd_conf(network)
42
+ conf_location = dhcpd_conf_location(network)
43
+ escaped_conf_location = Vagrant::Util::ShellQuote.escape(conf_location, "'")
44
+
45
+ sudo_command = ""
46
+ sudo_command = "sudo " if !File.writable?(conf_location)
47
+
48
+ output = get_dhcpd_section(network)
49
+
50
+ @logger.debug("DHCPD template for interface #{network[:vnet]} is #{output}")
51
+
52
+ before = File.open(conf_location).read
53
+ @logger.debug("Before altering, dhcpd.conf content is #{before}")
54
+
55
+ output.split("\n").each do |line|
56
+ line = Vagrant::Util::ShellQuote.escape(line, "'")
57
+ system(%Q[echo '#{line}' | #{sudo_command}tee -a '#{escaped_conf_location}' >/dev/null])
58
+ end
59
+
60
+ after = File.open(conf_location).read
61
+ @logger.debug("After, dhcpd.conf content is #{after}")
62
+ end
63
+
64
+ def trigger_dhcpd_update
65
+ # Per http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1026510
66
+
67
+ vmnet_cli = "/Applications/VMware Fusion.app/Contents/Library/vmnet-cli"
68
+
69
+ configureCommand = [ "sudo", vmnet_cli, "--configure" ].flatten
70
+ stopCommand = [ "sudo", vmnet_cli, "--stop" ].flatten
71
+ startCommand = [ "sudo", vmnet_cli, "--start" ].flatten
72
+ statusCommand = [ "sudo", vmnet_cli, "--status" ].flatten
73
+
74
+ Vagrant::Util::Subprocess.execute(*configureCommand)
75
+ Vagrant::Util::Subprocess.execute(*stopCommand)
76
+ Vagrant::Util::Subprocess.execute(*startCommand)
77
+ r = Vagrant::Util::Subprocess.execute(*statusCommand)
78
+
79
+ if r.exit_code != 0
80
+ @env[:ui].error("VMNet status exited with code #{r.exit_code} and output:\n#{r.stdout.chomp}")
81
+ end
82
+
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,78 @@
1
+ require "log4r"
2
+ require "digest"
3
+
4
+ # Someone who's had some sleep recently is welcome to come fill in comments here...
5
+ module VagrantPlugins
6
+ module VagrantVmwareDhcp
7
+ module Action
8
+ class ConfigDhcpWindows < ConfigDhcp
9
+
10
+ protected
11
+
12
+ def dhcpd_conf_location(network)
13
+ # Locations from https://pubs.vmware.com/workstation-9/index.jsp?topic=%2Fcom.vmware.ws.using.doc%2FGUID-04D783E1-3AB9-4D98-9891-2C58215905CC.html
14
+
15
+ if File.exist?('c:\ProgramData\VMware\vmnetdhcp.conf')
16
+ location = 'C:\ProgramData\VMware\vmnetdhcp.conf'
17
+ elsif File.exist?('C:\Documents and Settings\All Users\Application Data\VMware\vmnetdhcp.conf')
18
+ location = 'C:\Documents and Settings\All Users\Application Data\VMware\vmnetdhcp.conf'
19
+ end
20
+
21
+ @logger.debug("Using dhcpd.conf at #{location}")
22
+
23
+ return location
24
+ end
25
+
26
+ def prune_dhcpd_conf(network)
27
+ conf_location = dhcpd_conf_location(network)
28
+
29
+ mac = network[:mac]
30
+
31
+ before = File.open(conf_location).read
32
+
33
+ @logger.debug("Before altering, dhcpd.conf content is #{before}")
34
+
35
+ after = before.gsub(/^# VAGRANT-BEGIN: #{mac}.*^# VAGRANT-END: #{mac}\s+/m, '')
36
+
37
+ File.open(conf_location, "w") { |fd| fd.write(after) }
38
+
39
+ after = File.open(conf_location).read
40
+ @logger.debug("After altering, dhcpd.conf content is #{after}")
41
+ end
42
+
43
+ def write_dhcpd_conf(network)
44
+ conf_location = dhcpd_conf_location(network)
45
+
46
+ section = get_dhcpd_section(network)
47
+
48
+ @logger.debug("DHCPD template for interface #{network[:vnet]} is #{section}")
49
+
50
+ before = File.open(conf_location).read
51
+ @logger.debug("Before altering, dhcpd.conf content is #{before}")
52
+
53
+ after = "#{before}\n\n#{section}\n"
54
+
55
+ File.open(conf_location, "w") { |fd| fd.write(after) }
56
+
57
+ after = File.open(conf_location).read
58
+ @logger.debug("After, dhcpd.conf content is #{after}")
59
+ end
60
+
61
+ def trigger_dhcpd_update
62
+ # This is non-authoritative, but is the obvious solution and seems to work.
63
+
64
+ stopCommand = [ "NET", "STOP", "VMware DHCP Service" ]
65
+ startCommand = [ "NET", "START", "VMware DHCP Service" ]
66
+
67
+ Vagrant::Util::Subprocess.execute(*stopCommand)
68
+ r = Vagrant::Util::Subprocess.execute(*startCommand)
69
+
70
+ if r.exit_code != 0
71
+ @env[:ui].error("VMNet dhcp start exited with code #{r.exit_code} and output:\n#{r.stdout.chomp}")
72
+ end
73
+
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -16,6 +16,10 @@ module VagrantPlugins
16
16
 
17
17
  machine = env[:machine]
18
18
 
19
+ # @env[:ui].error("Host is #{YAML::dump(env[:host].public_methods)}")
20
+
21
+ @env[:host].capability?("darwin")
22
+
19
23
  if machine
20
24
  set_mac_address(env)
21
25
  end
@@ -2,5 +2,8 @@ module AutoNetwork
2
2
  module Action
3
3
  require 'vagrant-vmware-dhcp/action/set_mac'
4
4
  require 'vagrant-vmware-dhcp/action/config_dhcp'
5
+ require 'vagrant-vmware-dhcp/action/config_dhcp_darwin'
6
+ require 'vagrant-vmware-dhcp/action/config_dhcp_linux'
7
+ require 'vagrant-vmware-dhcp/action/config_dhcp_windows'
5
8
  end
6
9
  end
@@ -14,9 +14,21 @@ module VagrantPlugins
14
14
  hook.before(action, VagrantVmwareDhcp::Action::SetMac)
15
15
  end
16
16
 
17
+
18
+
19
+ if Vagrant::Util::Platform.windows?
20
+ ConfigDhcpClass = VagrantVmwareDhcp::Action::ConfigDhcpWindows
21
+ ActionClass = HashiCorp::VagrantVMwaredesktop::Action::Network
22
+ elsif Vagrant::Util::Platform.linux?
23
+ ConfigDhcpClass = VagrantVmwareDhcp::Action::ConfigDhcpLinux
24
+ ActionClass = HashiCorp::VagrantVMwaredesktop::Action::Network
25
+ elsif Vagrant::Util::Platform.darwin?
26
+ ConfigDhcpClass = VagrantVmwareDhcp::Action::ConfigDhcpDarwin
27
+ ActionClass = HashiCorp::VagrantVMwarefusion::Action::Network
28
+ end
29
+
17
30
  action_hook('DA VMWare Network: Configure dhcp.conf') do |hook|
18
- action = HashiCorp::VagrantVMwarefusion::Action::Network
19
- hook.after(action, VagrantVmwareDhcp::Action::ConfigDhcp)
31
+ hook.after(ActionClass, ConfigDhcpClass)
20
32
  end
21
33
 
22
34
  # action_hook(:init_i18n, :environment_load) { init_i18n }
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module VagrantVmwareDhcp
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  end
data/shipit.sh ADDED
@@ -0,0 +1,9 @@
1
+ rvm use 2.0.0@da-vmware-network --create
2
+
3
+ rake build
4
+
5
+ cp pkg/* ~/gemrepo/gems/
6
+ (
7
+ cd ~/gemrepo/gems
8
+ gem generate_index
9
+ )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-vmware-dhcp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Israel Shirk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-14 00:00:00.000000000 Z
11
+ date: 2015-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -54,10 +54,14 @@ files:
54
54
  - lib/vagrant-vmware-dhcp.rb
55
55
  - lib/vagrant-vmware-dhcp/action.rb
56
56
  - lib/vagrant-vmware-dhcp/action/config_dhcp.rb
57
+ - lib/vagrant-vmware-dhcp/action/config_dhcp_darwin.rb
58
+ - lib/vagrant-vmware-dhcp/action/config_dhcp_linux.rb
59
+ - lib/vagrant-vmware-dhcp/action/config_dhcp_windows.rb
57
60
  - lib/vagrant-vmware-dhcp/action/set_mac.rb
58
61
  - lib/vagrant-vmware-dhcp/plugin.rb
59
62
  - lib/vagrant-vmware-dhcp/version.rb
60
63
  - locales/en.yml
64
+ - shipit.sh
61
65
  - spec/spec_helper.rb
62
66
  - spec/vagrant/vmware/dhcp_spec.rb
63
67
  - templates/dhcpd_static.erb