diff --git a/glance_store/_drivers/cinder.py b/glance_store/_drivers/cinder.py index f27e3308..3b3f64ee 100644 --- a/glance_store/_drivers/cinder.py +++ b/glance_store/_drivers/cinder.py @@ -18,6 +18,7 @@ import hashlib import logging import math import os +import shlex import socket import time @@ -38,10 +39,12 @@ try: from cinderclient import exceptions as cinder_exception from cinderclient.v2 import client as cinderclient from os_brick.initiator import connector + from oslo_privsep import priv_context except ImportError: cinder_exception = None cinderclient = None connector = None + priv_context = None CONF = cfg.CONF @@ -473,6 +476,7 @@ class Store(glance_store.driver.Store): attach_mode = 'rw' if mode == 'wb' else 'ro' device = None root_helper = get_root_helper() + priv_context.init(root_helper=shlex.split(root_helper)) host = socket.gethostname() properties = connector.get_connector_properties(root_helper, host, False, False) diff --git a/glance_store/tests/unit/test_cinder_store.py b/glance_store/tests/unit/test_cinder_store.py index 9cbae7d7..d40ec2ff 100644 --- a/glance_store/tests/unit/test_cinder_store.py +++ b/glance_store/tests/unit/test_cinder_store.py @@ -158,12 +158,14 @@ class TestCinderStore(base.StoreBaseTest, kwargs['conn']) return fake_connector + root_helper = "sudo glance-rootwrap /etc/glance/rootwrap.conf" with mock.patch.object(cinder.Store, '_wait_volume_status', return_value=fake_volume), \ mock.patch.object(cinder, 'temporary_chown', side_effect=fake_chown), \ - mock.patch.object(cinder, 'get_root_helper'), \ + mock.patch.object(cinder, 'get_root_helper', + return_value=root_helper), \ mock.patch.object(connector, 'get_connector_properties'), \ mock.patch.object(connector.InitiatorConnector, 'factory', side_effect=fake_factory): diff --git a/setup.cfg b/setup.cfg index 89f19ee7..8ccefc92 100644 --- a/setup.cfg +++ b/setup.cfg @@ -62,6 +62,7 @@ cinder = python-cinderclient>=2.0.1 # Apache-2.0 os-brick>=1.8.0 # Apache-2.0 oslo.rootwrap>=5.0.0 # Apache-2.0 + oslo.privsep>=1.9.0 # Apache-2.0 [build_sphinx] source-dir = doc/source