Skip to content

Commit 277fe32

Browse files
committed
Merge pull request #1 from haphan/hypervisor-stats
Added Hypervisor stats sdk
2 parents 21547b5 + f7b7a74 commit 277fe32

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

src/Compute/v2/Api.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,4 +555,14 @@ public function deleteVolumeAttachments(): array
555555
]
556556
];
557557
}
558+
559+
public function getHypervisorStatistics(): array
560+
{
561+
return [
562+
'method' => 'GET',
563+
'path' => 'os-hypervisors/statistics',
564+
'params' => [
565+
]
566+
];
567+
}
558568
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php declare (strict_types = 1);
2+
3+
namespace OpenStack\Compute\v2\Models;
4+
5+
use OpenCloud\Common\Resource\Creatable;
6+
use OpenCloud\Common\Resource\OperatorResource;
7+
use OpenCloud\Common\Resource\Retrievable;
8+
use OpenCloud\Common\Transport\Utils;
9+
10+
/**
11+
* Represents a Compute v2 Quota
12+
*
13+
* @property \OpenStack\Compute\v2\Api $api
14+
*/
15+
class HypervisorStatistic extends OperatorResource
16+
{
17+
public $count;
18+
public $vcpus_used;
19+
public $local_gb_used;
20+
public $memory_mb;
21+
public $current_workload;
22+
public $vcpus;
23+
public $running_vms;
24+
public $free_disk_gb;
25+
public $disk_available_least;
26+
public $local_gb;
27+
public $free_ram_mb;
28+
public $memory_mb_used;
29+
protected $resourceKey = 'hypervisor_statistics';
30+
}

src/Compute/v2/Service.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use OpenCloud\Common\Service\AbstractService;
66
use OpenStack\Compute\v2\Models\Flavor;
7+
use OpenStack\Compute\v2\Models\HypervisorStatistic;
78
use OpenStack\Compute\v2\Models\Image;
89
use OpenStack\Compute\v2\Models\Keypair;
910
use OpenStack\Compute\v2\Models\Limit;
@@ -186,4 +187,16 @@ public function getLimits(): Limit
186187
$limits->populateFromResponse($this->execute($this->api->getLimits(), []));
187188
return $limits;
188189
}
190+
191+
/**
192+
* Shows summary statistics for all hypervisors over all compute nodes.
193+
*
194+
* @return HypervisorStatistic
195+
*/
196+
public function getHypervisorStatistics(): HypervisorStatistic
197+
{
198+
$statistics = $this->model(HypervisorStatistic::class);
199+
$statistics->populateFromResponse($this->execute($this->api->getHypervisorStatistics(), []));
200+
return $statistics;
201+
}
189202
}

0 commit comments

Comments
 (0)