Write build log to file, and detect installation failure
This commit is contained in:
committed by
Brian O'Connor
parent
20ba29590a
commit
803a1a5489
+14
-2
@@ -71,13 +71,14 @@ isoURLs = {
|
|||||||
'ubuntu-13.10-server-amd64.iso',
|
'ubuntu-13.10-server-amd64.iso',
|
||||||
}
|
}
|
||||||
|
|
||||||
logStartTime = time()
|
LogStartTime = time()
|
||||||
|
LogFile = None
|
||||||
|
|
||||||
def log( *args, **kwargs ):
|
def log( *args, **kwargs ):
|
||||||
"""Simple log function: log( message along with local and elapsed time
|
"""Simple log function: log( message along with local and elapsed time
|
||||||
cr: False/0 for no CR"""
|
cr: False/0 for no CR"""
|
||||||
cr = kwargs.get( 'cr', True )
|
cr = kwargs.get( 'cr', True )
|
||||||
elapsed = time() - logStartTime
|
elapsed = time() - LogStartTime
|
||||||
clocktime = strftime( '%H:%M:%S', localtime() )
|
clocktime = strftime( '%H:%M:%S', localtime() )
|
||||||
msg = ' '.join( str( arg ) for arg in args )
|
msg = ' '.join( str( arg ) for arg in args )
|
||||||
output = '%s [ %.3f ] %s' % ( clocktime, elapsed, msg )
|
output = '%s [ %.3f ] %s' % ( clocktime, elapsed, msg )
|
||||||
@@ -85,6 +86,11 @@ def log( *args, **kwargs ):
|
|||||||
print output
|
print output
|
||||||
else:
|
else:
|
||||||
print output,
|
print output,
|
||||||
|
# Optionally mirror to LogFile
|
||||||
|
if type( LogFile ) is file:
|
||||||
|
if cr:
|
||||||
|
output += '\n'
|
||||||
|
LogFile.write( output )
|
||||||
|
|
||||||
|
|
||||||
def run( cmd, **kwargs ):
|
def run( cmd, **kwargs ):
|
||||||
@@ -350,6 +356,9 @@ def installUbuntu( iso, image, logfilename='install.log' ):
|
|||||||
# Unmount iso and clean up
|
# Unmount iso and clean up
|
||||||
srun( 'umount ' + mnt )
|
srun( 'umount ' + mnt )
|
||||||
run( 'rmdir ' + mnt )
|
run( 'rmdir ' + mnt )
|
||||||
|
if vm.returncode != 0:
|
||||||
|
raise Exception( 'Ubuntu installation returned error %d' %
|
||||||
|
vm.returncode )
|
||||||
log( '* UBUNTU INSTALLATION COMPLETED FOR', image )
|
log( '* UBUNTU INSTALLATION COMPLETED FOR', image )
|
||||||
log( '* Ubuntu installation completed in %.2f seconds ' % elapsed )
|
log( '* Ubuntu installation completed in %.2f seconds ' % elapsed )
|
||||||
|
|
||||||
@@ -501,6 +510,7 @@ def genVirtImage( name, mem, diskname, disksize ):
|
|||||||
|
|
||||||
def build( flavor='raring32server' ):
|
def build( flavor='raring32server' ):
|
||||||
"Build a Mininet VM"
|
"Build a Mininet VM"
|
||||||
|
global LogFile
|
||||||
start = time()
|
start = time()
|
||||||
date = strftime( '%y%m%d-%H-%M-%S', localtime())
|
date = strftime( '%y%m%d-%H-%M-%S', localtime())
|
||||||
dir = 'mn-%s-%s' % ( flavor, date )
|
dir = 'mn-%s-%s' % ( flavor, date )
|
||||||
@@ -509,6 +519,8 @@ def build( flavor='raring32server' ):
|
|||||||
except:
|
except:
|
||||||
raise Exception( "Failed to create build directory %s" % dir )
|
raise Exception( "Failed to create build directory %s" % dir )
|
||||||
os.chdir( dir )
|
os.chdir( dir )
|
||||||
|
LogFile = open( 'build.log', 'w' )
|
||||||
|
log( '* Logging to ', abspath( LogFile.name ) )
|
||||||
log( '* Created working directory', dir )
|
log( '* Created working directory', dir )
|
||||||
image, kernel, initrd = findBaseImage( flavor )
|
image, kernel, initrd = findBaseImage( flavor )
|
||||||
volume = flavor + '.qcow2'
|
volume = flavor + '.qcow2'
|
||||||
|
|||||||
Reference in New Issue
Block a user