Skip to content

Commit 0adb4a7

Browse files
committed
Update README; Coding Standards
1 parent 3c47315 commit 0adb4a7

File tree

3 files changed

+382
-371
lines changed

3 files changed

+382
-371
lines changed

README.md

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1-
This class provides the building blocks for someone wanting to use PHP to talk to Proxmox 2.0.
2-
Relatively simple piece of code, just provides a get/put/post/delete abstraction layer as methods
3-
on top of Proxmox's REST API, while also handling the Login Ticket headers required for authentication.
1+
# PVE2 API - PHP Client #
42

5-
See http://pve.proxmox.com/wiki/Proxmox_VE_API for information about how this API works.
6-
API spec available at http://pve.proxmox.com/pve2-api-doc/
3+
This class provides the building blocks for someone wanting to use PHP to talk
4+
to Proxmox 2.0+. Relatively simple piece of code, just provides a
5+
get/put/post/delete abstraction layer as methods on top of Proxmox's REST API,
6+
while also handling the Login Ticket headers required for authentication.
77

8-
## Requirements: ##
8+
See <http://pve.proxmox.com/wiki/Proxmox_VE_API> for information about how this
9+
API works. API spec available at <http://pve.proxmox.com/pve2-api-doc/>
10+
11+
## Requirements ##
912

1013
PHP 5 with cURL (including SSL) support.
1114

12-
## Usage: ##
15+
## Usage ##
1316

1417
Example - Return status array for each Proxmox Host in this cluster.
1518

19+
```php
1620
require("./pve2-api-php-client/pve2_api.class.php");
1721

1822
# You can try/catch exception handle the constructor here if you want.
1923
$pve2 = new PVE2_API("hostname", "username", "realm", "password");
2024
# realm above can be pve, pam or any other realm available.
2125

22-
/* Optional - enable debugging. It print()'s any results currently */
23-
// $pve2->set_debug(true);
24-
2526
if ($pve2->login()) {
2627
foreach ($pve2->get_node_list() as $node_name) {
2728
print_r($pve2->get("/nodes/".$node_name."/status"));
@@ -30,20 +31,18 @@ Example - Return status array for each Proxmox Host in this cluster.
3031
print("Login to Proxmox Host failed.\n");
3132
exit;
3233
}
34+
```
3335

3436
Example - Create a new OpenVZ Container on the first host in the cluster.
3537

38+
```php
3639
require("./pve2-api-php-client/pve2_api.class.php");
3740

3841
# You can try/catch exception handle the constructor here if you want.
3942
$pve2 = new PVE2_API("hostname", "username", "realm", "password");
4043
# realm above can be pve, pam or any other realm available.
4144

42-
/* Optional - enable debugging. It print()'s any results currently */
43-
// $pve2->set_debug(true);
44-
4545
if ($pve2->login()) {
46-
4746
# Get first node name.
4847
$nodes = $pve2->get_node_list();
4948
$first_node = $nodes[0];
@@ -69,20 +68,18 @@ Example - Create a new OpenVZ Container on the first host in the cluster.
6968
print("Login to Proxmox Host failed.\n");
7069
exit;
7170
}
71+
```
7272

7373
Example - Modify DNS settings on an existing container on the first host.
7474

75+
```php
7576
require("./pve2-api-php-client/pve2_api.class.php");
7677

7778
# You can try/catch exception handle the constructor here if you want.
7879
$pve2 = new PVE2_API("hostname", "username", "realm", "password");
7980
# realm above can be pve, pam or any other realm available.
8081

81-
/* Optional - enable debugging. It print()'s any results currently */
82-
// $pve2->set_debug(true);
83-
8482
if ($pve2->login()) {
85-
8683
# Get first node name.
8784
$nodes = $pve2->get_node_list();
8885
$first_node = $nodes[0];
@@ -98,25 +95,25 @@ Example - Modify DNS settings on an existing container on the first host.
9895
print("Login to Proxmox Host failed.\n");
9996
exit;
10097
}
98+
```
10199

102100
Example - Delete an existing container.
103101

102+
```php
104103
require("./pve2-api-php-client/pve2_api.class.php");
105104

106105
# You can try/catch exception handle the constructor here if you want.
107106
$pve2 = new PVE2_API("hostname", "username", "realm", "password");
108107
# realm above can be pve, pam or any other realm available.
109108

110-
/* Optional - enable debugging. It print()'s any results currently */
111-
// $pve2->set_debug(true);
112-
113109
if ($pve2->login()) {
114110
# NOTE - replace XXXX with node short name, and YYYY with container ID.
115111
var_dump($pve2->delete("/nodes/XXXX/openvz/YYYY"));
116112
} else {
117113
print("Login to Proxmox Host failed.\n");
118114
exit;
119115
}
116+
```
120117

121118
Licensed under the MIT License.
122119
See LICENSE file.

TODO

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
- add a new class extending PVE2_API that provides abstraction methods to common tasks, ie. create VM/container, change container settings, etc.
1+
- add a new class extending PVE2_API that provides abstraction methods to
2+
common tasks, ie. create VM/container, change container settings, etc.

0 commit comments

Comments
 (0)