Merge "SPDK drivers: Update RPC calls to match latest SPDK changes"
This commit is contained in:
commit
13a5b7feda
@ -220,16 +220,16 @@ class JSONRPCException(Exception):
|
||||
|
||||
class JSONRPCClient(object):
|
||||
def __init__(self, addr=None, port=None):
|
||||
self.methods = {"get_bdevs": self.get_bdevs,
|
||||
self.methods = {"bdev_get_bdevs": self.get_bdevs,
|
||||
"construct_nvmf_subsystem":
|
||||
self.construct_nvmf_subsystem,
|
||||
"delete_nvmf_subsystem": self.delete_nvmf_subsystem,
|
||||
"nvmf_subsystem_create": self.nvmf_subsystem_create,
|
||||
"nvmf_delete_subsystem": self.delete_nvmf_subsystem,
|
||||
"nvmf_create_subsystem": self.nvmf_subsystem_create,
|
||||
"nvmf_subsystem_add_listener":
|
||||
self.nvmf_subsystem_add_listener,
|
||||
"nvmf_subsystem_add_ns":
|
||||
self.nvmf_subsystem_add_ns,
|
||||
"get_nvmf_subsystems": self.get_nvmf_subsystems}
|
||||
"nvmf_get_subsystems": self.get_nvmf_subsystems}
|
||||
self.bdevs = copy.deepcopy(BDEVS)
|
||||
self.nvmf_subsystems = copy.deepcopy(NVMF_SUBSYSTEMS)
|
||||
|
||||
@ -362,7 +362,7 @@ class SpdkNvmfDriverTestCase(test.TestCase):
|
||||
def test__get_spdk_volume_name(self):
|
||||
with mock.patch.object(self.driver, "_rpc_call",
|
||||
self.jsonrpcclient.call):
|
||||
bdevs = self.driver._rpc_call("get_bdevs")
|
||||
bdevs = self.driver._rpc_call("bdev_get_bdevs")
|
||||
bdev_name = bdevs[0]['name']
|
||||
volume_name = self.driver._get_spdk_volume_name(bdev_name)
|
||||
self.assertEqual(bdev_name, volume_name)
|
||||
@ -373,7 +373,7 @@ class SpdkNvmfDriverTestCase(test.TestCase):
|
||||
with mock.patch.object(self.driver, "_rpc_call",
|
||||
self.jsonrpcclient.call):
|
||||
nqn = self.driver._get_nqn_with_volume_name("Nvme0n1p0")
|
||||
nqn_tmp = self.driver._rpc_call("get_nvmf_subsystems")[1]['nqn']
|
||||
nqn_tmp = self.driver._rpc_call("nvmf_get_subsystems")[1]['nqn']
|
||||
self.assertEqual(nqn, nqn_tmp)
|
||||
nqn = self.driver._get_nqn_with_volume_name("fake")
|
||||
self.assertIsNone(nqn)
|
||||
@ -387,21 +387,21 @@ class SpdkNvmfDriverTestCase(test.TestCase):
|
||||
def test_create_nvmeof_target(self):
|
||||
with mock.patch.object(self.driver, "_rpc_call",
|
||||
self.jsonrpcclient.call):
|
||||
subsystems_first = self.driver._rpc_call("get_nvmf_subsystems")
|
||||
subsystems_first = self.driver._rpc_call("nvmf_get_subsystems")
|
||||
self.driver.create_nvmeof_target("Nvme0n1p1",
|
||||
"nqn.2016-06.io.spdk",
|
||||
"192.168.0.1",
|
||||
4420, "rdma", -1, -1, "")
|
||||
subsystems_last = self.driver._rpc_call("get_nvmf_subsystems")
|
||||
subsystems_last = self.driver._rpc_call("nvmf_get_subsystems")
|
||||
self.assertEqual(len(subsystems_first) + 1, len(subsystems_last))
|
||||
|
||||
def test_delete_nvmeof_target(self):
|
||||
with mock.patch.object(self.driver, "_rpc_call",
|
||||
self.jsonrpcclient.call):
|
||||
subsystems_first = self.driver._rpc_call("get_nvmf_subsystems")
|
||||
subsystems_first = self.driver._rpc_call("nvmf_get_subsystems")
|
||||
target = Target()
|
||||
self.driver.delete_nvmeof_target(target)
|
||||
subsystems_last = self.driver._rpc_call("get_nvmf_subsystems")
|
||||
subsystems_last = self.driver._rpc_call("nvmf_get_subsystems")
|
||||
self.assertEqual(len(subsystems_first) - 1, len(subsystems_last))
|
||||
target.name = "fake"
|
||||
self.driver.delete_nvmeof_target(target)
|
||||
|
@ -250,23 +250,23 @@ class JSONRPCException(Exception):
|
||||
|
||||
class JSONRPCClient(object):
|
||||
def __init__(self, addr=None, port=None):
|
||||
self.methods = {"get_bdevs": self.get_bdevs,
|
||||
"get_lvol_stores": self.get_lvol_stores,
|
||||
"destroy_lvol_bdev": self.destroy_lvol_bdev,
|
||||
"snapshot_lvol_bdev": self.snapshot_lvol_bdev,
|
||||
"clone_lvol_bdev": self.clone_lvol_bdev,
|
||||
"construct_lvol_bdev": self.construct_lvol_bdev,
|
||||
"resize_lvol_bdev": self.resize_lvol_bdev,
|
||||
"get_nvmf_subsystems": self.get_nvmf_subsystems,
|
||||
self.methods = {"bdev_get_bdevs": self.get_bdevs,
|
||||
"bdev_lvol_get_lvstores": self.get_lvol_stores,
|
||||
"bdev_lvol_delete": self.destroy_lvol_bdev,
|
||||
"bdev_lvol_snapshot": self.snapshot_lvol_bdev,
|
||||
"bdev_lvol_clone": self.clone_lvol_bdev,
|
||||
"bdev_lvol_create": self.construct_lvol_bdev,
|
||||
"bdev_lvol_resize": self.resize_lvol_bdev,
|
||||
"nvmf_get_subsystems": self.get_nvmf_subsystems,
|
||||
"construct_nvmf_subsystem":
|
||||
self.construct_nvmf_subsystem,
|
||||
"nvmf_subsystem_create":
|
||||
"nvmf_create_subsystem":
|
||||
self.nvmf_subsystem_create,
|
||||
"nvmf_subsystem_add_listener":
|
||||
self.nvmf_subsystem_add_listener,
|
||||
"nvmf_subsystem_add_ns":
|
||||
self.nvmf_subsystem_add_ns,
|
||||
"inflate_lvol_bdev": self.inflate_lvol_bdev}
|
||||
"bdev_lvol_inflate": self.inflate_lvol_bdev}
|
||||
self.bdevs = copy.deepcopy(BDEVS)
|
||||
self.nvmf_subsystems = copy.deepcopy(NVMF_SUBSYSTEMS)
|
||||
self.lvol_stores = copy.deepcopy(LVOL_STORES)
|
||||
@ -536,7 +536,7 @@ class SpdkDriverTestCase(test.TestCase):
|
||||
with mock.patch.object(self.driver, "_rpc_call",
|
||||
self.jsonrpcclient.call):
|
||||
bdev = self.driver._rpc_call(
|
||||
"get_bdevs", params={"name": "lvs_test/lvol0"})
|
||||
"bdev_get_bdevs", params={"name": "lvs_test/lvol0"})
|
||||
self.assertEqual(
|
||||
bdev[0]['driver_specific']['lvol']['lvol_store_uuid'],
|
||||
self.driver._get_spdk_lvs_uuid(
|
||||
@ -547,7 +547,7 @@ class SpdkDriverTestCase(test.TestCase):
|
||||
def test__get_spdk_lvs_free_space(self):
|
||||
with mock.patch.object(self.driver, "_rpc_call",
|
||||
self.jsonrpcclient.call):
|
||||
lvs = self.driver._rpc_call("get_lvol_stores")
|
||||
lvs = self.driver._rpc_call("bdev_lvol_get_lvstores")
|
||||
lvol_store = None
|
||||
for lvol in lvs:
|
||||
if lvol['name'] == "lvs_test":
|
||||
@ -583,7 +583,7 @@ class SpdkDriverTestCase(test.TestCase):
|
||||
bdev)
|
||||
volume_clone = Volume()
|
||||
volume_clone.name = "clone0"
|
||||
self.driver._rpc_call("snapshot_lvol_bdev",
|
||||
self.driver._rpc_call("bdev_lvol_snapshot",
|
||||
params={'snapshot_name': "snapshot0",
|
||||
'lvol_name': "lvs_test/lvol2"})
|
||||
bdev = self.driver._get_spdk_volume_name("lvs_test/snapshot0")
|
||||
@ -628,19 +628,19 @@ class SpdkDriverTestCase(test.TestCase):
|
||||
db_volume = objects.Volume._from_db_object(ctxt, objects.Volume(),
|
||||
db_volume)
|
||||
volume_get.return_value = db_volume
|
||||
start_bdevs_len = len(self.driver._rpc_call('get_bdevs'))
|
||||
start_bdevs_len = len(self.driver._rpc_call('bdev_get_bdevs'))
|
||||
self.driver.create_volume(db_volume)
|
||||
tmp_bdevs = self.driver._rpc_call('get_bdevs')
|
||||
tmp_bdevs = self.driver._rpc_call('bdev_get_bdevs')
|
||||
self.assertEqual(start_bdevs_len + 1, len(tmp_bdevs))
|
||||
volume = Volume()
|
||||
volume.name = "lvs_test/%s" % db_volume.name
|
||||
volume_name = self.driver._get_spdk_volume_name(volume.name)
|
||||
self.driver._rpc_call('destroy_lvol_bdev', {"name": volume_name})
|
||||
self.driver._rpc_call('bdev_lvol_delete', {"name": volume_name})
|
||||
self.driver.delete_volume(volume)
|
||||
bdev = self.driver._get_spdk_volume_name("lvs_test/%s"
|
||||
% db_volume.name)
|
||||
self.assertIsNone(bdev)
|
||||
tmp_bdevs = self.driver._rpc_call('get_bdevs')
|
||||
tmp_bdevs = self.driver._rpc_call('bdev_get_bdevs')
|
||||
self.assertEqual(start_bdevs_len, len(tmp_bdevs))
|
||||
|
||||
def get_volume_stats(self):
|
||||
@ -654,7 +654,7 @@ class SpdkDriverTestCase(test.TestCase):
|
||||
self.jsonrpcclient.call):
|
||||
volume_clone = Volume()
|
||||
volume_clone.name = "clone0"
|
||||
self.driver._rpc_call("snapshot_lvol_bdev",
|
||||
self.driver._rpc_call("bdev_lvol_snapshot",
|
||||
params={'snapshot_name': "snapshot0",
|
||||
'lvol_name': "lvs_test/lvol2"})
|
||||
snapshot = Snapshot()
|
||||
@ -688,7 +688,7 @@ class SpdkDriverTestCase(test.TestCase):
|
||||
self.jsonrpcclient.call):
|
||||
snapshot = Snapshot()
|
||||
snapshot.name = "snapshot0"
|
||||
self.driver._rpc_call("snapshot_lvol_bdev",
|
||||
self.driver._rpc_call("bdev_lvol_snapshot",
|
||||
params = {'snapshot_name': snapshot.name})
|
||||
self.driver.delete_snapshot(snapshot)
|
||||
snapshot = self.driver._get_spdk_volume_name("lvs_test/" +
|
||||
@ -750,7 +750,7 @@ class SpdkDriverTestCase(test.TestCase):
|
||||
volume = Volume()
|
||||
volume.name = "lvs_test/lvol0"
|
||||
self.driver.extend_volume(volume, 2)
|
||||
bdev = self.driver._rpc_call("get_bdevs",
|
||||
bdev = self.driver._rpc_call("bdev_get_bdevs",
|
||||
params={"name": "lvs_test/lvol0"})
|
||||
self.assertEqual(2 * units.Gi,
|
||||
bdev[0]['num_blocks'] * bdev[0]['block_size'])
|
||||
|
@ -92,7 +92,7 @@ class SPDKDriver(driver.VolumeDriver):
|
||||
pools_status = []
|
||||
self.lvs = []
|
||||
|
||||
output = self._rpc_call('get_lvol_stores')
|
||||
output = self._rpc_call('bdev_lvol_get_lvstores')
|
||||
if output:
|
||||
for lvs in output:
|
||||
pool = {}
|
||||
@ -128,14 +128,14 @@ class SPDKDriver(driver.VolumeDriver):
|
||||
lvs['free_size'])
|
||||
|
||||
def _get_spdk_volume_name(self, name):
|
||||
output = self._rpc_call('get_bdevs')
|
||||
output = self._rpc_call('bdev_get_bdevs')
|
||||
for bdev in output:
|
||||
for alias in bdev['aliases']:
|
||||
if name in alias:
|
||||
return bdev['name']
|
||||
|
||||
def _get_spdk_lvs_uuid(self, spdk_name):
|
||||
output = self._rpc_call('get_bdevs')
|
||||
output = self._rpc_call('bdev_get_bdevs')
|
||||
for bdev in output:
|
||||
if spdk_name in bdev['name']:
|
||||
return bdev['driver_specific']['lvol']['lvol_store_uuid']
|
||||
@ -153,13 +153,13 @@ class SPDKDriver(driver.VolumeDriver):
|
||||
spdk_name = self._get_spdk_volume_name(name)
|
||||
if spdk_name is not None:
|
||||
params = {'name': spdk_name}
|
||||
self._rpc_call('destroy_lvol_bdev', params)
|
||||
self._rpc_call('bdev_lvol_delete', params)
|
||||
LOG.debug('SPDK bdev %s deleted', spdk_name)
|
||||
else:
|
||||
LOG.debug('Could not find volume %s using SPDK driver', name)
|
||||
|
||||
def _create_volume(self, volume, snapshot=None):
|
||||
output = self._rpc_call('get_lvol_stores')
|
||||
output = self._rpc_call('bdev_lvol_get_lvstores')
|
||||
for lvs in output:
|
||||
free_size = (lvs['free_clusters'] * lvs['cluster_size'])
|
||||
if free_size / units.Gi >= volume.size:
|
||||
@ -168,22 +168,22 @@ class SPDKDriver(driver.VolumeDriver):
|
||||
'lvol_name': volume.name,
|
||||
'size': volume.size * units.Gi,
|
||||
'uuid': lvs['uuid']}
|
||||
output2 = self._rpc_call('construct_lvol_bdev', params)
|
||||
output2 = self._rpc_call('bdev_lvol_create', params)
|
||||
else:
|
||||
snapshot_spdk_name = (
|
||||
self._get_spdk_volume_name(snapshot.name))
|
||||
params = {
|
||||
'clone_name': volume.name,
|
||||
'snapshot_name': snapshot_spdk_name}
|
||||
output2 = self._rpc_call('clone_lvol_bdev', params)
|
||||
output2 = self._rpc_call('bdev_lvol_clone', params)
|
||||
spdk_name = self._get_spdk_volume_name(volume.name)
|
||||
params = {'name': spdk_name}
|
||||
self._rpc_call('inflate_lvol_bdev', params)
|
||||
self._rpc_call('bdev_lvol_inflate', params)
|
||||
|
||||
if volume.size > snapshot.volume_size:
|
||||
params = {'name': spdk_name,
|
||||
'size': volume.size * units.Gi}
|
||||
self._rpc_call('resize_lvol_bdev', params)
|
||||
self._rpc_call('bdev_lvol_resize', params)
|
||||
|
||||
LOG.debug('SPDK created lvol: %s', output2)
|
||||
|
||||
@ -196,7 +196,7 @@ class SPDKDriver(driver.VolumeDriver):
|
||||
|
||||
def do_setup(self, context):
|
||||
try:
|
||||
payload = {'method': 'get_bdevs', 'jsonrpc': '2.0', 'id': 1}
|
||||
payload = {'method': 'bdev_get_bdevs', 'jsonrpc': '2.0', 'id': 1}
|
||||
self.url = ('http://%(ip)s:%(port)s/' %
|
||||
{'ip': self.configuration.spdk_rpc_ip,
|
||||
'port': self.configuration.spdk_rpc_port})
|
||||
@ -217,7 +217,7 @@ class SPDKDriver(driver.VolumeDriver):
|
||||
"""Verify that requirements are in place to use LVM driver."""
|
||||
|
||||
# If configuration is incorrect we will get exception here
|
||||
self._rpc_call('get_bdevs')
|
||||
self._rpc_call('bdev_get_bdevs')
|
||||
|
||||
def create_volume(self, volume):
|
||||
"""Creates a logical volume."""
|
||||
@ -269,10 +269,10 @@ class SPDKDriver(driver.VolumeDriver):
|
||||
params = {
|
||||
'lvol_name': spdk_name,
|
||||
'snapshot_name': snapshot['name']}
|
||||
self._rpc_call('snapshot_lvol_bdev', params)
|
||||
self._rpc_call('bdev_lvol_snapshot', params)
|
||||
|
||||
params = {'name': spdk_name}
|
||||
self._rpc_call('inflate_lvol_bdev', params)
|
||||
self._rpc_call('bdev_lvol_inflate', params)
|
||||
|
||||
def delete_snapshot(self, snapshot):
|
||||
"""Deletes a snapshot."""
|
||||
@ -281,12 +281,12 @@ class SPDKDriver(driver.VolumeDriver):
|
||||
return
|
||||
|
||||
params = {'name': spdk_name}
|
||||
bdev = self._rpc_call('get_bdevs', params)
|
||||
bdev = self._rpc_call('bdev_get_bdevs', params)
|
||||
if 'clones' in bdev[0]['driver_specific']['lvol']:
|
||||
for clone in bdev[0]['driver_specific']['lvol']['clones']:
|
||||
spdk_name = self._get_spdk_volume_name(clone)
|
||||
params = {'name': spdk_name}
|
||||
self._rpc_call('inflate_lvol_bdev', params)
|
||||
self._rpc_call('bdev_lvol_inflate', params)
|
||||
|
||||
self._delete_bdev(snapshot.name)
|
||||
|
||||
@ -306,21 +306,21 @@ class SPDKDriver(driver.VolumeDriver):
|
||||
params = {
|
||||
'lvol_name': spdk_name,
|
||||
'snapshot_name': snapshot_name}
|
||||
self._rpc_call('snapshot_lvol_bdev', params)
|
||||
self._rpc_call('bdev_lvol_snapshot', params)
|
||||
|
||||
params = {'name': spdk_name}
|
||||
self._rpc_call('inflate_lvol_bdev', params)
|
||||
self._rpc_call('bdev_lvol_inflate', params)
|
||||
|
||||
snapshot_spdk_name = self._get_spdk_volume_name(snapshot_name)
|
||||
params = {
|
||||
'clone_name': volume.name,
|
||||
'snapshot_name': snapshot_spdk_name}
|
||||
|
||||
self._rpc_call('clone_lvol_bdev', params)
|
||||
self._rpc_call('bdev_lvol_clone', params)
|
||||
|
||||
spdk_name = self._get_spdk_volume_name(volume.name)
|
||||
params = {'name': spdk_name}
|
||||
self._rpc_call('inflate_lvol_bdev', params)
|
||||
self._rpc_call('bdev_lvol_inflate', params)
|
||||
|
||||
self._delete_bdev(snapshot_name)
|
||||
|
||||
@ -387,7 +387,7 @@ class SPDKDriver(driver.VolumeDriver):
|
||||
"""Extend an existing volume's size."""
|
||||
spdk_name = self._get_spdk_volume_name(volume.name)
|
||||
params = {'name': spdk_name, 'size': new_size * units.Gi}
|
||||
self._rpc_call('resize_lvol_bdev', params)
|
||||
self._rpc_call('bdev_lvol_resize', params)
|
||||
|
||||
# ####### Interface methods for DataPath (Target Driver) ########
|
||||
def ensure_export(self, context, volume):
|
||||
|
@ -91,7 +91,7 @@ class SpdkNvmf(nvmeof.NVMeOF):
|
||||
return req.json()['result']
|
||||
|
||||
def _get_spdk_volume_name(self, name):
|
||||
output = self._rpc_call('get_bdevs')
|
||||
output = self._rpc_call('bdev_get_bdevs')
|
||||
|
||||
for bdev in output:
|
||||
for alias in bdev['aliases']:
|
||||
@ -99,7 +99,7 @@ class SpdkNvmf(nvmeof.NVMeOF):
|
||||
return bdev['name']
|
||||
|
||||
def _get_nqn_with_volume_name(self, name):
|
||||
output = self._rpc_call('get_nvmf_subsystems')
|
||||
output = self._rpc_call('nvmf_get_subsystems')
|
||||
|
||||
spdk_name = self._get_spdk_volume_name(name)
|
||||
|
||||
@ -112,7 +112,7 @@ class SpdkNvmf(nvmeof.NVMeOF):
|
||||
def _get_first_free_node(self):
|
||||
cnode_num = []
|
||||
|
||||
output = self._rpc_call('get_nvmf_subsystems')
|
||||
output = self._rpc_call('nvmf_get_subsystems')
|
||||
|
||||
# Get node numbers for nqn string like this: nqn.2016-06.io.spdk:cnode1
|
||||
|
||||
@ -149,7 +149,7 @@ class SpdkNvmf(nvmeof.NVMeOF):
|
||||
'allow_any_host': True,
|
||||
'serial_number': serial,
|
||||
}
|
||||
self._rpc_call('nvmf_subsystem_create', params)
|
||||
self._rpc_call('nvmf_create_subsystem', params)
|
||||
|
||||
listen_address = {
|
||||
'trtype': transport_type,
|
||||
@ -189,7 +189,7 @@ class SpdkNvmf(nvmeof.NVMeOF):
|
||||
if nqn is not None:
|
||||
try:
|
||||
params = {'nqn': nqn}
|
||||
self._rpc_call('delete_nvmf_subsystem', params)
|
||||
self._rpc_call('nvmf_delete_subsystem', params)
|
||||
LOG.debug('SPDK subsystem %s deleted', nqn)
|
||||
except Exception as e:
|
||||
LOG.debug('SPDK ERROR: subsystem not deleted: %s', e)
|
||||
|
@ -15,7 +15,8 @@ SPDK NVMe-oF target installation
|
||||
--------------------------------
|
||||
|
||||
Follow instructions available on https://spdk.io/doc/nvmf.html to install
|
||||
and configure environment with SPDK NVMe-oF target application.
|
||||
and configure environment with SPDK NVMe-oF target application. Starting
|
||||
from Ussuri release SPDK release v19.10 or higher is required.
|
||||
|
||||
Storage pools configuration
|
||||
---------------------------
|
||||
|
6
releasenotes/notes/rpc-update-50bef83f48d4f96f.yaml
Normal file
6
releasenotes/notes/rpc-update-50bef83f48d4f96f.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
SPDK target and volume drivers have been updated with new SPDK specific
|
||||
RPC calls due to deprecation of some old RPC calls. Starting from Ussuri
|
||||
release SPDK release v19.10 or higher is required.
|
Loading…
Reference in New Issue
Block a user