Will use the already provided bind ip to also bind websocket listener.
Change-Id: Ia2084fd3e064f579d34ba7a60fec0df5b910e411
Signed-off-by: Tim Rozet <trozet@redhat.com>
Signed-off-by: Daniel Farrell <dfarrell@redhat.com>
- Only support stateful security mode. Remove all related configs
2017-11-15 Release 6.0.0
- Allow full customization of ODL RPM repo
+2017-11-17 Release 6.1.0
+- Configure websocket address
}
```
+### Configuring websocket address
+
+Websocket address can be configured to the IP of ODL rather than default 0.0.0.0. This IP will
+be defined by `odl_bind_ip`.
+
## Reference
### Classes
changes => [
"set Call[2]/Arg/New/Set[#attribute[name='port']]/Property/#attribute/default ${opendaylight::odl_rest_port}"]
}
+ $initial_config_dir = '/opt/opendaylight/configuration/initial'
+
+ file { $initial_config_dir:
+ ensure => directory,
+ mode => '0755',
+ owner => 'odl',
+ group => 'odl',
+ }
if $opendaylight::odl_bind_ip != '0.0.0.0' {
# Configuration of ODL NB REST IP to listen on
if $::opendaylight::enable_ha {
if $ha_node_count >= 2 {
# Configure ODL OSVDB Clustering
- $cluster_config_dir = '/opt/opendaylight/configuration/initial'
-
- file { $cluster_config_dir:
- ensure => directory,
- mode => '0755',
- owner => 'odl',
- group => 'odl',
- }
file {'akka.conf':
ensure => file,
- path => "${cluster_config_dir}/akka.conf",
+ path => "${initial_config_dir}/akka.conf",
owner => 'odl',
group => 'odl',
content => template('opendaylight/akka.conf.erb'),
- require => File[$cluster_config_dir]
+ require => File[$initial_config_dir]
}
file {'modules.conf':
ensure => file,
- path => "${cluster_config_dir}/modules.conf",
+ path => "${initial_config_dir}/modules.conf",
owner => 'odl',
group => 'odl',
content => template('opendaylight/modules.conf.erb'),
- require => File[$cluster_config_dir]
+ require => File[$initial_config_dir]
}
file {'module-shards.conf':
ensure => file,
- path => "${cluster_config_dir}/module-shards.conf",
+ path => "${initial_config_dir}/module-shards.conf",
owner => 'odl',
group => 'odl',
content => template('opendaylight/module-shards.conf.erb'),
- require => File[$cluster_config_dir]
+ require => File[$initial_config_dir]
}
} else {
}
}
+ $odl_dirs = [
+ '/opt/opendaylight/etc/opendaylight',
+ '/opt/opendaylight/etc/opendaylight/karaf',
+ '/opt/opendaylight/etc/opendaylight/datastore',
+ '/opt/opendaylight/etc/opendaylight/datastore/initial',
+ '/opt/opendaylight/etc/opendaylight/datastore/initial/config',
+ ]
+
+ file { $odl_dirs:
+ ensure => directory,
+ mode => '0755',
+ owner => 'odl',
+ group => 'odl',
+ }
+
if ('odl-netvirt-openstack' in $opendaylight::features or 'odl-netvirt-sfc' in $opendaylight::features) {
# Configure SNAT
- $odl_datastore = [
- '/opt/opendaylight/etc/opendaylight',
- '/opt/opendaylight/etc/opendaylight/datastore',
- '/opt/opendaylight/etc/opendaylight/datastore/initial',
- '/opt/opendaylight/etc/opendaylight/datastore/initial/config',
- ]
-
- file { $odl_datastore:
- ensure => directory,
- mode => '0755',
- owner => 'odl',
- group => 'odl',
- }
- -> file { 'netvirt-natservice-config.xml':
+
+ file { 'netvirt-natservice-config.xml':
ensure => file,
path => '/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-natservice-config.xml',
owner => 'odl',
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'],
+ }
}
{
"name": "opendaylight-opendaylight",
- "version": "6.0.0",
+ "version": "6.1.0",
"author": "Daniel Farrell",
"summary": "Puppet module that installs and configures the OpenDaylight SDN controller",
"license": "BSD-2-Clause",
sfc_validations
end
end
+
+ describe 'testing websocket address config' do
+ context 'using default ip' do
+ # Call specialized helper fn to install OpenDaylight
+ install_odl
+
+ # Call specialized helper fn for websocket address config validations
+ websocket_address_validations
+ end
+
+ context 'overriding default ip' do
+ # Call specialized helper fn to install OpenDaylight
+ install_odl(odl_bind_ip: '127.0.0.1')
+
+ # Call specialized helper fn for websocket address config validations
+ websocket_address_validations(odl_bind_ip: '127.0.0.1')
+ end
+ end
end
username_password_tests('test', 'test')
end
end
+
+ # websocket address tests
+ describe 'ODL websocket address tests' do
+ # Non-OS-type tests assume CentO
+ # See issue #43 for reasoning:
+ # https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
+ osfamily = 'RedHat'
+ operatingsystem = 'CentOS'
+ operatingsystemmajrelease = '7'
+ context 'using default websocket address' do
+ let(:facts) {{
+ :osfamily => osfamily,
+ :operatingsystem => operatingsystem,
+ :operatingsystemmajrelease => operatingsystemmajrelease,
+ }}
+
+ let(:params) {{ }}
+
+ # Run shared tests applicable to all supported OSs
+ # Note that this function is defined in spec_helper
+ generic_tests
+
+ # Run test that specialize in checking websocket address
+ # Note that this function is defined in spec_helper
+ odl_websocket_address_tests
+ end
+
+ context 'overriding websocket address' do
+ let(:facts) {{
+ :osfamily => osfamily,
+ :operatingsystem => operatingsystem,
+ :operatingsystemmajrelease => operatingsystemmajrelease,
+ }}
+
+ let(:params) {{
+ :odl_bind_ip => '127.0.0.1'
+ }}
+
+ # Run shared tests applicable to all supported OSs
+ # Note that this function is defined in spec_helper
+ generic_tests
+
+ # Run test that specialize in checking websocket address
+ # Note that this function is defined in spec_helper
+ odl_websocket_address_tests(odl_bind_ip: '127.0.0.1')
+ end
+ end
end
)
}
end
+
+# ODL websocket address tests
+def odl_websocket_address_tests(options = {})
+ # Extract params
+ # NB: This default value should be the same as one in opendaylight::params
+ # TODO: Remove this possible source of bugs^^
+ 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_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>/
+ )
+ }
+end
\ No newline at end of file
its(:content) { should match /<gpe-extension-enabled>true<\/gpe-extension-enabled>/ }
end
end
+
+def websocket_address_validations(options = {})
+ # NB: This param default should match the one used by the opendaylight
+ # class, which is defined in opendaylight::params
+ # 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>/ }
+ end
+end
--- /dev/null
+<?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&revision=2014-07-24</capability>
+ </required-capabilities>
+</snapshot>
\ No newline at end of file