FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
common-vm.php
1 <?php
2 /*
3  Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
39 function vmOps($host,$vm, $command)
40 {
41  $inout = array();
42  $inrtn = -1;
43  $turnOnVm = NULL;
44  $errors = 0;
45 
46  if(empty($host))
47  {
48  return(FALSE); // void
49  }
50  if(empty($command))
51  {
52  return(FALSE);
53  }
54  if(is_array($vm))
55  {
56  foreach($vm as $machine)
57  {
58  $turnOnVm = "vmware-cmd -H $host -U root -P iforgot $vm $command 2>&1";
59  $laston = exec($turnOnVm, $inout, $inrtn);
60  echo "DB: Ops: inrtn is:$inrtn\n";
61  echo "DB: Ops: inout is:\n"; print_r($inout) . "\n";
62  if($inrtn != 0)
63  {
64  echo "Error: could not $command on $vm on $host\n";
65  $errors++;
66  }
67  $inout = array();
68  }
69  }
70  else
71  {
72  $turnOnVm = "vmware-cmd -H $host -U root -P iforgot $vm $command 2>&1";
73  $laston = exec($turnOnVm, $inout, $inrtn);
74  //echo "DB: Ops: inrtn is:$inrtn\n";
75  //echo "DB: Ops: inout is:\n"; print_r($inout) . "\n";
76  if($inrtn != 0)
77  {
78  echo "Error: could not $command on $vm on $host\n";
79  $errors++;
80  }
81  }
82  if($errors)
83  {
84  return(FALSE);
85  }
86  else
87  {
88  return(TRUE);
89  }
90 }
91 ?>