2016-02-18 02:53:35 +03:00
# Copyright (C) 2015-2016 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import multiprocessing
import queue
import itertools
2023-03-06 19:25:22 +03:00
from utils import LvmDebugData
2016-08-29 22:51:26 +03:00
from lvmdbusd import path
2016-02-18 02:53:35 +03:00
LVM_CMD = os . getenv ( ' LVM_BINARY ' , path . LVM_BINARY )
2022-08-09 04:48:10 +03:00
LOCK_FILE = os . getenv ( " LVM_DBUSD_LOCKFILE " , " /var/lock/lvm/lvmdbusd " )
2023-03-06 19:25:22 +03:00
# Save off the debug data needed for lvm team to debug issues
# only used for 'fullreport' at this time.
lvmdebug = LvmDebugData ( os . getenv ( ' LVM_DBUSD_COLLECT_LVM_DEBUG ' , False ) )
2016-02-18 02:53:35 +03:00
# This is the global object manager
om = None
# This is the global bus connection
bus = None
2016-08-25 02:29:35 +03:00
# Command line args
args = None
2023-02-16 19:24:06 +03:00
# Set to true if we depend on external events for updates
2017-03-20 17:43:34 +03:00
got_external_event = False
2016-08-25 02:29:35 +03:00
2016-02-18 02:53:35 +03:00
# Shared state variable across all processes
run = multiprocessing . Value ( ' i ' , 1 )
2023-02-16 19:24:06 +03:00
# If this is set to true, the current setup support lvm shell, and we are
2016-08-25 02:29:35 +03:00
# running in that mode of operation
SHELL_IN_USE = None
2016-02-18 02:53:35 +03:00
# Lock used by pprint
stdout_lock = multiprocessing . Lock ( )
worker_q = queue . Queue ( )
# Main event loop
loop = None
2022-09-21 18:05:36 +03:00
# Used to instruct the daemon if we should ignore SIGTERM
ignore_sigterm = False
2016-11-04 21:26:31 +03:00
BUS_NAME = os . getenv ( ' LVM_DBUS_NAME ' , ' com.redhat.lvmdbus1 ' )
2016-02-18 02:53:35 +03:00
BASE_INTERFACE = ' com.redhat.lvmdbus1 '
PV_INTERFACE = BASE_INTERFACE + ' .Pv '
VG_INTERFACE = BASE_INTERFACE + ' .Vg '
2019-10-08 00:58:10 +03:00
VG_VDO_INTERFACE = BASE_INTERFACE + ' .VgVdo '
2016-02-18 02:53:35 +03:00
LV_INTERFACE = BASE_INTERFACE + ' .Lv '
LV_COMMON_INTERFACE = BASE_INTERFACE + ' .LvCommon '
THIN_POOL_INTERFACE = BASE_INTERFACE + ' .ThinPool '
2019-10-09 15:49:58 +03:00
VDO_POOL_INTERFACE = BASE_INTERFACE + ' .VdoPool '
2016-02-18 02:53:35 +03:00
CACHE_POOL_INTERFACE = BASE_INTERFACE + ' .CachePool '
LV_CACHED = BASE_INTERFACE + ' .CachedLv '
SNAPSHOT_INTERFACE = BASE_INTERFACE + ' .Snapshot '
MANAGER_INTERFACE = BASE_INTERFACE + ' .Manager '
JOB_INTERFACE = BASE_INTERFACE + ' .Job '
BASE_OBJ_PATH = ' / ' + BASE_INTERFACE . replace ( ' . ' , ' / ' )
PV_OBJ_PATH = BASE_OBJ_PATH + ' /Pv '
VG_OBJ_PATH = BASE_OBJ_PATH + ' /Vg '
LV_OBJ_PATH = BASE_OBJ_PATH + ' /Lv '
THIN_POOL_PATH = BASE_OBJ_PATH + " /ThinPool "
2019-10-09 15:49:58 +03:00
VDO_POOL_PATH = BASE_OBJ_PATH + " /VdoPool "
2016-02-18 02:53:35 +03:00
CACHE_POOL_PATH = BASE_OBJ_PATH + " /CachePool "
HIDDEN_LV_PATH = BASE_OBJ_PATH + " /HiddenLv "
MANAGER_OBJ_PATH = BASE_OBJ_PATH + ' /Manager '
JOB_OBJ_PATH = BASE_OBJ_PATH + ' /Job '
# Counters for object path generation
pv_id = itertools . count ( )
vg_id = itertools . count ( )
lv_id = itertools . count ( )
thin_id = itertools . count ( )
2019-10-09 15:49:58 +03:00
vdo_id = itertools . count ( )
2016-02-18 02:53:35 +03:00
cache_pool_id = itertools . count ( )
job_id = itertools . count ( )
hidden_lv = itertools . count ( )
# Used to prevent circular imports...
load = None
2016-11-10 21:19:48 +03:00
event = None
2016-02-18 02:53:35 +03:00
2019-10-08 00:57:05 +03:00
# Boolean to denote if lvm supports VDO integration
vdo_support = False
2016-02-18 02:53:35 +03:00
# Global cached state
db = None
2016-03-22 01:22:56 +03:00
# lvm flight recorder
2022-08-10 01:55:27 +03:00
flightrecorder = None
2017-03-09 00:31:45 +03:00
# RequestEntry ctor
create_request_entry = None
2018-12-18 18:49:36 +03:00
2022-08-18 01:24:08 +03:00
# Circular debug log
debug = None
2018-12-18 18:49:36 +03:00
def exit_daemon ( ) :
"""
Exit the daemon cleanly
: return :
"""
if run and loop :
run . value = 0
loop . quit ( )
2022-08-31 23:04:59 +03:00
2022-09-01 05:25:36 +03:00
systemd = False