.. _dmtf_profiles:

DMTF profiles
=============
OpenLMI Software providers implement two *DMTF* profiles:

    * `Software Inventory Profile`_
    * `Software Update Profile`_

.. _software_inventory_profile:

Software Inventory Profile
--------------------------
Implemented *DMTF* version: ``1.0.1``

Described by `DSP1023`_

The Software Inventory Profile describes the CIM schema elements required to
provide an inventory of installed BIOS, firmware, drivers, and related
software in a managed system. This profile also describes the CIM schema
elements required to represent the software that can be installed on a
managed system.


Not implemented optional features
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This implementation does not support:

    Representing a Software Bundle
        Software bundle is represented by LMI_SoftwareIndentity instance
        having ``"Software Bundle"`` value present in its ``Classifications``
        property. It shall prepresent software groups. It extends the profile
        for subclasses of ``CIM_OrderedComponent``.

    Representing Installation Dependencies
        Dependencies between software packages are also unimplemented. This
        also extends the profile for subclasses of ``CIM_OrderedDependency``
        referencing :ref:`CIM-SoftwareIdentity` instances.

Deviations
~~~~~~~~~~
Version Comparison
^^^^^^^^^^^^^^^^^^
Version comparison is based on different approach than in *Software Inventory
Profile* where the following properties are present to uniquely specify
package version:

    * ``uint16`` :ref:`MajorVersion<CIM-SoftwareIdentity-MajorVersion>`
    * ``uint16`` :ref:`MinorVersion<CIM-SoftwareIdentity-MinorVersion>`
    * ``uint16`` :ref:`RevisionNumber<CIM-SoftwareIdentity-RevisionNumber>`
    * ``uint16`` :ref:`BuildNumber<CIM-SoftwareIdentity-BuildNumber>`

And also a :ref:`VersionString<LMI-SoftwareIdentity-VersionString>` property
which is a composition of previous ones separed with dots.

Unfortunately versioning of RPM packages is incompatible with this scheme.
Version of RPM package is composed of following properties:

.. _version_properties:

    * ``uint32`` :ref:`Epoch<LMI-SoftwareIdentity-Epoch>`
    * ``string`` :ref:`Version<LMI-SoftwareIdentity-Version>`
    * ``string`` :ref:`Release<LMI-SoftwareIdentity-Release>`

Where ``Version`` and ``Release`` can contain arbitrary set of characters [1]_.
These attributes were added to ``LMI_SoftwareIdentity`` class and will be
filled for every RPM package. On the other hand ``MajorVersion``,
``MinorVersion``, ``RevisionNumber`` and ``BuildNumber`` will not be filled.

This implementetion composes ``VersionString`` in following way: ::

    <Epoch>:<Version>-<Release>.<Architecture>

The algorithm for comparing two RPM packages version is following:

    1. Compare the ``Epoch`` (which is a number) of both packages. The one
       with higher epoch is newer. If they match, continue to point 2.
    2. Compare their ``Version`` attributes with `rpmvercmp`_ algorithm.
       Package with larger ``Version`` (according to `rpmvercmp`_) is newer.
       If they match, continue to point 3.
    3. Compare their ``Release`` attributes with `rpmvercmp`_ algorithm.
       Package with larger ``Release`` string is newer. Otherwise packages
       have the same version.

Relationships between *Software Identity* and *Managed Element*
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
are not modeled. RPM package database does not provide such informations
that would allow to associate particular package with a piece of hardware
it relates to.

Querying for packages
^^^^^^^^^^^^^^^^^^^^^
Since enumeration of *Software Identities* is disabled due to a huge
amount of data generated by large package database, the query
execution on them is also disallowed [2]_. The only way how to search
for packages is using the method
:ref:`LMI_SoftwareInstallationService.FindIdentity<LMI-SoftwareInstallationService-FindIdentity>`.

.. _identifying_software_identity:

Identifying software identity
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:ref:`InstanceID<LMI-SoftwareIdentity-InstanceID>` key property is the one
and only identification string of :ref:`LMI-SoftwareIdentity` instances
representing RPM packages. It's composed of following strings: ::

    LMI:LMI_SoftwareIdentity:<Name>-<Epoch>:<Version>-<Release>.<Architecture>

Where the prefix ``"LMI:LMI_SoftwareIdentity:"`` is compared
case-insensitively. The rest is also known as a *NEVRA*. When calling
``GetInstance()`` on this class, the ``"<Epoch>:"`` part can be omitted in the
``InstanceID`` key property of passed ``InstanceName`` in case the epoch is
zero.

Example
^^^^^^^
Take for example package ``vim-enhanced`` installed on Fedora 18: ::

    $ yum info vim-enhanced
    Installed Packages
    Name        : vim-enhanced
    Arch        : x86_64
    Epoch       : 2
    Version     : 7.4.027
    Release     : 2.fc18
    Size        : 2.1 M
    Repo        : installed
    From repo   : updates-testing

The output has been shortened. This package is represented by
an instance of ``LMI_SoftwareIdentity`` with ``InstanceID`` equal to: ::

    LMI:LMI_SoftwareIdentity:vim-enhanced-2:7.4.027-2.fc18.x86_64

Profile extensions
~~~~~~~~~~~~~~~~~~
List of additional attributes of ``LMI_SoftwareIdentity``:

    * version properties mentioned above (`version_properties`_)
    * ``string Architecture`` - Target machine architecture. Packages
      with architecture independent content will have ``"noarch"`` value
      set.

List of additional attributes of ``LMI_SoftwareIdentityResource``:

    ``Cost`` : sint32
        Relative cost of accessing this repository.
    ``GPGCheck`` : boolean
        Whether the GPG signature check should be performed.
    ``TimeOfLastUpdate`` : datetime
        Time of repository's last update on server.

Class overview
~~~~~~~~~~~~~~

    +-------------------------------------------------------------------------------+---------------------------------------------------------------------+------------------+
    | Class-name                                                                    | Parent_class                                                        | Type             |
    +===============================================================================+=====================================================================+==================+
    | :ref:`LMI_SoftwareIdentity<LMI-SoftwareIdentity>`                             | :ref:`CIM_SoftwareIdentity<CIM-SoftwareIdentity>`                   | Plain            |
    +-------------------------------------------------------------------------------+---------------------------------------------------------------------+------------------+
    | :ref:`LMI_SystemSoftwareCollection<LMI-SystemSoftwareCollection>`             | :ref:`CIM_SystemSpecificCollection<CIM-SystemSpecificCollection>`   | Plain            |
    +-------------------------------------------------------------------------------+---------------------------------------------------------------------+------------------+
    | :ref:`LMI_SoftwareIdentityResource<LMI-SoftwareIdentityResource>`             | :ref:`CIM_SoftwareIdentityResource<CIM-SoftwareIdentityResource>`   | Plain            |
    +-------------------------------------------------------------------------------+---------------------------------------------------------------------+------------------+
    | :ref:`LMI_HostedSoftwareCollection<LMI-HostedSoftwareCollection>`             | :ref:`CIM_HostedCollection<CIM-HostedCollection>`                   | Association      |
    +-------------------------------------------------------------------------------+---------------------------------------------------------------------+------------------+
    | :ref:`LMI_InstalledSoftwareIdentity<LMI-InstalledSoftwareIdentity>`           | :ref:`CIM_InstalledSoftwareIdentity<CIM-InstalledSoftwareIdentity>` | Association      |
    +-------------------------------------------------------------------------------+---------------------------------------------------------------------+------------------+
    | :ref:`LMI_HostedSoftwareIdentityResource<LMI-HostedSoftwareIdentityResource>` | :ref:`CIM_HostedAccessPoint<CIM-HostedAccessPoint>`                 | Association      |
    +-------------------------------------------------------------------------------+---------------------------------------------------------------------+------------------+
    | :ref:`LMI_ResourceForSoftwareIdentity<LMI-ResourceForSoftwareIdentity>`       | :ref:`CIM_SAPAvailableForElement<CIM-SAPAvailableForElement>`       | Association      |
    +-------------------------------------------------------------------------------+---------------------------------------------------------------------+------------------+
    | :ref:`LMI_MemberOfSoftwareCollection<LMI-MemberOfSoftwareCollection>`         | :ref:`CIM_MemberOfCollection<CIM-MemberOfCollection>`               | Aggregation      |
    +-------------------------------------------------------------------------------+---------------------------------------------------------------------+------------------+

    .. seealso::
        Class model in :ref:`introduction` where above classes are coloured blue.

.. _software_update_profile:

Software Update Profile
-----------------------
Implemented *DMTF* version: ``1.0.0``

Described by `DSP1025`_.

The Software Update Profile describes the classes, associations, properties,
and methods used to support the installation and update of BIOS, firmware,
drivers and related software on a managed element within a managed system.


Implemented optional features
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This implementation supports:

    Advertising the Location Information of a Software Identity
        This optional feature provides association of *Software Identity* to
        its resource. In other words each available package is associated to
        a corresponding repository defined in configuration files of *YUM*.
        Repositories are represented with
        :ref:`LMI_SoftwareIdentityResource<LMI-SoftwareIdentityResource>` and
        are associated to :ref:`LMI_SoftwareIdentity<LMI-SoftwareIdentity>`
        via
        :ref:`LMI_ResourceForSoftwareIdentity<LMI-ResourceForSoftwareIdentity>`.

Not implemented features
~~~~~~~~~~~~~~~~~~~~~~~~
Following methods are not implemented:

    * :ref:`CIM_SoftwareInstallationService.InstallFromByteStream<CIM-SoftwareInstallationService-InstallFromByteStream>`
    * :ref:`LMI_SoftwareInstallationService.CheckSoftwareIdentity<LMI-SoftwareInstallationService-CheckSoftwareIdentity>`

Profile extensions
~~~~~~~~~~~~~~~~~~

RPM package verification
^^^^^^^^^^^^^^^^^^^^^^^^
*Software Inventory* and *Softare Update* profiles don't allow for software
verification. That is quite useful and desired operation done on RPM packages.
Following additions has been added to provide such a functionality.

Following classes have been added:

    :ref:`LMI_SoftwareIdentityFileCheck<LMI-SoftwareIdentityFileCheck>`
        Represents single file contained and installed by *RPM* package.
        It contains properties allowing for comparison of installed file
        attributes with those stored in a package database. In case those
        attributes do not match, file fails the verification test.

    :ref:`LMI_SoftwareIdentityChecks<LMI-SoftwareIdentityChecks>`
        Associates *Software Identity File Check* to corresponding
        *Software Identity*.

Following methods have been added:

    :ref:`LMI_SoftwareInstallationService.VerifyInstalledIdentity<LMI-SoftwareInstallationService-VerifyInstalledIdentity>`
        This allows to run verification test on particular *Software Identity*
        and returns a list of files that failed.

.. _package_searching:

Package searching
^^^^^^^^^^^^^^^^^
On modern Linux distributions we have thousands of software packages
available for installation making it nearly impossible for *CIMOM* to
enumerate them all because it consumes a lot of resources. That's why
the ``EnumerateInstances()`` and ``EnumerateInstanceNames()`` calls have been
disabled *Software Identities*. As a consequence the ``ExecQuery()`` call is prohibited also.

But the ability to search for packages is so important that a fallback
solution has been provided. Method
:ref:`FindIdentity()<LMI-SoftwareInstallationService-FindIdentity>` has been
added to
:ref:`LMI_SoftwareInstallationService<LMI-SoftwareInstallationService>`
allowing to create complex queries on package database.

Class overview
~~~~~~~~~~~~~~

    +-----------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------+--------------------+
    | Class-name                                                                                          | Parent_class                                                            | Type               |
    +=====================================================================================================+=========================================================================+====================+
    | :ref:`LMI_SoftwareInstallationService<LMI-SoftwareInstallationService>`                             | :ref:`CIM_SoftwareInstallationService<CIM-SoftwareInstallationService>` | Plain              |
    +-----------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------+--------------------+
    | :ref:`LMI_SoftwareJob<LMI-SoftwareJob>`                                                             | :ref:`LMI_ConcreteJob<LMI-ConcreteJob>`                                 | Plain              |
    +-----------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------+--------------------+
    | :ref:`LMI_SoftwareInstallationJob<LMI-SoftwareInstallationJob>`                                     | :ref:`LMI_SoftwareJob<LMI-SoftwareJob>`                                 | Plain              |
    +-----------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------+--------------------+
    | :ref:`LMI_SoftwareVerificationJob<LMI-SoftwareVerificationJob>`                                     | :ref:`LMI_SoftwareJob<LMI-SoftwareJob>`                                 | Association        |
    +-----------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------+--------------------+
    | :ref:`LMI_SoftwareMethodResult<LMI-SoftwareMethodResult>`                                           | :ref:`LMI_MethodResult<LMI-MethodResult>`                               | Association        |
    +-----------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------+--------------------+
    | :ref:`LMI_SoftwareIdentityFileCheck<LMI-SoftwareIdentityFileCheck>`                                 | :ref:`CIM_FileSpecification<CIM-FileSpecification>`                     | Association        |
    +-----------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------+--------------------+
    | :ref:`LMI_SoftwareInstallationServiceAffectsElement<LMI-SoftwareInstallationServiceAffectsElement>` | :ref:`CIM_ServiceAffectsElement<CIM-ServiceAffectsElement>`             | Association        |
    +-----------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------+--------------------+
    | :ref:`LMI_SoftwareIdentityChecks<LMI-SoftwareIdentityChecks>`                                       |                                                                         | Aggregation        |
    +-----------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------+--------------------+
    | :ref:`LMI_HostedSoftwareInstallationService<LMI-HostedSoftwareInstallationService>`                 | :ref:`CIM_HostedService<CIM-HostedService>`                             | Plain              |
    +-----------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------+--------------------+
    | :ref:`LMI_AffectedSoftwareJobElement<LMI-AffectedSoftwareJobElement>`                               | :ref:`CIM_AffectedJobElement<CIM-AffectedJobElement>`                   | Plain              |
    +-----------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------+--------------------+
    | :ref:`LMI_OwningSoftwareJobElement<LMI-OwningSoftwareJobElement>`                                   | :ref:`LMI_OwningJobElement<LMI-OwningJobElement>`                       | Plain              |
    +-----------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------+--------------------+
    | :ref:`LMI_AssociatedSoftwareJobMethodResult<LMI-AssociatedSoftwareJobMethodResult>`                 | :ref:`LMI_AssociatedJobMethodResult<LMI-AssociatedJobMethodResult>`     | Plain              |
    +-----------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------+--------------------+

    .. seealso::
        Class model in :ref:`introduction` where above classes are coloured blue.

..
    ***************************************************************************
.. _DSP1023: http://www.dmtf.org/sites/default/files/standards/documents/DSP1023_1.0.1.pdf
.. _DSP1025: http://www.dmtf.org/sites/default/files/standards/documents/DSP1025_1.0.0.pdf
.. _rpmvercmp: http://fedoraproject.org/wiki/Tools/RPM/VersionComparison

------------------------------------------------------------------------------

.. [1] Precisely ``Release`` must match following regular expression ``r"[\\w.+{}]+"``.
       ``Version`` allows also tilde character: ``r"[~\\w.+{}]+"``.
.. [2] Because internally the query is executed upon the list obtained by
       enumeration of instances.
