Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1#!/usr/bin/python3 

2 

3# Copyright (C) Cloud Software Group, Inc. 

4# 

5# This program is free software; you can redistribute it and/or modify 

6# it under the terms of the GNU Lesser General Public License as published 

7# by the Free Software Foundation; version 2.1 only. 

8# 

9# This program is distributed in the hope that it will be useful, 

10# but WITHOUT ANY WARRANTY; without even the implied warranty of 

11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

12# GNU Lesser General Public License for more details. 

13# 

14# You should have received a copy of the GNU Lesser General Public License 

15# along with this program; if not, write to the Free Software Foundation, Inc., 

16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 

17 

18""" 

19Health check for SR, to be triggered periodically by a systemd timer. What is checked is 

20SR implementation type dependent. 

21""" 

22 

23import SR 

24import util 

25 

26 

27def main(): 

28 """ 

29 For all locally plugged SRs check that they are healthy 

30 """ 

31 try: 

32 session = util.get_localAPI_session() 

33 except SR.SROSError: 

34 util.SMlog("Unable to open local XAPI session", priority=util.LOG_ERR) 

35 return 

36 

37 localhost = util.get_localhost_ref(session) 

38 

39 sm_types = [x['type'] for x in session.xenapi.SM.get_all_records_where( 

40 'field "required_api_version" = "1.0"').values()] 

41 for sm_type in sm_types: 

42 srs = session.xenapi.SR.get_all_records_where( 

43 f'field "type" = "{sm_type}"') 

44 for sr in srs: 

45 pbds = session.xenapi.PBD.get_all_records_where( 

46 f'field "SR" = "{sr}" and field "host" = "{localhost}"') 

47 if not pbds: 

48 continue 

49 

50 pbd_ref, pbd = pbds.popitem() 

51 if not pbd['currently_attached']: 

52 continue 

53 

54 sr_uuid = srs[sr]['uuid'] 

55 sr_obj = SR.SR.from_uuid(session, sr_uuid) 

56 sr_obj.check_sr(sr_uuid) 

57 

58 

59if __name__ == "__main__": 59 ↛ 60line 59 didn't jump to line 60, because the condition on line 59 was never true

60 main()