sapistudio/proxmox

2.0.3 2020-09-21 22:01 UTC

This package is auto-updated.

Last update: 2024-09-22 06:35:36 UTC


README

https://github.com/ZzAntares/ProxmoxVE.git 后分支

这个 PHP 5.4+ 库允许您通过 API 与您的 Proxmox 服务器交互。

安装

建议使用 [Composer] 进行安装,如果您还没有 [Composer],您还在等什么?

在您的项目根目录下执行以下操作

$ composer require sapistudio/proxmox

用法

<?php

// Require the autoloader
require_once 'vendor/autoload.php';

// Use the library namespace
use SapiStudio\Proxmox\Handler;

// Create your credentials array
$credentials = [
    'hostname' => 'proxmox.server.com',  // Also can be an IP
    'username' => 'root',
    'password' => 'secret',
];

// realm and port defaults to 'pam' and '8006' but you can specify them like so
$credentials = [
    'hostname' => 'proxmox.server.com',
    'username' => 'root',
    'password' => 'secret',
    'realm' => 'pve',
    'port' => '9009',
];

// Then simply pass your credentials when creating the API client object.
$proxmox = Handler::Nodes($credentials);

$allNodes = $proxmox->listNodes();

print_r($allNodes);

示例输出

Array
(
    [data] => Array
        (
            [0] => Array
                (
                    [disk] => 2539465464
                    [cpu] => 0.031314446882002
                    [maxdisk] => 30805066770
                    [maxmem] => 175168446464
                    [node] => mynode1
                    [maxcpu] => 24
                    [level] =>
                    [uptime] => 139376
                    [id] => node/mynode1
                    [type] => node
                    [mem] => 20601992182
                )

        )

)

访问节点 ID 数据

// set node id
$proxmox->setNodeId($noedName);
//and access nodeIddata
$proxmox->listNodeQemus();

许可证

本项目采用 MIT 许可证发布。有关详细信息,请参阅附带 的 [LICENSE] 文件。