Hi,
On 02/27/2014 03:14 PM, Sergej Roytman wrote:
I have been finding the scripting mode that is shown here‹
http://linux-iscsi.org/wiki/ISCSI#Scripting_with_RTSlib
very useful. More convenient, for some things, than having to do a little
configuration dance inside targetcli. Do the changes you describe extend
that, or are they something different?
This is not a "scripting mode". This is just python code using the the
python rtslib API.
This does not change and is still available.
Both targetcli and the lio CLI are applications built on top of it, as
is the new config API.
Using that new config API from python, instead of:
from rtslib import *
backstore = IBlockBackstore(3, mode='create')
so = IBlockStorageObject(backstore, "sdb", "/dev/sdb", gen_wwn=True)
fabric = FabricModule('iscsi')
target = Target(fabric,
"iqn.2003-01.org.linux-iscsi.x.x8664:sn.d3d8b0500fde")
tpg = TPG(target, 1)
portal = NetworkPortal(tpg, "192.168.1.128", "5060")
lun0 = tpg.lun(0, so, "my_lun")
node_acl =
tpg.node_acl("iqn.2003-01.org.linux-iscsi.y.x8664:sn.abcdefghijkl")
mapped_lun = node_acl.mapped_lun(0, 0, False)
You could write:
from rtslib.config import Config
conf = Config()
conf.set("storage iblock disk sdb path /dev/sdb")
tpg = "fabric iscsi target
iqn.2003-01.org.linux-iscsi.x.x8664:sn.d3d8b0500fde tpgt 1"
conf.set(tpg + "portal 192.168.1.128:5060")
conf.set(tpg + "lun 0 backend iblock:sdb")
conf.set(tpg + "acl
iqn.2003-01.org.linux-iscsi.y.x8664:sn.abcdefghijkl mapped_lun 0
target_lun 0")
But that would be overkill, as you could just create a "snippet.lio"
config file like this:
storage iblock disk sdb path /dev/sdb
fabric iscsi target
iqn.2003-01.org.linux-iscsi.x.x8664:sn.d3d8b0500fde tpgt 1 {
portal 192.168.1.128:5060
lun 0 backend iblock:sdb
acl iqn.2003-01.org.linux-iscsi.y.x8664:sn.abcdefghijkl mapped_lun
0 target_lun 0
}
And simply load it from the lio cli using "load snippet.lio" in config
mode, or "merge snippet.lio" if you want to merge that to the current
configuration. Then you just need to issue 'commit' when your
configuration is ready to be applied on the system and saved as the next
startup config.
But the lio cli is more practical for that kind of small snippets: you
enter the same amount of text, exactly the same statements, but get
autocompletion to help you type it :-) Also it will check the values
type as soon as you enter them, provide you with unlimited undo levels,
rollback to the last commited configuration, etc.
Best,
--
Jerome
--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html