Blame tests/p_vconfig/10_test_vconfig.sh

Christoph Galuschka 7d92e8
#!/bin/sh
Christoph Galuschka ff12d7
# Author: Christoph Galuschka <tigalch@tigalch.org>
Christoph Galuschka 7d92e8
#         Athmane Madjoudj <athmanem@gmail.com>
Christoph Galuschka 7d92e8
Christoph Galuschka 7d92e8
t_Log "Running $0 - create VLAN IF, assign IP on VLAN IF and tear down VLAN IF test"
Christoph Galuschka 7d92e8
ret_val=0
Christoph Galuschka 7d92e8
Christoph Galuschka 1723ad
if [ $centos_ver -gt 6 ]
Christoph Galuschka ff12d7
then
Christoph Galuschka 1723ad
  t_Log 'vconfig is only supported on C5 and C6, skipping'
Christoph Galuschka 1723ad
  t_CheckExitStatus $ret_val
Christoph Galuschka 1723ad
  exit 0
Christoph Galuschka 1723ad
fi
Christoph Galuschka 1723ad
Christoph Galuschka 1723ad
# create VLAN-IF 10 on eth0
Christoph Galuschka 1723ad
vconfig add eth0 10
Christoph Galuschka 1723ad
ip addr list | grep -q eth0.10
Christoph Galuschka 1723ad
if [ $? == 1 ]
Christoph Galuschka 1723ad
  then
Christoph Galuschka 1723ad
  t_Log "VLAN-IF creation failed"
Christoph Galuschka 1723ad
  ret_val=1
Christoph Galuschka 1723ad
else
Christoph Galuschka 1723ad
  t_Log "VLAN-IF successfully created"
Christoph Galuschka 1723ad
fi
Christoph Galuschka 7d92e8
Christoph Galuschka 1723ad
#assign IP address on VLAN-IF
Christoph Galuschka 1723ad
ifconfig eth0.10 172.16.30.1 netmask 255.255.255.255
Christoph Galuschka 1723ad
ip addr list | grep -q 172.16.30.1
Christoph Galuschka 1723ad
if [ $? == 1 ]
Christoph Galuschka 1723ad
  then
Christoph Galuschka 1723ad
  t_Log "IP address assignment on eth0.10 failed"
Christoph Galuschka 1723ad
  ret_val=1
Christoph Galuschka 1723ad
else
Christoph Galuschka b89473
  t_Log "IP address successfully assigned on eth0.10"
Christoph Galuschka 1723ad
fi
Christoph Galuschka 7d92e8
Christoph Galuschka 1723ad
#testing address with ping
Christoph Galuschka 1723ad
ping -c 4 -q 172.16.30.1 | grep -q '4 received'
Christoph Galuschka 1723ad
if [ $? == 1 ]
Christoph Galuschka 1723ad
  then
Christoph Galuschka 1723ad
  t_Log "pinging on eth0.10 failed"
Christoph Galuschka 1723ad
  ret_val=1
Christoph Galuschka 1723ad
else
Christoph Galuschka 1723ad
  t_Log "local ping on VLAN IF worked"
Christoph Galuschka 1723ad
fi
Christoph Galuschka 7d92e8
Christoph Galuschka 1723ad
# delete VLAN-IF 10 on eth0
Christoph Galuschka 1723ad
vconfig rem eth0.10
Christoph Galuschka 1723ad
ip addr list | grep -q eth0.10
Christoph Galuschka 1723ad
if [ $? == 0 ]
Christoph Galuschka 1723ad
  then
Christoph Galuschka 1723ad
  t_Log "Removing VLAN IF failed"
Christoph Galuschka 1723ad
  ret_val=1
Christoph Galuschka 7d92e8
else
Christoph Galuschka 1723ad
  t_Log "Removing of VLAN IF worked"
Christoph Galuschka 7d92e8
fi
Christoph Galuschka 7d92e8
Christoph Galuschka 7d92e8
t_CheckExitStatus $ret_val