2015-08-27 21:06:07 +02:00
< ? php
2015-08-28 11:01:36 +02:00
/*
* Copyright ( C ) 2015 Mark Schouten < mark @ tuxis . nl >
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; version 2 dated June ,
* 1991.
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
2021-02-09 00:29:04 +01:00
* See https :// www . gnu . org / licenses / gpl . txt for the full license
2015-08-28 11:01:36 +02:00
*/
2015-09-01 10:14:15 +02:00
/**
* Fetch all VM ' s in a Proxmox Cluster
2021-09-10 20:09:53 +02:00
*
2021-09-08 23:35:56 +02:00
* @ param string $c Clustername
2015-09-01 10:14:15 +02:00
* @ return array An array with all the VM ' s on this cluster
*/
2016-08-18 20:28:22 -05:00
function proxmox_cluster_vms ( $c )
{
2020-09-21 15:59:34 +02:00
return dbFetchRows ( 'SELECT * FROM proxmox WHERE cluster = ? ORDER BY vmid' , [ $c ]);
2015-08-27 21:06:07 +02:00
}
2015-09-01 10:14:15 +02:00
/**
* Fetch all VM ' s on a Proxmox node
2021-09-10 20:09:53 +02:00
*
2021-09-08 23:35:56 +02:00
* @ param int $n device_id
2015-09-01 10:14:15 +02:00
* @ return array An array with all the VM ' s on this node
*/
2016-08-18 20:28:22 -05:00
function proxmox_node_vms ( $n )
{
2020-09-21 15:59:34 +02:00
return dbFetchRows ( 'SELECT * FROM proxmox WHERE device_id = ? ORDER BY vmid' , [ $n ]);
2015-08-27 21:06:07 +02:00
}
2015-09-01 10:14:15 +02:00
/**
* Fetch all info about a Proxmox VM
2021-09-10 20:09:53 +02:00
*
2021-09-08 23:35:56 +02:00
* @ param int $vmid Proxmox VM ID
* @ param string $c Clustername
2015-09-01 10:14:15 +02:00
* @ return array An array with all info of this VM on this cluster , including ports
*/
2016-08-18 20:28:22 -05:00
function proxmox_vm_info ( $vmid , $c )
{
2020-09-21 15:59:34 +02:00
$vm = dbFetchRow ( 'SELECT pm.*, d.hostname AS host, d.device_id FROM proxmox pm, devices d WHERE pm.device_id = d.device_id AND pm.vmid = ? AND pm.cluster = ?' , [ $vmid , $c ]);
$appid = dbFetchRow ( 'SELECT app_id FROM applications WHERE device_id = ? AND app_type = ?' , [ $vm [ 'device_id' ], 'proxmox' ]);
2015-08-27 21:06:07 +02:00
2020-09-21 15:59:34 +02:00
$vm [ 'ports' ] = dbFetchRows ( 'SELECT * FROM proxmox_ports WHERE vm_id = ?' , [ $vm [ 'id' ]]);
2015-08-27 21:06:07 +02:00
$vm [ 'app_id' ] = $appid [ 'app_id' ];
2020-09-21 15:40:17 +02:00
2015-08-27 21:06:07 +02:00
return $vm ;
}