Coverage for python/lsst/ctrl/bps/ping.py: 67%

9 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2022-10-08 02:08 -0700

1# This file is part of ctrl_bps. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

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

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

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

17# GNU General Public License for more details. 

18# 

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

20# along with this program. If not, see <https://www.gnu.org/licenses/>. 

21 

22"""Supporting functions for pinging WMS service. 

23""" 

24 

25__all__ = ["ping"] 

26 

27import logging 

28 

29from lsst.utils import doImport 

30 

31_LOG = logging.getLogger(__name__) 

32 

33 

34def ping(wms_service, pass_thru=None): 

35 """Checks whether WMS services are up, reachable, and any authentication, 

36 if needed, succeeds. 

37 

38 The services to be checked are those needed for submit, report, cancel, 

39 restart, but ping cannot guarantee whether jobs would actually run 

40 successfully. 

41 

42 Parameters 

43 ---------- 

44 wms_service : `str` 

45 Name of the class. 

46 pass_thru : `str` 

47 A string to pass directly to the WMS service class. 

48 

49 Returns 

50 ------- 

51 status : `int` 

52 Services are available (0) or problems (not 0) 

53 message : `str` 

54 Any message from WMS (e.g., error details). 

55 """ 

56 wms_service_class = doImport(wms_service) 

57 wms_service = wms_service_class({}) 

58 

59 return wms_service.ping(pass_thru)