Ejemplo n.º 1
0
function showTab_cloudstack_import()
{
    /**************************
        File paths
       **************************/
    define("CLOUDSTACKCLIENT_FILE", dirname(__FILE__) . "/cloudstack_import/cloudstack-php-client/src/CloudStackClient.php");
    define("CLOUDSTACKCLIENT_CONFIG", dirname(__FILE__) . "/cloudstack_import/config.php");
    require CLOUDSTACKCLIENT_FILE;
    $config = (require CLOUDSTACKCLIENT_CONFIG);
    //Initialization
    $cloudstack = new CloudStackClient($config['endpoint'], $config['api_key'], $config['secret_key']);
    //Lists
    $vms = $cloudstack->listVirtualMachines($account = "fengce", $domainId = "9b832394-f254-4f6d-ba67-ed3979ac9fc6", $isRecursive = "true");
    $vm_count = count($vms);
    $html = "<table>";
    foreach ($vms as $vm) {
        $html = $html . "<tr>";
        $html .= "<td>" . $vm->state . "</td>";
        $html .= "<td>" . $vm->instancename . "</td>";
        $html .= "<td>" . $vm->zonename . "</td>";
        $html .= "<td>" . $vm->account . "</td>";
        $html .= "<td>" . $vm->hypervisor . "</td>";
        $html .= "<td>" . $vm->cpunumber . "</td>";
        $html .= "<td>" . $vm->memory . "</td>";
        $html .= "<td>" . $vm->created . "</td>";
        $html .= "<td>" . $vm->displayname . "</td>";
        $html .= "<td>" . $vm->hostname . "</td>";
        $html .= "</tr>";
    }
    $html .= "</table>";
    echo $html;
}
Ejemplo n.º 2
0
function showTab_cloudstack_import()
{
    /**************************
        File paths
       **************************/
    define("CLOUDSTACKCLIENT_FILE", dirname(__FILE__) . "/cloudstack_import/cloudstack-php-client/src/CloudStackClient.php");
    define("CLOUDSTACKCLIENT_CONFIG", dirname(__FILE__) . "/cloudstack_import/config.php");
    require CLOUDSTACKCLIENT_FILE;
    $config = (require CLOUDSTACKCLIENT_CONFIG);
    //Initialization
    $cloudstack = new CloudStackClient($config['endpoint'], $config['api_key'], $config['secret_key']);
    //Lists
    $vms = $cloudstack->listVirtualMachines();
    foreach ($vms as $vm) {
        echo "{$vm->id} : {$vm->name} {$vm->state}<br>";
    }
}
Ejemplo n.º 3
0
 */
require_once 'CloudStack/CloudStackClient.php';
$VERSION = '1.0';
$data = array('Running' => 0, 'Starting' => 0, 'Stopping' => 0, 'Destroyed' => 0);
$options = getopt('f:h', array('help'));
if (isset($options['h']) || isset($options['help'])) {
    usage();
}
if (isset($options['f']) && is_file($options['f'])) {
    $config = (require_once $options['f']);
} else {
    echo "UNKNOWN - No configuration file (-f) found.";
    exit(3);
}
$cloudstack = new CloudStackClient($config['API_ENDPOINT'], $config['API_KEY'], $config['API_SECRET']);
$vms = $cloudstack->listVirtualMachines();
$count = 0;
foreach ($vms as $vm) {
    if (isset($data[$vm->state])) {
        $data[$vm->state]++;
    }
}
$perfdata = array();
foreach ($data as $key => $value) {
    $perfdata[] = "{$key}={$value}";
}
echo "OK - " . implode(' ', $perfdata) . '|' . implode(' ', $perfdata);
exit(0);
function usage()
{
    global $data, $VERSION;