Merge pull request #237 from FirmlyReality/master

1.check usrgw when call has_user. 2.update base_url in container
This commit is contained in:
Yujian Zhu 2017-05-15 23:39:11 +08:00 committed by GitHub
commit e84a7e35aa
2 changed files with 31 additions and 0 deletions

View File

@ -544,6 +544,10 @@ class NetworkMgr(object):
def has_user(self, username):
[status, _value] = self.etcd.getkey("network/users/"+username)
self.load_usrgw(username)
if username not in self.usrgws.keys():
self.usrgws[username] = self.masterip
self.dump_usrgw(username)
return status
def acquire_userips(self, username, num=1):

27
tools/update_baseurl.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/sh
toolsdir=${0%/*}
DOCKLET_TOOLS=$(cd $toolsdir; pwd)
DOCKLET_HOME=${DOCKLET_TOOLS%/*}
DOCKLET_CONF=$DOCKLET_HOME/conf
. $DOCKLET_CONF/docklet.conf
masterip=$(ifconfig ${NETWORK_DEVICE} | awk '/inet/ {print $2}' | awk -F: '{print $2}' | head -1)
cons=$(ls /var/lib/lxc)
echo ${masterip}
for i in ${cons}
do
sed -i "s/BASE_URL=\/go/BASE_URL=\/${masterip}\/go/g" /var/lib/lxc/${i}/rootfs/home/jupyter/jupyter.config
running=$(lxc-info -n ${i} | grep RUNNING)
if [ "${running}" != '' ]
then
echo "Stop ${i}..."
lxc-stop -k -n ${i}
echo "Start ${i}..."
lxc-start -n ${i}
lxc-attach -n ${i} -- su -c /home/jupyter/start_jupyter.sh
lxc-attach -n ${i} -- service ssh start
fi
done