diff -aurp targetcli-fb-2.1.fb41/targetcli/ui_backstore.py targetcli-fb-2.1.fb41.work/targetcli/ui_backstore.py --- targetcli-fb-2.1.fb41/targetcli/ui_backstore.py 2015-06-23 11:23:34.000000000 -0500 +++ targetcli-fb-2.1.fb41.work/targetcli/ui_backstore.py 2015-07-29 02:55:51.305430180 -0500 @@ -109,6 +109,7 @@ class UIBackstores(UINode): UIRDMCPBackstore(self) UIFileIOBackstore(self) UIBlockBackstore(self) + UIRBDBackstore(self) UIUserBackedBackstore(self) @@ -402,6 +403,41 @@ class UIBlockBackstore(UIBackstore): completions = [completions[0] + ' '] return completions +class UIRBDBackstore(UIBackstore): + ''' + RBD backstore UI. + ''' + def __init__(self, parent): + self.so_cls = UIRBDStorageObject + UIBackstore.__init__(self, 'rbd', parent) + + def ui_command_create(self, name, dev, readonly=None): + ''' + Creates an RBD Storage object. I{dev} is the path to the RBD + block device to use. + ''' + self.assert_root() + + readonly = self.ui_eval_param(readonly, 'bool', False) + + so = RBDStorageObject(name, dev, readonly=readonly) + ui_so = UIRBDStorageObject(so, self) + self.setup_model_alias(so) + self.shell.log.info("Created RBD storage object %s using %s." + % (name, dev)) + return self.new_node(ui_so) + + def ui_complete_create(self, parameters, text, current_param): + ''' + Auto-completes the device name + ''' + if current_param != 'dev': + return [] + completions = complete_path(text, stat.S_ISBLK) + if len(completions) == 1 and not completions[0].endswith('/'): + completions = [completions[0] + ' '] + return completions + class UIUserBackedBackstore(UIBackstore): ''' @@ -543,6 +579,21 @@ class UIBlockStorageObject(UIStorageObje return ("%s (%s) %s%s %s" % (so.udev_path, bytes_to_human(so.size), ro_str, wb_str, so.status), True) +class UIRBDStorageObject(UIStorageObject): + def summary(self): + so = self.rtsnode + + if so.write_back: + wb_str = "write-back" + else: + wb_str = "write-thru" + + ro_str = "" + if so.readonly: + ro_str = "ro " + + return ("%s (%s) %s%s %s" % (so.udev_path, bytes_to_human(so.size), + ro_str, wb_str, so.status), True) class UIUserBackedStorageObject(UIStorageObject): def summary(self):