FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
vmrevert.php
Go to the documentation of this file.
1 #!/usr/bin/php
2 <?php
3 /*
4  Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  version 2 as published by the Free Software Foundation.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
27 require_once('../lib/common-vm.php');
28 
29 // parse the ini file
30 // cycle through the arrays and revert each vm
31 
32 $toRevert = parse_ini_file('vm.ini', 1);
33 // first shutdown then power off (don't need to power off VMs)
34 /*
35 foreach($toRevert as $host => $vms)
36 {
37  $host = trim($host);
38  foreach ($vms as $vmName => $vm)
39  {
40  //echo "DB: vmName is:$vmName\n";
41  //echo "DB: vm is:$vm\n";
42  echo "Performing a soft shutdown on host $host using $vmName on vm:\n$vm\n";
43  if(!vmOps($host, $vm, 'stop soft'))
44  {
45  echo "FATAL! count not revert the current snapshot for $vmName on vm\n$vm\n";
46  }
47  } // foreach
48 } // foreach
49 */
50 // now revert snapshot
51 foreach($toRevert as $host => $vms)
52 {
53  $host = trim($host);
54  foreach ($vms as $vmName => $vm)
55  {
56  //echo "DB: vmName is:$vmName\n";
57  //echo "DB: vm is:$vm\n";
58  echo "Reverting snapshot on host $host using $vmName on vm:\n$vm\n";
59  if(!vmOps($host, $vm, 'revertsnapshot'))
60  {
61  echo "FATAL! count not revert the current snapshot for $vmName on vm\n$vm\n";
62  }
63  } // foreach
64 } // foreach
65 ?>
char * trim(char *ptext)
Trimming whitespace.
Definition: fossconfig.c:695