+
+# Shared function for validations related to username/password
+def username_password_validations(options = {})
+ # NB: This param default should match the one used by the opendaylight
+ # class, which is defined in opendaylight::params
+ odl_username = options.fetch(:username, 'admin')
+ odl_password = options.fetch(:password, 'admin')
+ odl_check_url = 'http://127.0.0.1:8181/restconf'
+
+ describe file('/opt/opendaylight/data/idmlight.db.mv.db') do
+ it { should be_file }
+ end
+
+ describe command("loop_count=0; until [[ \$loop_count -ge 300 ]]; do curl -o /dev/null --fail --silent --head -u #{odl_username}:#{odl_password} #{odl_check_url} && break; loop_count=\$[\$loop_count+1]; sleep 1; done; echo \"Waited \$loop_count seconds for ODL to become active\"") do
+ its(:exit_status) { should eq 0 }
+ end
+
+ describe command("curl -o /dev/null --fail --silent --head -u #{odl_username}:#{odl_password} #{odl_check_url}") do
+ its(:exit_status) { should eq 0 }
+ end
+end
+
+# Shared function for validations related to the SNAT config file
+def snat_mechanism_validations(options = {})
+ # NB: This param default should match the one used by the opendaylight
+ # class, which is defined in opendaylight::params
+ snat_mechanism = options.fetch(:snat_mechanism, 'controller')
+
+ describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-natservice-config.xml') do
+ it { should be_file }
+ it { should be_owned_by 'odl' }
+ it { should be_grouped_into 'odl' }
+ its(:content) { should match /<nat-mode>#{snat_mechanism}<\/nat-mode>/ }
+ end
+end
+
+# Shared function for validations related to SFC
+def sfc_validations(options = {})
+ # NB: This param default should match the one used by the opendaylight
+ # class, which is defined in opendaylight::params
+
+ extra_features = options.fetch(:extra_features, [])
+ if extra_features.include? 'odl-netvirt-sfc'
+ sfc_enabled = true
+ else
+ sfc_enabled = false
+ end
+
+ describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/genius-itm-config.xml') do
+ it { should be_file }
+ it { should be_owned_by 'odl' }
+ it { should be_grouped_into 'odl' }
+ its(:content) { should match /<gpe-extension-enabled>#{sfc_enabled}<\/gpe-extension-enabled>/ }
+ end
+end
+
+# Shared function for validations related to tos value for DSCP marking
+def dscp_validations(options = {})
+ # NB: This param default should match the one used by the opendaylight
+ # class, which is defined in opendaylight::params
+
+ inherit_dscp_marking = options.fetch(:inherit_dscp_marking, false)
+
+ if inherit_dscp_marking
+ describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/genius-itm-config.xml') do
+ it { should be_file }
+ it { should be_owned_by 'odl' }
+ it { should be_grouped_into 'odl' }
+ its(:content) { should match /<default-tunnel-tos>inherit<\/default-tunnel-tos>/ }
+ end
+ 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
+ odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0')
+
+ 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
+
+def tls_validations(options = {})
+ # NB: This param default should match the one used by the opendaylight
+ # class, which is defined in opendaylight::params
+ tls_keystore_password = options.fetch(:tls_keystore_password)
+ odl_rest_port = options.fetch(:odl_rest_port, 8181)
+
+ describe file('/opt/opendaylight/etc/org.ops4j.pax.web.cfg') do
+ it { should be_file }
+ it { should be_owned_by 'odl' }
+ it { should be_grouped_into 'odl' }
+ its(:content) { should match /org.osgi.service.http.port.secure = #{odl_rest_port}/ }
+ its(:content) { should match /org.ops4j.pax.web.ssl.keystore = configuration\/ssl\/ctl.jks/ }
+ its(:content) { should match /org.ops4j.pax.web.ssl.password = #{tls_keystore_password}/ }
+ its(:content) { should match /org.ops4j.pax.web.ssl.keypassword = #{tls_keystore_password}/ }
+ its(:content) { should match /org.osgi.service.http.secure.enabled = true/ }
+ its(:content) { should match /org.osgi.service.http.enabled = false/ }
+ end
+
+ describe file('/opt/opendaylight/etc/org.opendaylight.ovsdb.library.cfg') do
+ it { should be_file }
+ it { should be_owned_by 'odl' }
+ it { should be_grouped_into 'odl' }
+ its(:content) { should match /use-ssl = true/ }
+ end
+
+ describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/default-openflow-connection-config.xml') do
+ it { should be_file }
+ it { should be_owned_by 'odl' }
+ it { should be_grouped_into 'odl' }
+ its(:content) { should match /<keystore-password>#{tls_keystore_password}<\/keystore-password>/ }
+ its(:content) { should match /<truststore-password>#{tls_keystore_password}<\/truststore-password>/ }
+ its(:content) { should match /<transport-protocol>TLS<\/transport-protocol>/ }
+ end
+
+ describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/aaa-cert-config.xml') do
+ it { should be_file }
+ it { should be_owned_by 'odl' }
+ it { should be_grouped_into 'odl' }
+ its(:content) { should match /<store-password>#{tls_keystore_password}<\/store-password>/ }
+ its(:content) { should match /<use-mdsal>false<\/use-mdsal>/ }
+ end
+
+ describe file('/opt/opendaylight/etc/jetty.xml') do
+ it { should be_file }
+ it { should be_owned_by 'odl' }
+ it { should be_grouped_into 'odl' }
+ its(:content) { should match /<Property name="jetty.secure.port" default="#{odl_rest_port}" \/>/ }
+ end
+end
+
+# Shared function for validations related to OVS statistics polling
+def stats_polling_validations(options = {})
+ # NB: This param default should match the one used by the opendaylight
+ # class, which is defined in opendaylight::params
+
+ stats_polling_enabled = options.fetch(:stats_polling_enabled, false)
+ describe file('/opt/opendaylight/etc/org.opendaylight.openflowplugin.cfg') do
+ it { should be_file }
+ it { should be_owned_by 'odl' }
+ it { should be_grouped_into 'odl' }
+ its(:content) { should match /is-statistics-polling-on=#{stats_polling_enabled}/ }
+ end
+end
+
+# Shared function for validations related to inactivity probe
+def inactivity_probe_validations(options = {})
+ # NB: This param default should match the one used by the opendaylight
+ # class, which is defined in opendaylight::params
+
+ inactivity_probe = options.fetch(:inactivity_probe, :undef)
+ unless inactivity_probe == :undef
+ describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-elanmanager-config.xml') do
+ it { should be_file }
+ it { should be_owned_by 'odl' }
+ it { should be_grouped_into 'odl' }
+ its(:content) { should match /<controller-inactivity-probe>#{inactivity_probe}/ }
+ end
+ end
+end