summaryrefslogtreecommitdiffstats
path: root/src/software/lmi/software/core/InstallationServiceAffectsElement.py
blob: c305468e06cf4bb734fc49a7e59c83f2b8872a82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# -*- encoding: utf-8 -*-
# Software Management Providers
#
# Copyright (C) 2012-2013 Red Hat, Inc.  All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""
Just a common functionality related to class
LMI_SoftwareInstallationServiceAffectsElement.
"""

import pywbem

from lmi.common import cmpi_logging
from lmi.software.core import ComputerSystem
from lmi.software.core import Identity

class Values(object):
    class ElementEffects(object):
        Unknown = pywbem.Uint16(0)
        Other = pywbem.Uint16(1)
        Exclusive_Use = pywbem.Uint16(2)
        Performance_Impact = pywbem.Uint16(3)
        Element_Integrity = pywbem.Uint16(4)
        Manages = pywbem.Uint16(5)
        Consumes = pywbem.Uint16(6)
        Enhances_Integrity = pywbem.Uint16(7)
        Degrades_Integrity = pywbem.Uint16(8)
        Enhances_Performance = pywbem.Uint16(9)
        Degrades_Performance = pywbem.Uint16(10)
        # DMTF_Reserved = ..
        # Vendor_Reserved = 0x8000..0xFFFF
        _reverse_map = {
                0  : 'Unknown',
                1  : 'Other',
                2  : 'Exclusive Use',
                3  : 'Performance Impact',
                4  : 'Element Integrity',
                5  : 'Manages',
                6  : 'Consumes',
                7  : 'Enhances Integrity',
                8  : 'Degrades Integrity',
                9  : 'Enhances Performance',
                10 : 'Degrades Performance'
        }

@cmpi_logging.trace_function
def fill_model_computer_system(model, keys_only=True):
    """
    Fills model's AffectedElement and all non-key properties.
    """
    model["AffectedElement"] = ComputerSystem.get_path()
    if not keys_only:
        model["ElementEffects"] = [
                Values.ElementEffects.Enhances_Integrity,
                Values.ElementEffects.Degrades_Integrity,
                Values.ElementEffects.Other,
                Values.ElementEffects.Other]
        model["OtherElementEffectsDescriptions"] = [
                "Enhances Integrity",
                "Degrades Integrity",
                "Enhances Functionality",
                "Degrades Functionality"]
    return model

@cmpi_logging.trace_function
def fill_model_identity(model, pkg, keys_only=True, identity_model=None):
    """
    Fills model's AffectedElement and all non-key properties.
    """
    model["AffectedElement"] = Identity.pkg2model(pkg, model=identity_model)
    if not keys_only:
        model["ElementEffects"] = [Values.ElementEffects.Other]
        model["OtherElementEffectsDescriptions"] = ["Allows to install"]
    return model