Minor changes and script evolution.
This commit is contained in:
+18
-10
@@ -55,7 +55,7 @@ from sys import exit
|
|||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
# boot can be slooooow!!!! need to debug/optimize somehow
|
# boot can be slooooow!!!! need to debug/optimize somehow
|
||||||
TIMEOUT=120
|
TIMEOUT=600
|
||||||
|
|
||||||
VMImageDir = os.environ[ 'HOME' ] + '/vm-images'
|
VMImageDir = os.environ[ 'HOME' ] + '/vm-images'
|
||||||
|
|
||||||
@@ -167,15 +167,17 @@ def addMininetUser( img ):
|
|||||||
print '* Adding mininet user to', img
|
print '* Adding mininet user to', img
|
||||||
# 1. We bind-mount / into a temporary directory, and
|
# 1. We bind-mount / into a temporary directory, and
|
||||||
# then mount the volume's /etc and /home on top of it!
|
# then mount the volume's /etc and /home on top of it!
|
||||||
bind = mkdtemp()
|
|
||||||
mnt = mkdtemp()
|
mnt = mkdtemp()
|
||||||
srun( 'mount -B / ' + bind )
|
bind = mkdtemp()
|
||||||
srun( 'mount %s %s' % ( img, mnt ) )
|
srun( 'mount %s %s' % ( img, mnt ) )
|
||||||
|
srun( 'mount -B / ' + bind )
|
||||||
srun( 'mount -B %s/etc %s/etc' % ( mnt, bind ) )
|
srun( 'mount -B %s/etc %s/etc' % ( mnt, bind ) )
|
||||||
srun( 'mount -B %s/home %s/home' % ( mnt, bind ) )
|
srun( 'mount -B %s/home %s/home' % ( mnt, bind ) )
|
||||||
def chroot( cmd ):
|
def chroot( cmd ):
|
||||||
"Chroot into bind mount and run command"
|
"Chroot into bind mount and run command"
|
||||||
call( 'sudo chroot %s ' % bind + cmd, shell=True )
|
call( 'sudo chroot %s ' % bind + cmd, shell=True )
|
||||||
|
# 1a. Add hostname entry in /etc/hosts
|
||||||
|
addTo( bind + '/etc/hosts', '127.0.1.1 mininet-vm' )
|
||||||
# 2. Next, we delete any old mininet user and add a new one
|
# 2. Next, we delete any old mininet user and add a new one
|
||||||
chroot( 'deluser mininet' )
|
chroot( 'deluser mininet' )
|
||||||
chroot( 'useradd --create-home mininet' )
|
chroot( 'useradd --create-home mininet' )
|
||||||
@@ -193,10 +195,11 @@ def addMininetUser( img ):
|
|||||||
chroot( 'sed -i "s/tty1/ttyS0/g" /etc/init/ttyS0.conf' )
|
chroot( 'sed -i "s/tty1/ttyS0/g" /etc/init/ttyS0.conf' )
|
||||||
# 3. Lastly, we umount and clean up everything
|
# 3. Lastly, we umount and clean up everything
|
||||||
run( 'sync' )
|
run( 'sync' )
|
||||||
srun( 'umount %s/etc ' % bind )
|
|
||||||
srun( 'umount %s/home ' % bind )
|
srun( 'umount %s/home ' % bind )
|
||||||
|
srun( 'umount %s/etc ' % bind )
|
||||||
srun( 'umount %s' % bind )
|
srun( 'umount %s' % bind )
|
||||||
srun( 'umount ' + mnt )
|
srun( 'umount ' + mnt )
|
||||||
|
run( 'rmdir ' + bind )
|
||||||
run( 'rmdir ' + mnt )
|
run( 'rmdir ' + mnt )
|
||||||
# 4. Just to make sure, we check the filesystem
|
# 4. Just to make sure, we check the filesystem
|
||||||
run( 'e2fsck -y ' + img )
|
run( 'e2fsck -y ' + img )
|
||||||
@@ -212,6 +215,8 @@ def makeCOWDisk( image ):
|
|||||||
print '* Resizing COW disk and file system'
|
print '* Resizing COW disk and file system'
|
||||||
run( 'qemu-img resize %s +8G' % cow )
|
run( 'qemu-img resize %s +8G' % cow )
|
||||||
srun( 'modprobe nbd')
|
srun( 'modprobe nbd')
|
||||||
|
# Ideally we should check if it's being used...
|
||||||
|
srun( 'qemu-nbd -d /dev/nbd0' )
|
||||||
srun( 'qemu-nbd -c /dev/nbd0 ' + cow )
|
srun( 'qemu-nbd -c /dev/nbd0 ' + cow )
|
||||||
srun( 'e2fsck -fy /dev/nbd0' )
|
srun( 'e2fsck -fy /dev/nbd0' )
|
||||||
srun( 'resize2fs /dev/nbd0' )
|
srun( 'resize2fs /dev/nbd0' )
|
||||||
@@ -288,15 +293,18 @@ def interact( vm ):
|
|||||||
vm.expect( prompt )
|
vm.expect( prompt )
|
||||||
print '* Testing Mininet'
|
print '* Testing Mininet'
|
||||||
vm.sendline( 'sudo mn --test pingall' )
|
vm.sendline( 'sudo mn --test pingall' )
|
||||||
vm.expect( '0% dropped' )
|
if vm.expect( [ ' 0% dropped', pexpect.TIMEOUT ], timeout=30 ):
|
||||||
print '* Basic test succeeded'
|
print '* Sanity check succeeded'
|
||||||
|
else:
|
||||||
|
print '* Sanity check FAILED'
|
||||||
|
vm.expect( prompt )
|
||||||
|
print '* Making sure cgroups are mounted'
|
||||||
|
vm.sendline( 'sudo service cgroup-lite restart' )
|
||||||
|
vm.expect( prompt )
|
||||||
|
vm.sendline( 'sudo cgroups-mount' )
|
||||||
vm.expect( prompt )
|
vm.expect( prompt )
|
||||||
print '* Running make test'
|
print '* Running make test'
|
||||||
vm.sendline( 'cd ~/mininet; sudo make test' )
|
vm.sendline( 'cd ~/mininet; sudo make test' )
|
||||||
vm.expect( 'OK' )
|
|
||||||
print '* Basic test succeeded'
|
|
||||||
vm.expect( 'OK' )
|
|
||||||
print '* Hi-Fi test succeeded'
|
|
||||||
vm.expect( prompt )
|
vm.expect( prompt )
|
||||||
print '* Shutting down'
|
print '* Shutting down'
|
||||||
vm.sendline( 'sync; sudo shutdown -h now' )
|
vm.sendline( 'sync; sudo shutdown -h now' )
|
||||||
|
|||||||
Reference in New Issue
Block a user