Exemplo n.º 1
0
function stop()
{
    $pve2 = new PVE2_API((string) $_SESSION['api'], (string) $_SESSION['user'], "pve", (string) $_SESSION['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()) {
            print_r($pve2->post("/nodes/" . $_SESSION['pve'] . "/openvz/" . $_SESSION['vm'] . "/status/stop", "stop"));
            print "\n\n";
        } else {
            print "Login to Proxmox Host failed.\n";
            exit;
        }
    }
}
Exemplo n.º 2
0
<?php

header("Content-type: text/javascript");
require "../../config.php";
require "./assets/pve2_api.class.php";
$srv = mysql_real_escape_string($_GET['srv']);
$query = mysql_query('SELECT primary_server.address, primary_server.pve, vm.vm FROM server, primary_server, vm WHERE vm.name="' . $_GET['srv'] . '" AND primary_server.id = server.id_primary_server AND server.id_users = "' . $_SESSION['id'] . '"') or die(mysql_error());
$row = mysql_fetch_array($query) or die(mysql_error());
//$pve2 = new PVE2_API((string)$_SESSION['pve'], (string)$_SESSION['user'], "pve", (string)$_SESSION['password']);
$pve2 = new PVE2_API((string) $row['address'], (string) $_SESSION['user'], "pve", (string) $_SESSION['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()) {
        //print_r($pve2->get("/nodes/local/openvz/101/status/current"));
        echo json_encode($pve2->get("/nodes/" . $row['pve'] . "/openvz/" . $row['vm'] . "/status/current"));
    } else {
        print "Login to Proxmox Host failed.\n";
        exit;
    }
} else {
    print "Could not create PVE2_API object.\n";
    exit;
}