Skip to content

Commit 27c9e65

Browse files
committed
mgr/cephadm: add function to get service specs by service type
Instead of having to get all of them and then filter the results by service type, we can just have a function in the SpecStore class to do it for us. Signed-off-by: Adam King <[email protected]>
1 parent 7fcd9cb commit 27c9e65

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/pybind/mgr/cephadm/inventory.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,20 @@ def __getitem__(self, name: str) -> SpecDescription:
273273
self.spec_created[name],
274274
self.spec_deleted.get(name, None))
275275

276+
def get_by_service_type(self, service_type: str) -> List[SpecDescription]:
277+
matching_specs: List[SpecDescription] = []
278+
for name, spec in self._specs.items():
279+
if spec.service_type == service_type:
280+
matching_specs.append(
281+
SpecDescription(
282+
spec,
283+
self._rank_maps.get(name),
284+
self.spec_created[name],
285+
self.spec_deleted.get(name, None)
286+
)
287+
)
288+
return matching_specs
289+
276290
@property
277291
def active_specs(self) -> Mapping[str, ServiceSpec]:
278292
return {k: v for k, v in self._specs.items() if k not in self.spec_deleted}

0 commit comments

Comments
 (0)