C: Remove ambiguity in class checking

The function value_to_* make sure that the value we are converting
too matches the class in question.  If for some reason the json
does not match expected we return a NULL, which is the same as if
we had a failure to allocate memory.  Added checks before to
ensure that we have the correct json representation of the class
before we convert from Value type to C struct type.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
Clean up system status constants

 * Removed these system status as no plugin support it:
    stress
    starting
    stopping
    stopped
 * Updated SMI-S plugin to fit this change:
    1. Split DMTF class to dmtf.py(Makefile and RPM SPEC file updated).
    2. If facing other status, will mark as STATUS_OTHER and store the
       name into system_info.
       I tried on many SMI-S providers, I only got degraded.

Signed-off-by: Gris Ge <fge@redhat.com>
Library: Remove unused pool status

Remove these status:
    LSM_POOL_STATUS_STRESSED/Pool.STATUS_STRESSED
    LSM_POOL_STATUS_READ_ONLY/Pool.STATUS_READ_ONLY
    LSM_POOL_STATUS_DORMAT/Pool.STATUS_DORMAT
    LSM_POOL_STATUS_SHRINKING/Pool.STATUS_SHRINKING

Signed-off-by: Gris Ge <fge@redhat.com>
ONTAP plugin: Improve pool query method

 * Use 'raid-status' and 'status' to detect pool status.
 * NetApp volume pool status is copy from its aggregate pool status.
 * Tested in ONTAP simulator for these status:
    STATUS_DEGRADED
    STATUS_STOPPED
    STATUS_RECONSTRUCTING
    STATUS_GROWING
 * Change pool.id as the path of NetApp volume.
   # This introduced some bug for lsm.Volume.
   # It has been fixed by other patches in this patch set.

Signed-off-by: Gris Ge <fge@redhat.com>
SMIS plugin: Clean up pool status query

 * Just use the same status converting way of system.
   # Sorry, actual changes in dmtf.py is included by previous patches of
   # this same patch set.

Signed-off-by: Gris Ge <fge@redhat.com>
Python Library: Remove Volume.state, add Volume.admin_state

 * Remove Volume.state
   Currently, volume status is fully inherited from pool. There is no need
   to maintain two status.
   For volume individual thin provisioning status, we can discuss that
   when plugin need it.
 * Add Volume.admin_state
   Indicate whether this volume is disabled by administrator or not.
   Just two integer:
     ADMIN_STATE_DISABLED = 0
     ADMIN_STATE_ENABLED = 1

Signed-off-by: Gris Ge <fge@redhat.com>
Python Library: Rename volume_online to volume_enable()

 * Rename volume_online() to volume_enable() and _offline() to _disable().
   The word 'online' might mis-leading user to health.
   But we actually indicate this method is for volume admin state.

Signed-off-by: Gris Ge <fge@redhat.com>
lsmcli: Remove Volume.state, add Volume.admin_state

 * Remove Volume.state. Add Volume.admin_state.
   The Volume.admin_state will be shown as 'Dsiabled: Yes' or 'Disabled: No'
   Example:
        lsmcli lv -s
        ------------------------------------------------
        ID            | VOL_ID_00000001
        Name          | Volume 000
        SCSI VPD 0x83 | 29D2EBE29486EDA9055AF9234263A664
        Block Size    | 512
        #blocks       | 419430400
        Size          | 214748364800
        Disabled      | No
        Pool ID       | POO1
        System ID     | sim-01
        ------------------------------------------------
        ID            | VOL_ID_00000002
        Name          | Volume 001
        SCSI VPD 0x83 | AD1E85E3FA30F423498C5751EC56AB82
        Block Size    | 512
        #blocks       | 419430400
        Size          | 214748364800
        Disabled      | No
        Pool ID       | POO1
        System ID     | sim-01
        ------------------------------------------------

Signed-off-by: Gris Ge <fge@redhat.com>
lsmcli: Add volume-enable and volume-disable commands

 * Add volume_enable() and volume_disable() support.
 * Add aliases:
    ve == volume-enable
    vi == volume-disable

Signed-off-by: Gris Ge <fge@redhat.com>
nstor: Remove Volume.state, add Volume.admin_state

 * Remove Volume.state, add Volume.admin_state

Signed-off-by: Gris Ge <fge@redhat.com>
smis: Remove Volume.state, add Volume.admin_state

 * Remove Volume.state, add Volume.admin_state
 * Remove volume_online() and volume_offline(). We should let iplugin.py
   raise NO_SUPPORT instead of silently return pass.

Signed-off-by: Gris Ge <fge@redhat.com>
targetd: Remove Volume.state, add Volume.admin_state

 * Remove Volume.state, add Volume.admin_state
 * Convert num_of_blocks to long.

Signed-off-by: Gris Ge <fge@redhat.com>
sim: volume admin status related changes

 * Data version bump to 2.8.
 * Add sim_vol['admin_state'] storing Volume.admin_state.
 * Add support of volume_enable() and volume_disable()

Signed-off-by: Gris Ge <fge@redhat.com>
ontap: volume admin status related changes

 * Fix bug introduced by changing NetApp volume pool id to path.
 * Remove Volume.status and add Volume.admin_status
 * Add error handling to volume_disable() and volume_enable().

Signed-off-by: Gris Ge <fge@redhat.com>
simarray.py: Fix missing admin_state for volume_replicate

Signed-off-by: Tony Asleson <tasleson@redhat.com>
C API: Rename volume online|offline to enable|disable

C bits for Gris's python patch set

Signed-off-by: Tony Asleson <tasleson@redhat.com>
C API: Change volume status to admin_state

Volume status or health doesn't have much value as it's really just one
of many items that can be created from a pool which does have a health
status.

There are the C bits to follow on to Gris's python patch set.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
Get both simc and sim to work with plugin_test.py

Ensure that the simulated plug-ins work with the plug-in test.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
plugin_test.py: Correct random iqn generation

Was creating invalid IQNs.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
plugin_test.py: Add test for IS_MASKED

Ensure we get an IS_MASKED error if we try to delete an access group
that has a masked volume.

Tested against sim & simc

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