Fix websockets ip address config 77/66777/10
authorMoshe Levi <moshele@mellanox.com>
Wed, 27 Dec 2017 14:49:29 +0000 (16:49 +0200)
committerTim Rozet <trozet@redhat.com>
Thu, 4 Jan 2018 19:31:12 +0000 (19:31 +0000)
Opendaylight master commit 96914ace4fd625d9a9c89ec49ddeb411fff180b9
uses restconf.cfg to config the websockets ip address.
Opendaylight carbon comiit a6bd56636d246fddcfbbef60277d77d3a7663b46
uses 10-rest-connector.xml to config the websockets ip address.

Commit 168424499efb9c7ed35bf627c417f323164682fa
allow to configure websocket ip address, but for
carbon release. This patch fix it to be
correct to master to configure the restconf.cfg instead
of 10-rest-connector.xml.

Change-Id: I304e15df5c7982283e843285c1910ae3c9a463cc
Signed-off-by: Moshe Levi <moshele@mellanox.com>
manifests/config.pp
spec/spec_helper.rb
spec/spec_helper_acceptance.rb
templates/10-rest-connector.xml.erb [deleted file]

index 7e9e5e0b018acc4071d26e7aef6d24bc2bb6fa28..2dc97fd151ae8cefaa79b6637f094012764982cd 100644 (file)
@@ -171,6 +171,20 @@ class opendaylight::config {
       line    => "org.ops4j.pax.web.listening.addresses = ${opendaylight::odl_bind_ip}",
       require => File['org.ops4j.pax.web.cfg']
     }
+
+    # Configure websocket address
+    file { '/opt/opendaylight/etc/org.opendaylight.restconf.cfg':
+      ensure => file,
+      path   => '/opt/opendaylight/etc/org.opendaylight.restconf.cfg',
+      owner  => 'odl',
+      group  => 'odl',
+    }
+    -> file_line { 'websocket-address':
+      ensure => present,
+      path   => '/opt/opendaylight/etc/org.opendaylight.restconf.cfg',
+      line   => "websocket-address=${::opendaylight::odl_bind_ip}",
+      match  => '^websocket-address=.*$',
+    }
   }
 
   # Set any custom log levels
@@ -317,14 +331,4 @@ class opendaylight::config {
     password => $::opendaylight::password,
     before   => Service['opendaylight'],
   }
-
-  # Configure websocket address
-  file { '10-rest-connector.xml':
-    ensure  => file,
-    path    => '/opt/opendaylight/etc/opendaylight/karaf/10-rest-connector.xml',
-    owner   => 'odl',
-    group   => 'odl',
-    content => template('opendaylight/10-rest-connector.xml.erb'),
-    require => File['/opt/opendaylight/etc/opendaylight/karaf'],
-  }
 }
index d0a2acb5322219364d78a6fabf0f75e7c5f8143a..d8cea47121444866f6c0d26830a70094bbba49ce 100644 (file)
@@ -427,15 +427,28 @@ def odl_websocket_address_tests(options = {})
   # 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_file('10-rest-connector.xml').with(
-      'ensure'      => 'file',
-      'path'        => '/opt/opendaylight/etc/opendaylight/karaf/10-rest-connector.xml',
-      'owner'   => 'odl',
-      'group'   => 'odl',
-      'content'     =>  /<websocket-address>#{odl_bind_ip}<\/websocket-address>/
-    )
-  }
+
+  if not odl_bind_ip.eql? '0.0.0.0'
+    it {
+      should contain_file('/opt/opendaylight/etc/org.opendaylight.restconf.cfg').with(
+        'ensure'      => 'file',
+        'path'        => '/opt/opendaylight/etc/org.opendaylight.restconf.cfg',
+        'owner'   => 'odl',
+        'group'   => 'odl',
+      )
+    }
+    it {
+        should contain_file_line('websocket-address').with(
+          'path'    => '/opt/opendaylight/etc/org.opendaylight.restconf.cfg',
+          'line'    => "websocket-address=#{odl_bind_ip}",
+          'match'   => '^websocket-address=.*$',
+      )
+    }
+  else
+    it {
+      should_not contain_file_line('websocket-address')
+    }
+  end
 end
 
 def odl_tls_tests(options = {})
index 0f3d80738b7d86bba7ae3e642a34d6f4da7d79fb..d7af31ffb430d165180202c6988e148c903ef92c 100644 (file)
@@ -445,11 +445,17 @@ def websocket_address_validations(options = {})
   # TODO: Remove this possible source of bugs^^
   odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0')
 
-  describe file('/opt/opendaylight/etc/opendaylight/karaf/10-rest-connector.xml') do
-    it { should be_file }
-    it { should be_owned_by 'odl' }
-    it { should be_grouped_into 'odl' }
-    its(:content) { should match /<websocket-address>#{odl_bind_ip}<\/websocket-address>/ }
+  if not odl_bind_ip.eql? '0.0.0.0'
+    describe file('/opt/opendaylight/etc/org.opendaylight.restconf.cfg') do
+      it { should be_file }
+      it { should be_owned_by 'odl' }
+      it { should be_grouped_into 'odl' }
+      its(:content) { should match /^websocket-address=#{odl_bind_ip}/ }
+    end
+  else
+    describe file('/opt/opendaylight/etc/org.opendaylight.restconf.cfg') do
+      it { should be_file }
+    end
   end
 end
 
diff --git a/templates/10-rest-connector.xml.erb b/templates/10-rest-connector.xml.erb
deleted file mode 100644 (file)
index 3a5d6cf..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
-
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0 which accompanies this distribution,
-and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<snapshot>
-  <configuration>
-    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
-      <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-        <!-- default OF-switch-connection-provider (port 6633) -->
-        <module>
-          <type xmlns:rest="urn:opendaylight:params:xml:ns:yang:controller:md:sal:rest:connector">rest:rest-connector-impl</type>
-          <name>rest-connector-default-impl</name>
-          <websocket-address><%= scope.lookupvar('opendaylight::odl_bind_ip') %></websocket-address>
-          <websocket-port>8185</websocket-port>
-          <dom-broker>
-            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
-            <name>dom-broker</name>
-          </dom-broker>
-        </module>
-      </modules>
-
-      <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-        <service>
-          <type xmlns:rest="urn:opendaylight:params:xml:ns:yang:controller:md:sal:rest:connector">rest:rest-connector</type>
-          <instance>
-            <name>rest-connector-default</name>
-            <provider>
-              /modules/module[type='rest-connector-impl'][name='rest-connector-default-impl']
-            </provider>
-          </instance>
-        </service>
-      </services>
-    </data>
-  </configuration>
-  <required-capabilities>
-      <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:rest:connector?module=opendaylight-rest-connector&amp;revision=2014-07-24</capability>
-  </required-capabilities>
-</snapshot>
\ No newline at end of file