Change in vdsm[master]: add a constants.py file for HSM service standalone
shaohef at linux.vnet.ibm.com
shaohef at linux.vnet.ibm.com
Tue Nov 20 07:22:14 UTC 2012
Hello Shu Ming,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/9348
to review the following change.
Change subject: add a constants.py file for HSM service standalone
......................................................................
add a constants.py file for HSM service standalone
constants.py is installed in a separate python site-packages for hsm
Remame P_VDSM_RUN as P_HSM_RUN
This is one of step to make HSM service standalone
wiki-page: http://wiki.ovirt.org/wiki/HSM_service_stand_alone
Change-Id: I092c11d8ee022c7d2954d52352ff44ea37233f37
Signed-off-by: Shu Ming <shuming at linux.vnet.ibm.com>
Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
M .gitignore
M build-aux/Makefile.subs
M configure.ac
M vdsm.spec.in
M vdsm/storage/Makefile.am
M vdsm/storage/blockSD.py
A vdsm/storage/constants.py.in
M vdsm/storage/devicemapper.py
M vdsm/storage/fileSD.py
M vdsm/storage/fileUtils.py
M vdsm/storage/fuser.py
M vdsm/storage/hsm.py
M vdsm/storage/iscsi.py
M vdsm/storage/iscsiadm.py
M vdsm/storage/lvm.py
M vdsm/storage/misc.py
M vdsm/storage/mount.py
M vdsm/storage/multipath.py
M vdsm/storage/remoteFileHandler.py
M vdsm/storage/safelease.py
M vdsm/storage/sd.py
M vdsm/storage/sp.py
M vdsm/storage/storage_mailbox.py
M vdsm/storage/volume.py
24 files changed, 172 insertions(+), 23 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/48/9348/1
diff --git a/.gitignore b/.gitignore
index b5b17e4..577453f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@
vdsm/mom.conf
vdsm/sos/vdsm.py
vdsm/storage/config.py
+vdsm/storage/constants.py
vdsm/storage/protect/safelease
vdsm/sudoers.vdsm
vdsm/vdsm-gencerts.sh
diff --git a/build-aux/Makefile.subs b/build-aux/Makefile.subs
index 74b7153..5f88984 100644
--- a/build-aux/Makefile.subs
+++ b/build-aux/Makefile.subs
@@ -34,7 +34,8 @@
-e "s,[@]VDSMLOGDIR[@],$(vdsmlogdir),g" \
-e "s,[@]VDSMREPO[@],$(vdsmrepo),g" \
-e "s,[@]VDSMRUNDIR[@],$(vdsmrundir),g" \
- -e "s,[@]VDSMUPGRADEDIR[@],$(vdsmupgradedir),g"
+ -e "s,[@]VDSMUPGRADEDIR[@],$(vdsmupgradedir),g" \
+ -e "s,[@]HSMRUNDIR[@],$(hsmrundir),g"
CONFIGSUBST = $(top_builddir)/config.status --file=-
diff --git a/configure.ac b/configure.ac
index a384823..2412a01 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,6 +82,8 @@
# HSM default paths
AC_SUBST([hsmpylibdir], ['${pyexecdir}/hsmd'])
+# FIXME: this path should be modified when HSM service standalone was done
+AC_SUBST([hsmrundir], ['${localstatedir}/run/vdsm'])
# VDSM registration default paths
AC_SUBST([vdsmregdir], ['${datarootdir}/vdsm-reg'])
diff --git a/vdsm.spec.in b/vdsm.spec.in
index a9f1379..c5997e8 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -779,6 +779,7 @@
%{python_sitearch}/%{vdsm_name}/tool/load_needed_modules.py*
%{python_sitearch}/%{hsm_name}/__init__.py*
%{python_sitearch}/%{hsm_name}/config.py*
+%{python_sitearch}/%{hsm_name}/constants.py*
%files tests
%doc %{_datadir}/%{vdsm_name}/tests/README
diff --git a/vdsm/storage/Makefile.am b/vdsm/storage/Makefile.am
index 9af470e..09028a5 100644
--- a/vdsm/storage/Makefile.am
+++ b/vdsm/storage/Makefile.am
@@ -70,7 +70,8 @@
__init__.py
nodist_hsmpylib_PYTHON = \
- config.py
+ config.py \
+ constants.py
nodist_noinst_DATA = \
hsm.conf.sample
@@ -81,7 +82,8 @@
EXTRA_DIST = \
12-vdsm-lvm.rules \
- config.py.in
+ config.py.in \
+ constants.py.in
hsm.conf.sample: Makefile config.py
@echo " CONFIG $@"; $(PYTHON) $(builddir)/config.py > $@
diff --git a/vdsm/storage/blockSD.py b/vdsm/storage/blockSD.py
index d59aa05..e0e2e95 100644
--- a/vdsm/storage/blockSD.py
+++ b/vdsm/storage/blockSD.py
@@ -32,7 +32,7 @@
from operator import itemgetter
from hsmd.config import config
-from vdsm import constants
+from hsmd import constants
import misc
import fileUtils
import sd
diff --git a/vdsm/storage/constants.py.in b/vdsm/storage/constants.py.in
new file mode 100644
index 0000000..292d8a5
--- /dev/null
+++ b/vdsm/storage/constants.py.in
@@ -0,0 +1,142 @@
+#
+# Copyright 2009-2012 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+#
+# Description: Constants definitions for hsm and utilities.
+
+#
+# file ownership definitions
+#
+DISKIMAGE_USER = '@VDSMUSER@'
+DISKIMAGE_GROUP = '@QEMUGROUP@'
+METADATA_USER = '@METADATAUSER@'
+METADATA_GROUP = '@METADATAGROUP@'
+QEMU_PROCESS_USER = '@QEMUUSER@'
+
+# This is the domain version translation list
+# DO NOT CHANGE OLD VALUES ONLY APPEND
+DOMAIN_VERSIONS = (0, 2, 3)
+SUPPORTED_BLOCKSIZE = (512,)
+
+# This contains the domains versions that this HSM
+# accepts currently its all of the version but in the
+# future we might slice it (eg. tuple(DOMAIN_VERSION[1:]))
+SUPPORTED_DOMAIN_VERSIONS = DOMAIN_VERSIONS
+
+UUID_GLOB_PATTERN = '*-*-*-*-*'
+
+MEGAB = 2 ** 20 # = 1024 ** 2 = 1 MiB
+
+#
+# Path definitions
+#
+P_HSM_RUN = '@HSMRUNDIR@/'
+
+
+#
+# External programs (sorted, please keep in order).
+#
+
+EXT_CHOWN = '@CHOWN_PATH@'
+EXT_CP = '@CP_PATH@'
+
+EXT_DD = '@DD_PATH@'
+EXT_DMSETUP = '@DMSETUP_PATH@'
+
+EXT_FSCK = '@FSCK_PATH@'
+EXT_FUSER = '@FUSER_PATH@'
+
+EXT_IONICE = '@IONICE_PATH@'
+EXT_ISCSIADM = '@ISCSIADM_PATH@'
+EXT_TC = '@TC_PATH@'
+
+EXT_KILL = '@KILL_PATH@'
+
+EXT_LSBLK = '@LSBLK_PATH@'
+EXT_LVM = '@LVM_PATH@'
+
+EXT_MKFS = '@MKFS_PATH@'
+EXT_MKFS_MSDOS = '@MKFS_MSDOS_PATH@'
+EXT_MKISOFS = '@MKISOFS_PATH@'
+EXT_MOUNT = '@MOUNT_PATH@'
+EXT_MULTIPATH = '@MULTIPATH_PATH@'
+EXT_MV = '@MV_PATH@'
+
+EXT_NICE = '@NICE_PATH@'
+
+EXT_PERSIST = '@PERSIST_PATH@'
+EXT_PGREP = '@PGREP_PATH@'
+EXT_PYTHON = '@PYTHON@'
+
+EXT_QEMUIMG = '@QEMUIMG_PATH@'
+
+EXT_REBOOT = '@REBOOT_PATH@'
+EXT_RSYNC = '@RSYNC_PATH@'
+
+EXT_SCSI_ID = '@SCSI_ID_PATH@' # TBD !
+EXT_SERVICE = '@SERVICE_PATH@'
+EXT_SETSID = '@SETSID_PATH@'
+EXT_SH = '/bin/sh' # The shell path is invariable
+EXT_SHOWMOUNT = '@SHOWMOUNT_PATH@'
+EXT_SU = '@SU_PATH@'
+EXT_SUDO = '@SUDO_PATH@'
+
+EXT_TAR = '@TAR_PATH@'
+EXT_TUNE2FS = '@TUNE2FS_PATH@'
+
+EXT_UDEVADM = '@UDEVADM_PATH@'
+
+EXT_UMOUNT = '@UMOUNT_PATH@'
+EXT_UNPERSIST = '@UNPERSIST_PATH@'
+
+EXT_IPROUTE = '@IPROUTE_PATH@'
+
+EXT_WGET = '@WGET_PATH@'
+
+CMD_LOWPRIO = [EXT_NICE, '-n', '19', EXT_IONICE, '-c', '3']
+
+#
+# Storage constants
+#
+STRG_ISCSI_HOST = "iscsi_host/"
+STRG_SCSI_HOST = "scsi_host/"
+STRG_ISCSI_SESSION = "iscsi_session/"
+STRG_MPATH_CONF = (
+"\n\n"
+"defaults {\n"
+" polling_interval 5\n"
+" getuid_callout \"@SCSI_ID_PATH@ --whitelisted "
+ "--replace-whitespace --device=/dev/%n\"\n"
+" no_path_retry fail\n"
+" user_friendly_names no\n"
+" flush_on_last_del yes\n"
+" fast_io_fail_tmo 5\n"
+" dev_loss_tmo 30\n"
+" max_fds 4096\n"
+"}\n"
+"\n"
+"devices {\n"
+"device {\n"
+" vendor \"HITACHI\"\n"
+" product \"DF.*\"\n"
+" getuid_callout \"@SCSI_ID_PATH@ --whitelisted "
+ "--replace-whitespace --device=/dev/%n\"\n"
+"}\n"
+"}"
+)
diff --git a/vdsm/storage/devicemapper.py b/vdsm/storage/devicemapper.py
index a1651e0..c931085 100644
--- a/vdsm/storage/devicemapper.py
+++ b/vdsm/storage/devicemapper.py
@@ -25,7 +25,7 @@
import re
from supervdsm import getProxy
-from vdsm.constants import EXT_DMSETUP
+from hsmd.constants import EXT_DMSETUP
DMPATH_FORMAT = "/dev/mapper/%s"
diff --git a/vdsm/storage/fileSD.py b/vdsm/storage/fileSD.py
index 90ffecd..7ec3718 100644
--- a/vdsm/storage/fileSD.py
+++ b/vdsm/storage/fileSD.py
@@ -32,7 +32,7 @@
import outOfProcess as oop
from remoteFileHandler import Timeout
from persistentDict import PersistentDict, DictValidator
-from vdsm import constants
+from hsmd import constants
import time
import supervdsm
import mount
diff --git a/vdsm/storage/fileUtils.py b/vdsm/storage/fileUtils.py
index 13a8cfa..834fd3b 100644
--- a/vdsm/storage/fileUtils.py
+++ b/vdsm/storage/fileUtils.py
@@ -33,7 +33,7 @@
import subprocess
import shutil
-from vdsm import constants
+from hsmd import constants
import logging
import errno
libc = ctypes.CDLL("libc.so.6", use_errno=True)
diff --git a/vdsm/storage/fuser.py b/vdsm/storage/fuser.py
index d9becbc..6de3032 100644
--- a/vdsm/storage/fuser.py
+++ b/vdsm/storage/fuser.py
@@ -18,7 +18,7 @@
# Refer to the README and COPYING files for full details of the license
#
import misc
-from vdsm import constants
+from hsmd import constants
def fuser(path, mountPoint=False):
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 476eed8..8b29707 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -56,7 +56,7 @@
import safelease
import storage_exception as se
from threadLocal import vars
-from vdsm import constants
+from hsmd import constants
from storageConstants import STORAGE
from task import Job
from resourceFactories import IMAGE_NAMESPACE
@@ -84,7 +84,7 @@
# FIXME: moved from spm.py but this should be somewhere else
SECTOR_SIZE = 512
-STORAGE_CONNECTION_DIR = os.path.join(constants.P_VDSM_RUN, "connections/")
+STORAGE_CONNECTION_DIR = os.path.join(constants.P_HSM_RUN, "connections/")
def public(f=None, **kwargs):
if f is None:
diff --git a/vdsm/storage/iscsi.py b/vdsm/storage/iscsi.py
index 4723746..57dfe4a 100644
--- a/vdsm/storage/iscsi.py
+++ b/vdsm/storage/iscsi.py
@@ -30,7 +30,7 @@
import time
from collections import namedtuple
-from vdsm import constants
+from hsmd import constants
import misc
from hsmd.config import config
import devicemapper
diff --git a/vdsm/storage/iscsiadm.py b/vdsm/storage/iscsiadm.py
index 6b58d15..6182d15 100644
--- a/vdsm/storage/iscsiadm.py
+++ b/vdsm/storage/iscsiadm.py
@@ -1,6 +1,6 @@
from threading import Lock
import misc
-from vdsm import constants
+from hsmd import constants
# iscsiadm exit statuses
ISCSI_ERR_SESS_EXISTS = 15
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index 8c77a6a..8543a26 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -37,7 +37,7 @@
from itertools import chain
from subprocess import list2cmdline
-from vdsm import constants
+from hsmd import constants
import misc
import multipath
import storage_exception as se
@@ -120,7 +120,7 @@
}
"""
-VAR_RUN_VDSM = constants.P_VDSM_RUN
+VAR_RUN_VDSM = constants.P_HSM_RUN
VDSM_LVM_SYSTEM_DIR = os.path.join(VAR_RUN_VDSM, "lvm")
VDSM_LVM_CONF = os.path.join(VDSM_LVM_SYSTEM_DIR, "lvm.conf")
diff --git a/vdsm/storage/misc.py b/vdsm/storage/misc.py
index bf3ae79..9de1e93 100644
--- a/vdsm/storage/misc.py
+++ b/vdsm/storage/misc.py
@@ -56,7 +56,7 @@
import inspect
sys.path.append("../")
-from vdsm import constants
+from hsmd import constants
import storage_exception as se
from vdsm.betterPopen import BetterPopen
import logUtils
diff --git a/vdsm/storage/mount.py b/vdsm/storage/mount.py
index 94cfae0..1659a89 100644
--- a/vdsm/storage/mount.py
+++ b/vdsm/storage/mount.py
@@ -24,7 +24,7 @@
import os
import stat
-from vdsm import constants
+from hsmd import constants
import misc
# Common vfs types
diff --git a/vdsm/storage/multipath.py b/vdsm/storage/multipath.py
index c43cb09..627f2ce 100644
--- a/vdsm/storage/multipath.py
+++ b/vdsm/storage/multipath.py
@@ -29,7 +29,7 @@
import re
from collections import namedtuple
-from vdsm import constants
+from hsmd import constants
import misc
import iscsi
import supervdsm
diff --git a/vdsm/storage/remoteFileHandler.py b/vdsm/storage/remoteFileHandler.py
index edf8e68..47f4f1c 100644
--- a/vdsm/storage/remoteFileHandler.py
+++ b/vdsm/storage/remoteFileHandler.py
@@ -44,7 +44,7 @@
# don't need anything when the child spawns. Plus anything you don't have
# to import is less memory taken by each helper.
from vdsm.betterPopen import BetterPopen
- from vdsm import constants
+ from hsmd import constants
else:
# We add the parent directory so that imports that import the storage
# package would work even though CWD is inside the storage package.
diff --git a/vdsm/storage/safelease.py b/vdsm/storage/safelease.py
index 5184224..9ce880c 100644
--- a/vdsm/storage/safelease.py
+++ b/vdsm/storage/safelease.py
@@ -24,7 +24,7 @@
import subprocess
import sanlock
from contextlib import nested
-from vdsm import constants
+from hsmd import constants
import storage_exception as se
import threading
import logging
diff --git a/vdsm/storage/sd.py b/vdsm/storage/sd.py
index 52f80aa..7bfbcd3 100644
--- a/vdsm/storage/sd.py
+++ b/vdsm/storage/sd.py
@@ -30,7 +30,7 @@
import resourceFactories
from resourceFactories import IMAGE_NAMESPACE, VOLUME_NAMESPACE
import resourceManager as rm
-from vdsm import constants
+from hsmd import constants
import safelease
import outOfProcess as oop
from persistentDict import unicodeEncoder, unicodeDecoder
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index 77452e9..d3f5c82 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -32,7 +32,7 @@
from imageRepository.formatConverter import DefaultFormatConverter
-from vdsm import constants
+from hsmd import constants
import storage_mailbox
import blockSD
import fileSD
diff --git a/vdsm/storage/storage_mailbox.py b/vdsm/storage/storage_mailbox.py
index 4743940..a14f603 100644
--- a/vdsm/storage/storage_mailbox.py
+++ b/vdsm/storage/storage_mailbox.py
@@ -34,7 +34,7 @@
from threadLocal import vars
from threadPool import ThreadPool
from storage_exception import InvalidParameterException
-from vdsm import constants
+from hsmd import constants
__author__="ayalb"
__date__ ="$Mar 9, 2009 5:25:07 PM$"
diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index b97e6f3..0c854e4 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -25,7 +25,7 @@
from contextlib import contextmanager
import image
-from vdsm import constants
+from hsmd import constants
import storage_exception as se
import sd
from sdc import sdCache
--
To view, visit http://gerrit.ovirt.org/9348
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I092c11d8ee022c7d2954d52352ff44ea37233f37
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
Gerrit-Reviewer: Shu Ming <shuming at linux.vnet.ibm.com>
More information about the vdsm-patches
mailing list