Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to set T10 Vendor ID for backstore #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
17 changes: 11 additions & 6 deletions targetcli/ui_backstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,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. I{size} is the size of the ramdisk.

Expand All @@ -400,7 +400,8 @@ 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)

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("Created ramdisk %s with size %s."
Expand Down Expand Up @@ -555,7 +556,8 @@ def _ui_block_ro_check(self, dev):
return False
return True

def ui_command_create(self, name, dev, readonly=None, wwn=None):
def ui_command_create(self, name, dev, readonly=None, wwn=None,
vendor_id=None):
'''
Creates an Block Storage object. I{dev} is the path to the TYPE_DISK
block device to use.
Expand All @@ -571,7 +573,8 @@ def ui_command_create(self, name, dev, readonly=None, wwn=None):

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

so = BlockStorageObject(name, dev, readonly=readonly, wwn=wwn)
so = BlockStorageObject(name, dev, readonly=readonly, wwn=wwn,
vendor_id=vendor_id)
ui_so = UIBlockStorageObject(so, self)
self.setup_model_alias(so)
self.shell.log.info("Created block storage object %s using %s."
Expand Down Expand Up @@ -620,7 +623,8 @@ 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 @@ -637,6 +641,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 @@ -647,7 +652,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