From c4e58a8f44233bd163a0d3345894a924ac4274a4 Mon Sep 17 00:00:00 2001 From: Janki Chhatbar Date: Thu, 2 Aug 2018 16:05:14 +0530 Subject: [PATCH] IPv6 support for ODL-OVS deployment Add feature to also set OVS manager to the IPv6 address of ODL based on "enable_ipv6" flag value. Change-Id: I88d369082de1ce71cdeddf69287867c0af6d9e07 Closes-Bug: #1783067 --- manifests/plugins/ovs/opendaylight.pp | 54 +++++++++---------- ...-for-IPv6-deployment-8aa288ee1195f81c.yaml | 6 +++ .../neutron_plugins_ovs_opendaylight_spec.rb | 29 +++++++++- 3 files changed, 59 insertions(+), 30 deletions(-) create mode 100644 releasenotes/notes/add-support-for-IPv6-deployment-8aa288ee1195f81c.yaml diff --git a/manifests/plugins/ovs/opendaylight.pp b/manifests/plugins/ovs/opendaylight.pp index 53021e7c7..44c7ac080 100644 --- a/manifests/plugins/ovs/opendaylight.pp +++ b/manifests/plugins/ovs/opendaylight.pp @@ -106,7 +106,8 @@ class neutron::plugins::ovs::opendaylight ( $enable_tls = false, $tls_key_file = undef, $tls_cert_file = undef, - $tls_ca_cert_file = undef + $tls_ca_cert_file = undef, + $enable_ipv6 = false, ) { include ::neutron::deps @@ -136,26 +137,10 @@ class neutron::plugins::ovs::opendaylight ( } } - if $odl_ovsdb_iface =~ /^tcp/ { - warning('TLS enabled but odl_ovsdb_iface set to tcp. Will override to ssl') - $odl_ovsdb_iface_parsed = regsubst($odl_ovsdb_iface, 'tcp:', 'ssl:', 'G') - } else { - $odl_ovsdb_iface_parsed = $odl_ovsdb_iface - } - - if $ovsdb_server_iface =~ /^ptcp/ { - warning('TLS enabled but ovsdb_server_iface set to ptcp. Will override to pssl') - $ovsdb_server_iface_parsed = regsubst($ovsdb_server_iface, '^ptcp', 'pssl') - } else { - $ovsdb_server_iface_parsed = $ovsdb_server_iface - } - - if $odl_check_url =~ /^http:/ { - warning('TLS enabled but odl_check_url set to http. Will override to https') - $odl_check_url_parsed = regsubst($odl_check_url, '^http:', 'https:') - } else { - $odl_check_url_parsed = $odl_check_url - } + warning('TLS enabled, overriding all protocols') + $odl_ovsdb_iface_proto = 'ssl' + $ovsdb_server_iface_proto = 'pssl' + $odl_check_url_proto = 'https' $cert_data = convert_cert_to_string($tls_cert_file) $rest_data = @("END":json/L) @@ -177,8 +162,8 @@ class neutron::plugins::ovs::opendaylight ( } |-END - $ovsdb_arr = split($odl_ovsdb_iface_parsed, ' ') - $odl_rest_port = regsubst($odl_check_url_parsed, '^.*:([0-9]+)/.*$', '\1') + $ovsdb_arr = split($odl_ovsdb_iface, ' ') + $odl_rest_port = regsubst($odl_check_url, '^.*:([0-9]+)/.*$', '\1') $ovsdb_arr.each |$ovsdb_uri| { $odl_ip = regsubst($ovsdb_uri, 'ssl:(.+):[0-9]+', '\1') @@ -195,15 +180,26 @@ class neutron::plugins::ovs::opendaylight ( require => Exec['Wait for NetVirt OVSDB to come up'] } } - - } else { - $odl_ovsdb_iface_parsed = $odl_ovsdb_iface - $ovsdb_server_iface_parsed = $ovsdb_server_iface - $odl_check_url_parsed = $odl_check_url + } + else { + $odl_ovsdb_iface_proto = 'tcp' + $ovsdb_server_iface_proto = 'ptcp' + $odl_check_url_proto = 'http' } + if $enable_ipv6 { + $ovsdb_server_ip = '[::1]' + } + else { + $ovsdb_server_ip = '127.0.0.1' + } + + $odl_ovsdb_iface_parsed = regsubst($odl_ovsdb_iface, 'tcp', $odl_ovsdb_iface_proto, 'G') + $ovsdb_server_iface_parsed = "${ovsdb_server_iface_proto}:6639:${ovsdb_server_ip}" + $odl_check_url_parsed = regsubst($odl_check_url, 'http', $odl_check_url_proto) + exec { 'Wait for NetVirt OVSDB to come up': - command => "curl -k -o /dev/null --fail --silent --head -u ${odl_username}:${odl_password} ${odl_check_url_parsed}", + command => "curl -g -k -o /dev/null --fail --silent --head -u ${odl_username}:${odl_password} ${odl_check_url_parsed}", tries => $retry_count, try_sleep => $retry_interval, path => '/usr/sbin:/usr/bin:/sbin:/bin', diff --git a/releasenotes/notes/add-support-for-IPv6-deployment-8aa288ee1195f81c.yaml b/releasenotes/notes/add-support-for-IPv6-deployment-8aa288ee1195f81c.yaml new file mode 100644 index 000000000..5f2bf4c27 --- /dev/null +++ b/releasenotes/notes/add-support-for-IPv6-deployment-8aa288ee1195f81c.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Added logic to support IPv6 deployment on underlay network + with ODL. The logic is implemented such that both TLS and + IPv6 can be enabled or either of them or none. diff --git a/spec/classes/neutron_plugins_ovs_opendaylight_spec.rb b/spec/classes/neutron_plugins_ovs_opendaylight_spec.rb index cbf5adf87..7b2a95f09 100644 --- a/spec/classes/neutron_plugins_ovs_opendaylight_spec.rb +++ b/spec/classes/neutron_plugins_ovs_opendaylight_spec.rb @@ -17,6 +17,7 @@ describe 'neutron::plugins::ovs::opendaylight' do :vhostuser_mode => 'server', :enable_hw_offload => false, :enable_tls => false, + :enable_ipv6 => false, } end @@ -116,7 +117,7 @@ describe 'neutron::plugins::ovs::opendaylight' do :enable_tls => true, :tls_key_file => 'dummy.pem', :tls_cert_file => 'dummy.crt', - :odl_ovsdb_iface => 'tcp:127.0.0.1:6640 tcp:172.0.0.1:6640'}) + :odl_ovsdb_iface => 'ssl:127.0.0.1:6640 ssl:172.0.0.1:6640'}) end it_configures 'with TLS and ODL HA' it {is_expected.to contain_vs_ssl('system').with( @@ -127,6 +128,15 @@ describe 'neutron::plugins::ovs::opendaylight' do 'before' => 'Exec[Set OVS Manager to OpenDaylight]' )} end + context 'with IPv6 enabled' do + before do + params.merge!({ + :enable_ipv6 => true, + :odl_ovsdb_iface => 'tcp:[::1]:6640', + }) + end + it_configures 'with IPv6 enabled' + end end shared_examples_for 'with default parameters' do @@ -170,6 +180,9 @@ describe 'neutron::plugins::ovs::opendaylight' do end shared_examples_for 'with TLS enabled' do + before do + params.merge!({ :odl_ovsdb_iface => 'ssl:127.0.0.1:6640' }) + end it 'configures OVS for ODL' do is_expected.to contain_exec('Add trusted cert: dummy.crt to https://127.0.0.1:8080') is_expected.to contain_exec('Set OVS Manager to OpenDaylight').with( @@ -198,6 +211,20 @@ describe 'neutron::plugins::ovs::opendaylight' do end end + shared_examples_for 'with IPv6 enabled' do + it 'configures OVS for ODL' do + is_expected.to contain_exec('Wait for NetVirt OVSDB to come up') + is_expected.to contain_exec('Set OVS Manager to OpenDaylight').with( + :command => "ovs-vsctl set-manager ptcp:6639:[::1] tcp:[::1]:6640" + ) + is_expected.to contain_vs_config('other_config:local_ip') + is_expected.not_to contain_vs_config('other_config:provider_mappings') + is_expected.to contain_vs_config('external_ids:odl_os_hostconfig_hostid') + is_expected.to contain_vs_config('external_ids:hostname') + is_expected.to contain_vs_config('external_ids:odl_os_hostconfig_config_odl_l2') + end + end + context 'on RedHat platforms' do let :facts do @default_facts.merge(test_facts.merge({