Initialize privsep root_helper command

Currently, when using the Cinder backend, Glance
tries to execute os-brick commands directly using
"privsep-helper".  They should be launched via
"glance-rootwrap".

Depends-On: Ib7923543862275629d86a0fa76baa88722493bad
Change-Id: I26d9474d4aadcc0e58e2fce746708f148138c71f
This commit is contained in:
Eric Harney 2017-04-19 14:52:04 -04:00
parent 60d3e01631
commit d16dff9a08
3 changed files with 8 additions and 1 deletions

View File

@ -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)

View File

@ -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):

View File

@ -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