mypy: privileged/rbd.py

Change-Id: I0f0f61dc7a247af2a701c76993f9966e0c812b7e
This commit is contained in:
Eric Harney
2022-07-08 09:36:04 -04:00
parent 2a071914f5
commit b3f89a304f
2 changed files with 6 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ os_brick/initiator/host_driver.py
os_brick/initiator/linuxfc.py
os_brick/initiator/utils.py
os_brick/privileged/nvmeof.py
os_brick/privileged/rbd.py
os_brick/remotefs/remotefs.py
os_brick/initiator/linuxrbd.py
os_brick/encryptors/luks.py

View File

@@ -13,13 +13,15 @@
# License for the specific language governing permissions and limitations
# under the License.
from typing import Optional
from oslo_utils import fileutils
from oslo_utils import importutils
import os_brick.privileged
# Lazy load the rbd module to avoid circular references
RBDConnector = None
RBDConnector: Optional['os_brick.initiator.connectors.rbd.RBDConnector'] = None
def _get_rbd_class():
@@ -48,6 +50,7 @@ def root_create_ceph_conf(monitor_ips, monitor_ports, cluster_name, user,
keyring):
"""Create a .conf file for Ceph cluster only accessible by root."""
get_rbd_class()
assert RBDConnector is not None
return RBDConnector._create_ceph_conf(monitor_ips, monitor_ports,
cluster_name, user, keyring)
@@ -55,5 +58,6 @@ def root_create_ceph_conf(monitor_ips, monitor_ports, cluster_name, user,
@os_brick.privileged.default.entrypoint
def check_valid_path(path):
get_rbd_class()
assert RBDConnector is not None
with open(path, 'rb') as rbd_handle:
return RBDConnector._check_valid_device(rbd_handle)