Demo 1ΒΆ

This script allows an admin to be sure that the guest is started, and confirm that the guest really is running Apache and MySQL.

Here’s the step-by-step breakdown.

  1. Connect to a given VMware Host. In this case, with no arguments, it’s the local host.
  2. It will launch (or find) the specified guest OS running on that host.
  3. It will be sure that tools are running.
  4. It will then login and dump a list of processes that include the words “apache” or “mysql”.
"""Demo script 1."""
from __future__ import print_function
from pyvix2 import Host, Error, Tools_State
import sys

#guest_os= r"C:\Fedora14\Fedora.vmx"
guest_os= r"G:\VMplanet-openSUSE11.3\[VMplanet] openSUSE 11.3.vmx"

host= Host()
running= host.find_items()

# Already Running?
if running:
    if guest_os not in running:
        print( "Error:", running, "running in host, stopping." )
    print( "Found", running, "already running." )
    vm= host.openVM(guest_os)
    vm= host.openVM(guest_os)
    print( "Running:", host.find_items() )

# Confirm Tools
    vm.wait_for_tools_in_guest( 60 )
except Error as e:
    print( e )
print( "Tools:", Tools_State[vm.tools_state.value] )

# Login and check processes
vm.login( "user", "password" )
procs= vm.process_list()
for pid, owner, name, start_time, command in procs:
    if 'apache' in name or 'mysql' in name:
        print( pid, owner, command )

Previous topic


Next topic

Demo 2

This Page