source: trunk/class/Server.php

Last change on this file was 18, checked in by maron, 13 years ago

kostra webu

File size: 2.1 KB
Line 
1<?php
2
3// class to control vps server
4// Date: 2012-06-23
5
6/*
7vzctl [flags] create CTID --parameter value [...]
8vzctl [flags] start CTID [--wait] [--force]
9vzctl [flags] stop CTID [--fast]
10vzctl [flags] restart CTID [--wait] [--force] [--fast]
11vzctl [flags] chkpnt | restore [--dumpfile name]
12vzctl [flags] snapshot [--id uuid] [--name name] [--description desc] [--skip-suspend]
13vzctl [flags] snapshot-switch | snapshot-delete --id uuid
14vzctl [flags] snapshot-list
15vzctl [flags] set CTID --parameter value [...] [--save] [--force] [--reset_ub] [--setmode restart|ignore]
16vzctl [flags] destroy | delete | mount | umount | status | quotaon | quotaoff | quotainit CTID
17vzctl [flags] console CTID [ttynum]
18vzctl [flags] convert CTID [--layout ploop[:{expanded|plain|raw}]]
19vzctl [flags] exec | exec2 CTID command [arg ...]
20vzctl [flags] enter CTID [--exec command [arg ...]]
21vzctl [flags] runscript CTID script
22vzctl --help | --version
23 */
24
25
26
27
28class Server
29{
30 protected $Id = -1;
31 public $LastReturn = -1;
32 private $LogFile = '/var/log/'; //vps.ID.log
33
34 function __construct($Id)
35 {
36 $this->Id = $Id;
37 $this->LogFile = $this->LogFile.'.'.$this->Id.'.log';
38 }
39
40 function create()
41 {
42 exec('vzctl create '.$this->Id.' 1> '.$this->LogFile,$output,$this->LastReturn);
43 return $this->LastReturn;
44 }
45
46 function start()
47 {
48 exec('vzctl start '.$this->Id.' 1> '.$this->LogFile,$output,$this->LastReturn);
49 return $this->LastReturn;
50 }
51
52 function stop()
53 {
54 exec('vzctl stop '.$this->Id.' 1> '.$this->LogFile,$output,$this->LastReturn);
55 return $this->LastReturn;
56 }
57
58 function restart()
59 {
60 exec('vzctl restart '.$this->Id.' 1> '.$this->LogFile,$output,$this->LastReturn);
61 return $this->LastReturn;
62 }
63
64 function destroy()
65 {
66 exec('vzctl destroy '.$this->Id.' 1> '.$this->LogFile,$output,$this->LastReturn);
67 return $this->LastReturn;
68 }
69
70
71 function exec($command)
72 {
73 exec('vzctl create '.$this->Id.' '.$command.' 1> '.$this->LogFile,$output,$this->LastReturn);
74 return $this->LastReturn;
75 }
76
77 function GetId()
78 {
79 return $this->Id;
80 }
81}
82
83?>
Note: See TracBrowser for help on using the repository browser.