$ sudo cat >> /usr/bin/nova-ssh << END
FIRST=$1
IDX=`expr index $1 "@"`
if [[ $IDX == "0" ]] ; then
echo "please input the user name"
exit 1
fi
USER=${FIRST%@*}
IP=${FIRST#*@}
NINFO=`nova list | grep $IP | awk '{print $12}'`
NID=${NINFO%=*}
PIP=${NINFO#*=}
PIP=${PIP%,}
NAME=`nova list | grep $IP |awk '{print $4}'`
echo "VM name: $NAME"
if [ -z $NID ]; then
echo "invalid $IP"
echo "not find the network id of $IP for $NAME"
exit 1
fi
NS=`nova network-show $NID | grep "|s+ids+|"`
NS=${NS%|}
NS=${NS/|*id*| /qdhcp-}
shift
echo "login $USER@$PIP, it will take some time..."
sudo ip netns exec $NS ssh "$USER@$PIP" $@ -i $HOME/.ssh/id_rsa
END
$ sudo chmod a+x /usr/bin/nova-ssh
$ # nova-ssh user@private_ip/id/name
$ nova-ssh minion@3a76ccfc-fc55-4102-8848-fa62003110be