From e446e7a2f4e709c33d64bcb1ba645969cb11b414 Mon Sep 17 00:00:00 2001 From: Bahtiar `kalkin-` Gadimov Date: Sat, 15 Apr 2017 16:29:50 +0200 Subject: [PATCH] Rename qubes.devices.BlockDevice to qubes.storage.BlockDevice Signed-off-by: Bahtiar `kalkin-` Gadimov --- qubes/devices.py | 13 ------------- qubes/storage/__init__.py | 20 +++++++++++++++++--- qubes/storage/file.py | 5 ++--- qubes/storage/lvm.py | 4 ++-- qubes/vm/qubesvm.py | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/qubes/devices.py b/qubes/devices.py index f088966b..5e9cebd5 100644 --- a/qubes/devices.py +++ b/qubes/devices.py @@ -344,19 +344,6 @@ class UnknownDevice(DeviceInfo): frontend_domain, **kwargs) -class BlockDevice(object): - # pylint: disable=too-few-public-methods - def __init__(self, path, name, script=None, rw=True, domain=None, - devtype='disk'): - assert name, 'Missing device name' - assert path, 'Missing device path' - self.path = path - self.name = name - self.rw = rw - self.script = script - self.domain = domain - self.devtype = devtype - class PersistentCollection(object): ''' Helper object managing persistent `DeviceAssignment`s. diff --git a/qubes/storage/__init__.py b/qubes/storage/__init__.py index 1f8aa44a..c0baf334 100644 --- a/qubes/storage/__init__.py +++ b/qubes/storage/__init__.py @@ -34,7 +34,6 @@ from datetime import datetime import lxml.etree import pkg_resources import qubes -import qubes.devices import qubes.exc import qubes.utils @@ -46,6 +45,21 @@ class StoragePoolException(qubes.exc.QubesException): pass +class BlockDevice(object): + ''' Represents a storage block device. ''' + # pylint: disable=too-few-public-methods + def __init__(self, path, name, script=None, rw=True, domain=None, + devtype='disk'): + assert name, 'Missing device name' + assert path, 'Missing device path' + self.path = path + self.name = name + self.rw = rw + self.script = script + self.domain = domain + self.devtype = devtype + + class Volume(object): ''' Encapsulates all data about a volume for serialization to qubes.xml and libvirt config. @@ -119,10 +133,10 @@ class Volume(object): return lxml.etree.Element('volume', **config) def block_device(self): - ''' Return :py:class:`qubes.devices.BlockDevice` for serialization in + ''' Return :py:class:`BlockDevice` for serialization in the libvirt XML template as . ''' - return qubes.devices.BlockDevice(self.path, self.name, self.script, + return BlockDevice(self.path, self.name, self.script, self.rw, self.domain, self.devtype) @property diff --git a/qubes/storage/file.py b/qubes/storage/file.py index 1f939b0f..ed7f1161 100644 --- a/qubes/storage/file.py +++ b/qubes/storage/file.py @@ -30,7 +30,6 @@ import os.path import re import subprocess -import qubes.devices import qubes.storage BLKSIZE = 512 @@ -358,7 +357,7 @@ class FileVolume(qubes.storage.Volume): return 'block-snapshot' def block_device(self): - ''' Return :py:class:`qubes.devices.BlockDevice` for serialization in + ''' Return :py:class:`qubes.storage.BlockDevice` for serialization in the libvirt XML template as . ''' path = self.path @@ -366,7 +365,7 @@ class FileVolume(qubes.storage.Volume): path += ":" + self.path_source_cow if self._is_origin or self._is_snapshot: path += ":" + self.path_cow - return qubes.devices.BlockDevice(path, self.name, self.script, self.rw, + return qubes.storage.BlockDevice(path, self.name, self.script, self.rw, self.domain, self.devtype) @property diff --git a/qubes/storage/lvm.py b/qubes/storage/lvm.py index 58137148..a560d513 100644 --- a/qubes/storage/lvm.py +++ b/qubes/storage/lvm.py @@ -394,11 +394,11 @@ class ThinVolume(qubes.storage.Volume): "You shouldn't use lvm size setter") def block_device(self): - ''' Return :py:class:`qubes.devices.BlockDevice` for serialization in + ''' Return :py:class:`qubes.storage.BlockDevice` for serialization in the libvirt XML template as . ''' if self.snap_on_start: - return qubes.devices.BlockDevice( + return qubes.storage.BlockDevice( '/dev/' + self._vid_snap, self.name, self.script, self.rw, self.domain, self.devtype) else: diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index 2a666f09..6879d593 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -567,7 +567,7 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM): @property def block_devices(self): - ''' Return all :py:class:`qubes.devices.BlockDevice`s for current domain + ''' Return all :py:class:`qubes.storage.BlockDevice`s for current domain for serialization in the libvirt XML template as . ''' return [v.block_device() for v in self.volumes.values()]