Git Product home page Git Product logo

rtslib-fb's Issues

load modules only when needed

Don't load all kernel modules when targetcli comes up, change class FabricModule to overload check_self, it loads the kmod and creates the cfs group.

def _check_self(self):
    if not self._is_loaded:
        self._load()
        print "LOADED %s" % self.name
        self._is_loaded = True
    super(FabricModule, self)._check_self()

The "pr" database root directory /var/target should be moved from /var

The target_core_mod module allows changing the target "database" root directory from the current default of /var/target to another location.

The target_core_mod module allows changing the db directory if and only if no target modules have been loaded,

Since rtslib loads the target_core_mod module, it is the place that needs to be fixed to allow changing this directory.

I looked for a config option for rtslib, but I don't see any. I have a branch that unconditionally changes the directory to /etc/target, but I'm not sure that's the best approach for everybody, even if that will work for me.

Ideas?

Race condition mounting configfs

On systems where loading the configfs module (modprobe configfs) automatically mounts /sys/kernel/config, a race condition can occur in the mount_configfs() function in utils.py.

As that function is called immediately after the modprode function, the os.path.ismount check can be called before configfs is finished mounting. The mount command is then run but fails because the mount is busy as it's mounted.

One possible workaround is to make a second os.path.ismount check if the mount command fails, and if it is mounted then we don't raise an exception.
if process.returncode != 0 and not os.path.ismount("/sys/kernel/config"):
raise RTSLibError("Cannot mount configfs")

I submitted a pull request #73 with this workaround. There are other ways this could be handled as well, this is just one fix that worked for me.

last commits made both qla2xxx and tcm_fc targets disappear

commit that caused the error : c79ee86

git checkout 751ca29
gives me
targetcli ls
o- / ......................................................................................................................... [...]
o- backstores .............................................................................................................. [...]
| o- block .................................................................................................. [Storage Objects: 0]
| o- fileio ................................................................................................. [Storage Objects: 0]
| o- pscsi .................................................................................................. [Storage Objects: 0]
| o- ramdisk ................................................................................................ [Storage Objects: 0]
o- iscsi ............................................................................................................ [Targets: 0]
o- loopback ......................................................................................................... [Targets: 0]
o- qla2xxx .......................................................................................................... [Targets: 0]
o- tcm_fc ........................................................................................................... [Targets: 0]
o- vhost ............................................................................................................ [Targets: 0]

git checkout master
gives me
targetcli ls
o- / ......................................................................................................................... [...]
o- backstores .............................................................................................................. [...]
| o- block .................................................................................................. [Storage Objects: 0]
| o- fileio ................................................................................................. [Storage Objects: 0]
| o- pscsi .................................................................................................. [Storage Objects: 0]
| o- ramdisk ................................................................................................ [Storage Objects: 0]
o- iscsi ............................................................................................................ [Targets: 0]
o- loopback ......................................................................................................... [Targets: 0]
o- vhost ............................................................................................................ [Targets: 0]

recent changes about renaming README to README.md cause "make rpm" to fail

Source : current git
make rpm
Exporting the repository files...
Cleaning up the target tree...
Fixing version string...
( too long text cut for clarity )
cp: cannot stat 'README': No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.qZMxBU (%doc)

RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.qZMxBU (%doc)
make: *** [build/rpm-stamp] Error 1

Build host : Fedora 18, kernel-3.8.11-200.fc18.x86_64
Same thing for the other packages (targetcli and configshell)

handle new attributes better, based on kernel version

whenever an attribute is added to configfs, we need to be able to cope with it being present or not being present (on older kernels). right now we just catch exceptions & ignore when they're not there, but this is bad because it may mask times we do want to raise, on newer kernels.

Implement a cleaner way to do reads/writes that looks at the kernel version and acts appropriately.

targetctl restore should activate tcmu-runner if needed

If there are any tcmu-backed storage objects, then tcmu-runner likely needs to be running to handle them. This can be done by making a call to the DBus interface, which will activate the daemon.

We should only activate tcmu-runner this way if tcmu backstores are actually in use.

Issue warning when using fileio bs for block device

Nick says we can't defeature fileio support for block devices, but the usage case is a pretty advanced one.

To protect against users inadvertently using fileio when block backstore would be better, issue a warning and recommend block.

restore from json - failed auth from iscsi initiators

If I run these commands my initiator can login:

targetcli "/backstores/block create name=mptarget4 dev=/dev/vg_storage/station4mp"
targetcli "/iscsi set discovery_auth enable=1"
targetcli "/iscsi set discovery_auth mutual_userid=target"
targetcli "/iscsi set discovery_auth mutual_password=itsreallyme"
targetcli "/iscsi set discovery_auth userid=initiator"
targetcli "/iscsi set discovery_auth password=letmein"
targetcli "/iscsi create wwn=iqn.2003-01.org.linux-iscsi.storage:mptarget4"
targetcli "/iscsi/iqn.2003-01.org.linux-iscsi.storage:mptarget4/tpgt1/luns create storage_object=/backstores/block/mptarget4"
targetcli "/iscsi/iqn.2003-01.org.linux-iscsi.storage:mptarget4/tpgt1/acls create wwn=iqn.1994-05.com.redhat:station4"
targetcli "/iscsi/iqn.2003-01.org.linux-iscsi.storage:mptarget4/tpgt1/acls/iqn.1994-05.com.redhat:station4 set auth mutual_userid=target"
targetcli "/iscsi/iqn.2003-01.org.linux-iscsi.storage:mptarget4/tpgt1/acls/iqn.1994-05.com.redhat:station4 set auth mutual_password=itsreallyme"
targetcli "/iscsi/iqn.2003-01.org.linux-iscsi.storage:mptarget4/tpgt1/acls/iqn.1994-05.com.redhat:station4 set auth userid=station4"
targetcli "/iscsi/iqn.2003-01.org.linux-iscsi.storage:mptarget4/tpgt1/acls/iqn.1994-05.com.redhat:station4 set auth password=letmein"
targetcli "/iscsi/iqn.2003-01.org.linux-iscsi.storage:mptarget4/tpgt1/portals create 10.100.0.199 ip_port=3260"

And on my initiator:

iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.storage:mptarget4 -l

Logging in to [iface: default, target: iqn.2003-01.org.linux-iscsi.storage:mptarget4, portal: 10.100.0.199,3260]
Login to [iface: default, target: iqn.2003-01.org.linux-iscsi.storage:mptarget4, portal: 10.100.0.199,3260] successful.

But if I I then do a:

targetcli "/ saveconfig"

and

targetcli restoreconfig clear_existing=true (or a reboot)

Then the initiator can't login and I get "iSCSI Login negotiation failed" in dmesg on the target.

Here is the saveconfig.json that saveconfig creates above and that the initiator can't login with:

[root@storage ~]# cat /etc/target/saveconfig.json
{
"fabric_modules": [
{
"discovery_enable_auth": true,
"discovery_mutual_password": "itsreallyme",
"discovery_mutual_userid": "target",
"discovery_password": "letmein",
"discovery_userid": "initiator",
"name": "iscsi"
}
],
"storage_objects": [
{
"attributes": {
"block_size": 512,
"emulate_dpo": 0,
"emulate_fua_read": 0,
"emulate_fua_write": 1,
"emulate_rest_reord": 0,
"emulate_tas": 1,
"emulate_tpu": 0,
"emulate_tpws": 0,
"emulate_ua_intlck_ctrl": 0,
"emulate_write_cache": 0,
"enforce_pr_isids": 1,
"is_nonrot": 0,
"max_sectors": 1024,
"max_unmap_block_desc_count": 0,
"max_unmap_lba_count": 0,
"optimal_sectors": 1024,
"queue_depth": 128,
"task_timeout": 0,
"unmap_granularity": 0,
"unmap_granularity_alignment": 0
},
"dev": "/dev/vg_storage/station4mp",
"name": "mptarget4",
"plugin": "block",
"wwn": "6be30fb6-3bc9-43c4-a866-4d8633af5cf2"
}
],
"targets": [
{
"fabric": "iscsi",
"tpgs": [
{
"attributes": {
"authentication": 1,
"cache_dynamic_acls": 0,
"default_cmdsn_depth": 16,
"demo_mode_write_protect": 1,
"generate_node_acls": 0,
"login_timeout": 15,
"netif_timeout": 2,
"prod_mode_write_protect": 0
},
"luns": [
{
"index": 0,
"storage_object": "/backstores/block/mptarget4"
}
],
"node_acls": [
{
"attributes": {
"dataout_timeout": 3,
"dataout_timeout_retries": 5,
"default_erl": 0,
"nopin_response_timeout": 5,
"nopin_timeout": 5,
"random_datain_pdu_offsets": 0,
"random_datain_seq_offsets": 0,
"random_r2t_offsets": 0
},
"chap_mutual_password": "itsreallyme",
"chap_mutual_userid": "target",
"chap_password": "letmein",
"chap_userid": "station4",
"mapped_luns": [
{
"index": 0,
"write_protect": false
}
],
"node_wwn": "iqn.1994-05.com.redhat:station4",
"tcq_depth": 16
}
],
"portals": [
{
"ip_address": "10.100.0.199",
"port": 3260
}
],
"tag": 1
}
],
"wwn": "iqn.2003-01.org.linux-iscsi.storage:mptarget4"
}
]
}

fabric wwns() calls shouldn't use from_fabric_wwn

Both from_fabric_wwn and wwns() are converting a wwn in some format to rtslib's canonical format, but they need not be the SAME format.

For example, with fcoe, the possible wwns are listed in /sys/class/fc_host/host*/port_name as 0x123456. The wwns() method should be stripping the 0x, and adding the "naa." type at the front. But, the fcoe LIO fabric does 12:34:56. So, from_fabric_wwn should be stripping colons and adding the type. These are close but not identical conversions, and trying to do them both in from_fabric_wwn is confusing.

The obstacle to fixing this right away is we want to be able to test and verify for each fabric that we fixed it right. Fabrics have evolved from_fabric_wwn's that handle both, and we don't want to keep breaking stuff.

setup() really wants to be a generator

err_func is a hack -- it's more natural to return nonfatal error messages with yield!

Unfortunately, py 2.7 doesn't have 'yield from', which would let us convert without ugly for loops every time we call another setup(). This will be a nice cleanup once we are py3-only.

dpkg: error processing python-rtslib-fb (--install): SyntaxError

After a make deb and doing a dpkg -i dist/*.deb I get :

Setting up python-rtslib-fb (2.1.fb49) ...
SyntaxError: ('invalid syntax', ('/usr/lib/python2.6/dist-packages/rtslib/fabric.py', 120, 36, 'version_attributes = {"lio_version", "version"}\n'))

dpkg: error processing python-rtslib-fb (--install):
 subprocess installed post-installation script returned error exit status 101
Setting up python-rtslib-fb-docs (2.1.fb49) ...
Errors were encountered while processing:
 python-rtslib-fb

Raised exception has changed when a storage object is not found: RTSLibNotInCFS became RTSLibError

After upgrading rtslib-fb in a NAS firmware at work that uses a custom software on top of rtslib-fb, I observed that the exception raised when a storage object is not found in lookup mode is now RTSLibError. It used to be RTSLibNotInCFS prior to rtslib-fb v2.1.fb44:

Behaviour up to rtslib-fb v2.1.fb43:

>>> import rtslib
>>> rtslib.tcm.FileIOStorageObject('foo', None, None, None, False)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/rtslib/tcm.py", line 566, in __init__
  File "build/bdist.linux-x86_64/egg/rtslib/tcm.py", line 48, in __init__
  File "build/bdist.linux-x86_64/egg/rtslib/tcm.py", line 798, in __init__
  File "build/bdist.linux-x86_64/egg/rtslib/node.py", line 53, in _create_in_cfs_ine
rtslib.utils.RTSLibNotInCFS: No such _Backstore in configfs: /sys/kernel/config/target/core/fileio_0.

Since rtslib-fb v2.1.fb44:

>>> import rtslib_fb
>>> rtslib_fb.tcm.FileIOStorageObject('foo', None, None, None, False)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/rtslib/tcm.py", line 566, in __init__
  File "build/bdist.linux-x86_64/egg/rtslib/tcm.py", line 48, in __init__
  File "build/bdist.linux-x86_64/egg/rtslib/tcm.py", line 785, in __init__
rtslib.utils.RTSLibError: Storage object fileio/foo not found

@grover, I can provide a patch if you consider this is an issue.

Please remove the Debian folder from the repository

Hi,

I'm the package maintainer for python-rtslib-fb in Debian. I maintain my package using git.debian.org, where all of the packaging is stored. Unfortunately, upstream holding a debian folder is a very bad idea, as it prevents me from merging your latest tags (ie: it create merge conflicts in my Git when I do so).

Could you please remove the debian folder, or at least rename it to something like "debian-upstream", or alternatively, push it to a separate branch (which is perfect for using git-buildpackage, especially if you privde a debian/gbp.conf file)?

Also, I would very much enjoy having contribution within the OpenStack packaging team, to improve the package. The packaging improvements will go to both Debian and Ubuntu (as they sync the package from Debian).

Best would be if you could release a new tag without that debian folder asap, and then I'll be able to package and upload that to Debian Sid.

Thanks in advance.

Update for Fedora 17?

This is probably not the best place to ask this but I saw that you maintain the python-rtslib package for Fedora, are you intending to release another update for the package on Fedora 17 or will it be left at 2.1.fb14? I ask because I'm trying out ZFS on Linux and one of the updates to rtslib fixes a iSCSI block device issue with ZFS devices (openzfs/zfs#515). I see updates to the f17 branch for it here http://pkgs.fedoraproject.org/cgit/python-rtslib.git/log/?h=f17 but I don't know enough about the Fedora packaging process to know whether that means an updated package will actually be released.

fail to save due to invalid literal for attributes

issue

When I save (exit) targetcli shell, I am getting following error.

Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Traceback (most recent call last):
  File "/usr/bin/targetcli", line 121, in <module>
    main()
  File "/usr/bin/targetcli", line 117, in main
    root_node.ui_command_saveconfig()
  File "/usr/lib/python3.6/site-packages/targetcli/ui_root.py", line 90, in ui_command_saveconfig
    self.rtsroot.save_to_file(savefile)
  File "/usr/lib/python3.6/site-packages/rtslib_fb/root.py", line 270, in save_to_file
    f.write(json.dumps(self.dump(), sort_keys=True, indent=2))
  File "/usr/lib/python3.6/site-packages/rtslib_fb/root.py", line 160, in dump
    d['storage_objects'] = [so.dump() for so in self.storage_objects]
  File "/usr/lib/python3.6/site-packages/rtslib_fb/root.py", line 160, in <listcomp>
    d['storage_objects'] = [so.dump() for so in self.storage_objects]
  File "/usr/lib/python3.6/site-packages/rtslib_fb/tcm.py", line 839, in dump
    d = super(UserBackedStorageObject, self).dump()
  File "/usr/lib/python3.6/site-packages/rtslib_fb/tcm.py", line 294, in dump
    d = super(StorageObject, self).dump()
  File "/usr/lib/python3.6/site-packages/rtslib_fb/node.py", line 217, in dump
    attrs[item] = int(self.get_attribute(item))

step to reproduce

NOTE: sorry, I am premised on using tcmu-runner.

1. create dummy file

qemu-img create -f qcow2 /tmp/test.img 3G

2. start targetcli shell

# targetcli 
targetcli shell version 2.1.fb46
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.
/>

3. create backstore with string attributes and exit

/> backstores/user:qcow create cfgstring=/tmp/test.img name=test.img size=3G
Created user-backed storage object test.img size 3221225472.
/> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Traceback (most recent call last):
  File "/usr/bin/targetcli", line 121, in <module>
    main()
  File "/usr/bin/targetcli", line 117, in main
    root_node.ui_command_saveconfig()
  File "/usr/lib/python3.6/site-packages/targetcli/ui_root.py", line 90, in ui_command_saveconfig
    self.rtsroot.save_to_file(savefile)
  File "/usr/lib/python3.6/site-packages/rtslib_fb/root.py", line 270, in save_to_file
    f.write(json.dumps(self.dump(), sort_keys=True, indent=2))
  File "/usr/lib/python3.6/site-packages/rtslib_fb/root.py", line 160, in dump
    d['storage_objects'] = [so.dump() for so in self.storage_objects]
  File "/usr/lib/python3.6/site-packages/rtslib_fb/root.py", line 160, in <listcomp>
    d['storage_objects'] = [so.dump() for so in self.storage_objects]
  File "/usr/lib/python3.6/site-packages/rtslib_fb/tcm.py", line 839, in dump
    d = super(UserBackedStorageObject, self).dump()
  File "/usr/lib/python3.6/site-packages/rtslib_fb/tcm.py", line 294, in dump
    d = super(StorageObject, self).dump()
  File "/usr/lib/python3.6/site-packages/rtslib_fb/node.py", line 217, in dump
    attrs[item] = int(self.get_attribute(item))
ValueError: invalid literal for int() with base 10: 'qcow//tmp/test.img'

latest releases not on pypi

Hi, I'd like to update our package of this, but it looks like the 2.1.61 release at least isn't on pypi. Was it missed?

Display a more meaningful error when the preferred DB root does not exist

@sithglan reported on the targetcli-fb mailing list that he could not run the upstream version of targetcli-fb due to the following error:

(debian) [~] targetcli
[Errno 22] Invalid argument

I looked at his issue and I found that the error happens when the /etc/target directory is missing. The root cause of the error is that targetcli fails to change the value in /sys/kernel/config/target/dbroot from /var/target (kernel default) to /etc/target/ (preferred by targetcli) because the directory does not exist. When this happens, the following error is displayed in dmesg:

# dmesg
db_root: cannot open: /etc/target

I will provide a patch to display a more meaningful error when this error occurs.

Invalid distutils versioning

If you try to create a Python package that depends on rtslib using distutils, it isn't possible to require a specific version or range of versions, such as >=2.1.fb27. When processing setup.py, you see:
<...>
File "/usr/lib64/python2.7/distutils/version.py", line 40, in init
self.parse(vstring)
File "/usr/lib64/python2.7/distutils/version.py", line 107, in parse
raise ValueError, "invalid version number '%s'" % vstring
ValueError: invalid version number '2.1.fb27'

This is because of the rules as described in http://epydoc.sourceforge.net/stdlib/distutils.version.StrictVersion-class.html .

rtslib on PyPI should use a different scheme such as 2.1.27.

mount configfs with rtslib / Could not create RTSRoot in configFS

Most packages include target rc script or systemd service file to make sure configfs is not only loaded as a kernel module, but also /sys/kernel/config is mounted.

However, targetcli/rtslib also works halfway without it.
When targetcli starts it uses rtslib to check that target_core_mod is mounted. If configfs is loaded and mounted then modprobe target_core_mod works fine.

When configfs is not mounted then modprobe target_core_mod will also load configfs as a dependency, but /sys/kernel/config is not mounted, which then leads to:

Could not create RTSRoot in configfs

since /sys/kernel/config is there, but you can't write to it.

rtslib could possibly also check for the configfs mount and mount it if it isn't present.
A service/rc file is still necessary to actually start and load the target configuration at boot, but targetcli would be available for testing without these scripts already.

Debian packet can not be build due to pythonpath error

Hello,

There is a problem with the building of the Debian packet.
Here is my output:

make[1]: Entering directory `/root/rtslib-fb/build/rtslib-2.1.fb40.10.g3fbe7e4'
dh_testdir
/usr/bin/python ./setup.py --quiet build --build-base build install \
                --no-compile --install-purelib debian/tmp/lib/rtslib \
                --install-scripts debian/tmp/bin
TEST FAILED: debian/tmp/lib/rtslib/ does NOT support .pth files
error: bad install directory or PYTHONPATH

You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from.  The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    debian/tmp/lib/rtslib/

and your PYTHONPATH environment variable currently contains:

    ''

regards,
Alex

set emulate_model_alias

Nick posted he'd like to accept a feature to set the SCSI model name based on the name of the backstore (I think.) This sounds like a cool feature, but Nick wants to disable it so existing people relying on the name won't have issues.

I think we want this on by default, and we will need to set

/sys/kernel/config/target/core/$HBA/$DEV/attrib/emulate_model_alias

to 1.

targetcli may fail to start since eecb633 "Display a more meaningful error when targetcli cannot change dbroot"

At revision eecb633, I added some code to display a more meaningful error when rtslib cannot change the "dbroot" value. This error can be raised when the new "dbroot" value points to a directory that does not exist.

However, there is at least another situation where the "dbroot" value cannot be changed: when the target drivers are already loaded:

# dmesg
db_root: cannot be changed: target drivers registered

This second situation should not prevent targetcli from starting.

get_disk_size failure on partitioned drives

get_disk_size(path) fails on partitioned drives. e.g. it will look for the size of /dev/sda1 in /sys/block/sda1/size instead of /sys/block/sda/sda1/size. This causes targetcli-fb to crash on many commands. Especially on re-starting of the software.

add return types to epydoc docstrings

Working on the session API I realized, that most properties and functions don't list a return type.
The format is @return: description and @rtype: type for functions and @type: type for properties (and instance variables). This is especially helpful because we can even link the types: L{NodeACL}.

epydoc is already used and there is also an old documentation online. There is a lot of epydoc-specific parameter documentation in the docstrings of functions, but somehow return types are missing.

I documented my session branch (JonnyJD/rtslib-fb@d95ecc6) additions.

I note that we don't really have to document private functions and variables this way.

qla2xxx broken

commit 76b7af4 changed the name of the qla2xxx module to qla2xxxx which is IMHO a bad thing.

RPM, Deb scripts missing from all -fb repos.

I read one of the commit logs... and blaming debian for removing a functional, working feature is just low. Bring it back. Many of us use it when we're installing from source. You can easily omit it from the release tarballs if you want for debian's pleasure, but anybody working from the repo probably wants and needs those rpm/apt bits.

Documentation/Examples

Can you please add some example code to the repo? I was unable to find even how to create a backstore and link it to a target after a day's reading code from both rtslib-fb and targetcli-fb. Some simple example code would be sufficient to understand how the API is to be used.

Thanks

code deduplication (LUN)

There is loop.LUN and target.LUN.

I see that they are different, but they do share a LOT of code.__init__ is quite similar, _configure , _get_alias,``_get_storage_object` are completely the same. Maybe even more, I didn't check.

This needs a single LUN class and LoopLUN and TargetLUN that inherit from it.
That LUN class should probably go in tcm.py.

If we don't want to change the API we might keep the class names, but we should still have a super class. I would prefer changing the names, because having two (or 3) different LUN classes in the lib is not optimal.

OSError: [Errno 16] Device or resource busy: '/sys/kernel/config/target/core/fileio_2/tmp-test3.raw'

/backstores/fileio> ls
o- fileio ..................................................................................................... [Storage Objects: 3]
  o- tmp-test3.raw ................................................................. [/tmp/test3.raw (50.0MiB) write-thru ACTIVATED]
  o- tmp-youpi.raw .................................................................. [/tmp/youpi.raw (1.0GiB) write-thru ACTIVATED]
  o- youpi ........................................................................ [/tmp/youpi.raw (1.0GiB) write-back DEACTIVATED]
/backstores/fileio> delete tmp-test3.raw 
Traceback (most recent call last):
  File "/usr/bin/targetcli", line 100, in <module>
    main()
  File "/usr/bin/targetcli", line 90, in main
    shell.run_interactive()
  File "/usr/lib/python3/dist-packages/configshell/shell.py", line 948, in run_interactive
    self._cli_loop()
  File "/usr/lib/python3/dist-packages/configshell/shell.py", line 777, in _cli_loop
    self.run_cmdline(cmdline)
  File "/usr/lib/python3/dist-packages/configshell/shell.py", line 891, in run_cmdline
    self._execute_command(path, command, pparams, kparams)
  File "/usr/lib/python3/dist-packages/configshell/shell.py", line 866, in _execute_command
    result = target.execute_command(command, pparams, kparams)
  File "/usr/lib/python3/dist-packages/configshell/node.py", line 1413, in execute_command
    return method(*pparams, **kparams)
  File "/usr/lib/python3/dist-packages/targetcli/ui_backstore.py", line 150, in ui_command_delete
    child.rtsnode.delete()
  File "/usr/lib/python3/dist-packages/rtslib/tcm.py", line 235, in delete
    super(StorageObject, self).delete()
  File "/usr/lib/python3/dist-packages/rtslib/node.py", line 199, in delete
    os.rmdir(self.path)
OSError: [Errno 16] Device or resource busy: '/sys/kernel/config/target/core/fileio_2/tmp-test3.raw'

Maybe this operation should generate an error instead of a traceback?

AttributeError: 'UUID' object has no attribute 'get_hex'

/loopback> create
Traceback (most recent call last):
  File "/usr/bin/targetcli", line 100, in <module>
    main()
  File "/usr/bin/targetcli", line 90, in main
    shell.run_interactive()
  File "/usr/lib/python3/dist-packages/configshell/shell.py", line 948, in run_interactive
    self._cli_loop()
  File "/usr/lib/python3/dist-packages/configshell/shell.py", line 777, in _cli_loop
    self.run_cmdline(cmdline)
  File "/usr/lib/python3/dist-packages/configshell/shell.py", line 891, in run_cmdline
    self._execute_command(path, command, pparams, kparams)
  File "/usr/lib/python3/dist-packages/configshell/shell.py", line 866, in _execute_command
    result = target.execute_command(command, pparams, kparams)
  File "/usr/lib/python3/dist-packages/configshell/node.py", line 1413, in execute_command
    return method(*pparams, **kparams)
  File "/usr/lib/python3/dist-packages/targetcli/ui_target.py", line 183, in ui_command_create
    target = Target(self.rtsnode, wwn, mode='create')
  File "/usr/lib/python3/dist-packages/rtslib/target.py", line 74, in __init__
    self.wwn = generate_wwn(fabric_module.wwn_types[0])
  File "/usr/lib/python3/dist-packages/rtslib/utils.py", line 284, in generate_wwn
    return "naa.5001405" + uuid.uuid4().get_hex()[-9:]
AttributeError: 'UUID' object has no attribute 'get_hex'

move saveconfig to rtslib

Now that there are >1 entities using rtslib (targetcli and targetd), in order to properly save state for both, this function must be centralized in rtslib.

synchronize access to configfs

As raised on target-devel, it is possible that more than one agent could be changing configfs at the same time. This is very bad. We should establish a locking convention that all target configfs-accessing libs (not just this one) will follow in order to make configfs changes atomic.

Some kind of lockfile would be the normal way to do this, I guess.

Adding RBD disk with ValueError: No JSON object could be decoded

After creating iSCSI gateways successfully, I add RBD disk by using

create pool=rbd image=iscsi-test-16T size=16T

Then, I got the following error

ValueError: No JSON object could be decoded

The rbd-target-api daemon is

[root@ceph-gw-1 ~]# journalctl -u rbd-target-api
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]: (LUN.allocate) created rbd/iscsi-test-16T successfully
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]: (LUN.add_dev_to_lio) Adding image 'rbd.iscsi-test-16T' to LIO
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]: 127.0.0.1 - - [10/Nov/2017 12:00:18] "PUT /api/_disk/rbd.iscsi-test-16T HTTP/1.1" 500 -
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]: Traceback (most recent call last):
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1997, in __call__
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     return self.wsgi_app(environ, start_response)
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     response = self.handle_exception(e)
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1540, in handle_exception
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     reraise(exc_type, exc_value, tb)
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     response = self.full_dispatch_request()
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_req
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     rv = self.handle_user_exception(e)
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1517, in handle_user_excep
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     reraise(exc_type, exc_value, tb)
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_req
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     rv = self.dispatch_request()
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     return self.view_functions[rule.endpoint](**req.view_args)
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib/python2.7/site-packages/gwcli-2.5-py2.7.egg/EGG-INFO/scripts/rbd-target-
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib/python2.7/site-packages/gwcli-2.5-py2.7.egg/EGG-INFO/scripts/rbd-target-
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "build/bdist.linux-x86_64/egg/ceph_iscsi_config/lun.py", line 426, in allocate
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     lun = self.add_dev_to_lio()
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "build/bdist.linux-x86_64/egg/ceph_iscsi_config/lun.py", line 612, in add_dev_to_l
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     wwn=in_wwn)
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib/python2.7/site-packages/rtslib_fb/tcm.py", line 815, in __init__
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     self._configure(config, size, wwn, hw_max_sectors)
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib/python2.7/site-packages/rtslib_fb/tcm.py", line 831, in _configure
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     self._enable()
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib/python2.7/site-packages/rtslib_fb/tcm.py", line 172, in _enable
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     fwrite(path, "1\n")
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib/python2.7/site-packages/rtslib_fb/utils.py", line 79, in fwrite
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     file_fd.write(str(string))
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]: IOError: [Errno 2] No such file or directory
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]: _disk change on 127.0.0.1 failed with 500
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]: 127.0.0.1 - - [10/Nov/2017 12:00:18] "PUT /api/disk/rbd.iscsi-test-16T HTTP/1.1" 500 -
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]: Traceback (most recent call last):
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1997, in __call__
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     return self.wsgi_app(environ, start_response)
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     response = self.handle_exception(e)
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1540, in handle_exception
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     reraise(exc_type, exc_value, tb)
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     response = self.full_dispatch_request()
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_req
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     rv = self.handle_user_exception(e)
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1517, in handle_user_excep
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     reraise(exc_type, exc_value, tb)
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_req
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     rv = self.dispatch_request()
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     return self.view_functions[rule.endpoint](**req.view_args)
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib/python2.7/site-packages/gwcli-2.5-py2.7.egg/EGG-INFO/scripts/rbd-target-
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib/python2.7/site-packages/gwcli-2.5-py2.7.egg/EGG-INFO/scripts/rbd-target-
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib/python2.7/site-packages/gwcli-2.5-py2.7.egg/EGG-INFO/scripts/rbd-target-
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib/python2.7/site-packages/requests/models.py", line 866, in json
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     return complexjson.loads(self.text, **kwargs)
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/json/__init__.py", line 339, in loads
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     return _default_decoder.decode(s)
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/json/decoder.py", line 364, in decode
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:   File "/usr/lib64/python2.7/json/decoder.py", line 382, in raw_decode
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]:     raise ValueError("No JSON object could be decoded")
11月 10 12:00:18 ceph-gw-1 rbd-target-api[779]: ValueError: No JSON object could be decoded

And the log file: /var/log/rbd-target-api.log

[root@ceph-gw-1 log]# tail rbd-target-api.log
2017-11-10 12:00:18,133    DEBUG [lun.py:323:allocate()] - rados pool 'rbd' contains the following - [u'iscsi-test-8T']
2017-11-10 12:00:18,133    DEBUG [lun.py:328:allocate()] - Hostname Check - this host is ceph-gw-1, target host for allocations is ceph-gw-1
2017-11-10 12:00:18,594    DEBUG [common.py:256:add_item()] - (Config.add_item) config updated to {u'updated': u'2017/11/10 01:50:09', u'disks': {'rbd.iscsi-test-16T': {'created': '2017/11/10 04:00:18'}}, u'created': u'2017/11/08 07:36:52', u'clients': {}, u'epoch': 4, u'version': 3, u'gateways': {u'iqn': u'iqn.2017-11.com.ctcloud.iscsi-gw:ceph-igw', u'created': u'2017/11/09 08:56:41', u'ceph-gw-1': {u'gateway_ip_list': [u'192.168.100.248', u'192.168.100.246'], u'active_luns': 0, u'created': u'2017/11/10 00:30:31', u'updated': u'2017/11/10 01:20:25', u'iqn': u'iqn.2017-11.com.ctcloud.iscsi-gw:ceph-igw', u'inactive_portal_ips': [u'192.168.100.246'], u'portal_ip_address': u'192.168.100.248', u'tpgs': 2}, u'ip_list': [u'192.168.100.248', u'192.168.100.246'], u'ceph-gw-2': {u'gateway_ip_list': [u'192.168.100.248', u'192.168.100.246'], u'active_luns': 0, u'created': u'2017/11/10 01:50:09', u'updated': u'2017/11/10 01:50:09', u'iqn': u'iqn.2017-11.com.ctcloud.iscsi-gw:ceph-igw', u'inactive_portal_ips': [u'192.168.100.248'], u'portal_ip_address': u'192.168.100.246', u'tpgs': 2}}, u'groups': {}}
2017-11-10 12:00:18,594     INFO [lun.py:344:allocate()] - (LUN.allocate) created rbd/iscsi-test-16T successfully
2017-11-10 12:00:18,595    DEBUG [lun.py:384:allocate()] - Check the rbd image size matches the request
2017-11-10 12:00:18,595    DEBUG [lun.py:407:allocate()] - Begin processing LIO mapping
2017-11-10 12:00:18,595     INFO [lun.py:598:add_dev_to_lio()] - (LUN.add_dev_to_lio) Adding image 'rbd.iscsi-test-16T' to LIO
2017-11-10 12:00:18,633     INFO [_internal.py:87:_log()] - 127.0.0.1 - - [10/Nov/2017 12:00:18] "PUT /api/_disk/rbd.iscsi-test-16T HTTP/1.1" 500 -
2017-11-10 12:00:18,640    ERROR [rbd-target-api:1266:call_api()] - _disk change on 127.0.0.1 failed with 500
2017-11-10 12:00:18,651     INFO [_internal.py:87:_log()] - 127.0.0.1 - - [10/Nov/2017 12:00:18] "PUT /api/disk/rbd.iscsi-test-16T HTTP/1.1" 500 -

And I tried touch a new file in /sys/kernel/config/target/, but I failed.

What is it? How could I solve the problem? Thanks!

problem with qla2xxx wwn conversion to naa.*

Problem : In recent releases, the wwn format 21:00:00:XX:XX:XX:XX:XX has been dropped in favor of the NAA format : naa.210000XXXXXXXXXX (I don't know why ?). And there are some conversions missing in the code.

Version tested :

  • configshell-fb-1.1.fb7
  • rtslib-fb-2.1.fb33
  • targetcli-fb-2.1.fb24

downloaded from https://fedorahosted.org/released/targetcli-fb/.
kernel: kernel-3.8.11-200.fc18.x86_64

Symptoms :

PYTHONPATH=. targetcli-fb-2.1.fb24/scripts/targetcli
targetcli shell version 2.1.24
Copyright 2011 by RisingTide Systems LLC and others.
For help on commands, type 'help'.

/> saveconfig
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json
/> /qla2xxx
/qla2xxx> info
Fabric module name: qla2xxx
ConfigFS path: /sys/kernel/config/target/qla2xxx
Allowed WWN types: naa
Allowed WWNs list: naa.21000024ff369652, naa.21000024ff369653, naa.21000024ff369874, naa.21000024ff369875
Fabric module features: acls
Corresponding kernel module: tcm_qla2xxx
/qla2xxx> create naa.21000024ff369652
Created target naa.21000024ff369652.
/qla2xxx> /
/> saveconfig
WWN not valid as: naa
/> exit
Global pref auto_save_on_exit=true
Traceback (most recent call last):
File "targetcli-fb-2.1.fb24/scripts/targetcli", line 88, in
main()
File "targetcli-fb-2.1.fb24/scripts/targetcli", line 84, in main
root_node.ui_command_saveconfig()
File "/root/downloads/t/targetcli/ui_root.py", line 69, in ui_command_saveconfig
f.write(json.dumps(RTSRoot().dump(), sort_keys=True, indent=2))
File "/root/downloads/t/rtslib/root.py", line 132, in dump
d['targets'] = [t.dump() for t in self.targets]
File "/root/downloads/t/rtslib/root.py", line 76, in _list_targets
for target in fabric_module.targets:
File "/root/downloads/t/rtslib/fabric.py", line 161, in _list_targets
yield Target(self, self.from_fabric_wwn(wwn), 'lookup')
File "/root/downloads/t/rtslib/target.py", line 72, in init
self.wwn, self.wwn_type = fabric_module.to_normalized_wwn(wwn)
File "/root/downloads/t/rtslib/fabric.py", line 181, in to_normalized_wwn
return normalize_wwn(self.wwn_types, wwn, self.wwns)
File "/root/downloads/t/rtslib/utils.py", line 322, in normalize_wwn
raise RTSLibError("WWN not valid as: %s" % ", ".join(wwn_types))
rtslib.utils.RTSLibError: WWN not valid as: naa

The current code seems to be calling normalize_wwn with these parameters :
normalize_wwn(('naa',),'naa.:00:00:24:ff:36:96:52')

As you can see, the WWN is kinda broken (missing '21', replaced by 'naa.')

Add support for emulex ocs_fc_lio

Hi,

So far we used with standard "rtslib" by providing spec file in /var/target/fabric/ to configure our Emulex OCS LIO targets. Now we wanted to use ocs_fc_lio kernel module driver with "rtslib-fc" module. We added code to support Emulex ocs_fc_lio driver in "fabric.py" and verified the code changes. Could you please review the attached patch and let me know if any modifications are required?

I also wanted to know the code check-in

process, I'm not sure if i can do commit at this time or not

Thanks,
Ravindar
rtslib-fb.txt

convert to python 3

support Python 3. I did some test 2to3 runs and it seemed to get pretty much everything, but more examination of the results is needed before pulling the trigger.

MappedLUN constructor fails

I wanted to create a mapped lun. I got a LUN object (lun) and an NodeACL object (acl). First i tried this:

'MappedLUN(acl, lun.lun, lun)' and it fails with

Traceback (most recent call last):
File "", line 2, in
File "/usr/lib/python2.7/site-packages/rtslib/target.py", line 1028, in init
+ "a NodeACL object")
rtslib.utils.RTSLibError: The parent_nodeacl parameter must be a NodeACL object

with a 'type(acl)' i could verify that it is of type:
<class 'rtslib_fb.target.NodeACL'>

But do it the other way with:
acl.mapped_lun(lun.lun, lun) it worked.

YAML instead of JSON for config savefile

Should we use YAML instead of JSON for the config savefile? It's supposed to be a little more human-readable, but when I tried it the results were a little messy (using PyYAML). It's not clear to me the usage model yet for the savefile - if it will ever really be modified by users directly, or always via targetcli.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.