create-cell 474 Bytes
#!/bin/bash
# Creates a new cell.

name="$1"
ipx="$2"
spec="$3"
shift 3
key="$@"

cd $(dirname $0)

nodes=${spec%+*}
mininet=${spec#*+}

sudo lxc-attach -n bit-proxy -- bash -c "grep -qF \"$key\" /home/sdn/.ssh/authorized_keys || echo $key >> /home/sdn/.ssh/authorized_keys"

if [ $mininet -ge 1 ]; then
    ./clone-node base-mininet ${ipx/x/0} $name-n "$key"
fi

let n=1
while [ $n -le $nodes ]; do
    ./clone-node base-onos ${ipx/x/$n} $name-$n "$key"
    let n=n+1
done