Skip to content

Commit 58d4f8c

Browse files
committed
Focusing on hypervisor instead of host
1 parent 613b597 commit 58d4f8c

File tree

3 files changed

+18
-61
lines changed

3 files changed

+18
-61
lines changed

src/Compute/v2/Api.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -642,23 +642,23 @@ public function getHypervisorStatistics(): array
642642
];
643643
}
644644

645-
public function getHosts(): array
645+
public function getHypervisors(): array
646646
{
647647
return [
648648
'method' => 'GET',
649-
'path' => 'os-hosts',
649+
'path' => 'os-hypervisors',
650650
'params' => [
651-
'name' => $this->params->filterName()
651+
'limit' => $this->params->limit(),
652+
'marker' => $this->params->marker()
652653
],
653654
];
654655
}
655656

656-
public function getHost(): array
657+
public function getHypervisorsDetail(): array
657658
{
658-
return [
659-
'method' => 'GET',
660-
'path' => 'os-hosts/{name}',
661-
'params' => ['name' => $this->params->urlId('host')]
662-
];
659+
$definition = $this->getHypervisors();
660+
$definition['path'] .= '/detail';
661+
return $definition;
663662
}
663+
664664
}

src/Compute/v2/Models/Host.php

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/Compute/v2/Service.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use OpenStack\Compute\v2\Models\Keypair;
1010
use OpenStack\Compute\v2\Models\Limit;
1111
use OpenStack\Compute\v2\Models\Server;
12-
use OpenStack\Compute\v2\Models\Host;
12+
use OpenStack\Compute\v2\Models\Hypervisor;
1313

1414
/**
1515
* Compute v2 service for OpenStack.
@@ -202,16 +202,19 @@ public function getHypervisorStatistics(): HypervisorStatistic
202202
}
203203

204204
/**
205-
* List hosts.
205+
* List hypervisors.
206206
*
207-
* @param array $options {@see \OpenStack\Compute\v2\Api::getHosts}
207+
* @param bool $detailed Determines whether detailed information will be returned. If FALSE is specified, only
208+
* the ID, name and links attributes are returned, saving bandwidth.
209+
* @param array $options {@see \OpenStack\Compute\v2\Api::getHypervisors}
208210
* @param callable $mapFn A callable function that will be invoked on every iteration of the list.
209211
*
210212
* @return \Generator
211213
*/
212-
public function listHosts(array $options = [], callable $mapFn = null): \Generator
214+
public function listHypervisors(bool $detailed = false, array $options = [], callable $mapFn = null): \Generator
213215
{
214-
$def = $this->api->getHosts();
215-
return $this->model(Host::class)->enumerate($def, $options, $mapFn);
216+
$def = ($detailed === true) ? $this->api->getHypervisorsDetail() : $this->api->getHypervisors();
217+
return $this->model(Hypervisor::class)->enumerate($def, $options, $mapFn);
216218
}
219+
217220
}

0 commit comments

Comments
 (0)