Commit f66e4310 authored by Maria Matejka's avatar Maria Matejka

Bi-directional links working, not assigning addresses yet

parent 7e9803c7
......@@ -34,8 +34,23 @@ if [ "$1" = "--install" ]; then
shift 2
fi
qemu-system-$HOSTARCH -enable-kvm -m $HOSTMEMORY -hda $ROOT/img/$HOSTIMAGE $HOSTCOW -display none ${HOSTVNCID:+-vnc 10.0.0.11:$HOSTVNCID} -netdev tap,id=ctl,ifname=$HOSTTAP,script=no -device e1000,netdev=ctl,mac=$HOSTMAC -pidfile $ROOT/run/$NAME.pid -monitor unix:$ROOT/run/$NAME.sock,server,nowait -daemonize $INSTALL "$@"
declare -a HOSTNICVLAN
if [ -n "$HOSTNICMAC" ]; then
for M in $(tr ',' ' ' <<<"$HOSTNICMAC"); do
TAPID=vl-$(tr -d ':' <<<"$M")
HOSTNICDEV="$HOSTNICDEV -netdev tap,id=$TAPID,ifname=$TAPID,script=no -device e1000,netdev=$TAPID,mac=$M"
echo "IP4 ${HOSTNICIP4%%,*}" > $ROOT/nfs/net/$TAPID
HOSTNICVLAN+=( $TAPID )
HOSTNICIP4=${HOSTNICIP4#*,}
done
fi
qemu-system-$HOSTARCH -enable-kvm -m $HOSTMEMORY -hda $ROOT/img/$HOSTIMAGE $HOSTCOW -display none ${HOSTVNCID:+-vnc 10.0.0.11:$HOSTVNCID} -netdev tap,id=ctl,ifname=$HOSTTAP,script=no -device e1000,netdev=ctl,mac=$HOSTMAC $HOSTNICDEV -pidfile $ROOT/run/$NAME.pid -monitor unix:$ROOT/run/$NAME.sock,server,nowait -daemonize $INSTALL "$@"
#-runas $VIRTUSER
ip link set $HOSTTAP up
vsctl add-port $VIRTBR $HOSTTAP tag=1
for T in ${HOSTNICVLAN[@]}; do
vsctl add-port $VIRTBR $T tag=$((100 + (0x${T:4:4} % 3800)))
done
......@@ -15,6 +15,11 @@ function ok() {
if gethost $NAME; then
$ROOT/bin/omapi del $HOSTMAC
vsctl del-port $HOSTTAP
if [ -n "$HOSTNICMAC" ]; then
for M in $(tr ',' ' ' <<<"$HOSTNICMAC"); do
vsctl del-port vl-$(tr -d ':' <<<"$M")
done
fi
else
echo "Warning: Config not found for this host"
fi
......
......@@ -37,11 +37,15 @@ SOCAT=$ROOT/bin/socat
declare -A HOSTS
declare -A CONF
function getmac() {
echo 52:54:$(sed -r 's/^.*(..)(..)(..)(..)$/\1:\2:\3:\4/'<<<"$1")
}
function hostctlnet() {
if [ -z "${CONF[$1;NETWORK]}" ]; then
local SHA=$(sha1sum <<<"$1" | head -c 12)
CONF[$1;TAP]=vc-$SHA
CONF[$1;MAC]=02:$(sed -r 's/^.*(..)(..)(..)(..)(..)$/\1:\2:\3:\4:\5/'<<<"$SHA")
CONF[$1;MAC]=$(getmac $SHA)
CONF[$1;IP4]=192.168.$((193+((0x$SHA / 254) % 63))).$((0x$SHA % 254))
else
read CONF[$1;TAP] CONF[$1;MAC] CONF[$1;IP4] <<<"${CONF[$1;NETWORK]}"
......@@ -81,10 +85,22 @@ function linkhosts() {
local ai=$2
local bn=$3
local bi=$4
if [ -z "$an" ] || [ -z "$ai" ] || [ -z "$bn" ] || [ -z "$bi" ]; then
echo "Link usage: 'Link host IP host IP' in config."
exit 2
fi
local SHA=$(sha1sum <<<"$an;$ai;$bn;$bi" | head -c 16)
local AMAC=$(getmac ${SHA:0:8})
local BMAC=$(getmac ${SHA:8:8})
CONF[$an;NICMAC]=${CONF[$an;NICMAC]},$AMAC
CONF[$bn;NICMAC]=${CONF[$bn;NICMAC]},$BMAC
CONF[$an;NICIP4]=${CONF[$an;NICIP4]},$ai
CONF[$bn;NICIP4]=${CONF[$bn;NICIP4]},$bi
}
HOSTNAME=
......
......@@ -51,5 +51,7 @@ Copy freebsd10 fb1 fb2 fb3
Copy debian8 d1 d2 d3
Link fb1 192.168.55.64/32 d1 192.168.55.71/32
Link ob1 192.168.55.77/32 d1 192.168.55.33/32
Link ob1 192.168.55.17/32 fb1 192.168.55.241/32
#Net fb1 192.168.44.1/24 fb2 192.168.44.2/24 fb3 192.168.44.3/24
#Net d1 192.168.66.1/24 d2 192.168.66.2/24 d3 192.168.66.3/24
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment