alexisducastel / pve2api
该包最新版本(1.0.1)没有提供许可信息。
这是一个简单的PHP客户端,用于Proxmox API。
1.0.1
2014-05-30 22:21 UTC
This package is not auto-updated.
Last update: 2024-09-24 06:05:08 UTC
README
此类实现了对Proxmox API(版本2或更高)的简单PHP客户端。
有关此API工作方式的信息,请参阅 http://pve.proxmox.com/wiki/Proxmox_VE_API。API规范可在 http://pve.proxmox.com/pve2-api-doc/ 找到。
要求
PHP 5支持cURL(包括SSL)。
用法
示例 - 返回此集群中每个Proxmox主机的状态数组。
# use composer autoloader
require_once __DIR__."/vendor/autoload.php";
$api=new PVE\Api\Client('hostname');
# realm can be pve, pam or any other realm available.
$api->login('login','realm','password');
foreach ($api->get_node_list() as $node_name) {
print_r($api->get("/nodes/".$node_name."/status"));
}
示例 - 在集群中的第一个主机上创建一个新的OpenVZ容器。
# use composer autoloader
require_once __DIR__."/vendor/autoload.php";
$api=new PVE\Api\Client('hostname');
# realm can be pve, pam or any other realm available.
$api->login('login','realm','password');
# Get first node name.
$nodes = $api->get_node_list();
# Create a VZ container on the first node in the cluster.
$new_container_settings = array();
$new_container_settings['ostemplate'] = "local:vztmpl/debian-6.0-standard_6.0-4_amd64.tar.gz";
$new_container_settings['vmid'] = "1234";
$new_container_settings['cpus'] = "2";
$new_container_settings['description'] = "Test VM using Proxmox 2.0 API";
$new_container_settings['disk'] = "8";
$new_container_settings['hostname'] = "testapi.domain.tld";
$new_container_settings['memory'] = "1024";
$new_container_settings['nameserver'] = "8.8.8.8";
print_r($api->post("/nodes/".$nodes[0]."/openvz", $new_container_settings));
示例 - 修改第一个主机上现有容器的DNS设置。
# use composer autoloader
require_once __DIR__."/vendor/autoload.php";
$api=new PVE\Api\Client('hostname');
# realm can be pve, pam or any other realm available.
$api->login('login','realm','password');
# Get first node name.
$nodes = $api->get_node_list();
$openvzId = "100";
# Update container settings.
$container_settings = array();
$container_settings['nameserver'] = "4.2.2.2";
var_dump($api->put("/nodes/".$first_node."/openvz/".$openvzId."/config", $container_settings));
示例 - 删除现有容器。
# use composer autoloader
require_once __DIR__."/vendor/autoload.php";
$api=new PVE\Api\Client('hostname');
# realm can be pve, pam or any other realm available.
$api->login('login','realm','password');
# Get first node name.
$nodes = $api->get_node_list();
$openvzId = "100";
var_dump($api->delete("/nodes/".$nodes[0]."/openvz/".$openvzId));
根据MIT许可协议授权。请参阅LICENSE文件。