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 aa7b6a
if [ $centos_ver -lt 7 ]
Christoph Galuschka ff12d7
then
Christoph Galuschka ff12d7
  # create VLAN-IF 10 on eth0
Christoph Galuschka ff12d7
  vconfig add eth0 10
Christoph Galuschka ff12d7
  ip addr list | grep -q eth0.10
Christoph Galuschka ff12d7
  if [ $? == 1 ]
Christoph Galuschka ff12d7
    then
Christoph Galuschka ff12d7
    t_Log "VLAN-IF creation failed"
Christoph Galuschka ff12d7
    ret_val=1
Christoph Galuschka ff12d7
  else
Christoph Galuschka ff12d7
    t_Log "VLAN-IF successfully created"
Christoph Galuschka ff12d7
  fi
Christoph Galuschka 7d92e8
Christoph Galuschka ff12d7
  #assign IP address on VLAN-IF
Christoph Galuschka ff12d7
  ifconfig eth0.10 172.16.30.1 netmask 255.255.255.255
Christoph Galuschka ff12d7
  ip addr list | grep -q 172.16.30.1
Christoph Galuschka ff12d7
  if [ $? == 1 ]
Christoph Galuschka ff12d7
    then
Christoph Galuschka ff12d7
    t_Log "IP address assignment on eth0.10 failed"
Christoph Galuschka ff12d7
    ret_val=1
Christoph Galuschka ff12d7
  else
Christoph Galuschka ff12d7
    t_Log "IP address successfully assigned on eth1.10"
Christoph Galuschka ff12d7
  fi
Christoph Galuschka 7d92e8
Christoph Galuschka ff12d7
  #testing address with ping
Christoph Galuschka ff12d7
  ping -c 4 -q 172.16.30.1 | grep -q '4 received'
Christoph Galuschka ff12d7
  if [ $? == 1 ]
Christoph Galuschka ff12d7
    then
Christoph Galuschka ff12d7
    t_Log "pinging on eth0.10 failed"
Christoph Galuschka ff12d7
    ret_val=1
Christoph Galuschka ff12d7
  else
Christoph Galuschka ff12d7
    t_Log "local ping on VLAN IF worked"
Christoph Galuschka ff12d7
  fi
Christoph Galuschka 7d92e8
Christoph Galuschka ff12d7
  # delete VLAN-IF 10 on eth0
Christoph Galuschka ff12d7
  vconfig rem eth0.10
Christoph Galuschka ff12d7
  ip addr list | grep -q eth0.10
Christoph Galuschka ff12d7
  if [ $? == 0 ]
Christoph Galuschka ff12d7
    then
Christoph Galuschka ff12d7
    t_Log "Removing VLAN IF failed"
Christoph Galuschka ff12d7
    ret_val=1
Christoph Galuschka ff12d7
  else
Christoph Galuschka ff12d7
    t_Log "Removing of VLAN IF worked"
Christoph Galuschka ff12d7
  fi
Christoph Galuschka 7d92e8
else
Christoph Galuschka aa7b6a
  t_Log 'vconfig is only supported on C5 and C6, skipping'
Christoph Galuschka 7d92e8
fi
Christoph Galuschka 7d92e8
Christoph Galuschka 7d92e8
t_CheckExitStatus $ret_val