Created
September 12, 2016 22:45
-
-
Save bbyhuy/29c6d6ef04ac6c85fbed8bbe5de6a693 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@osa-controller-3:~# /usr/local/bin/lxc-veth-wiring infra3_heat_engine_container-37127731 7127731_eth2.41 eth2.41 br-mgmt | |
# Execution example: lxc-veth-wiring.sh testing VETHTEST eth1 br-mgmt | |
# CLI variables | |
CONTAINER_NAME="${1}" | |
VETH="${2}" | |
INTERFACE="${3}" | |
BRIDGE="${4}" | |
VETH_PEER="$(openssl rand -hex 4)" | |
openssl rand -hex 4 | |
# PID of running container | |
PID="$(lxc-info -pHn ${CONTAINER_NAME})" | |
lxc-info -pHn ${CONTAINER_NAME} | |
# Exit 0 means no change, exit 3 is changed, any other exit is fail. | |
EXIT_CODE=0 | |
if ! ip a l "${VETH}";then | |
ip link add name "${VETH}" type veth peer name "${VETH_PEER}" | |
ip link set dev "${VETH}" up | |
EXIT=3 | |
else | |
ip link set dev "${VETH}" up | |
fi | |
103: 7127731_eth2.41@if102: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-mgmt state UP group default qlen 1000 | |
link/ether 72:e3:38:87:69:6e brd ff:ff:ff:ff:ff:ff link-netnsid 19 | |
inet6 fe80::70e3:38ff:fe87:696e/64 scope link | |
valid_lft forever preferred_lft forever | |
if ip a l "${VETH_PEER}";then | |
ip link set dev "${VETH_PEER}" up | |
ip link set dev "${VETH_PEER}" netns "${PID}" name "${INTERFACE}" | |
EXIT=3 | |
fi | |
Device "054677ac" does not exist. | |
if ! brctl show "${BRIDGE}" | grep -q "${VETH}"; then | |
brctl addif "${BRIDGE}" "${VETH}" | |
EXIT=3 | |
fi | |
lxc-attach --name "${CONTAINER_NAME}" <<EOC | |
ip link set dev "${INTERFACE}" up | |
ifdown "${INTERFACE}" | |
ifup "${INTERFACE}" | |
EOC | |
ifdown: interface eth2.41 not configured | |
RTNETLINK answers: File exists | |
Failed to bring up eth2.41. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment