Fix bind IP config for REST 86/63286/4
authorTim Rozet <trozet@redhat.com>
Tue, 19 Sep 2017 13:45:21 +0000 (09:45 -0400)
committerTim Rozet <trozet@redhat.com>
Tue, 19 Sep 2017 18:25:51 +0000 (14:25 -0400)
Changes bind ip to be set as a default attribute rather than value and
also configures pax web cfg as recommended in
https://bugs.opendaylight.org/show_bug.cgi?id=9158

Note explicitly configuring 0.0.0.0 does not work so if default we skip
configuring bind IP and it defaults to 0.0.0.0.

Also increases sleep before curling REST in acceptance tests because
Karaf 4 takes longer to boot.

Change-Id: I23e7b1d501c782d5d1df0aa6d8b3e6cac9540de7
Signed-off-by: Tim Rozet <trozet@redhat.com>
.gitignore
manifests/config.pp
spec/acceptance/class_spec.rb
spec/classes/opendaylight_spec.rb
spec/spec_helper.rb
spec/spec_helper_acceptance.rb

index 96d1f9c03bb0c6873210efdcadf006fcef2ffea3..9f9ccf756f2b28d0d233411fdea3842f7426e199 100644 (file)
@@ -8,3 +8,4 @@ vendor
 Gemfile.lock
 *.log
 *.tox
+.idea/**
index f5089999988285f3650db369ae5839225a129360..373b8ad688edc9ee1d20eb270ca96c40d762e938 100644 (file)
@@ -19,17 +19,38 @@ class opendaylight::config {
     match => '^featuresBoot=.*$',
   }
 
-  # Configuration of ODL NB REST port and IP to listen on
-  augeas {'jetty.xml':
+  # Configuration of ODL NB REST port to listen on
+  augeas {'ODL REST Port':
     incl    => '/opt/opendaylight/etc/jetty.xml',
     context => '/files/opt/opendaylight/etc/jetty.xml/Configure',
     lens    => 'Xml.lns',
     changes => [
-      "set Call[2]/Arg/New/Set[#attribute[name='port']]/Property/#attribute/default ${opendaylight::odl_rest_port}",
-      "set Call[1]/Arg/New/Set[#attribute[name='host']]/#text[1] ${opendaylight::odl_bind_ip}",
-      "rm Call[1]/Arg/New/Set[#attribute[name='host']]/Property",
-      "set Call[2]/Arg/New/Set[#attribute[name='host']]/#text[1] ${opendaylight::odl_bind_ip}",
-      "rm Call[2]/Arg/New/Set[#attribute[name='host']]/Property"]
+      "set Call[2]/Arg/New/Set[#attribute[name='port']]/Property/#attribute/default ${opendaylight::odl_rest_port}"]
+  }
+
+  if $opendaylight::odl_bind_ip != '0.0.0.0' {
+    # Configuration of ODL NB REST IP to listen on
+    augeas { 'ODL REST IP':
+      incl    => '/opt/opendaylight/etc/jetty.xml',
+      context => '/files/opt/opendaylight/etc/jetty.xml/Configure',
+      lens    => 'Xml.lns',
+      changes => [
+        "set Call[1]/Arg/New/Set[#attribute[name='host']]/Property/#attribute/default ${opendaylight::odl_bind_ip}",
+        "set Call[2]/Arg/New/Set[#attribute[name='host']]/Property/#attribute/default ${opendaylight::odl_bind_ip}"]
+    }
+
+    file { 'org.ops4j.pax.web.cfg':
+      ensure => file,
+      path   => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
+      # Set user:group owners
+      owner  => 'odl',
+      group  => 'odl',
+    }
+    -> file_line { 'org.ops4j.pax.web.cfg':
+      ensure => present,
+      path   => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
+      line   => "org.ops4j.pax.web.listening.addresses = ${opendaylight::odl_bind_ip}"
+    }
   }
 
   # Set any custom log levels
index 384ea8a6b058b2f41f58de03299626becec86dfa..df3bc4b96ee28ebebaa0b600f3538e929632078f 100644 (file)
@@ -160,10 +160,11 @@ describe 'opendaylight class' do
   end
 
   describe 'testing odl username/password' do
+    bind_ip = '127.0.0.1'
     context 'using default username/password' do
-    context 'using default log levels' do
+    context 'using non-default bind ip' do
       # Call specialized helper fn to install OpenDaylight
-      install_odl({:extra_features => ['odl-restconf']})
+      install_odl({:odl_bind_ip => bind_ip, :extra_features => ['odl-restconf']})
 
       # Call specialized helper fn for username/password validations
       username_password_validations
index eb4910da0949d84c1271f63936ae348b167fde14..e591fbb8a0f6de31e05db1b8b2ed03704d61f6cd 100644 (file)
@@ -351,7 +351,7 @@ describe 'opendaylight' do
       odl_rest_port_tests
     end
 
-    context 'overriding default REST port' do
+    context 'overriding default REST and IP port' do
       let(:facts) {{
         :osfamily => osfamily,
         :operatingsystem => operatingsystem,
@@ -360,6 +360,7 @@ describe 'opendaylight' do
 
       let(:params) {{
         :odl_rest_port => 7777,
+        :odl_bind_ip => '127.0.0.1'
       }}
 
       # Run shared tests applicable to all supported OSs
@@ -368,7 +369,7 @@ describe 'opendaylight' do
 
       # Run test that specialize in checking ODL REST port config
       # Note that this function is defined in spec_helper
-      odl_rest_port_tests(odl_rest_port: 7777)
+      odl_rest_port_tests(odl_rest_port: 7777, odl_bind_ip: '127.0.0.1')
     end
   end
 
index 1726a30cb9544c21a11a608234b3f4a139888484..a30c70870bbc75ed2a9af109129ea0d2a7d968de 100644 (file)
@@ -118,13 +118,27 @@ def odl_rest_port_tests(options = {})
   # NB: This default value should be the same as one in opendaylight::params
   # TODO: Remove this possible source of bugs^^
   odl_rest_port = options.fetch(:odl_rest_port, 8080)
-
+  odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0')
   # Confirm properties of ODL REST port config file
   # NB: These hashes don't work with Ruby 1.8.7, but we
   #   don't support 1.8.7 so that's okay. See issue #36.
   it {
-    should contain_augeas('jetty.xml')
+    should contain_augeas('ODL REST Port')
   }
+
+  if not odl_bind_ip.eql? '0.0.0.0'
+    it {
+      should contain_augeas('ODL REST IP')
+      should contain_file_line('org.ops4j.pax.web.cfg').with(
+        'path'  => '/opt/opendaylight/etc/org.ops4j.pax.web.cfg',
+        'line'  => "org.ops4j.pax.web.listening.addresses = #{odl_bind_ip}",
+      )
+    }
+  else
+    it {
+      should_not contain_augeas('ODL REST IP')
+    }
+  end
 end
 
 def log_level_tests(options = {})
index 44d70eaa8c02bfc10088056bf9d07cb90a8efdad..04cf2b5e41d94476242c7ae8a6591199d8d71854 100644 (file)
@@ -383,7 +383,7 @@ def username_password_validations(options = {})
     it { should be_file }
   end
 
-  describe command("sleep 60 && curl -o /dev/null --fail --silent --head -u #{odl_username}:#{odl_password} #{odl_check_url}") do
+  describe command("sleep 180 && curl -o /dev/null --fail --silent --head -u #{odl_username}:#{odl_password} #{odl_check_url}") do
     its(:exit_status) { should eq 0 }
   end
 end