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

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

############################################################################### 

# (c) Copyright 2016 CERN # 

# # 

# This software is distributed under the terms of the GNU General Public # 

# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # 

# # 

# In applying this licence, CERN does not waive the privileges and immunities # 

# granted to it by virtue of its status as an Intergovernmental Organization # 

# or submit itself to any jurisdiction. # 

############################################################################### 

''' 

Slot manager for CVMFS Tools 

@author: Stefan-Gabriel CHITIC, Ben Couturier 

''' 

 

import subprocess 

import logging 

from lbCVMFSTools.TransactionHandlerInterface import \ 

TransactionHandlerInterface 

 

 

class CVMFSTransactionHandler(TransactionHandlerInterface): 

 

def __init__(self, reponame, *args, **kwargs): 

self.reponame = reponame 

super(CVMFSTransactionHandler, self).__init__(*args, **kwargs) 

self.log_prefix = '' 

if self.dry_run: 

self.log_prefix = 'IN DRY-RUN MODE: ' 

 

def transactionStart(self): 

""" Start a CVMFS transaction """ 

logging.info("%sCalled CVMFS Transaction start" % self.log_prefix) 

if self.dry_run is True: 

return 

rc = subprocess.call(["cvmfs_server", "transaction", self.reponame]) 

if rc != 0: 

raise(RuntimeError("Could not start CVMFS transaction")) 

 

def transactionPublish(self): 

""" Publish a CVMFS transaction """ 

logging.info("%sCalled CVMFS Transaction publish" % self.log_prefix) 

 

if self.dry_run is True: 

return 

subprocess.call(["checkfds"]) 

newenv = dict() 

newenv["PATH"] = "/home/cvlhcbdev/bin:/usr/sue/bin" \ 

":/sbin:/bin:/usr/sbin:/usr/bin:" \ 

"/usr/local/sbin:/home/cvlhcbdev/bin" 

rc = subprocess.call(["cvmfs_server", "publish", self.reponame], 

env=newenv) 

 

if rc != 0: 

subprocess.call(["checkfds"]) 

raise(RuntimeError("Could not publish CVMFS transaction")) 

 

def transactionAbort(self): 

""" Abort a CVMFS transaction """ 

logging.info("%sCalled CVMFS Transaction abort" % self.log_prefix) 

if self.dry_run is True: 

return 

rc = subprocess.call(["cvmfs_server", "abort", "-f", self.reponame]) 

if rc != 0: 

raise(RuntimeError("Could not abort CVMFS transaction"))