spdkcli: Check for uninitialized spdk instance

At start of spdkcli and on each configuration call
check if spdk subsystems are initialized.
Disallow using get/create/delete commands if system is
not initialized.

Change-Id: I8b9e0362c31a5007e6460d4f79cf3f9e91f71054
Signed-off-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.gerrithub.io/419510
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>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Karol Latecki 2018-07-17 12:25:19 +02:00 committed by Jim Harris
parent ff3cd4315e
commit cf43428221

View File

@ -15,8 +15,21 @@ class UIRoot(UINode):
self.current_vhost_ctrls = []
self.set_rpc_target(s)
self.verbose = False
self.is_init = self.check_init()
def refresh(self):
if self.is_init is False:
methods = self.get_rpc_methods(current=True)
methods = "\n".join(methods)
self.shell.log.warning("SPDK Application is not yet initialized.\n"
"Please initialize subsystems with start_subsystem_init command.\n"
"List of available commands in current state:\n"
"%s" % methods)
else:
# Pass because we'd like to build main tree structure for "ls"
# even if state is uninitialized
pass
self._children = set([])
UIBdevs(self)
UILvolStores(self)
@ -40,7 +53,19 @@ class UIRoot(UINode):
return r
return w
def ui_command_start_subsystem_init(self):
if rpc.start_subsystem_init(self.client):
self.is_init = True
self.refresh()
def get_rpc_methods(self, current=False):
return rpc.get_rpc_methods(self.client, current=current)
def check_init(self):
return "start_subsystem_init" not in self.get_rpc_methods(current=True)
def get_bdevs(self, bdev_type):
if self.is_init:
self.current_bdevs = rpc.bdev.get_bdevs(self.client)
# Following replace needs to be done in order for some of the bdev
# listings to work: logical volumes, split disk.
@ -132,6 +157,7 @@ class UIRoot(UINode):
rpc.bdev.delete_error_bdev(self.client, **kwargs)
def get_lvol_stores(self):
if self.is_init:
self.current_lvol_stores = rpc.lvol.get_lvol_stores(self.client)
for lvs in self.current_lvol_stores:
yield LvolStore(lvs)
@ -185,14 +211,17 @@ class UIRoot(UINode):
return response
def get_virtio_scsi_devs(self):
if self.is_init:
for bdev in rpc.vhost.get_virtio_scsi_devs(self.client):
test = Bdev(bdev)
yield test
def list_vhost_ctrls(self):
if self.is_init:
self.current_vhost_ctrls = rpc.vhost.get_vhost_controllers(self.client)
def get_vhost_ctrlrs(self, ctrlr_type):
if self.is_init:
self.list_vhost_ctrls()
for ctrlr in filter(lambda x: ctrlr_type in x["backend_specific"].keys(),
self.current_vhost_ctrls):