Skip to content

Commit

Permalink
Update README; Coding Standards
Browse files Browse the repository at this point in the history
  • Loading branch information
danhunsaker committed Jul 14, 2016
1 parent 9437acf commit 4ee7d36
Show file tree
Hide file tree
Showing 3 changed files with 383 additions and 375 deletions.
42 changes: 18 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
This class provides the building blocks for someone wanting to use PHP to talk to Proxmox 2.0.
Relatively simple piece of code, just provides a get/put/post/delete abstraction layer as methods
on top of Proxmox's REST API, while also handling the Login Ticket headers required for authentication.
# PVE2 API - PHP Client #

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

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

## Requirements ##

PHP 5 with cURL (including SSL) support.

## Usage: ##
## Usage ##

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

```php
require("./pve2-api-php-client/pve2_api.class.php");

$pve2 = new PVE2_API("hostname", "username", "realm", "password");
# realm above can be pve, pam or any other realm available.

if ($pve2->constructor_success()) {
/* Optional - enable debugging. It print()'s any results currently */
// $pve2->set_debug(true);

if ($pve2->login()) {
foreach ($pve2->get_node_list() as $node_name) {
print_r($pve2->get("/nodes/".$node_name."/status"));
Expand All @@ -34,21 +35,18 @@ Example - Return status array for each Proxmox Host in this cluster.
print("Could not create PVE2_API object.\n");
exit;
}
```

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

```php
require("./pve2-api-php-client/pve2_api.class.php");

$pve2 = new PVE2_API("hostname", "username", "realm", "password");
# realm above can be pve, pam or any other realm available.

if ($pve2->constructor_success()) {

/* Optional - enable debugging. It print()'s any results currently */
// $pve2->set_debug(true);

if ($pve2->login()) {

# Get first node name.
$nodes = $pve2->get_node_list();
$first_node = $nodes[0];
Expand Down Expand Up @@ -78,21 +76,18 @@ Example - Create a new OpenVZ Container on the first host in the cluster.
print("Could not create PVE2_API object.\n");
exit;
}
```

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

```php
require("./pve2-api-php-client/pve2_api.class.php");

$pve2 = new PVE2_API("hostname", "username", "realm", "password");
# realm above can be pve, pam or any other realm available.

if ($pve2->constructor_success()) {

/* Optional - enable debugging. It print()'s any results currently */
// $pve2->set_debug(true);

if ($pve2->login()) {

# Get first node name.
$nodes = $pve2->get_node_list();
$first_node = $nodes[0];
Expand All @@ -112,19 +107,17 @@ Example - Modify DNS settings on an existing container on the first host.
print("Could not create PVE2_API object.\n");
exit;
}
```

Example - Delete an existing container.

```php
require("./pve2-api-php-client/pve2_api.class.php");

$pve2 = new PVE2_API("hostname", "username", "realm", "password");
# realm above can be pve, pam or any other realm available.

if ($pve2->constructor_success()) {

/* Optional - enable debugging. It print()'s any results currently */
// $pve2->set_debug(true);

if ($pve2->login()) {
# NOTE - replace XXXX with node short name, and YYYY with container ID.
var_dump($pve2->delete("/nodes/XXXX/openvz/YYYY"));
Expand All @@ -136,6 +129,7 @@ Example - Delete an existing container.
print("Could not create PVE2_API object.\n");
exit;
}
```

Licensed under the MIT License.
See LICENSE file.
3 changes: 2 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- add a new class extending PVE2_API that provides abstraction methods to common tasks, ie. create VM/container, change container settings, etc.
- add a new class extending PVE2_API that provides abstraction methods to
common tasks, ie. create VM/container, change container settings, etc.
Loading

0 comments on commit 4ee7d36

Please sign in to comment.