Merge "[SPDK] Add https protocol option to communicate with SPDK"
This commit is contained in:
commit
79833e4cd1
|
@ -14,6 +14,8 @@ import copy
|
|||
import json
|
||||
from unittest import mock
|
||||
|
||||
import requests
|
||||
|
||||
from cinder.tests.unit import test
|
||||
from cinder.volume import configuration as conf
|
||||
from cinder.volume.targets import spdknvmf as spdknvmf_driver
|
||||
|
@ -355,10 +357,39 @@ class SpdkNvmfDriverTestCase(test.TestCase):
|
|||
self.configuration.target_protocol = "nvmet_rdma"
|
||||
self.configuration.spdk_rpc_ip = "127.0.0.1"
|
||||
self.configuration.spdk_rpc_port = 8000
|
||||
self.configuration.spdk_rpc_protocol = "https"
|
||||
self.configuration.spdk_rpc_username = "user"
|
||||
self.configuration.spdk_rpc_password = "password"
|
||||
self.configuration.driver_ssl_cert_verify = False
|
||||
self.driver = spdknvmf_driver.SpdkNvmf(configuration=
|
||||
self.configuration)
|
||||
self.jsonrpcclient = JSONRPCClient()
|
||||
|
||||
def get_item(self):
|
||||
return {'result': 'test_result'}
|
||||
|
||||
def test__rpc_parameters(self):
|
||||
url = ('%(protocol)s://%(ip)s:%(port)s/' %
|
||||
{'protocol': self.configuration.spdk_rpc_protocol,
|
||||
'ip': self.configuration.spdk_rpc_ip,
|
||||
'port': self.configuration.spdk_rpc_port})
|
||||
auth = (self.configuration.spdk_rpc_username,
|
||||
self.configuration.spdk_rpc_password)
|
||||
verify = self.configuration.driver_ssl_cert_verify
|
||||
|
||||
requests.post = mock.MagicMock()
|
||||
setattr(requests.post.service.__getitem__,
|
||||
'side_effect',
|
||||
self.get_item)
|
||||
|
||||
self.driver._rpc_call("bdev_get_bdevs")
|
||||
|
||||
requests.post.assert_called_once_with(url,
|
||||
auth=auth,
|
||||
data=mock.ANY,
|
||||
timeout=mock.ANY,
|
||||
verify=verify)
|
||||
|
||||
def test__get_spdk_volume_name(self):
|
||||
with mock.patch.object(self.driver, "_rpc_call",
|
||||
self.jsonrpcclient.call):
|
||||
|
|
|
@ -510,6 +510,7 @@ class SpdkDriverTestCase(test.TestCase):
|
|||
self.configuration.target_protocol = "nvmet_rdma"
|
||||
self.configuration.spdk_rpc_ip = "127.0.0.1"
|
||||
self.configuration.spdk_rpc_port = 8000
|
||||
self.configuration.spdk_rpc_protocol = "https"
|
||||
mock_safe_get = mock.Mock()
|
||||
mock_safe_get.return_value = 'spdk-nvmeof'
|
||||
self.configuration.safe_get = mock_safe_get
|
||||
|
|
|
@ -198,8 +198,9 @@ class SPDKDriver(driver.VolumeDriver):
|
|||
def do_setup(self, context):
|
||||
try:
|
||||
payload = {'method': 'bdev_get_bdevs', 'jsonrpc': '2.0', 'id': 1}
|
||||
self.url = ('http://%(ip)s:%(port)s/' %
|
||||
{'ip': self.configuration.spdk_rpc_ip,
|
||||
self.url = ('%(protocol)s://%(ip)s:%(port)s/' %
|
||||
{'protocol': self.configuration.spdk_rpc_protocol,
|
||||
'ip': self.configuration.spdk_rpc_ip,
|
||||
'port': self.configuration.spdk_rpc_port})
|
||||
requests.post(self.url,
|
||||
data=json.dumps(payload),
|
||||
|
|
|
@ -34,6 +34,10 @@ spdk_opts = [
|
|||
cfg.StrOpt('spdk_rpc_password',
|
||||
help='The NVMe target remote configuration password.',
|
||||
secret=True),
|
||||
cfg.StrOpt('spdk_rpc_protocol',
|
||||
choices=['http', 'https'],
|
||||
default='http',
|
||||
help='Protocol to be used with SPDK RPC proxy'),
|
||||
cfg.IntOpt('spdk_max_queue_depth',
|
||||
default=64,
|
||||
min=1, max=128,
|
||||
|
@ -52,8 +56,9 @@ class SpdkNvmf(nvmeof.NVMeOF):
|
|||
super(SpdkNvmf, self).__init__(*args, **kwargs)
|
||||
|
||||
self.configuration.append_config_values(spdk_opts)
|
||||
self.url = ('http://%(ip)s:%(port)s/' %
|
||||
{'ip': self.configuration.spdk_rpc_ip,
|
||||
self.url = ('%(protocol)s://%(ip)s:%(port)s/' %
|
||||
{'protocol': self.configuration.spdk_rpc_protocol,
|
||||
'ip': self.configuration.spdk_rpc_ip,
|
||||
'port': self.configuration.spdk_rpc_port})
|
||||
|
||||
# SPDK NVMe-oF Target application requires one time creation
|
||||
|
|
Loading…
Reference in New Issue