Coverage for python/lsst/ctrl/execute/pbsPlugin.py: 18%

Shortcuts 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

48 statements  

1#!/usr/bin/env python 

2 

3# 

4# LSST Data Management System 

5# Copyright 2008-2016 LSST Corporation. 

6# 

7# This product includes software developed by the 

8# LSST Project (http://www.lsst.org/). 

9# 

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

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

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

13# (at your option) any later version. 

14# 

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

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

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

18# GNU General Public License for more details. 

19# 

20# You should have received a copy of the LSST License Statement and 

21# the GNU General Public License along with this program. If not, 

22# see <http://www.lsstcorp.org/LegalNotices/>. 

23# 

24 

25import os 

26import sys 

27from string import Template 

28 

29from lsst.ctrl.execute.allocator import Allocator 

30 

31 

32class PbsPlugin(Allocator): 

33 

34 def submit(self, platform, platformPkgDir): 

35 # This have specific paths to prevent abitrary binaries from being 

36 # executed. The "gsi"* utilities are configured to use either grid 

37 # proxies or ssh, automatically. 

38 remoteLoginCmd = "/usr/bin/gsissh" 

39 remoteCopyCmd = "/usr/bin/gsiscp" 

40 

41 configName = os.path.join(platformPkgDir, "etc", "config", "pbsConfig.py") 

42 

43 self.loadPbs(configName) 

44 verbose = self.isVerbose() 

45 

46 pbsName = os.path.join(platformPkgDir, "etc", "templates", "generic.pbs.template") 

47 generatedPbsFile = self.createPbsFile(pbsName) 

48 

49 condorFile = os.path.join(platformPkgDir, "etc", "templates", "glidein_condor_config.template") 

50 generatedCondorConfigFile = self.createCondorConfigFile(condorFile) 

51 

52 scratchDirParam = self.getScratchDirectory() 

53 template = Template(scratchDirParam) 

54 scratchDir = template.substitute(USER_HOME=self.getUserHome()) 

55 

56 userName = self.getUserName() 

57 hostName = self.getHostName() 

58 

59 utilityPath = self.getUtilityPath() 

60 

61 # 

62 # execute copy of PBS file to XSEDE node 

63 # 

64 cmd = "%s %s %s@%s:%s/%s" % (remoteCopyCmd, generatedPbsFile, userName, 

65 hostName, scratchDir, os.path.basename(generatedPbsFile)) 

66 if verbose: 

67 print(cmd) 

68 exitCode = self.runCommand(cmd, verbose) 

69 if exitCode != 0: 

70 print("error running %s to %s." % (remoteCopyCmd, hostName)) 

71 sys.exit(exitCode) 

72 

73 # 

74 # execute copy of Condor config file to XSEDE node 

75 # 

76 cmd = "%s %s %s@%s:%s/%s" % (remoteCopyCmd, generatedCondorConfigFile, userName, 

77 hostName, scratchDir, os.path.basename(generatedCondorConfigFile)) 

78 if verbose: 

79 print(cmd) 

80 exitCode = self.runCommand(cmd, verbose) 

81 if exitCode != 0: 

82 print("error running %s to %s." % (remoteCopyCmd, hostName)) 

83 sys.exit(exitCode) 

84 

85 # 

86 # execute qsub command on XSEDE node to perform Condor glide-in 

87 # 

88 cmd = "%s %s@%s %s/qsub %s/%s" % (remoteLoginCmd, userName, hostName, 

89 utilityPath, scratchDir, os.path.basename(generatedPbsFile)) 

90 if verbose: 

91 print(cmd) 

92 exitCode = self.runCommand(cmd, verbose) 

93 if exitCode != 0: 

94 print("error running %s to %s." % (remoteLoginCmd, hostName)) 

95 sys.exit(exitCode) 

96 

97 self.printNodeSetInfo() 

98 

99 def loadPbs(self, name): 

100 configuration = self.loadAllocationConfig(name, "pbs") 

101 template = Template(configuration.platform.scratchDirectory) 

102 scratchDir = template.substitute(USER_HOME=self.getUserHome()) 

103 self.defaults["SCRATCH_DIR"] = scratchDir