bin/nsa in wakame-vdc-agents-11.06.0 vs bin/nsa in wakame-vdc-agents-11.12.0

- old
+ new

@@ -44,14 +44,14 @@ "--addn-hosts=%s --dhcp-hostsfile=%s --conf-file=%s", config_section.dhcp_hosts_conf + ".hosts", config_section.dhcp_hosts_conf + ".dhcp", config_section.dhcp_hosts_conf ) - cmd = "#{manifest.config.dnsmasq_bin_path} #{opts}" + @cmd = "#{manifest.config.dnsmasq_bin_path} #{opts}" @dnsmasq_pid = fork { - Process.exec(cmd) + Process.exec(@cmd) } begin if !Process.waitpid(@dnsmasq_pid, Process::WNOHANG).nil? abort("dnsmasq is terminated unexpectedly") end @@ -61,12 +61,12 @@ myinstance.refresh_dnsmasq_conf event = Isono::NodeModules::EventChannel.new(node) - event.subscribe('hva/instance_started', '#') do |args| - logger.info("refresh on instance_started: #{args.inspect}") + event.subscribe('instance.scheduled', '#') do |args| + logger.info("refresh on instance.scheduled: #{args.inspect}") myinstance.refresh_dnsmasq_conf end event.subscribe('hva/instance_terminated', '#') do |args| logger.info("refresh on instance_terminated: #{args.inspect}") @@ -81,11 +81,17 @@ def refresh_dnsmasq_conf EM.defer { begin generate_dhcp_conf() - system("/bin/kill -HUP #{@dnsmasq_pid}") + if Process.waitpid(@dnsmasq_pid, Process::WNOHANG).nil? + system("/bin/kill -HUP #{@dnsmasq_pid}") + else + @dnsmasq_pid = fork { + Process.exec(@cmd) + } + end logger.info("refreshed dnsmasq conf") rescue Exception => e logger.error(e) end } @@ -110,11 +116,15 @@ dhcp-option=tag:<%= nwid %>,option:domain-name,<%= v[:domain_name] %> #dhcp-option=tag:<%= nwid %>,option:domain-search,<%= v[:domain_name] %> <%- else # if @conf_ver_253 -%> dhcp-range=net:<%= nwid %>,<%= v[:ipv4_first] %>,static,<%= v[:netmask] %> dhcp-option=<%= nwid %>,option:netmask,<%= v[:netmask] %> +<%- if not v[:ipv4_gw].nil? -%> dhcp-option=<%= nwid %>,option:router,<%= v[:ipv4_gw] %> +<%- end -%> +<%- if not v[:dns_server].nil? -%> dhcp-option=<%= nwid %>,option:dns-server,<%= v[:dns_server] %> +<%- end -%> dhcp-option=<%= nwid %>,option:domain-name,<%= v[:domain_name] %> #dhcp-option=<%= nwid %>,option:domain-search,<%= v[:domain_name] %> <%- end # if @conf_ver_253 -%> <%- v[:mac2addr].each { |i| -%> #dhcp-host=<%= i[:mac_addr] %>,net:<%= nwid %>,<%= i[:ipaddr] %>