diff --git a/README.markdown b/README.markdown
index 0a5b8fa..c6763f0 100644
--- a/README.markdown
+++ b/README.markdown
@@ -232,6 +232,17 @@ class { 'opendaylight':
}
```
+### Disabling ODL DHCP Service
+
+To disable ODL DHCP Service, use the `enable_dhcp` flag. It's enabled by
+default.
+
+```puppet
+class { 'opendaylight':
+ enable_dhcp => false,
+}
+```
+
## Reference
### Classes
@@ -410,6 +421,31 @@ Default: `'https://github.com/dfarrell07/opendaylight-systemd/archive/master/ope
Valid options: A valid URL to an ODL systemd .service file (archived in a
tarball) as a string.
+##### `enable_dhcp`
+
+Enable or disable ODL DHCP Service.
+
+Default: `true`
+
+Valid options: Boolean values `true` and `false`.
+
+The ODL DHCP Service config in `/opt/opendaylight/etc/opendaylight/karaf/dhcpservice-impl-default-config.xml` is set to
+the value of the `enable_dhcp` param.
+
+A manifest like
+
+```puppet
+class { 'opendaylight':
+ enable_dhcp => false,
+}
+```
+
+Would would result in
+
+```
+false
+```
+
## Limitations
* Tested on Fedora 22, 23, CentOS 7 and Ubuntu 14.04.
diff --git a/manifests/config.pp b/manifests/config.pp
index f164278..2bdaf60 100644
--- a/manifests/config.pp
+++ b/manifests/config.pp
@@ -77,4 +77,15 @@
fail("Number of HA nodes less than 2: ${ha_node_count} and HA Enabled")
}
}
+
+ # Configure DHCP service
+ file { 'dhcpservice-impl-default-config.xml':
+ ensure => file,
+ path => '/opt/opendaylight/etc/opendaylight/karaf/dhcpservice-impl-default-config.xml',
+ # Set user:group owners
+ owner => 'odl',
+ group => 'odl',
+ # Use a template to populate the content
+ content => template('opendaylight/dhcpservice-impl-default-config.xml.erb'),
+ }
}
diff --git a/manifests/init.pp b/manifests/init.pp
index 17b2a8f..a9a789d 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -29,6 +29,8 @@
# Array of IPs for each node in the HA cluster.
# [*ha_node_index*]
# Index of ha_node_ips for this node.
+# [*enable_dhcp*]
+# Enable or disable ODL Netvirt DHCP service. Valid: true, false. Default: true
#
class opendaylight (
$default_features = $::opendaylight::params::default_features,
@@ -44,6 +46,7 @@
$enable_ha = $::opendaylight::params::enable_ha,
$ha_node_ips = $::opendaylight::params::ha_node_ips,
$ha_node_index = $::opendaylight::params::ha_node_index,
+ $enable_dhcp = $::opendaylight::params::enable_dhcp,
) inherits ::opendaylight::params {
# Validate OS family
diff --git a/manifests/params.pp b/manifests/params.pp
index f25ca06..95c61d7 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -21,4 +21,5 @@
$enable_ha = false
$ha_node_ips = []
$ha_node_index = ''
+ $enable_dhcp = true
}
diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb
index 3b04ad3..eb69b46 100644
--- a/spec/acceptance/class_spec.rb
+++ b/spec/acceptance/class_spec.rb
@@ -164,4 +164,30 @@
enable_l3_validations(enable_l3: true)
end
end
+
+ describe 'testing ODL DHCP Service config' do
+ context 'using enable_dhcp default' do
+ # Call specialized helper fn to install OpenDaylight
+ install_odl
+
+ # Call specialized helper fn for ODL DHCP Service config validations
+ enable_dhcp_validations
+ end
+
+ context 'using false for enable_dhcp' do
+ # Call specialized helper fn to install OpenDaylight
+ install_odl(enable_dhcp: false)
+
+ # Call specialized helper fn for ODL DHCP Service config validations
+ enable_dhcp_validations(enable_dhcp: false)
+ end
+
+ context 'using true for enable_dhcp' do
+ # Call specialized helper fn to install OpenDaylight
+ install_odl(enable_dhcp: true)
+
+ # Call specialized helper fn for ODL DHCP Service config validations
+ enable_dhcp_validations(enable_dhcp: true)
+ end
+ end
end
diff --git a/spec/classes/opendaylight_spec.rb b/spec/classes/opendaylight_spec.rb
index 20783e9..23e3f5d 100644
--- a/spec/classes/opendaylight_spec.rb
+++ b/spec/classes/opendaylight_spec.rb
@@ -46,6 +46,11 @@
# NB: Only testing defaults here, specialized enabling L3 tests elsewhere
# Note that this function is defined in spec_helper
enable_l3_tests
+
+ # Run tests that specialize in checking ODL DHCP Service config
+ # NB: Only testing defaults here, specialized enabling DHCP tests elsewhere
+ # Note that this function is defined in spec_helper
+ enable_dhcp_tests
end
end
@@ -105,6 +110,11 @@
# NB: Only testing defaults here, specialized enabling L3 tests elsewhere
# Note that this function is defined in spec_helper
enable_l3_tests
+
+ # Run tests that specialize in checking ODL DHCP Service config
+ # NB: Only testing defaults here, specialized enabling DHCP tests elsewhere
+ # Note that this function is defined in spec_helper
+ enable_dhcp_tests
end
end
@@ -180,6 +190,11 @@
# NB: Only testing defaults here, specialized enabling L3 tests elsewhere
# Note that this function is defined in spec_helper
enable_l3_tests
+
+ # Run tests that specialize in checking ODL DHCP Service config
+ # NB: Only testing defaults here, specialized enabling DHCP tests elsewhere
+ # Note that this function is defined in spec_helper
+ enable_dhcp_tests
end
end
@@ -538,6 +553,73 @@
end
end
+ # All DHCP Service enable/disable tests
+ describe 'DHCP Service enable/disable tests' do
+ # Non-OS-type tests assume CentOS 7
+ # See issue #43 for reasoning:
+ # https://github.com/dfarrell07/puppet-opendaylight/issues/43#issue-57343159
+ osfamily = 'RedHat'
+ operatingsystem = 'CentOS'
+ operatingsystemmajrelease = '7'
+ context 'using enable_dhcp default' 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 ODL DHCP Service config
+ # Note that this function is defined in spec_helper
+ enable_dhcp_tests
+ end
+
+ context 'using false for enable_dhcp' do
+ let(:facts) {{
+ :osfamily => osfamily,
+ :operatingsystem => operatingsystem,
+ :operatingsystemmajrelease => operatingsystemmajrelease,
+ }}
+
+ let(:params) {{
+ :enable_dhcp => false ,
+ }}
+
+ # 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 ODL DHCP Service config
+ # Note that this function is defined in spec_helper
+ enable_dhcp_tests(enable_dhcp: false)
+ end
+
+ context 'using true for enable_dhcp' do
+ let(:facts) {{
+ :osfamily => osfamily,
+ :operatingsystem => operatingsystem,
+ :operatingsystemmajrelease => operatingsystemmajrelease,
+ }}
+
+ let(:params) {{
+ :enable_dhcp => true,
+ }}
+
+ # 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 ODL DHCP Service config
+ # Note that this function is defined in spec_helper
+ enable_dhcp_tests(enable_dhcp: true)
+ end
+ end
+
# All install method tests
describe 'install method tests' do
# Non-OS-type tests assume CentOS 7
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index db1fe00..4e87cbd 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -227,6 +227,38 @@ def enable_l3_tests(options = {})
end
end
+# Shared tests that specialize in testing enabling DHCP Service
+def enable_dhcp_tests(options = {})
+ # Extract params
+ # NB: This default value should be the same as one in opendaylight::params
+ # TODO: Remove this possible source of bugs^^
+ enable_dhcp = options.fetch(:enable_dhcp, true)
+
+ if [true].include? enable_dhcp
+ # Confirm ODL DHCP Service is enabled
+ it {
+ should contain_file('custom.properties').with(
+ 'ensure' => 'file',
+ 'path' => '/opt/opendaylight/etc/opendaylight/karaf/dhcpservice-impl-default-config.xml',
+ 'owner' => 'odl',
+ 'group' => 'odl',
+ 'content' => /controller-dhcp-enabled>true/
+ )
+ }
+ elsif [false].include? enable_dhcp
+ # Confirm ODL DHCP Service is disabled
+ it {
+ should contain_file('custom.properties').with(
+ 'ensure' => 'file',
+ 'path' => '/opt/opendaylight/etc/opendaylight/karaf/dhcpservice-impl-default-config.xml',
+ 'owner' => 'odl',
+ 'group' => 'odl',
+ 'content' => /controller-dhcp-enabled>false/
+ )
+ }
+ end
+end
+
def tarball_install_tests(options = {})
# Extract params
# NB: These default values should be the same as ones in opendaylight::params
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
index 7fbe70e..49e8cfd 100644
--- a/spec/spec_helper_acceptance.rb
+++ b/spec/spec_helper_acceptance.rb
@@ -63,6 +63,7 @@ def install_odl(options = {})
odl_rest_port = options.fetch(:odl_rest_port, 8080)
log_levels = options.fetch(:log_levels, {})
enable_l3 = options.fetch(:enable_l3, 'no')
+ enable_dhcp = options.fetch(:enable_dhcp, true)
# Build script for consumption by Puppet apply
it 'should work idempotently with no errors' do
@@ -75,6 +76,7 @@ class { 'opendaylight':
odl_rest_port=> #{odl_rest_port},
enable_l3=> #{enable_l3},
log_levels=> #{log_levels},
+ enable_dhcp=> #{enable_dhcp},
}
EOS
@@ -306,6 +308,21 @@ def enable_l3_validations(options = {})
end
end
+# Shared function for validations related to ODL OVSDB L3 config
+def enable_dhcp_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^^
+ enable_dhcp = options.fetch(:enable_dhcp, true)
+
+ describe file('/opt/opendaylight/etc/opendaylight/karaf/dhcpservice-impl-default-config.xml') do
+ it { should be_file }
+ it { should be_owned_by 'odl' }
+ it { should be_grouped_into 'odl' }
+ its(:content) { should match /controller-dhcp-enabled>#{enable_dhcp}/ }
+ end
+end
+
# Shared function that handles validations specific to RPM-type installs
def rpm_validations()
rpm_repo = ENV['RPM_REPO']
diff --git a/templates/dhcpservice-impl-default-config.xml.erb b/templates/dhcpservice-impl-default-config.xml.erb
new file mode 100644
index 0000000..1019d64
--- /dev/null
+++ b/templates/dhcpservice-impl-default-config.xml.erb
@@ -0,0 +1,59 @@
+
+
+
+
+
+ urn:opendaylight:params:xml:ns:yang:dhcpservice:impl?module=dhcpservice-impl&revision=2015-07-10
+ urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28
+ urn:opendaylight:genius:mdsalutil?module=odl-mdsalutil&revision=2016-04-06
+ urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:entity-ownership-service?module=opendaylight-entity-ownership-service&revision=2015-08-10
+ urn:opendaylight:params:xml:ns:yang:neutronvpn:api?module=neutronvpn-api&revision=2015-08-12
+ urn:opendaylight:genius:interfacemgr?module=odl-interface&revision=2016-04-06
+
+
+
+
+
+
+ prefix:dhcpservice-impl
+ dhcpservice-default
+ <%= scope.lookupvar('opendaylight::enable_dhcp') %>
+
+ binding:binding-broker-osgi-registry
+ binding-osgi-broker
+
+
+ binding:binding-rpc-registry
+ binding-rpc-broker
+
+
+ binding:binding-notification-service
+ binding-notification-broker
+
+
+ mdsalutil:odl-mdsalutil
+ mdsalutil-service
+
+
+ neutronvpn:neutronvpn-api
+ neutronvpn
+
+
+ entity-ownership:entity-ownership-service
+ entity-ownership-service
+
+
+ odlif:odl-interface
+ interfacemgr-service
+
+
+
+
+
+