Revision e49c9d26

View differences:

util/vm/build.py
158 158
    run( 'sudo apt-get -y update' )
159 159
    run( 'sudo apt-get install -y'
160 160
         ' kvm cloud-utils genisoimage qemu-kvm qemu-utils'
161
         ' e2fsprogs dnsmasq'
161
         ' e2fsprogs dnsmasq curl'
162 162
         ' python-setuptools mtools zip' )
163 163
    run( 'sudo easy_install pexpect' )
164 164

  
......
457 457
    return vm
458 458

  
459 459

  
460
def login( vm ):
460
def login( vm, user='mininet', password='mininet' ):
461 461
    "Log in to vm (pexpect object)"
462 462
    log( '* Waiting for login prompt' )
463 463
    vm.expect( 'login: ' )
464 464
    log( '* Logging in' )
465
    vm.sendline( 'mininet' )
465
    vm.sendline( user )
466 466
    log( '* Waiting for password prompt' )
467 467
    vm.expect( 'Password: ' )
468 468
    log( '* Sending password' )
469
    vm.sendline( 'mininet' )
469
    vm.sendline( password )
470 470
    log( '* Waiting for login...' )
471 471

  
472 472

  
......
628 628
<Description>The nat  network</Description>
629 629
</Network>
630 630
</NetworkSection>
631
<VirtualSystem ovf:id="Mininet-VM">
632
<Info>A Mininet Virtual Machine (%(name)s)</Info>
633
<Name>mininet-vm</Name>
631
<VirtualSystem ovf:id="%(vmname)s">
632
<Info>%(vminfo)s (%(name)s)</Info>
633
<Name>%(vmname)s</Name>
634 634
<OperatingSystemSection ovf:id="%(osid)d">
635 635
<Info>The kind of installed guest operating system</Info>
636 636
<Description>%(osname)s</Description>
......
640 640
<Item>
641 641
<rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
642 642
<rasd:Description>Number of Virtual CPUs</rasd:Description>
643
<rasd:ElementName>1 virtual CPU(s)</rasd:ElementName>
643
<rasd:ElementName>%(cpus)s virtual CPU(s)</rasd:ElementName>
644 644
<rasd:InstanceID>1</rasd:InstanceID>
645 645
<rasd:ResourceType>3</rasd:ResourceType>
646
<rasd:VirtualQuantity>1</rasd:VirtualQuantity>
646
<rasd:VirtualQuantity>%(cpus)s</rasd:VirtualQuantity>
647 647
</Item>
648 648
<Item>
649 649
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
......
694 694
"""
695 695

  
696 696

  
697
def generateOVF( name, osname, osid, diskname, disksize, mem=1024 ):
697
def generateOVF( name, osname, osid, diskname, disksize, mem=1024, cpus=1,
698
                 vmname='Mininet-VM', vminfo='A Mininet Virtual Machine' ):
698 699
    """Generate (and return) OVF file "name.ovf"
699 700
       name: root name of OVF file to generate
700 701
       osname: OS name for OVF (Ubuntu | Ubuntu 64-bit)
701 702
       osid: OS ID for OVF (93 | 94 )
702 703
       diskname: name of disk file
703 704
       disksize: size of virtual disk in bytes
704
       mem: VM memory size in MB"""
705
       mem: VM memory size in MB
706
       cpus: # of virtual CPUs
707
       vmname: Name for VM (default name when importing)
708
       vmimfo: Brief description of VM for OVF"""
705 709
    ovf = name + '.ovf'
706 710
    filesize = stat( diskname )[ ST_SIZE ]
707 711
    params = dict( osname=osname, osid=osid, diskname=diskname,
708 712
                   filesize=filesize, disksize=disksize, name=name,
709
                   mem=mem )
713
                   mem=mem, cpus=cpus, vmname=vmname, vminfo=vminfo )
710 714
    xmltext = OVFTemplate % params
711 715
    with open( ovf, 'w+' ) as f:
712 716
        f.write( xmltext )

Also available in: Unified diff