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) 2026 Vates SAS 

4# 

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

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

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

8# (at your option) any later version. 

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 General Public License for more details. 

13# 

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

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

16# 

17 

18import sys 

19import os 

20sys.path.append("/opt/xensource/sm/") 

21import lvutil 

22import util 

23from lvmcache import LVMCache 

24 

25 

26def master_only(func): 

27 def wrapper(session, args): 

28 if not util.is_master(session): 

29 raise util.SMException(f"{func.__name__} must be called on master") 

30 return func(session, args) 

31 return wrapper 

32 

33 

34@master_only 

35def delete_cbt_log(session, args): 

36 util.SMlog(f"on_master.delete_cbt_log: {args}") 

37 os.environ['LVM_SYSTEM_DIR'] = lvutil.MASTER_LVM_CONF 

38 vgName = args["vgName"] 

39 lvName = args["lvName"] 

40 try: 

41 lvmcache = LVMCache(vgName) 

42 if lvmcache.checkLV(lvName): 

43 lvmcache.remove(lvName) 

44 except util.CommandException as e: 

45 util.SMlog(f"on_master.delete_cbt_log: failed to remove {lvName}: {e}") 

46 raise 

47 return "True" 

48 

49 

50if __name__ == "__main__": 

51 import XenAPIPlugin 

52 XenAPIPlugin.dispatch({ 

53 "delete_cbt_log": delete_cbt_log, 

54 })