plinker / lxd
通过RPC控制LXD
v0.0.30
2022-08-16 19:22 UTC
Requires
- plinker/core: >=0.1
Requires (Dev)
- phpunit/phpunit: 4.*
This package is not auto-updated.
Last update: 2024-09-25 05:17:52 UTC
README
通过RPC控制LXD,使用本地LXD实例和lxc query
来管理本地或远程LXD服务器。
安装
使用以下命令通过Composer安装此包:
$ composer require plinker/lxd
配置
Web服务器用户必须能够执行lxc
命令,因此请将该用户添加到sudoers文件中的User privilege specification
部分
# User privilege specification
root ALL=(ALL:ALL) ALL
www-data ALL=(ALL:ALL) NOPASSWD: /usr/bin/lxc
还要将www-data添加到lxd组中:
sudo usermod --append --groups lxd www-data
客户端
创建客户端实例的步骤如下
<?php
require 'vendor/autoload.php';
/**
* Initialize plinker client.
*
* @param string $server - URL to server listener.
* @param string $config - server secret, and/or a additional component data
*/
$client = new \Plinker\Core\Client(
'http://example.com/server.php',
[
'secret' => 'a secret password'
]
);
// or using global function
$client = plinker_client('http://example.com/server.php', 'a secret password');
基本用法
基本上,您可以使用单个$client->lxd->query()
方法执行任何LXD操作,或者您可以使用辅助方法,这些方法涵盖了所有LXD端点。
参数 & 调用
$client->lxd->query('remote:/1.0', 'GET', []);
完整文档
要查看此组件的完整文档(包括所有方法),请参阅:https://plinker-rpc.github.io/lxd/
方法
设置完成后,您可以通过其命名空间调用类及其方法,有关更多详细信息,请参阅文档。
列出容器
列出远程容器。
参数 & 调用
$client->lxd->containers->list('local', function ($result) { return str_replace('/1.0/containers/', '', $result); });
响应
Array
(
[0] => my-container
)
测试
此组件未设置测试。
贡献
请参阅CONTRIBUTING以获取详细信息。
安全
如果您发现任何安全相关的问题,请通过https://cherone.co.uk与我联系,而不是使用问题跟踪器。
致谢
开发鼓励
如果您使用此项目并从中获利或想表达您的感激之情,请随时捐赠https://www.paypal.me/lcherone,谢谢。
赞助商
在文档和每个GitHub仓库中列出您的公司或名称,请联系https://cherone.co.uk获取更多信息。
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。
请参阅组织页面以获取更多组件。