Exemplo n.º 1
0
 * that are ready to test in an array.  Write the array to a vm.ini file.  This
 * file will be used by vmrevert to revert the vms to the current snapshot.
 *
 */
$machinesReady = array();
foreach ($hosts as $host => $vms) {
    if (empty($vms)) {
        echo "Note: no vm's for host {$host}\n";
        continue;
    }
    foreach ($vms as $vm) {
        if (!vmOps($host, $vm, 'getstate')) {
            echo "Warning: {$vm} would not start, not in this test run.\n";
            continue;
        }
        if (!vmOps($host, $vm, 'hassnapshot')) {
            echo "Warning: {$vm} does not have a snapshot!\n";
        }
        $machinesReady[$host][] = $vm;
    }
}
//echo "DB: the machines that will be used to test are:\n";
//print_r($machinesReady) . "\n";
// create ini file, use vmname=vm for entries.
$dataFile = 'vm.ini';
$VM = fopen($dataFile, 'w') or die("FATAL! Cannot open {$dataFile}\n");
$message = "; This file was generated by vmcheck.php on:" . date("D M j G:i:s T Y") . "\n\n";
fwrite($VM, $message);
foreach ($machinesReady as $host => $vms) {
    if (!fwrite($VM, '[' . $host . "]\n")) {
        echo "FATAL! could not write to {$dataFile}\n";
Exemplo n.º 2
0
// first shutdown then power off (don't need to power off VMs)
/*
foreach($toRevert as $host => $vms)
{
  $host = trim($host);
  foreach ($vms as $vmName => $vm)
  {
    //echo "DB: vmName is:$vmName\n";
    //echo "DB: vm is:$vm\n";
    echo "Performing a soft shutdown on host $host using $vmName on vm:\n$vm\n";
    if(!vmOps($host, $vm, 'stop soft'))
    {
      echo "FATAL! count not revert the current snapshot for $vmName on vm\n$vm\n";
    }
  } // foreach
} // foreach
*/
// now revert snapshot
foreach ($toRevert as $host => $vms) {
    $host = trim($host);
    foreach ($vms as $vmName => $vm) {
        //echo "DB: vmName is:$vmName\n";
        //echo "DB: vm is:$vm\n";
        echo "Reverting snapshot on host {$host} using {$vmName} on vm:\n{$vm}\n";
        if (!vmOps($host, $vm, 'revertsnapshot')) {
            echo "FATAL! count not revert the current snapshot for {$vmName} on vm\n{$vm}\n";
        }
    }
    // foreach
}
// foreach