monogramm/proxmox-bundle

ProxmoxVE API 集成到 Symfony

1.0.0 2018-04-08 15:27 UTC

This package is auto-updated.

Last update: 2024-09-29 05:01:54 UTC


README

此包将 ZzAntares Proxmox 的非官方 PHP 客户端 集成到 Symfony 框架 中。

Build Status Scrutinizer Code Quality Latest version

安装

使用 Composer 安装包

composer require monogramm/proxmox-bundle

然后,更新你的 app/config/AppKernel.php 文件

    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Monogramm\ProxmoxBundle\MonogrammProxmoxBundle(),
            // ...
        );

        return $bundles;
    }

app/config/config.yml 中配置包

monogramm_proxmox:
    hostname: "%proxmox_hostname%"
    username: "%proxmox_username%"
    password: "%proxmox_password%"
    realm:    "%proxmox_realm%"
    port:     "%proxmox_port%"

最后,更新你的 app/config/parameters.yml 文件以存储你的 Proxmox VE API 凭据

parameters:
    # ...
    proxmox_hostname: "proxmox.company.com"
    proxmox_username: "root"
    proxmox_password: "mysupersecretpassword"
    proxmox_realm:    "pam"
    proxmox_port:     "8006"

使用方法

该包自动在依赖注入容器中注册了一个 proxmox 服务。该服务是 \ProxmoxVE\Proxmox 的一个实例。

控制器中的示例使用

// ...

    public function nodesAction()
    {
        // Get all nodes
        $this
            ->get('proxmox')
            ->getNodes()
        ;

        // ...
    }

    public function createVmAction($targetnode, $id)
    {
        // Create an lxc container
        $this
            ->get('proxmox')
            ->create(
                "/nodes/$targetnode/lxc",
                [
                    'net0' => 'name=myct0,bridge=vmbr0',
                    'ostemplate' => 'local:vztmpl/debian-8.0-standard_8.0-1_amd64.tar.gz',
                    'vmid' => "$id",
                ]
            )
        ;

        // ...
    }


// ...

贡献

查看 CONTRIBUTING 文件。

许可证

查看 LICENSE 文件。

作者

优秀的贡献者