Skip to content

Commit

Permalink
fix import cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
Wescoeur committed Jan 23, 2025
1 parent cd7c836 commit 6cca2a7
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 25 deletions.
3 changes: 2 additions & 1 deletion drivers/LVMSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@
from journaler import Journaler
from refcounter import RefCounter
from ipc import IPCFlag
from constants import NS_PREFIX_LVM, VG_LOCATION, VG_PREFIX
from cowutil import getCowUtil
from lvmcowutil import LV_PREFIX, NS_PREFIX_LVM, VG_LOCATION, VG_PREFIX, LvmCowUtil
from lvmcowutil import LV_PREFIX, LvmCowUtil
from lvmanager import LVActivator
from vditype import VdiType
import XenAPI # pylint: disable=import-error
Expand Down
2 changes: 1 addition & 1 deletion drivers/blktap2.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
import xs_errors
import XenAPI # pylint: disable=import-error
import scsiutil
from constants import NS_PREFIX_LVM
from syslog import openlog, syslog
from stat import * # S_ISBLK(), ...
from lvmcowutil import NS_PREFIX_LVM
from vditype import VdiType
import nfs

Expand Down
3 changes: 2 additions & 1 deletion drivers/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@
from functools import reduce
from time import monotonic as _time

from constants import NS_PREFIX_LVM, VG_LOCATION, VG_PREFIX
from cowutil import CowUtil, getCowUtil
from lvmcowutil import LV_PREFIX, NS_PREFIX_LVM, VG_LOCATION, VG_PREFIX, LvmCowUtil
from lvmcowutil import LV_PREFIX, LvmCowUtil
from vditype import VdiType, VdiTypeExtension, VDI_COW_TYPES, VDI_TYPE_TO_EXTENSION

try:
Expand Down
9 changes: 9 additions & 0 deletions drivers/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
from sm_typing import Final

EXT_PREFIX = 'XSLocalEXT-'
CBT_BLOCK_SIZE = (64 * 1024)
CBTLOG_TAG = "cbtlog"
CBT_UTIL = "/usr/sbin/cbt-util"

VG_LOCATION: Final = "/dev"
VG_PREFIX: Final = "VG_XenStorage-"

# Ref counting for VDI's: we need a ref count for LV activation/deactivation
# on the master.
NS_PREFIX_LVM: Final = "lvm-"
2 changes: 1 addition & 1 deletion drivers/lvmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import time
import util

from lvmcowutil import NS_PREFIX_LVM
from constants import NS_PREFIX_LVM

class LVManagerException(util.SMException):
pass
Expand Down
2 changes: 1 addition & 1 deletion drivers/lvmcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import lvutil
import os
import util
from constants import NS_PREFIX_LVM
from lock import Lock
from lvmcowutil import NS_PREFIX_LVM
from refcounter import RefCounter


Expand Down
8 changes: 1 addition & 7 deletions drivers/lvmcowutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import util
import XenAPI

from constants import NS_PREFIX_LVM, VG_LOCATION, VG_PREFIX
from cowutil import CowImageInfo, CowUtil, getCowUtil
from journaler import Journaler
from lvmcache import LVInfo, LVMCache
Expand All @@ -38,13 +39,6 @@

# ------------------------------------------------------------------------------

VG_LOCATION: Final = "/dev"
VG_PREFIX: Final = "VG_XenStorage-"

# Ref counting for VDI's: we need a ref count for LV activation/deactivation
# on the master.
NS_PREFIX_LVM: Final = "lvm-"

LOCK_RETRY_ATTEMPTS: Final = 20

LV_PREFIX: Final = {
Expand Down
3 changes: 1 addition & 2 deletions drivers/lvutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
import util
import xs_errors
import xml.dom.minidom
from lvmcowutil import VG_LOCATION, VG_PREFIX
from constants import EXT_PREFIX
from constants import EXT_PREFIX, VG_LOCATION, VG_PREFIX
import lvmcache
import srmetadata

Expand Down
3 changes: 2 additions & 1 deletion drivers/tapdisk-pause
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ import xs_errors
import XenAPI
import lvmcache

from constants import NS_PREFIX_LVM, VG_PREFIX
from cowutil import getCowUtil
from lvmcowutil import LV_PREFIX, LV_PREFIX_TO_VDI_TYPE, NS_PREFIX_LVM, VG_PREFIX
from lvmcowutil import LV_PREFIX, LV_PREFIX_TO_VDI_TYPE
from vditype import VdiType

try:
Expand Down
2 changes: 1 addition & 1 deletion drivers/trim_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import lock
import lvutil

from lvmcowutil import VG_LOCATION, VG_PREFIX
from constants import VG_LOCATION, VG_PREFIX

TRIM_LV_TAG = "_trim_lv"
TRIM_CAP = "SR_TRIM"
Expand Down
3 changes: 2 additions & 1 deletion drivers/verifyVHDsOnSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@

import VDI

from constants import NS_PREFIX_LVM, VG_LOCATION, VG_PREFIX
from lock import Lock
from lvmcowutil import NS_PREFIX_LVM, LV_PREFIX, VG_LOCATION, VG_PREFIX
from lvmcowutil import LV_PREFIX
from refcounter import RefCounter
from vditype import VdiType

Expand Down
18 changes: 10 additions & 8 deletions tests/test_on_slave.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import util

import on_slave

from constants import NS_PREFIX_LVM
from vditype import VdiType


Expand Down Expand Up @@ -184,7 +186,7 @@ def test_multi_vdi_inactive(self, mock_refcount):
sr_uuid = str(uuid.uuid4())
vdi_uuid = str(uuid.uuid4())
vdi_fileName = "test-vdi.vhd"
lock_ref = lvmcowutil.NS_PREFIX_LVM + sr_uuid
lock_ref = NS_PREFIX_LVM + sr_uuid

args = {"vgName": vgName,
"action1": "deactivateNoRefcount",
Expand Down Expand Up @@ -233,7 +235,7 @@ def test_multi_update_slave_rename(self, mock_refcount):
origParentUuid = str(uuid.uuid4())
vdi_uuid = str(uuid.uuid4())

lock_ref = lvmcowutil.NS_PREFIX_LVM + vdi_uuid
lock_ref = NS_PREFIX_LVM + vdi_uuid

args = {"vgName": vgName,
"action1": "deactivateNoRefcount",
Expand All @@ -257,7 +259,7 @@ def test_multi_refresh_on_slaves(self):
vdi_uuid = str(uuid.uuid4())
lv_name = 'test_lv'

lock_ref = lvmcowutil.NS_PREFIX_LVM + sr_uuid
lock_ref = NS_PREFIX_LVM + sr_uuid

args = {"vgName": vgName,
"action1": "activate",
Expand Down Expand Up @@ -288,7 +290,7 @@ def test_multi_rename_deactivate_error(self, mock_refcount):
origParentUuid = str(uuid.uuid4())
vdi_uuid = str(uuid.uuid4())

lock_ref = lvmcowutil.NS_PREFIX_LVM + vdi_uuid
lock_ref = NS_PREFIX_LVM + vdi_uuid

self.mock_lvmcache.deactivateNoRefcount.side_effect = util.CommandException(errno.EIO, 'activate')

Expand Down Expand Up @@ -317,7 +319,7 @@ def test_multi_rename_refresh_error(self, mock_refcount):
origParentUuid = str(uuid.uuid4())
vdi_uuid = str(uuid.uuid4())

lock_ref = lvmcowutil.NS_PREFIX_LVM + vdi_uuid
lock_ref = NS_PREFIX_LVM + vdi_uuid

self.mock_lvmcache.activateNoRefcount.side_effect = util.CommandException(errno.EIO, 'activate')

Expand All @@ -343,7 +345,7 @@ def test_multi_refresh_on_slaves_activate_error(self):
vdi_uuid = str(uuid.uuid4())
lv_name = 'test_lv'

lock_ref = lvmcowutil.NS_PREFIX_LVM + sr_uuid
lock_ref = NS_PREFIX_LVM + sr_uuid

self.mock_lvmcache.activate.side_effect = util.CommandException(errno.EIO, 'activate')

Expand Down Expand Up @@ -373,7 +375,7 @@ def test_multi_refresh_on_slaves_refresh_error(self):
vdi_uuid = str(uuid.uuid4())
lv_name = 'test_lv'

lock_ref = lvmcowutil.NS_PREFIX_LVM + sr_uuid
lock_ref = NS_PREFIX_LVM + sr_uuid

self.mock_lvmcache.activateNoRefcount.side_effect = util.CommandException(errno.EIO, 'activate')

Expand Down Expand Up @@ -404,7 +406,7 @@ def test_multi_refresh_on_slaves_deactivate_error(self):
vdi_uuid = str(uuid.uuid4())
lv_name = 'test_lv'

lock_ref = lvmcowutil.NS_PREFIX_LVM + sr_uuid
lock_ref = NS_PREFIX_LVM + sr_uuid

self.mock_lvmcache.deactivate.side_effect = util.CommandException(errno.EIO, 'activate')

Expand Down

0 comments on commit 6cca2a7

Please sign in to comment.