test/spdkcli: Delete multiple items from nvmf node

Change-Id: I72e5815eb318e82a8701e48c5b502b0a3ca1c367
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/429821
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@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-17 16:44:40 -04:00 committed by Jim Harris
parent 9b91f9c47c
commit c016b65939
2 changed files with 63 additions and 24 deletions

View File

@ -74,6 +74,12 @@ class UINVMfSubsystems(UINode):
for subsystem in self.get_root().get_nvmf_subsystems():
UINVMfSubsystem(subsystem, self)
def delete(self, subsystem_nqn):
try:
self.get_root().delete_nvmf_subsystem(nqn=subsystem_nqn)
except JSONRPCException as e:
self.shell.log.error(e.message)
def ui_command_create(self, nqn, serial_number=None,
max_namespaces=None, allow_any_host="false"):
"""Create subsystem with given parameteres.
@ -102,10 +108,13 @@ class UINVMfSubsystems(UINode):
Arguments:
nqn_subsystem - Name of susbsytem to delete
"""
try:
self.get_root().delete_nvmf_subsystem(nqn=subsystem_nqn)
except JSONRPCException as e:
self.shell.log.error(e.message)
self.delete(subsystem_nqn)
self.refresh()
def ui_command_delete_all(self):
"""Delete all subsystems"""
for child in self._children:
self.delete(child.subsystem.nqn)
self.refresh()
def summary(self):
@ -180,6 +189,14 @@ class UINVMfSubsystemListeners(UINode):
self.listen_addresses = subsystem.listen_addresses
self.refresh()
def delete(self, trtype, traddr, trsvcid, adrfam=None):
try:
self.get_root().nvmf_subsystem_remove_listener(
nqn=self.parent.subsystem.nqn, trtype=trtype,
traddr=traddr, trsvcid=trsvcid, adrfam=adrfam)
except JSONRPCException as e:
self.shell.log.error(e.message)
def ui_command_create(self, trtype, traddr, trsvcid, adrfam):
"""Create address listener for subsystem.
@ -207,12 +224,14 @@ class UINVMfSubsystemListeners(UINode):
trsvcid - NVMe-oF transport service id: e.g., a port number.
adrfam - Optional argument. Address family ("IPv4", "IPv6", "IB" or "FC").
"""
try:
self.get_root().nvmf_subsystem_remove_listener(
nqn=self.parent.subsystem.nqn, trtype=trtype,
traddr=traddr, trsvcid=trsvcid, adrfam=adrfam)
except JSONRPCException as e:
self.shell.log.error(e.message)
self.delete(trtype, traddr, trsvcid, adrfam)
self.get_root().refresh()
self.refresh_node()
def ui_command_delete_all(self):
"""Remove all address listeners from subsystem."""
for la in self.listen_addresses:
self.delete(la['trtype'], la['traddr'], la['trsvcid'], la['adrfam'])
self.get_root().refresh()
self.refresh_node()
@ -247,6 +266,13 @@ class UINVMfSubsystemHosts(UINode):
self.hosts = subsystem.hosts
self.refresh()
def delete(self, host):
try:
self.get_root().nvmf_subsystem_remove_host(
nqn=self.parent.subsystem.nqn, host=host)
except JSONRPCException as e:
self.shell.log.error(e.message)
def ui_command_create(self, host):
"""Add a host NQN to the whitelist of allowed hosts.
@ -267,11 +293,14 @@ class UINVMfSubsystemHosts(UINode):
Arguments:
host - NQN of host to remove.
"""
try:
self.get_root().nvmf_subsystem_remove_host(
nqn=self.parent.subsystem.nqn, host=host)
except JSONRPCException as e:
self.shell.log.error(e.message)
self.delete(host)
self.get_root().refresh()
self.refresh_node()
def ui_command_delete_all(self):
"""Delete host from subsystem"""
for host in self.hosts:
self.delete(host['nqn'])
self.get_root().refresh()
self.refresh_node()
@ -302,6 +331,13 @@ class UINVMfSubsystemNamespaces(UINode):
self.namespaces = subsystem.namespaces
self.refresh()
def delete(self, nsid):
try:
self.get_root().nvmf_subsystem_remove_ns(
nqn=self.parent.subsystem.nqn, nsid=nsid)
except JSONRPCException as e:
self.shell.log.error(e.message)
def ui_command_create(self, bdev_name, nsid=None,
nguid=None, eui64=None, uuid=None):
"""Add a namespace to a subsystem.
@ -331,11 +367,14 @@ class UINVMfSubsystemNamespaces(UINode):
nsid - Id of namespace to remove.
"""
nsid = self.ui_eval_param(nsid, "number", None)
try:
self.get_root().nvmf_subsystem_remove_ns(
nqn=self.parent.subsystem.nqn, nsid=nsid)
except JSONRPCException as e:
self.shell.log.error(e.message)
self.delete(nsid)
self.get_root().refresh()
self.refresh_node()
def ui_command_delete_all(self):
"""Delete all namespaces from subsystem."""
for namespace in self.namespaces:
self.delete(namespace['nsid'])
self.get_root().refresh()
self.refresh_node()

View File

@ -63,13 +63,13 @@ timing_exit spdkcli_check_match
timing_enter spdkcli_clear_nvmf_config
$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/namespaces delete nsid=1" "Malloc3"
$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/namespaces delete nsid=2" "Malloc4"
$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/namespaces delete_all" "Malloc4"
$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/hosts delete nqn.2014-08.org.spdk:cnode2" "nqn.2014-08.org.spdk:cnode2"
$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode3/hosts delete_all" "nqn.2014-08.org.spdk:cnode1"
$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/listen_addresses delete RDMA $NVMF_TARGET_IP 4262" "$NVMF_TARGET_IP:4262"
$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/listen_addresses delete RDMA $NVMF_TARGET_IP 4261" "$NVMF_TARGET_IP:4261"
$spdkcli_job "/nvmf/subsystem/nqn.2014-08.org.spdk:cnode1/listen_addresses delete_all" "$NVMF_TARGET_IP:4261"
$spdkcli_job "/nvmf/subsystem delete nqn.2014-08.org.spdk:cnode3" "nqn.2014-08.org.spdk:cnode3"
$spdkcli_job "/nvmf/subsystem delete nqn.2014-08.org.spdk:cnode2" "nqn.2014-08.org.spdk:cnode2"
$spdkcli_job "/nvmf/subsystem delete nqn.2014-08.org.spdk:cnode1" "nqn.2014-08.org.spdk:cnode1"
$spdkcli_job "/nvmf/subsystem delete_all" "nqn.2014-08.org.spdk:cnode2"
$spdkcli_job "/bdevs/malloc delete Malloc6" "Malloc6"
$spdkcli_job "/bdevs/malloc delete Malloc5" "Malloc5"
$spdkcli_job "/bdevs/malloc delete Malloc4" "Malloc4"