From 270b0cb7c77127e964468bbc39ec51c681b41ab8 Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Thu, 14 Jul 2016 13:48:35 +0200 Subject: [PATCH] [inspection] allow to configure HTTP port We currently allow changing the HTTP port for Ironic iPXE support, but we don't allow the same for ironic-inspector. This patch fixes it. Change-Id: I62effb9d0196474a3768ef7e80528f730df8a543 Closes-Bug: #1602976 --- manifests/inspector.pp | 5 +++++ spec/classes/ironic_inspector_spec.rb | 9 +++++++-- templates/inspector_dnsmasq_http.erb | 2 +- templates/inspector_ipxe.erb | 4 ++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/manifests/inspector.pp b/manifests/inspector.pp index 79f6fc1f..feee751b 100644 --- a/manifests/inspector.pp +++ b/manifests/inspector.pp @@ -162,6 +162,10 @@ # (optional) ipxe timeout in second. Should be an integer. # Defaults to '0' for unlimited. # +# [*http_port*] +# (optional) port used by the HTTP service serving introspection images. +# Defaults to 8088. +# class ironic::inspector ( $package_ensure = 'present', $enabled = true, @@ -199,6 +203,7 @@ class ironic::inspector ( $additional_processing_hooks = undef, $ramdisk_kernel_args = undef, $ipxe_timeout = 0, + $http_port = 8088, ) { include ::ironic::params diff --git a/spec/classes/ironic_inspector_spec.rb b/spec/classes/ironic_inspector_spec.rb index 09d4f91f..f7aca991 100644 --- a/spec/classes/ironic_inspector_spec.rb +++ b/spec/classes/ironic_inspector_spec.rb @@ -48,7 +48,8 @@ describe 'ironic::inspector' do :swift_auth_url => 'http://127.0.0.1:5000/v2.0', :dnsmasq_ip_range => '192.168.0.100,192.168.0.120', :dnsmasq_local_ip => '192.168.0.1', - :ipxe_timeout => 0, } + :ipxe_timeout => 0, + :http_port => 8088, } end let :params do @@ -161,6 +162,7 @@ describe 'ironic::inspector' do :additional_processing_hooks => 'hook1,hook2', :ramdisk_kernel_args => 'foo=bar', :enable_uefi => true, + :http_port => 3816, ) end it 'should replace default parameter with new value' do @@ -181,6 +183,9 @@ describe 'ironic::inspector' do 'require' => 'Package[ironic-inspector]', 'content' => /ipxe/, ) + is_expected.to contain_file('/etc/ironic-inspector/dnsmasq.conf').with_content( + /dhcp-boot=tag:ipxe,http:\/\/192.168.0.1:3816\/inspector.ipxe/ + ) end it 'should contain file /httpboot/inspector.ipxe' do is_expected.to contain_file('/httpboot/inspector.ipxe').with( @@ -189,7 +194,7 @@ describe 'ironic::inspector' do 'content' => /ipxe/, ) is_expected.to contain_file('/httpboot/inspector.ipxe').with_content( - /kernel http:\/\/192.168.0.1:8088\/agent.kernel ipa-inspection-callback-url=http:\/\/192.168.0.1:5050\/v1\/continue ipa-inspection-collectors=default.* foo=bar || goto retry_boot/ + /kernel http:\/\/192.168.0.1:3816\/agent.kernel ipa-inspection-callback-url=http:\/\/192.168.0.1:5050\/v1\/continue ipa-inspection-collectors=default.* foo=bar || goto retry_boot/ ) end it 'should contain iPXE chainload images' do diff --git a/templates/inspector_dnsmasq_http.erb b/templates/inspector_dnsmasq_http.erb index 132a5f5b..9c797582 100644 --- a/templates/inspector_dnsmasq_http.erb +++ b/templates/inspector_dnsmasq_http.erb @@ -10,7 +10,7 @@ dhcp-match=ipxe,175 dhcp-match=set:efi,option:client-arch,7 <% end -%> # Client is running iPXE; move to next stage of chainloading -dhcp-boot=tag:ipxe,http://<%= @dnsmasq_local_ip %>:8088/inspector.ipxe +dhcp-boot=tag:ipxe,http://<%= @dnsmasq_local_ip %>:<%= @http_port %>/inspector.ipxe <% if @enable_uefi -%> # Client is running PXE over EFI; send EFI version of iPXE chainloader dhcp-boot=tag:efi,ipxe.efi diff --git a/templates/inspector_ipxe.erb b/templates/inspector_ipxe.erb index b1401660..5336b238 100644 --- a/templates/inspector_ipxe.erb +++ b/templates/inspector_ipxe.erb @@ -5,6 +5,6 @@ dhcp || goto retry_dhcp :retry_boot imgfree -kernel <% if @ipxe_timeout != "0" %>--timeout <%= Integer(@ipxe_timeout) * 1000 %> <% end %>http://<%= @dnsmasq_local_ip %>:8088/agent.kernel ipa-inspection-callback-url=http://<%= @dnsmasq_local_ip %>:5050/v1/continue ipa-inspection-collectors=<%= @ramdisk_collectors %> systemd.journald.forward_to_console=yes BOOTIF=${mac} <%= @ramdisk_kernel_args %> initrd=agent.ramdisk || goto retry_boot -initrd <% if @ipxe_timeout != "0" %>--timeout <%= Integer(@ipxe_timeout) * 1000 %> <% end %>http://<%= @dnsmasq_local_ip %>:8088/agent.ramdisk || goto retry_boot +kernel <% if @ipxe_timeout != "0" %>--timeout <%= Integer(@ipxe_timeout) * 1000 %> <% end %>http://<%= @dnsmasq_local_ip %>:<%= @http_port %>/agent.kernel ipa-inspection-callback-url=http://<%= @dnsmasq_local_ip %>:5050/v1/continue ipa-inspection-collectors=<%= @ramdisk_collectors %> systemd.journald.forward_to_console=yes BOOTIF=${mac} <%= @ramdisk_kernel_args %> initrd=agent.ramdisk || goto retry_boot +initrd <% if @ipxe_timeout != "0" %>--timeout <%= Integer(@ipxe_timeout) * 1000 %> <% end %>http://<%= @dnsmasq_local_ip %>:<%= @http_port %>/agent.ramdisk || goto retry_boot boot