Targetd Plugin: Fix vpd83 of targetd volume

 * Target API only expose LVM UUID out. We have to convert it to VPD83 device
   id using Linux LIO kernel way:
    1. Prefix:
        6 001405
        - ------
        ^   ^
        |   |-- OpenFabric OUI   [1]
        |
        |-- NAA IEEE Registered Extended DESIGNATOR 6h in T10 SPC 4 [2]

    2. Extract all [a-f0-9A-F] from UUID out and convert to lower digits.
       Example:
            UUID: gQTwyb-PoV5-NxWw-gMn1-0u7X-2tGp-8iaV0A
                       ^    ^         ^ ^ ^  ^    ^ ^ ^^
            VPD 83 device ID(1h): 6001405b510728a0a000000000000000
                                         ^^^^^^^^^^
    3. File up to 32 digits with zero.

[1] https://standards.ieee.org/develop/regauth/oui/oui.txt
[2] http://www.t10.org/members/w_spc4.htm

Changes in V2(base on Andy Grover's suggest, many thanks to him):
    1. Remove _lio prefix from method name.
    2. Add detail explanation into code comments.
    3. Remove 'if' check as `'0' * -1` will get a empty string.

Signed-off-by: Gris Ge <fge@redhat.com>
Removal of unused constants

On IRC Gris provided the following list of unused plug-in constants
with a script he put together.

The constants are shared between python and C code, thus for a constant
to be un-used it cannot be referenced in the C or python code.  However,
just because a constant isn't used in a plug-in doesn't mean it not
needed in other parts of the library.

FAIL: ErrorNumber.UNSUPPORTED_SEARCH_KEY is un-used
Used in both, just not in the plug-ins

FAIL: ErrorNumber.TRANSPORT_SERIALIZATION is un-used
Used in C when converting types for JSON

FAIL: ErrorNumber.TRANSPORT_INVALID_ARG is un-used
Used in C when parsing expected parameters from JSON

FAIL: ErrorNumber.PLUGIN_SOCKET_PERMISSION is un-used
FAIL: ErrorNumber.PLUGIN_NOT_EXIST is un-used
FAIL: ErrorNumber.PLUGIN_IPC_FAIL is un-used
Used in both, just not in the plug-ins

FAIL: ErrorNumber.OK is un-used
Used in C code

FAIL: ErrorNumber.NO_SUPPORT_OFFLINE_CHANGE is un-used
Probably should keep both so that we have both available
(NO_SUPPORT_ONLINE_CHANGE, NO_SUPPORT_OFFLINE_CHANGE)

FAIL: ErrorNumber.NO_MEMORY is un-used
This error only pertains to C code and it is possible for a C plug-in to
return this error and thus we need the corresponding value in python as well.

FAIL: ErrorNumber.LIB_BUG is un-used
Used C code of the library and simc plug-in

FAIL: ErrorNumber.JOB_STARTED is un-used
Used in cmdline.py and in C code

FAIL: ErrorNumber.DAEMON_NOT_RUNNING is un-used
Used in _client.py

FAIL: Client.FLAG_RSVD is un-used
Used in C code, should be used in python code too

FAIL: Capabilities.SUPPORTED is un-used
Used in both C and Python

This patch does the following:

FAIL: TargetPort.TYPE_UNKNOWN is un-used
FAIL: TargetPort.TYPE_OTHER is un-used
Kept TYPE_OTHER, removed UNKNOWN.

FAIL: Pool.ELEMENT_TYPE_UNKNOWN is un-used
FAIL: Pool.STATUS_STARTING is un-used
FAIL: Pool.STATUS_DESTROYING is un-used
FAIL: Disk.TYPE_NOT_APPLICABLE is un-used
FAIL: JobStatus.STOPPED is un-used
FAIL: ErrorNumber.VOLUME_BUSY is un-used
FAIL: ErrorNumber.STORAGE_SDK_BUG is un-used
FAIL: ErrorNumber.SIZE_LIMIT_REACHED is un-used
Removed

FAIL: Capabilities.ACCESS_GROUP_INITIATOR_ADD_MIX is un-used
Removed, add later if needed

FAIL: Capabilities.VOLUME_THIN is un-used
Not used, however should this be retained as couldn't we be using this:

if DMTF.SCS_CAP_SUP_ST_VOLUME in element_types or \
        DMTF.SCS_CAP_SUP_THIN_ST_VOLUME in element_types:
    cap.set(Capabilities.VOLUMES)
    # Check to see if thin is supported and denote that too?
    if DMTF.SCS_CAP_SUP_THIN_ST_VOLUME in element_types:
        cap.set(Capabilities.VOLUME_THIN)

FAIL: Volume.PROVISION_FULL is un-used
This isn't referenced, however the other constants are so I think we should keep
for completeness.

Regards,
Tony

Signed-off-by: Tony Asleson <tasleson@redhat.com>
smis.py: Check for duplicate volume name

If we fail to create a volume, lets check to see if we have
a volume with that name already.  If we do we will assume that
we failed because of duplicate volume name.  This is an O(N)
operation in the error path.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
Rename UNSUPPORTED_VOLUME_EXPAND to UNSUPPORTED_VOLUME_GROW

 * With Pool.STATUS_GROWING, we should use GROW instead of EXPAND.

Signed-off-by: Gris Ge <fge@redhat.com>
lsmcli: add some key back to column display way

 * Simply the code workflow by:
    1. Rename XXX_MAN_HEADER to XXX_HEADER as we don't have any optional
       properties anymore.
    2. Replace XXX_COLUMN_KEYS with XXX_COLUMN_SKIP_KEYS for easier
       continence.

 * Add these keys back for column display way:
    1. 'system_id' for 'list --type volumes' and 'list --type fs'
    2. 'root' for 'list --type EXPORTS'

Signed-off-by: Gris Ge <fge@redhat.com>
lsmcli: Rename some lsmcli output cloumn key

 * Hide initiator type when listing access group as lsmcli user can easily
   identify a iSCSI IQN or WWPN access group base on their initiator.
 * Rename 'Status Info' to 'Info' to save column text width.
 * Rename '#blocks' to 'Block Count'.
 * Rename 'Element type' to 'Element Type'.
 * Rename element type from 'FILE_SYSTEM' to 'FS' to save column text width.

Signed-off-by: Gris Ge <fge@redhat.com>
Rename VOLUME_ONLINE to VOLUME_ENABLE and _OFFLINE to _DISABLE

 * Just be consistent with volume_enable() and volume_disable() methods.

Signed-off-by: Gris Ge <fge@redhat.com>
C and Python Library: Rename error ACCESS_GROUP_MASKED to LAST_INIT_IN_ACCESS_GROUP

 * Rename 'ACCESS_GROUP_MASKED' to 'LAST_INIT_IN_ACCESS_GROUP' for better
   definition:
        LSM refuse to delete the last initiator from an access group.

Signed-off-by: Gris Ge <fge@redhat.com>
SMI-S plugin: Handle LAST_INIT_IN_ACCESS_GROUP, NO_STATE_CHANGE error in access_group_initiator_delete()

 * As LSM require us to refuse deletion on last initiator of an access group,
   we remove the capacity checking codes for empty access group.
 * Raise NO_STATE_CHANGE when initiator does not exist in defined access group
   for access_group_initiator_delete().
 * Fix capabilities() call as we don't require empty access group support.
 * Fix a incorrect error in access_group_delete():
   Should raise IS_MASKED if access group has volume masked.

Signed-off-by: Gris Ge <fge@redhat.com>
ONTAP plugin: Improve volume_mask() and access_group_initiator_delete()

 * Handle these errors in volume_mask():
    NOT_FOUND_ACCESS_GROUP
    EMPTY_ACCESS_GROUP
    NO_STATE_CHANGE     # already masked.
 * Handle these errors in access_group_initiator_delete():
    NOT_FOUND_ACCESS_GROUP
    NO_STATE_CHANGE     # initiator not exist in defined access group
    LAST_INIT_IN_ACCESS_GROUP   # Refuse to delete the last initiator

Signed-off-by: Gris Ge <fge@redhat.com>
Remove SIZE_TOO_SMALL error and add POOL_NOT_READY error

 * Remove SIZE_TOO_SMALL as volume_create() and volume_resize() should
   return larger or equal size volume than requested.
 * Add POOL_NOT_READY and LSM_ERR_POOL_NOT_READY error:
   Pool is not ready for volume/fs/etc create/resize/delete/etc
 * SIZE_TOO_SMALL support status by plugin:
    * SMI-S plugin:
        Never handle SIZE_TOO_SMALL, so no harm for this.
        EMC VMAX and VNX support this without code changes.
    * ONTAP plugin:
        Use lun_min_size() method to get minimum size and create/resize using
        that size.
 * Extra changes for ONTAP plugin:
    1. Handle disabled NetApp volume(LSM Pool) status.
    2. Handle POOL_NOT_READY in volume_create().
    3. Handle NO_STATE_CHANGE in volume_resize().

Changes in V2:
 * Remove POOL_NOT_READY error handling in volume_resize().
   Once NetApp Volume is disable, all its LUNs(LSM Volumes) gone.
   User will always get NOT_FOUND_VOLUME error in that case.

Signed-off-by: Gris Ge <fge@redhat.com>
Targetd plugin: Fix TargetdError handling and remove Volume.STATUS_OK

 1. Fix python syntax error when handling TargetdError:
        % te.errno, te.reason)
        % (te.errno, te.reason))
          ^                   ^
 2. Fix the error got when creating volume as missing Volume.STATUS_OK.
    Volume.STATUS_OK is removed from library in previous patch
    and its functionality was replaced by ADMIN_STATE_ENABLED.
    In targetd, we always mark volume as Volume.ADMIN_STATE_ENABLED.

Signed-off-by: Gris Ge <fge@redhat.com>
Target plugin: Fix vpd83 of volume_create() returned Volume

 * Use exist method TargetdStorage._uuid_to_vpd83() to convert uuid to VPD83.

Signed-off-by: Gris Ge <fge@redhat.com>
nstor.py: Replace Volume.STATUS_OK to ADMIN_STATE_ENABLED

Signed-off-by: Tony Asleson <tasleson@redhat.com>