Skip to content
Snippets Groups Projects
Commit 6159e923 authored by Bob Lantz's avatar Bob Lantz
Browse files

Add VM port forwarding option: --forward tcp:2222:22

parent 2ceb5791
No related branches found
No related tags found
No related merge requests found
...@@ -52,7 +52,8 @@ ...@@ -52,7 +52,8 @@
SaveQCOW2 = False # Save QCOW2 image rather than deleting it SaveQCOW2 = False # Save QCOW2 image rather than deleting it
NoKVM = False # Don't use kvm and use emulation instead NoKVM = False # Don't use kvm and use emulation instead
Branch = None # Branch to update and check out before testing Branch = None # Branch to update and check out before testing
Zip = False # Archive .ovf and .vmdk into a .zip file Zip = False # Archive .ovf and .vmdk into a .zip file
Forward = [] # VM port forwarding options (-redir)
VMImageDir = os.environ[ 'HOME' ] + '/vm-images' VMImageDir = os.environ[ 'HOME' ] + '/vm-images'
...@@ -464,6 +465,8 @@ def close( self, force=False ): ...@@ -464,6 +465,8 @@ def close( self, force=False ):
'-initrd', initrd, '-initrd', initrd,
'-drive file=%s,if=virtio' % cow, '-drive file=%s,if=virtio' % cow,
'-append "root=/dev/vda1 init=/sbin/init console=ttyS0" ' ] '-append "root=/dev/vda1 init=/sbin/init console=ttyS0" ' ]
if Forward:
cmd += sum( [ [ '-redir', f ] for f in Forward ], [] )
cmd = ' '.join( cmd ) cmd = ' '.join( cmd )
log( '* BOOTING VM FROM', cow ) log( '* BOOTING VM FROM', cow )
log( cmd ) log( cmd )
...@@ -934,7 +937,7 @@ def testString(): ...@@ -934,7 +937,7 @@ def testString():
def parseArgs(): def parseArgs():
"Parse command line arguments and run" "Parse command line arguments and run"
global LogToConsole, NoKVM, Branch, Zip, TIMEOUT global LogToConsole, NoKVM, Branch, Zip, TIMEOUT, Forward
parser = argparse.ArgumentParser( description='Mininet VM build script', parser = argparse.ArgumentParser( description='Mininet VM build script',
epilog=buildFlavorString() + ' ' + epilog=buildFlavorString() + ' ' +
testString() ) testString() )
...@@ -972,6 +975,8 @@ def parseArgs(): ...@@ -972,6 +975,8 @@ def parseArgs():
help='archive .ovf and .vmdk into .zip file' ) help='archive .ovf and .vmdk into .zip file' )
parser.add_argument( '-o', '--out', parser.add_argument( '-o', '--out',
help='output file for test image (vmdk)' ) help='output file for test image (vmdk)' )
parser.add_argument( '-f', '--forward', default=[], action='append',
help='forward VM ports to local server, e.g. tcp:5555::22' )
args = parser.parse_args() args = parser.parse_args()
if args.depend: if args.depend:
depend() depend()
...@@ -989,6 +994,8 @@ def parseArgs(): ...@@ -989,6 +994,8 @@ def parseArgs():
Zip = True Zip = True
if args.timeout: if args.timeout:
TIMEOUT = args.timeout TIMEOUT = args.timeout
if args.forward:
Forward = args.forward
if not args.test and not args.run and not args.post: if not args.test and not args.run and not args.post:
args.test = [ 'sanity', 'core' ] args.test = [ 'sanity', 'core' ]
for flavor in args.flavor: for flavor in args.flavor:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment