Coverage for manila/api/views/scheduler_stats.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2026-02-18 22:19 +0000

1# Copyright (c) 2014 eBay Inc. 

2# Copyright (c) 2015 Rushil Chugh 

3# Copyright (c) 2015 Clinton Knight 

4# All Rights Reserved. 

5# 

6# Licensed under the Apache License, Version 2.0 (the "License"); you may 

7# not use this file except in compliance with the License. You may obtain 

8# a copy of the License at 

9# 

10# http://www.apache.org/licenses/LICENSE-2.0 

11# 

12# Unless required by applicable law or agreed to in writing, software 

13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

15# License for the specific language governing permissions and limitations 

16# under the License. 

17 

18from manila.api import common 

19 

20 

21class ViewBuilder(common.ViewBuilder): 

22 """Model scheduler-stats API responses as a python dictionary.""" 

23 

24 _collection_name = "scheduler-stats" 

25 

26 def pool_summary(self, pool): 

27 """Summary view of a single pool.""" 

28 return { 

29 'pool': { 

30 'name': pool.get('name'), 

31 'host': pool.get('host'), 

32 'backend': pool.get('backend'), 

33 'pool': pool.get('pool'), 

34 } 

35 } 

36 

37 def pool_detail(self, pool): 

38 """Detailed view of a single pool.""" 

39 return { 

40 'pool': { 

41 'name': pool.get('name'), 

42 'host': pool.get('host'), 

43 'backend': pool.get('backend'), 

44 'pool': pool.get('pool'), 

45 'capabilities': pool.get('capabilities'), 

46 } 

47 } 

48 

49 def pools(self, pools, detail=False): 

50 """View of a list of pools seen by scheduler.""" 

51 view_method = self.pool_detail if detail else self.pool_summary 

52 return {"pools": [view_method(pool)['pool'] for pool in pools]}