Fix srpt wwn function

We want to remove all ':'s from the WWN notation. strip() doesn't do
this, translate() does.

Signed-off-by: Andy Grover <agrover@redhat.com>
Make fread() call strip()

If we are stripping whitespace from all freads, let's just do in *in*
fread().

Signed-off-by: Andy Grover <agrover@redhat.com>
Fix CnP error

Fix improper indentation leading to wrong output

Don't strip last character, should no longer be needed.

Fix docstring

Signed-off-by: Andy Grover <agrover@redhat.com>
Cleanup module docstring

Remove references to spec files.

Signed-off-by: Andy Grover <agrover@redhat.com>
Do not throw exception if disabling a disabled TPG

Also, just call enable = False in TPG.delete().

Signed-off-by: Andy Grover <agrover@redhat.com>
Add a cache for backstore lookups

For each new SO we need to verify there isn't an existing one with the
same (type, name). Unfortunately these are nested in directories, so
adding each new SO requires more directory searches. AFAIK there's no
way around this without changing configfs layout.

This change adds a backstore cache. We still resort to glob() for new
SOs (it's still O(n^2)) but avoiding this for SOs we've seen before really
seems to help a lot.

Signed-off-by: Andy Grover <agrover@redhat.com>
Use alias path to create a tpg_lun's so directly

Add a so_from_path factory classmethod to StorageObject to allow us to
get the SO associated with a LUN without walking through all SOs to match.

Change SO.all() classmethod to use the new so_from_path as well

Remove SO._hbas(), no longer needed.

Move imports needed for _gen_attached_luns to that function. This allows
target.py to import tcm.py, which seems more correct than the reverse.

Signed-off-by: Andy Grover <agrover@redhat.com>
Compile the regex in _Backstore._hbas

We're getting a little pokey, this should help a little.

Signed-off-by: Andy Grover <agrover@redhat.com>
Remove obsolete spec_dir variable

No more spec dir.

Signed-off-by: Andy Grover <agrover@redhat.com>
Allow 256 LUNs per tpg

Off-by-1 limited to 255.

Fix logic - lun variable was masked.

Improve error message.

Signed-off-by: Andy Grover <agrover@redhat.com>