open-iscsi / rtslib-fb

Python library for configuring the Linux kernel-based multiprotocol SCSI target (LIO)
Apache License 2.0
73 stars 90 forks source link

Expose session info #10

Closed agrover closed 12 years ago

agrover commented 12 years ago

See https://github.com/agrover/targetcli-fb/pull/9

Expose session info via rtslib API.

JonnyJD commented 12 years ago

I opted to implement the Session and Connection classes as Snapshots. So the information is parsed on creation and never parsed again for this object. This seemed like the natural way, since session information is volatile. Additionally, it wouldn't make sense to only to update certain attributes of the session, since you have to parse info whole anyways.

The session property of NodeACL is recreated on every access.

Also note, that Session and Connection don't inherite from CFSNode, because they are no cfs nodes.

JonnyJD commented 12 years ago

For reference:

info with no open session:

No active iSCSI Session for Initiator Endpoint: iqn.2005-03.org.open-iscsi:xxx

With an open session (1 local connection):

InitiatorName: iqn.2005-03.org.open-iscsi:xxx
InitiatorAlias: test-host
LIO Session ID: 2   ISID: 0x00 02 3d 11 00 00  TSIH: 2  SessionType: Normal
Session State: TARG_SESS_STATE_LOGGED_IN
---------------------[iSCSI Session Values]-----------------------
  CmdSN/WR  :  CmdSN/WC  :  ExpCmdSN  :  MaxCmdSN  :     ITT    :     TTT
 0x00000010   0x00000010   0x000000d6   0x000000e5   0x2e000000   0x00001e8d
----------------------[iSCSI Connections]-------------------------
CID: 0  Connection State: TARG_CONN_STATE_LOGGED_IN
   Address 127.0.0.1 TCP  StatSN: 0xee10583f
JonnyJD commented 12 years ago

Okay, that should do it. Please review. If you don't see any problems with this solution, I will merge (--no-ff) it to master.

We could possibly implement FabricModule/Target/TPG to having a list (or generator with yield) of open sessions each. That is basically the same as with has_session, but doesn't stop when just one is found and throws no information away. This highly depends on how we would display status information. If we don't need it, it might also be "clutter" in the API.

Technically also has_sessions is not a must-have and can be implemented in targetcli. After all you could list all kinds of things on all kinds of levels and also check for these on different levels. We have to implement this in targetlci then.

So if you say has_sessions doesn't belong in rtslib, I can also just merge 5e88ec215548a1f990df3eb4d70bb9a2fbafc686 (classes and .session in NodeACL) for now.

JonnyJD commented 12 years ago

I updated my targetstatus prototype as a usage example of the new rtslib session API.

JonnyJD commented 12 years ago

See #12 for the corresponding pull request.