Add VM port forwarding option: --forward tcp:2222:22
This commit is contained in:
+9
-2
@@ -52,7 +52,8 @@ LogToConsole = False # VM output to console rather than log file
|
|||||||
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 boot( cow, kernel, initrd, logfile, memory=1024 ):
|
|||||||
'-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():
|
|||||||
|
|
||||||
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():
|
|||||||
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():
|
|||||||
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:
|
||||||
|
|||||||
Reference in New Issue
Block a user