test/spdkcli: Add possibility to delete all bdevs

for subnodes (aio, error, logical_volume, etc)
              from bdev node

Change-Id: I346437da6cff6b0df6dc8a579da09e77bcddf610
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/430074
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Pawel Kaminski 2018-10-19 14:48:08 -04:00 committed by Jim Harris
parent f6f1161fcd
commit c042749882
7 changed files with 127 additions and 66 deletions

View File

@ -130,6 +130,13 @@ class UIBdev(UINode):
except JSONRPCException as e:
self.shell.log.error(e.message)
def ui_command_delete_all(self):
"""Delete all bdevs from this tree node."""
for bdev in self._children:
self.delete(bdev.name)
self.get_root().refresh()
self.refresh()
def summary(self):
return "Bdevs: %d" % len(self.children), None
@ -138,6 +145,12 @@ class UIMallocBdev(UIBdev):
def __init__(self, parent):
UIBdev.__init__(self, "malloc", parent)
def delete(self, name):
try:
self.get_root().delete_malloc_bdev(name=name)
except JSONRPCException as e:
self.shell.log.error(e.message)
def ui_command_create(self, size, block_size, name=None, uuid=None):
"""
Construct a Malloc bdev.
@ -172,10 +185,7 @@ class UIMallocBdev(UIBdev):
Arguments:
name - Is a unique identifier of the malloc bdev to be deleted - UUID number or name alias.
"""
try:
self.get_root().delete_malloc_bdev(name=name)
except JSONRPCException as e:
self.shell.log.error(e.message)
self.delete(name)
self.get_root().refresh()
self.refresh()
@ -184,6 +194,12 @@ class UIAIOBdev(UIBdev):
def __init__(self, parent):
UIBdev.__init__(self, "aio", parent)
def delete(self, name):
try:
self.get_root().delete_aio_bdev(name=name)
except JSONRPCException as e:
self.shell.log.error(e.message)
def ui_command_create(self, name, filename, block_size):
"""
Construct an AIO bdev.
@ -216,10 +232,7 @@ class UIAIOBdev(UIBdev):
Arguments:
name - Is a unique identifier of the aio bdev to be deleted - UUID number or name alias.
"""
try:
self.get_root().delete_aio_bdev(name=name)
except JSONRPCException as e:
self.shell.log.error(e.message)
self.delete(name)
self.get_root().refresh()
self.refresh()
@ -228,6 +241,12 @@ class UILvolBdev(UIBdev):
def __init__(self, parent):
UIBdev.__init__(self, "logical_volume", parent)
def delete(self, name):
try:
self.get_root().destroy_lvol_bdev(name=name)
except JSONRPCException as e:
self.shell.log.error(e.message)
def ui_command_create(self, name, size, lvs, thin_provision=None):
"""
Construct a Logical Volume bdev.
@ -270,10 +289,7 @@ class UILvolBdev(UIBdev):
Arguments:
name - Is a unique identifier of the lvol bdev to be deleted - UUID number or name alias.
"""
try:
self.get_root().destroy_lvol_bdev(name=name)
except JSONRPCException as e:
self.shell.log.error(e.message)
self.delete(name)
self.get_root().refresh()
self.refresh()
@ -282,6 +298,12 @@ class UINvmeBdev(UIBdev):
def __init__(self, parent):
UIBdev.__init__(self, "nvme", parent)
def delete(self, name):
try:
self.get_root().delete_nvme_controller(name=name)
except JSONRPCException as e:
self.shell.log.error(e.message)
def ui_command_create(self, name, trtype, traddr,
adrfam=None, trsvcid=None, subnqn=None):
@ -307,10 +329,7 @@ class UINvmeBdev(UIBdev):
Arguments:
name - Is a unique identifier of the NVMe controller to be deleted.
"""
try:
self.get_root().delete_nvme_controller(name=name)
except JSONRPCException as e:
self.shell.log.error(e.message)
self.delete(name)
self.get_root().refresh()
self.refresh()
@ -319,6 +338,12 @@ class UINullBdev(UIBdev):
def __init__(self, parent):
UIBdev.__init__(self, "null", parent)
def delete(self, name):
try:
self.get_root().delete_null_bdev(name=name)
except JSONRPCException as e:
self.shell.log.error(e.message)
def ui_command_create(self, name, size, block_size, uuid=None):
"""
Construct a Null bdev.
@ -353,10 +378,7 @@ class UINullBdev(UIBdev):
Arguments:
name - Is a unique identifier of the null bdev to be deleted - UUID number or name alias.
"""
try:
self.get_root().delete_null_bdev(name=name)
except JSONRPCException as e:
self.shell.log.error(e.message)
self.delete(name)
self.get_root().refresh()
self.refresh()
@ -365,6 +387,12 @@ class UIErrorBdev(UIBdev):
def __init__(self, parent):
UIBdev.__init__(self, "error", parent)
def delete(self, name):
try:
self.get_root().delete_error_bdev(name=name)
except JSONRPCException as e:
self.shell.log.error(e.message)
def ui_command_create(self, base_name):
"""
Construct a error injection bdev.
@ -388,10 +416,7 @@ class UIErrorBdev(UIBdev):
Arguments:
name - Is a unique identifier of the error bdev to be deleted - UUID number or name alias.
"""
try:
self.get_root().delete_error_bdev(name=name)
except JSONRPCException as e:
self.shell.log.error(e.message)
self.delete(name)
self.get_root().refresh()
self.refresh()
@ -400,6 +425,9 @@ class UISplitBdev(UIBdev):
def __init__(self, parent):
UIBdev.__init__(self, "split_disk", parent)
def delete(self, name):
pass
def ui_command_split_bdev(self, base_bdev, split_count, split_size_mb=None):
"""
Construct split block devices from a base bdev.
@ -444,6 +472,12 @@ class UIPmemBdev(UIBdev):
def __init__(self, parent):
UIBdev.__init__(self, "pmemblk", parent)
def delete(self, name):
try:
self.get_root().delete_pmem_bdev(name=name)
except JSONRPCException as e:
self.shell.log.error(e.message)
def ui_command_create_pmem_pool(self, pmem_file, total_size, block_size):
total_size = self.ui_eval_param(total_size, "number", None)
block_size = self.ui_eval_param(block_size, "number", None)
@ -487,10 +521,7 @@ class UIPmemBdev(UIBdev):
Arguments:
name - Is a unique identifier of the pmem bdev to be deleted - UUID number or name alias.
"""
try:
self.get_root().delete_pmem_bdev(name=name)
except JSONRPCException as e:
self.shell.log.error(e.message)
self.delete(name)
self.get_root().refresh()
self.refresh()
@ -499,6 +530,12 @@ class UIRbdBdev(UIBdev):
def __init__(self, parent):
UIBdev.__init__(self, "rbd", parent)
def delete(self, name):
try:
self.get_root().delete_rbd_bdev(name=name)
except JSONRPCException as e:
self.shell.log.error(e.message)
def ui_command_create(self, pool_name, rbd_name, block_size, name=None):
block_size = self.ui_eval_param(block_size, "number", None)
@ -521,10 +558,7 @@ class UIRbdBdev(UIBdev):
Arguments:
name - Is a unique identifier of the rbd bdev to be deleted - UUID number or name alias.
"""
try:
self.get_root().delete_rbd_bdev(name=name)
except JSONRPCException as e:
self.shell.log.error(e.message)
self.delete(name)
self.get_root().refresh()
self.refresh()
@ -533,6 +567,12 @@ class UIiSCSIBdev(UIBdev):
def __init__(self, parent):
UIBdev.__init__(self, "iscsi", parent)
def delete(self, name):
try:
self.get_root().delete_iscsi_bdev(name=name)
except JSONRPCException as e:
self.shell.log.error(e.message)
def ui_command_create(self, name, url, initiator_iqn):
"""
Create iSCSI bdev in configuration by connecting to remote
@ -562,11 +602,7 @@ class UIiSCSIBdev(UIBdev):
Arguments:
name - name of the iscsi bdev to be deleted.
"""
try:
self.get_root().delete_iscsi_bdev(name=name)
except JSONRPCException as e:
self.shell.log.error(e.message)
self.delete(name)
self.get_root().refresh()
self.refresh()

View File

@ -1,2 +1,3 @@
o- pmemblk .............................................................................................................. [Bdevs: 1]
o- pmem_bdev ........................................................................................... [Size=31.6M, Not claimed]
o- pmemblk .............................................................................................................. [Bdevs: 2]
o- pmem_bdev0 .......................................................................................... [Size=31.6M, Not claimed]
o- pmem_bdev1 .......................................................................................... [Size=31.6M, Not claimed]

View File

@ -1,2 +1,3 @@
o- rbd .................................................................................................................. [Bdevs: 1]
o- rbd .................................................................................................................. [Bdevs: 2]
o- Ceph0 ............................................................................................. [Size=1000.0M, Not claimed]
o- Ceph1 ............................................................................................. [Size=1000.0M, Not claimed]

View File

@ -1,19 +1,24 @@
o- / ......................................................................................................................... [...]
o- bdevs ................................................................................................................... [...]
| o- aio .............................................................................................................. [Bdevs: 1]
| | o- sample ........................................................................................... [Size=$(FP)M, Not claimed]
| o- error ............................................................................................................ [Bdevs: 1]
| o- aio .............................................................................................................. [Bdevs: 2]
| | o- sample0 .......................................................................................... [Size=$(FP)M, Not claimed]
| | o- sample1 .......................................................................................... [Size=$(FP)M, Not claimed]
| o- error ............................................................................................................ [Bdevs: 2]
| | o- EE_Malloc1 ...................................................................................... [Size=$(FP)M, Not claimed]
| | o- EE_Malloc4 ...................................................................................... [Size=$(FP)M, Not claimed]
| o- iscsi ............................................................................................................ [Bdevs: 0]
| o- logical_volume ................................................................................................... [Bdevs: 1]
| | o- $(X)-$(X)-$(X)-$(X)-$(X) .................................................. [lvs/lvol, Size=$(FP)M, Not claimed]
| o- malloc ........................................................................................................... [Bdevs: 4]
| o- logical_volume ................................................................................................... [Bdevs: 2]
| | o- $(X)-$(X)-$(X)-$(X)-$(X) ................................................. [lvs/lvol$(FP), Size=$(FP)M, Not claimed]
| | o- $(X)-$(X)-$(X)-$(X)-$(X) ................................................. [lvs/lvol$(FP), Size=$(FP)M, Not claimed]
| o- malloc ........................................................................................................... [Bdevs: 5]
| | o- Malloc0 ............................................................................................. [Size=$(FP)M, Claimed]
| | o- Malloc1 ............................................................................................. [Size=$(FP)M, Claimed]
| | o- Malloc2 ......................................................................................... [Size=$(FP)M, Not claimed]
| | o- Malloc3 ......................................................................................... [Size=$(FP)M, Not claimed]
| o- null ............................................................................................................. [Bdevs: 1]
| | o- null_bdev ....................................................................................... [Size=$(FP)M, Not claimed]
| | o- Malloc4 ............................................................................................. [Size=$(FP)M, Claimed]
| o- null ............................................................................................................. [Bdevs: 2]
| | o- null_bdev0 ...................................................................................... [Size=$(FP)M, Not claimed]
| | o- null_bdev1 ...................................................................................... [Size=$(FP)M, Not claimed]
| o- nvme ............................................................................................................. [Bdevs: 1]
| | o- Nvme0n1 $(S) [Size=$(FP)G, Claimed]
| o- pmemblk .......................................................................................................... [Bdevs: 0]
@ -50,7 +55,7 @@ o- / ...........................................................................
| o- portal_groups ............................................................................................ [Portal groups: 0]
| o- target_nodes .............................................................................................. [Target nodes: 0]
o- lvol_stores .................................................................................................. [Lvol stores: 1]
| o- lvs ................................................................................................ [Size=$(FP)M, Free=$(FP)M]
| o- lvs ................................................................................................. [Size=$(FP)M, Free=$(FP)M]
o- nvmf .................................................................................................................... [...]
| o- subsystem ................................................................................................... [Subsystems: 1]
| | o- nqn.2014-08.org.nvmexpress.discovery ....................................................... [st=Discovery, Allow any host]

View File

@ -14,8 +14,10 @@ run_spdk_tgt
timing_exit run_spdk_tgt
timing_enter spdkcli_create_pmem_config
$spdkcli_job "/bdevs/pmemblk create_pmem_pool /tmp/sample_pmem 32 512" "" True
$spdkcli_job "/bdevs/pmemblk create /tmp/sample_pmem pmem_bdev" "pmem_bdev" True
$spdkcli_job "/bdevs/pmemblk create_pmem_pool /tmp/sample_pmem0 32 512" "" True
$spdkcli_job "/bdevs/pmemblk create /tmp/sample_pmem0 pmem_bdev0" "pmem_bdev0" True
$spdkcli_job "/bdevs/pmemblk create_pmem_pool /tmp/sample_pmem1 32 512" "" True
$spdkcli_job "/bdevs/pmemblk create /tmp/sample_pmem1 pmem_bdev1" "pmem_bdev1" True
timing_exit spdkcli_create_pmem_config
timing_enter spdkcli_check_match
@ -23,8 +25,10 @@ check_match
timing_exit spdkcli_check_match
timing_enter spdkcli_clear_pmem_config
$spdkcli_job "/bdevs/pmemblk delete pmem_bdev" "pmem_bdev"
$spdkcli_job "/bdevs/pmemblk delete_pmem_pool /tmp/sample_pmem" ""
$spdkcli_job "/bdevs/pmemblk delete pmem_bdev0" "pmem_bdev0"
$spdkcli_job "/bdevs/pmemblk delete_pmem_pool /tmp/sample_pmem0" ""
$spdkcli_job "/bdevs/pmemblk delete_all" "pmem_bdev1"
$spdkcli_job "/bdevs/pmemblk delete_pmem_pool /tmp/sample_pmem1" ""
rm -f /tmp/sample_pmem
timing_exit spdkcli_clear_pmem_config

View File

@ -15,8 +15,10 @@ timing_exit run_spdk_tgt
timing_enter spdkcli_create_rbd_config
trap 'rbd_cleanup; on_error_exit' ERR
rootdir=$(readlink -f $SPDKCLI_BUILD_DIR)
rbd_cleanup
rbd_setup 127.0.0.1
$spdkcli_job "/bdevs/rbd create rbd foo 512" "Ceph0" True
$spdkcli_job "/bdevs/rbd create rbd foo 512" "Ceph1" True
timing_exit spdkcli_create_rbd_config
timing_enter spdkcli_check_match
@ -25,6 +27,7 @@ timing_exit spdkcli_check_match
timing_enter spdkcli_clear_rbd_config
$spdkcli_job "/bdevs/rbd delete Ceph0" "Ceph0"
$spdkcli_job "/bdevs/rbd delete_all" "Ceph1"
rbd_cleanup
timing_exit spdkcli_clear_rbd_config

View File

@ -14,14 +14,19 @@ run_spdk_tgt
timing_exit run_spdk_tgt
timing_enter spdkcli_create_bdevs_config
$spdkcli_job "/bdevs/malloc create 32 512 Malloc0" "Malloc0" True
$spdkcli_job "/bdevs/malloc create 40 512 Malloc0" "Malloc0" True
$spdkcli_job "/bdevs/malloc create 32 512 Malloc1" "Malloc1" True
$spdkcli_job "/bdevs/malloc create 32 512 Malloc2" "Malloc2" True
$spdkcli_job "/bdevs/malloc create 32 4096 Malloc3" "Malloc3" True
$spdkcli_job "/bdevs/malloc create 32 4096 Malloc4" "Malloc4" True
$spdkcli_job "/bdevs/error create Malloc1" "EE_Malloc1" True
$spdkcli_job "/bdevs/null create null_bdev 32 512" "null_bdev" True
$spdkcli_job "/bdevs/error create Malloc4" "EE_Malloc4" True
$spdkcli_job "/bdevs/null create null_bdev0 32 512" "null_bdev0" True
$spdkcli_job "/bdevs/null create null_bdev1 32 512" "null_bdev1" True
dd if=/dev/zero of=/tmp/sample_aio bs=2048 count=5000
$spdkcli_job "/bdevs/aio create sample /tmp/sample_aio 512" "sample" True
dd if=/dev/zero of=/tmp/sample_aio2 bs=2048 count=5000
$spdkcli_job "/bdevs/aio create sample0 /tmp/sample_aio 512" "sample0" True
$spdkcli_job "/bdevs/aio create sample1 /tmp/sample_aio2 512" "sample1" True
trtype=$($SPDKCLI_BUILD_DIR/scripts/gen_nvme.sh --json | jq -r '.config[].params | select(.name=="Nvme0").trtype')
traddr=$($SPDKCLI_BUILD_DIR/scripts/gen_nvme.sh --json | jq -r '.config[].params | select(.name=="Nvme0").traddr')
$spdkcli_job "/bdevs/nvme create Nvme0 $trtype $traddr" "Nvme0" True
@ -30,12 +35,13 @@ timing_exit spdkcli_create_bdevs_config
timing_enter spdkcli_create_lvols_config
$spdkcli_job "/lvol_stores create lvs Malloc0" "lvs" True
$spdkcli_job "/bdevs/logical_volume create lvol 16 lvs" "lvs/lvol" True
$spdkcli_job "/bdevs/logical_volume create lvol0 16 lvs" "lvs/lvol0" True
$spdkcli_job "/bdevs/logical_volume create lvol1 16 lvs" "lvs/lvol1" True
timing_exit spdkcli_create_lvols_config
timing_enter spdkcli_create_vhosts_config
$spdkcli_job "vhost/block create vhost_blk1 Nvme0n1p0" "Nvme0n1p0" True
$spdkcli_job "vhost/block create vhost_blk2 Nvme0n1p1 0x2 readonly" "Nvme0n1p1" True
$spdkcli_job "vhost/block create vhost_blk2 Nvme0n1p1 0x1 readonly" "Nvme0n1p1" True
$spdkcli_job "vhost/scsi create vhost_scsi1" "vhost_scsi1" True
$spdkcli_job "vhost/scsi create vhost_scsi2" "vhost_scsi2" True
$spdkcli_job "vhost/scsi/vhost_scsi1 add_lun 0 Malloc2" "Malloc2" True
@ -70,21 +76,25 @@ $spdkcli_job "vhost/scsi delete vhost_scsi1" "vhost_scsi1"
$spdkcli_job "vhost/block delete vhost_blk2" "vhost_blk2"
$spdkcli_job "vhost/block delete vhost_blk1" "vhost_blk1"
$spdkcli_job "/bdevs/split_disk destruct_split_bdev Nvme0n1" "Nvme0n1p0"
$spdkcli_job "/bdevs/aio delete sample" "sample"
$spdkcli_job "/bdevs/aio delete sample0" "sample0"
$spdkcli_job "/bdevs/aio delete_all" "sample1"
$spdkcli_job "/bdevs/nvme delete Nvme0" "Nvme0"
$spdkcli_job "/bdevs/null delete null_bdev" "null_bdev"
$spdkcli_job "/bdevs/logical_volume delete lvs/lvol" "lvs/lvol"
$spdkcli_job "/bdevs/null delete null_bdev0" "null_bdev0"
$spdkcli_job "/bdevs/null delete_all" "null_bdev1"
$spdkcli_job "/bdevs/logical_volume delete lvs/lvol0" "lvs/lvol0"
$spdkcli_job "/bdevs/logical_volume delete_all" "lvs/lvol1"
$spdkcli_job "/lvol_stores delete lvs" "lvs"
$spdkcli_job "/bdevs/error delete EE_Malloc1" "EE_Malloc1"
$spdkcli_job "/bdevs/error delete_all" "EE_Malloc4"
$spdkcli_job "/bdevs/malloc delete Malloc0" "Malloc0"
$spdkcli_job "/bdevs/malloc delete Malloc1" "Malloc1"
$spdkcli_job "/bdevs/malloc delete Malloc2" "Malloc2"
$spdkcli_job "/bdevs/malloc delete Malloc3" "Malloc3"
$spdkcli_job "/bdevs/malloc delete_all" "Malloc1"
timing_exit spdkcli_clear_config
timing_enter spdkcli_load_config
$spdkcli_job "load_config $testdir/config.json"
$spdkcli_job "/lvol_stores create lvs Malloc0" "lvs" True
$spdkcli_job "/bdevs/logical_volume create lvol 16 lvs" "lvs/lvol" True
$spdkcli_job "/bdevs/logical_volume create lvol0 16 lvs" "lvs/lvol0" True
$spdkcli_job "/bdevs/logical_volume create lvol1 16 lvs" "lvs/lvol1" True
check_match
$spdk_clear_config_py clear_config
# FIXME: remove this sleep when NVMe driver will be fixed to wait for reset to complete
@ -92,7 +102,8 @@ sleep 2
$spdkcli_job "load_subsystem_config $testdir/config_bdev.json"
$spdkcli_job "load_subsystem_config $testdir/config_vhost.json"
$spdkcli_job "/lvol_stores create lvs Malloc0" "lvs" True
$spdkcli_job "/bdevs/logical_volume create lvol 16 lvs" "lvs/lvol" True
$spdkcli_job "/bdevs/logical_volume create lvol0 16 lvs" "lvs/lvol0" True
$spdkcli_job "/bdevs/logical_volume create lvol1 16 lvs" "lvs/lvol1" True
check_match
rm -f $testdir/config.json
rm -f $testdir/config_bdev.json