Clean up code

Implement: Fuel install OVS with NSH/DPDK

Change-Id: I3fe071eb23f3f425e183725440c5a041f8b8cfae
Closes-Bug:#1507877
Signed-off-by: lingyu1 <ling.y.yu@intel.com>
This commit is contained in:
lingyu1 2015-12-22 21:38:45 +08:00
parent ea851c2249
commit 8e950c32dc
6 changed files with 77 additions and 80 deletions

View File

@ -3,27 +3,7 @@ if $operatingsystem == 'Ubuntu' {
if $fuel_settings['fuel-plugin-ovs']['use_dpdk'] { if $fuel_settings['fuel-plugin-ovs']['use_dpdk'] {
$NICS = $fuel_settings['fuel-plugin-ovs']['dpdk-bind-nic'] $NICS = $fuel_settings['fuel-plugin-ovs']['dpdk-bind-nic']
exec { "install dpdk": exec { "install dpdk":
command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk-install.sh; bash ./dpdk-install.sh", command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk-install.sh; bash ./dpdk-install.sh $NICS",
path => "/usr/bin:/usr/sbin:/bin:/sbin",
} ->
exec {'dpdk-init':
command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk.init -O /etc/init.d/dpdk;chmod +x /etc/init.d/dpdk",
path => "/usr/bin:/usr/sbin:/bin:/sbin",
} ->
exec {'dpdk-conf':
command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk.conf -O /etc/default/dpdk.conf",
path => "/usr/bin:/usr/sbin:/bin:/sbin",
} ->
exec {'adapt_conf_file':
command => "sed 's/DPDK_NIC_MAPPINGS=.*/DPDK_NIC_MAPPINGS=${NICS}/' -i /etc/default/dpdk.conf",
path => "/usr/bin:/usr/sbin:/bin:/sbin",
} ->
exec {'dpdk start':
command => "bash /etc/init.d/dpdk start",
path => "/usr/bin:/usr/sbin:/bin:/sbin",
} ->
exec { "install ovs with dpdk":
command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/ovs-dpdk-install.sh; bash ./ovs-dpdk-install.sh",
path => "/usr/bin:/usr/sbin:/bin:/sbin", path => "/usr/bin:/usr/sbin:/bin:/sbin",
} }
} else { } else {

View File

@ -3,27 +3,7 @@ if $operatingsystem == 'Ubuntu' {
if $fuel_settings['fuel-plugin-ovs']['use_dpdk'] { if $fuel_settings['fuel-plugin-ovs']['use_dpdk'] {
$NICS = $fuel_settings['fuel-plugin-ovs']['dpdk-bind-nic'] $NICS = $fuel_settings['fuel-plugin-ovs']['dpdk-bind-nic']
exec { "install dpdk": exec { "install dpdk":
command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk-install.sh; bash ./dpdk-install.sh", command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk-install.sh; bash ./dpdk-install.sh $NICS",
path => "/usr/bin:/usr/sbin:/bin:/sbin",
} ->
exec {'dpdk-init':
command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk.init -O /etc/init.d/dpdk;chmod +x /etc/init.d/dpdk",
path => "/usr/bin:/usr/sbin:/bin:/sbin",
} ->
exec {'dpdk-conf':
command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk.conf -O /etc/default/dpdk.conf",
path => "/usr/bin:/usr/sbin:/bin:/sbin",
} ->
exec {'adapt_conf_file':
command => "sed 's/DPDK_NIC_MAPPINGS=.*/DPDK_NIC_MAPPINGS=${NICS}/' -i /etc/default/dpdk.conf",
path => "/usr/bin:/usr/sbin:/bin:/sbin",
} ->
exec {'dpdk start':
command => "bash /etc/init.d/dpdk start",
path => "/usr/bin:/usr/sbin:/bin:/sbin",
} ->
exec { "install ovs with dpdk":
command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/ovs-dpdk-install.sh; bash ./ovs-dpdk-install.sh",
path => "/usr/bin:/usr/sbin:/bin:/sbin", path => "/usr/bin:/usr/sbin:/bin:/sbin",
} }
} else { } else {

View File

@ -3,27 +3,7 @@ if $operatingsystem == 'Ubuntu' {
if $fuel_settings['fuel-plugin-ovs']['use_dpdk'] { if $fuel_settings['fuel-plugin-ovs']['use_dpdk'] {
$NICS = $fuel_settings['fuel-plugin-ovs']['dpdk-bind-nic'] $NICS = $fuel_settings['fuel-plugin-ovs']['dpdk-bind-nic']
exec { "install dpdk": exec { "install dpdk":
command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk-install.sh; bash ./dpdk-install.sh", command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk-install.sh; bash ./dpdk-install.sh $NICS",
path => "/usr/bin:/usr/sbin:/bin:/sbin",
} ->
exec {'dpdk-init':
command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk.init -O /etc/init.d/dpdk;chmod +x /etc/init.d/dpdk",
path => "/usr/bin:/usr/sbin:/bin:/sbin",
} ->
exec {'dpdk-conf':
command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk.conf -O /etc/default/dpdk.conf",
path => "/usr/bin:/usr/sbin:/bin:/sbin",
} ->
exec {'adapt_conf_file':
command => "sed 's/DPDK_NIC_MAPPINGS=.*/DPDK_NIC_MAPPINGS=${NICS}/' -i /etc/default/dpdk.conf",
path => "/usr/bin:/usr/sbin:/bin:/sbin",
} ->
exec {'dpdk start':
command => "bash /etc/init.d/dpdk start",
path => "/usr/bin:/usr/sbin:/bin:/sbin",
} ->
exec { "install ovs with dpdk":
command => "wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/ovs-dpdk-install.sh; bash ./ovs-dpdk-install.sh",
path => "/usr/bin:/usr/sbin:/bin:/sbin", path => "/usr/bin:/usr/sbin:/bin:/sbin",
} }
} else { } else {

View File

@ -1,10 +1,23 @@
#!/bin/bash #!/bin/bash
set -eux
NICS=$1
INSTALL_HOME=/usr/share/dpdk/ INSTALL_HOME=/usr/share/dpdk/
sudo rm -rf $INSTALL_HOME ; mkdir -p $INSTALL_HOME sudo rm -rf $INSTALL_HOME ; mkdir -p $INSTALL_HOME
cd $INSTALL_HOME cd $INSTALL_HOME
wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk-2.1.0.tar.gz; wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk-2.1.0.tar.gz;
tar -xvzf dpdk-2.1.0.tar.gz tar -xvzf dpdk-2.1.0.tar.gz
cd $INSTALL_HOME/dpdk-2.1.0; make install T=x86_64-native-linuxapp-gcc cd $INSTALL_HOME/dpdk-2.1.0; make install T=x86_64-native-linuxapp-gcc
wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk.init -O /etc/init.d/dpdk
chmod +x /etc/init.d/dpdk
wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/dpdk.conf -O /etc/default/dpdk.conf
sed "s/DPDK_NIC_MAPPINGS=.*/DPDK_NIC_MAPPINGS=${NICS}/" -i /etc/default/dpdk.conf
sudo service dpdk start
INSTALL_HOME=/usr/share/ovs-dpdk/
sudo rm -rf $INSTALL_HOME ; mkdir -p $INSTALL_HOME
cd $INSTALL_HOME
wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/openvswitch-datapath-dkms_2.4.90-1_all.deb
sudo dpkg -i openvswitch-datapath-dkms_2.4.90-1_all.deb
wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/openvswitch-common_2.4.90-1_amd64.deb
sudo dpkg -i openvswitch-common_2.4.90-1_amd64.deb
wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/openvswitch-switch_2.4.90-1_amd64.deb
sudo dpkg -i openvswitch-switch_2.4.90-1_amd64.deb

View File

@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
set -eux
echo "sourcing config" echo "sourcing config"
source /etc/default/dpdk.conf source /etc/default/dpdk.conf
@ -22,6 +21,53 @@ RTE_SDK=${RTE_SDK:-/usr/share/dpdk/dpdk-2.1.0}
RTE_TARGET=${RTE_TARGET:-x86_64-native-linuxapp-gcc} RTE_TARGET=${RTE_TARGET:-x86_64-native-linuxapp-gcc}
DPDK_DIR=$RTE_SDK DPDK_DIR=$RTE_SDK
remove_igb_uio_module(){
sudo rmmod igb_uio
}
unbind_nics(){
NICS=`RTE_SDK=${DPDK_DIR} RTE_TARGET=build ${DPDK_DIR}/tools/dpdk_nic_bind.py --status | grep drv=igb_uio | head -1`
while [ "${NICS}" != "" ]
do
BUSID=`echo "${NICS}" | awk '{ print $1 }'`
NANTIC=`echo "${NICS}" | grep "82574L"`
FVL=`echo "${NICS}" | grep "X710"`
RRC=`echo "${NICS}" | grep "82576"`
EM=`echo "${NICS}" | grep "82540EM"`
if [ "${NANTIC}" != "" ] ;then
DRIVER=e1000e
elif [ "${FVL}" != "" ] ;then
DRIVER=i40e
elif [ "${RRC}" != "" ] ;then
DRIVER=igb
elif [ "${EM}" != "" ] ;then
DRIVER=e1000
else
DRIVER=ixgbe
fi
sudo RTE_SDK=${DPDK_DIR} RTE_TARGET=build ${DPDK_DIR}/tools/dpdk_nic_bind.py -b ${DRIVER} ${BUSID}
NICS=`RTE_SDK=${DPDK_DIR} RTE_TARGET=build ${DPDK_DIR}/tools/dpdk_nic_bind.py --status | grep drv=igb_uio | head -1`
done
}
free_hugepages() {
HUGEPAGE_SIZE=$(grep Hugepagesize /proc/meminfo | awk '{ print $2 }')
if [ -d $DPDK_HUGEPAGE_MOUNT ]; then
sudo rm -rf ${DPDK_HUGEPAGE_MOUNT}/rtemap*
fi
sudo umount ${DPDK_HUGEPAGE_MOUNT}
# de-allocate hugepages
if [ $DPDK_ALLOCATE_HUGEPAGES == 'True' ]; then
for d in /sys/devices/system/node/node? ; do
echo 0 | sudo tee $d/hugepages/hugepages-${HUGEPAGE_SIZE}kB/nr_hugepages
done
fi
}
load_igb_uio_module(){ load_igb_uio_module(){
if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko ];then if [ ! -f $RTE_SDK/$RTE_TARGET/kmod/igb_uio.ko ];then
echo "## ERROR: Target does not have the DPDK UIO Kernel Module." echo "## ERROR: Target does not have the DPDK UIO Kernel Module."
@ -77,13 +123,23 @@ cmd_start(){
load_igb_uio_module load_igb_uio_module
bind_nics bind_nics
} }
cmd_stop(){
#if physical nics bindings are defined, bind nics with linux driver
echo "rebinding nics to linux_driver"
unbind_nics
remove_igb_uio_module
echo "unmounting hugepages"
free_hugepages
}
case "$1" in case "$1" in
start) start)
cmd_start cmd_start
;; ;;
stop)
cmd_stop
;;
*) *)
echo "Usage: $0 {start}" >&2 echo "Usage: $0 {start|stop}" >&2
exit 1 exit 1
;; ;;
esac esac

View File

@ -1,12 +0,0 @@
#!/bin/bash
set -eux
INSTALL_HOME=/usr/share/ovs-dpdk/
sudo rm -rf $INSTALL_HOME ; mkdir -p $INSTALL_HOME
cd $INSTALL_HOME
wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/openvswitch-datapath-dkms_2.4.90-1_all.deb
sudo dpkg -i openvswitch-datapath-dkms_2.4.90-1_all.deb
wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/openvswitch-common_2.4.90-1_amd64.deb
sudo dpkg -i openvswitch-common_2.4.90-1_amd64.deb
wget http://10.20.0.2:8080/plugins/fuel-plugin-ovs-0.5/repositories/ubuntu/dpdk/openvswitch-switch_2.4.90-1_amd64.deb
sudo dpkg -i openvswitch-switch_2.4.90-1_amd64.deb