Skip to content
Snippets Groups Projects
Commit e49c9d26 authored by Brian O'Connor's avatar Brian O'Connor
Browse files

build.py: making ovf generation more generic

parent 8b215af8
No related branches found
No related tags found
No related merge requests found
......@@ -158,7 +158,7 @@ def depend():
run( 'sudo apt-get -y update' )
run( 'sudo apt-get install -y'
' kvm cloud-utils genisoimage qemu-kvm qemu-utils'
' e2fsprogs dnsmasq'
' e2fsprogs dnsmasq curl'
' python-setuptools mtools zip' )
run( 'sudo easy_install pexpect' )
......@@ -457,16 +457,16 @@ def boot( cow, kernel, initrd, logfile, memory=1024 ):
return vm
def login( vm ):
def login( vm, user='mininet', password='mininet' ):
"Log in to vm (pexpect object)"
log( '* Waiting for login prompt' )
vm.expect( 'login: ' )
log( '* Logging in' )
vm.sendline( 'mininet' )
vm.sendline( user )
log( '* Waiting for password prompt' )
vm.expect( 'Password: ' )
log( '* Sending password' )
vm.sendline( 'mininet' )
vm.sendline( password )
log( '* Waiting for login...' )
......@@ -628,9 +628,9 @@ def convert( cow, basename ):
<Description>The nat network</Description>
</Network>
</NetworkSection>
<VirtualSystem ovf:id="Mininet-VM">
<Info>A Mininet Virtual Machine (%(name)s)</Info>
<Name>mininet-vm</Name>
<VirtualSystem ovf:id="%(vmname)s">
<Info>%(vminfo)s (%(name)s)</Info>
<Name>%(vmname)s</Name>
<OperatingSystemSection ovf:id="%(osid)d">
<Info>The kind of installed guest operating system</Info>
<Description>%(osname)s</Description>
......@@ -640,10 +640,10 @@ def convert( cow, basename ):
<Item>
<rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
<rasd:Description>Number of Virtual CPUs</rasd:Description>
<rasd:ElementName>1 virtual CPU(s)</rasd:ElementName>
<rasd:ElementName>%(cpus)s virtual CPU(s)</rasd:ElementName>
<rasd:InstanceID>1</rasd:InstanceID>
<rasd:ResourceType>3</rasd:ResourceType>
<rasd:VirtualQuantity>1</rasd:VirtualQuantity>
<rasd:VirtualQuantity>%(cpus)s</rasd:VirtualQuantity>
</Item>
<Item>
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
......@@ -694,19 +694,23 @@ def convert( cow, basename ):
"""
def generateOVF( name, osname, osid, diskname, disksize, mem=1024 ):
def generateOVF( name, osname, osid, diskname, disksize, mem=1024, cpus=1,
vmname='Mininet-VM', vminfo='A Mininet Virtual Machine' ):
"""Generate (and return) OVF file "name.ovf"
name: root name of OVF file to generate
osname: OS name for OVF (Ubuntu | Ubuntu 64-bit)
osid: OS ID for OVF (93 | 94 )
diskname: name of disk file
disksize: size of virtual disk in bytes
mem: VM memory size in MB"""
mem: VM memory size in MB
cpus: # of virtual CPUs
vmname: Name for VM (default name when importing)
vmimfo: Brief description of VM for OVF"""
ovf = name + '.ovf'
filesize = stat( diskname )[ ST_SIZE ]
params = dict( osname=osname, osid=osid, diskname=diskname,
filesize=filesize, disksize=disksize, name=name,
mem=mem )
mem=mem, cpus=cpus, vmname=vmname, vminfo=vminfo )
xmltext = OVFTemplate % params
with open( ovf, 'w+' ) as f:
f.write( xmltext )
......
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