From 32ce2b41b1ca0b6224b45d8bf79039db5e15e997 Mon Sep 17 00:00:00 2001 From: Feng Pan Date: Mon, 6 Feb 2017 13:30:29 -0500 Subject: Add VPP binding to Honeycomb Change-Id: Ic44fc66892a8dbab8974ff711a485f4f581b3cbd Signed-off-by: Feng Pan --- lib/puppet/provider/vpp_service/vpp.rb | 2 -- manifests/honeycomb.pp | 53 +++++++++++++++++++++++++++--- spec/unit/provider/vpp_service/vpp_spec.rb | 2 -- templates/honeycomb.json.erb | 8 ++--- templates/startup.conf.erb | 10 +++--- 5 files changed, 58 insertions(+), 17 deletions(-) diff --git a/lib/puppet/provider/vpp_service/vpp.rb b/lib/puppet/provider/vpp_service/vpp.rb index e1c702c..a887404 100644 --- a/lib/puppet/provider/vpp_service/vpp.rb +++ b/lib/puppet/provider/vpp_service/vpp.rb @@ -71,8 +71,6 @@ Puppet::Type.type(:vpp_service).provide :vpp do systemctlcmd "restart", "vpp" systemctlcmd "enable", "vpp" sleep 10 - systemctlcmd "is-active", "vpp" - systemctlcmd "is-enabled", "vpp" #Configure VPP interfaces configure_vpp_interfaces diff --git a/manifests/honeycomb.pp b/manifests/honeycomb.pp index 3d28179..ccad9ca 100644 --- a/manifests/honeycomb.pp +++ b/manifests/honeycomb.pp @@ -3,6 +3,22 @@ # OpenDaylight Honeycomb Agent # # === Parameters: +# [*opendaylight_ip*] +# (optional) Opendaylight server IP used to bind VPP to Opendaylight. +# Defaults to '' +# +# [*opendaylight_port*] +# (optional) Opendaylight server Port. +# Defaults to '8081' +# +# [*opendaylight_username*] +# (optional) Opendaylight server user name. +# Defaults to 'admin' +# +# [*opendaylight_password*] +# (optional) Opendaylight server password. +# Defaults to 'admin' +# # [*rest_port*] # Port for Honeycomb REST interface to listen on. # @@ -15,12 +31,27 @@ # [*password*] # Password to configure in honeycomb. # +# [*bind_ip*] +# (optional) Honeycomb service binding IP +# Defaults to '127.0.0.1' +# +# [*node_id*] +# (optional) Node ID for binding VPP to Opendaylight +# Defaults to $::fqdn +# class fdio::honeycomb ( - $rest_port = '8181', - $websocket_rest_port = '7779', - $user = 'admin', - $password = 'admin', + $opendaylight_ip = '', + $opendaylight_port = '8081', + $opendaylight_username = 'admin', + $opendaylight_password = 'admin', + $rest_port = '8181', + $websocket_rest_port = '7779', + $user = 'admin', + $password = 'admin', + $bind_ip = '127.0.0.1', + $node_id = $::fqdn, ) { + include ::fdio package { 'honeycomb': @@ -48,4 +79,18 @@ class fdio::honeycomb ( restart => 'systemctl stop vpp;systemctl stop honeycomb;rm -rf /var/lib/honeycomb/persist/*;systemctl start vpp; sleep 5;systemctl start honeycomb', } + if !empty($opendaylight_ip) { + validate_ip_address($opendaylight_ip) + + $fdio_data = "{'node' : [{'node-id':'${node_id}','netconf-node-topology:host':'${bind_ip}','netconf-node-topology:port':'2831','netconf-node-topology:tcp-only':false,'netconf-node-topology:keepalive-delay':0,'netconf-node-topology:username':'${opendaylight_username}','netconf-node-topology:password':'${opendaylight_password}','netconf-node-topology:connection-timeout-millis':10000,'netconf-node-topology:default-request-timeout-millis':10000,'netconf-node-topology:max-connection-attempts':10,'netconf-node-topology:between-attempts-timeout-millis':10000,'netconf-node-topology:schema-cache-directory':'hcmount'}]}" + $fdio_url = "http://${opendaylight_ip}:${opendaylight_port}/restconf/config/network-topology:network-topology/network-topology:topology/topology-netconf/node/${node_id}" + + exec { 'VPP Mount into ODL': + command => "curl -o /dev/null --fail --silent -u ${opendaylight_username}:${opendaylight_password} ${fdio_url} -i -H 'Content-Type: application/json' --data \"${fdio_data}\" -X PUT", + tries => 5, + try_sleep => 30, + path => '/usr/sbin:/usr/bin:/sbin:/bin', + require => Service['honeycomb'], + } + } } diff --git a/spec/unit/provider/vpp_service/vpp_spec.rb b/spec/unit/provider/vpp_service/vpp_spec.rb index 1d9d9ba..f75f80c 100644 --- a/spec/unit/provider/vpp_service/vpp_spec.rb +++ b/spec/unit/provider/vpp_service/vpp_spec.rb @@ -30,8 +30,6 @@ describe 'Puppet::Type.type(:vpp_service).provider(:vpp)' do provider.expects(:configure_vpp_interfaces) provider.expects(:systemctlcmd).with('restart', 'vpp') provider.expects(:systemctlcmd).with('enable', 'vpp') - provider.expects(:systemctlcmd).with('is-enabled', 'vpp') - provider.expects(:systemctlcmd).with('is-active', 'vpp') provider.create end end diff --git a/templates/honeycomb.json.erb b/templates/honeycomb.json.erb index 6cf2bc3..7addc09 100644 --- a/templates/honeycomb.json.erb +++ b/templates/honeycomb.json.erb @@ -9,7 +9,7 @@ "restconf-http-enabled": "true", "restconf-root-path": "/restconf", "restconf-binding-address": "127.0.0.1", - "restconf-port": <%= scope.lookupvar('fdio::honeycomb::rest_port') %>, + "restconf-port": <%= scope['fdio::honeycomb::rest_port'] %>, "restconf-https-enabled": "true", "restconf-https-binding-address": "0.0.0.0", "restconf-https-port": 8443, @@ -18,7 +18,7 @@ "restconf-keystore-manager-password": "OBF:1v9s1unr1unn1vv51zlk1t331vg91x1b1vgl1t331zly1vu51uob1uo71v8u", "restconf-truststore": "/honeycomb-keystore", "restconf-truststore-password": "OBF:1v9s1unr1unn1vv51zlk1t331vg91x1b1vgl1t331zly1vu51uob1uo71v8u", - "restconf-websocket-port": <%= scope.lookupvar('fdio::honeycomb::websocket_rest_port') %>, + "restconf-websocket-port": <%= scope['fdio::honeycomb::websocket_rest_port'] %>, "restconf-pool-max-size": 10, "restconf-pool-min-size": 1, "restconf-acceptors-size": 1, @@ -36,6 +36,6 @@ "netconf-ssh-binding-port": 2831, "netconf-notification-stream-name": "honeycomb", - "username": "<%= scope.lookupvar('fdio::honeycomb::user') %>", - "password": "<%= scope.lookupvar('fdio::honeycomb::password') %>" + "username": "<%= scope['fdio::honeycomb::user'] %>", + "password": "<%= scope['fdio::honeycomb::password'] %>" } diff --git a/templates/startup.conf.erb b/templates/startup.conf.erb index e10dea4..46894d0 100644 --- a/templates/startup.conf.erb +++ b/templates/startup.conf.erb @@ -5,15 +5,15 @@ unix { } dpdk { - <% if @vpp_dpdk_devs.is_a? Array -%><% @vpp_dpdk_devs.each do |n| -%> - dev <%=n-%> <% if @vpp_vlan_enabled && system("lspci -s #{n} | grep VIC") -%> {vlan-strip-offload off}<%end%> + <% if scope['fdio::vpp_dpdk_devs'].is_a? Array -%><% scope['fdio::vpp_dpdk_devs'].each do |n| -%> + dev <%=n-%> <% if scope['fdio::vpp_vlan_enabled'] && system("lspci -s #{n} | grep VIC") -%> {vlan-strip-offload off}<%end%> <% end -%><% end -%> - uio-driver <%=@vpp_dpdk_uio_driver%> + uio-driver <%=scope['fdio::vpp_dpdk_uio_driver']%> } cpu { - <% if @vpp_cpu_main_core -%>main-core <%=@vpp_cpu_main_core%> <%end%> - <% if @vpp_cpu_corelist_workers -%>corelist-workers <%=@vpp_cpu_corelist_workers%> <%end%> + <% if scope['fdio::vpp_cpu_main_core'] -%>main-core <%=scope['fdio::vpp_cpu_main_core']%> <%end%> + <% if scope['fdio::vpp_cpu_corelist_workers'] -%>corelist-workers <%=scope['fdio::vpp_cpu_corelist_workers']%> <%end%> } api-trace { -- cgit 1.2.3-korg