OpenStack: Neutron L3 router

Recreate / move qrouter namespace

ROUTER_ID=74490819-028e-424e-b8f9-c7e48cf672af
 
# list router NS
openstack network agent list --router ${ROUTER_ID} --long
 
# list available l3 agents
openstack network agent list --agent-type l3
 
# recreate L3 agent
SOURCE_NODE=ctl1-dev
TARGET_NODE=ctl2-dev
 
SOURCE_L3_ID=$(openstack network agent list --host ${SOURCE_NODE} --agent-type l3 -f value -c ID)
TARGET_L3_ID=$(openstack network agent list --host ${TARGET_NODE} --agent-type l3 -f value -c ID)
 
openstack network agent add router --l3 ${TARGET_L3_ID} ${ROUTER_ID}
openstack network agent remove router --l3 ${SOURCE_L3_ID} ${ROUTER_ID}

Recreate all network agents

openstack router list --agent $SOURCE_L3_ID -f value -c ID | while read ROUTER_ID; do
    openstack network agent add router --l3 ${TARGET_L3_ID} ${ROUTER_ID}
    openstack network agent remove router --l3 ${SOURCE_L3_ID} ${ROUTER_ID}
done
 
openstack network agent set $SOURCE_L3_ID --disable

List floating IP in qrouter namespace

for ROUTER_NETNS in $(ip netns | grep qrouter | cut -d" " -f1); do
    echo ${ROUTER_NETNS}
    ip netns exec ${ROUTER_NETNS} ip a | grep "scope global qg-"
    echo
done

Manual failover all active router

for ROUTER_NETNS in $(ip netns | grep qrouter | cut -d" " -f1); do
    HA_INTERFACE=$(ip netns exec ${ROUTER_NETNS} ip a | grep "ha-" | cut -d" " -f2 | cut -d":" -f1)
    if [ ! -z ${HA_INTERFACE} ]; then
        echo ip netns exec ${ROUTER_NETNS} ip link set dev ${HA_INTERFACE} down
        ip netns exec ${ROUTER_NETNS} ip link set dev ${HA_INTERFACE} down
        sleep 30
    fi
done

Debug router connectivity

CTL_NODE=ctl2-stage
 
for ROUTER_NETNS in $(ssh ${CTL_NODE} ip netns | grep qrouter | cut -d" " -f1); do
    OUTPUT=$(ssh ${CTL_NODE} ip netns exec ${ROUTER_NETNS} ip a | grep "scope global qg-")
    if [ ! -z "${OUTPUT}" ]; then
        ROUTER_ID=${ROUTER_NETNS#*-}
 
        PROJECT_ID=$(openstack router show ${ROUTER_ID} -f value -c project_id)
        PROJECT_NAME=$(openstack project show ${PROJECT_ID} -f value -c name)
 
        DOMAIN_ID=$(openstack project show ${PROJECT_ID} -f value -c domain_id)
        DOMAIN_NAME=$(openstack project show ${DOMAIN_ID} -f value -c name)
 
        echo "ROUTER: ${ROUTER_ID}"
        echo "DOMAIN: ${DOMAIN_NAME}"
        echo "PROJECT: ${PROJECT_NAME}"
 
        echo "# ROUTER"
        openstack network agent list --router ${ROUTER_ID} --long
 
        echo "${OUTPUT}"
 
        echo "# ARP"
        ssh ${CTL_NODE} ip netns exec ${ROUTER_NETNS} ip n
 
        echo "# VMs"
        openstack server list --project ${PROJECT_ID}
 
        echo    
    fi
done