github.com/vmware/govmomi@v0.37.2/govc/test/boot_order_test.sh (about)

     1  #!/bin/bash -e
     2  
     3  # This test is not run via bats.
     4  # A VNC session will be opened to observe the VM boot order:
     5  # 1) from floppy  (followed by: eject floppy, reboot)
     6  # 2) from cdrom   (followed by: eject cdrom, reboot)
     7  # 3) from network (will timeout)
     8  # 4) from disk
     9  
    10  . $(dirname $0)/test_helper.bash
    11  
    12  upload_img
    13  upload_iso
    14  
    15  id=$(new_ttylinux_vm)
    16  
    17  function cleanup() {
    18    quit_vnc $vnc
    19    govc vm.destroy $id
    20    pkill -TERM -g $$ ^nc
    21  }
    22  
    23  trap cleanup EXIT
    24  
    25  govc device.cdrom.add -vm $id > /dev/null
    26  govc device.cdrom.insert -vm $id $GOVC_TEST_ISO
    27  
    28  govc device.floppy.add -vm $id > /dev/null
    29  govc device.floppy.insert -vm $id $GOVC_TEST_IMG
    30  
    31  govc device.boot -vm $id -delay 1000 -order floppy,cdrom,ethernet,disk
    32  
    33  vnc=$(govc vm.vnc -port 21122 -password govmomi -enable "${id}" | awk '{print $2}')
    34  
    35  echo "booting from floppy..."
    36  govc vm.power -on $id
    37  
    38  open_vnc $vnc
    39  
    40  sleep 10
    41  
    42  govc vm.power -off $id
    43  
    44  govc device.floppy.eject -vm $id
    45  
    46  # this is ttylinux-live, notice the 'boot:' prompt vs 'login:' prompt when booted from disk
    47  echo "booting from cdrom..."
    48  govc vm.power -on $id
    49  
    50  sleep 10
    51  
    52  govc vm.power -off $id
    53  
    54  govc device.cdrom.eject -vm $id
    55  
    56  govc device.serial.add -vm $id > /dev/null
    57  govc device.serial.connect -vm $id -
    58  
    59  echo "booting from network, will timeout then boot from disk..."
    60  govc vm.power -on $id
    61  
    62  # serial console log
    63  device=$(govc device.ls -vm "$id" | grep serialport- | awk '{print $1}')
    64  govc datastore.tail -f "$id/$device.log" &
    65  
    66  ip=$(govc vm.ip $id)
    67  
    68  echo "VM booted from disk (ip=$ip)"
    69  
    70  sleep 5
    71  
    72  govc vm.power -s $id
    73  
    74  sleep 5