Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/targetcli/ui_backstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def __init__(self, parent):
self.so_cls = UIRamdiskStorageObject
UIBackstore.__init__(self, 'ramdisk', parent)

def ui_command_create(self, name, size, nullio=None, wwn=None):
def ui_command_create(self, name, size, nullio=None, wwn=None, vendor_id=None):
'''
Creates an RDMCP storage object. "size" is the size of the ramdisk.

Expand All @@ -400,8 +400,10 @@ def ui_command_create(self, name, size, nullio=None, wwn=None):

nullio = self.ui_eval_param(nullio, 'bool', False)
wwn = self.ui_eval_param(wwn, 'string', None)
vendor_id = self.ui_eval_param(vendor_id, 'string', None)

so = RDMCPStorageObject(name, human_to_bytes(size), nullio=nullio, wwn=wwn)
so = RDMCPStorageObject(name, human_to_bytes(size), nullio=nullio, wwn=wwn,
vendor_id=vendor_id)
ui_so = UIRamdiskStorageObject(so, self)
self.setup_model_alias(so)
self.shell.log.info(f"Created ramdisk {name} with size {size}.")
Expand Down Expand Up @@ -443,7 +445,7 @@ def _create_file(self, filename, size, sparse=True):
f.close()

def ui_command_create(self, name, file_or_dev, size=None, write_back=None,
sparse=None, wwn=None):
sparse=None, wwn=None, vendor_id=None):
'''
Creates a FileIO storage object. If "file_or_dev" is a path
to a regular file to be used as backend, then the "size"
Expand Down Expand Up @@ -472,6 +474,7 @@ def ui_command_create(self, name, file_or_dev, size=None, write_back=None,
sparse = self.ui_eval_param(sparse, 'bool', True)
write_back = self.ui_eval_param(write_back, 'bool', True)
wwn = self.ui_eval_param(wwn, 'string', None)
vendor_id = self.ui_eval_param(vendor_id, 'string', None)

self.shell.log.debug(f"Using params size={size} write_back={write_back} sparse={sparse}")

Expand Down Expand Up @@ -504,7 +507,8 @@ def ui_command_create(self, name, file_or_dev, size=None, write_back=None,
self._create_file(file_or_dev, size, sparse)

so = FileIOStorageObject(name, file_or_dev, size,
write_back=write_back, wwn=wwn)
write_back=write_back, wwn=wwn,
vendor_id=vendor_id)
ui_so = UIFileioStorageObject(so, self)
self.setup_model_alias(so)
self.shell.log.info(f"Created fileio {name} with size {so.size}")
Expand Down Expand Up @@ -550,7 +554,7 @@ def _ui_block_ro_check(self, dev):
return struct.unpack('I', buf)[0] != 0

def ui_command_create(self, name, dev, readonly=None, wwn=None,
exclusive=None):
exclusive=None, vendor_id=None):
'''
Creates an Block Storage object. "dev" is the path to the TYPE_DISK
block device to use.
Expand All @@ -561,12 +565,13 @@ def ui_command_create(self, name, dev, readonly=None, wwn=None,
readonly = self._ui_block_ro_check(dev) if ro_string is None else self.ui_eval_param(readonly, "bool", False)

wwn = self.ui_eval_param(wwn, 'string', None)
vendor_id = self.ui_eval_param(vendor_id, 'string', None)

excl_string = self.ui_eval_param(exclusive, 'string', None)
exclusive = True if excl_string is None else self.ui_eval_param(exclusive, "bool", True)

so = BlockStorageObject(name, dev, readonly=readonly, wwn=wwn,
exclusive=exclusive)
exclusive=exclusive, vendor_id=vendor_id)
ui_so = UIBlockStorageObject(so, self)
self.setup_model_alias(so)
self.shell.log.info(f"Created block storage object {name} using {dev}.")
Expand Down Expand Up @@ -614,7 +619,7 @@ def ui_command_help(self, topic=None):
print()

def ui_command_create(self, name, size, cfgstring, wwn=None,
hw_max_sectors=None, control=None):
hw_max_sectors=None, control=None, vendor_id=None):
'''
Creates a User-backed storage object.

Expand All @@ -631,6 +636,7 @@ def ui_command_create(self, name, size, cfgstring, wwn=None,

size = human_to_bytes(size)
wwn = self.ui_eval_param(wwn, 'string', None)
vendor_id = self.ui_eval_param(vendor_id, 'string', None)

config = self.handler + "/" + cfgstring

Expand All @@ -641,7 +647,7 @@ def ui_command_create(self, name, size, cfgstring, wwn=None,
try:
so = UserBackedStorageObject(name, size=size, config=config,
wwn=wwn, hw_max_sectors=hw_max_sectors,
control=control)
control=control, vendor_id=vendor_id)
except:
raise ExecutionError("UserBackedStorageObject creation failed.")

Expand Down