summaryrefslogtreecommitdiffstats
path: root/src/software/openlmi/software/cimom_entry.py
blob: ad944c85ce274203a3130a823fc666b7f279c9f5 (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# -*- encoding: utf-8 -*-
# Software Management Providers
#
# Copyright (C) 2012-2013 Red Hat, Inc.  All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
#
# Authors: Michal Minar <miminar@redhat.com>
#

"""
Entry module for OpenLMI Software providers.
"""

from multiprocessing import Queue
from openlmi.common import cmpi_logging
from openlmi.common.IndicationManager import IndicationManager
from openlmi.software.core import InstallationJob
from openlmi.software.LMI_SoftwareIdentity import LMI_SoftwareIdentity
from openlmi.software.LMI_SystemSoftwareCollection import \
        LMI_SystemSoftwareCollection
from openlmi.software.LMI_HostedSoftwareCollection import \
        LMI_HostedSoftwareCollection
from openlmi.software.LMI_MemberOfSoftwareCollection import \
        LMI_MemberOfSoftwareCollection
from openlmi.software.LMI_InstalledSoftwareIdentity import \
        LMI_InstalledSoftwareIdentity
from openlmi.software.LMI_SoftwareIdentityResource import \
        LMI_SoftwareIdentityResource
from openlmi.software.LMI_ResourceForSoftwareIdentity import \
        LMI_ResourceForSoftwareIdentity
from openlmi.software.LMI_HostedSoftwareIdentityResource import \
        LMI_HostedSoftwareIdentityResource
from openlmi.software.LMI_SoftwareInstallationService import \
        LMI_SoftwareInstallationService
from openlmi.software.LMI_SoftwareInstallationServiceCapabilities import \
        LMI_SoftwareInstallationServiceCapabilities
from openlmi.software. \
        LMI_AssociatedSoftwareInstallationServiceCapabilities import \
        LMI_AssociatedSoftwareInstallationServiceCapabilities
from openlmi.software.LMI_HostedSoftwareInstallationService import \
        LMI_HostedSoftwareInstallationService
from openlmi.software.LMI_SoftwareInstallationServiceAffectsElement import \
        LMI_SoftwareInstallationServiceAffectsElement
from openlmi.software.LMI_SoftwareInstallationJob import \
        LMI_SoftwareInstallationJob
from openlmi.software.LMI_SoftwareMethodResult import \
        LMI_SoftwareMethodResult
from openlmi.software.LMI_AffectedSoftwareJobElement import \
        LMI_AffectedSoftwareJobElement
from openlmi.software.LMI_AssociatedSoftwareJobMethodResult import \
        LMI_AssociatedSoftwareJobMethodResult
from openlmi.software.LMI_OwningSoftwareJobElement import \
        LMI_OwningSoftwareJobElement
from openlmi.software.yumdb import jobmanager, YumDB

def get_providers(env):
    """
    @return mapping of provider names to corresponding provider instances.
    """
    cmpi_logging.LogManager.LOGGER_NAME = 'openlmi.software'
    cmpi_logging.LogManager(env)

    # jobmanager does not understand CIM models, give it a way to transform
    # job to CIMIndication instance
    jobmanager.JOB_TO_MODEL = lambda job: \
            InstallationJob.job2model(job, keys_only=False)

    providers = {
        "LMI_SoftwareIdentity"            : LMI_SoftwareIdentity(env),
        "LMI_SystemSoftwareCollection"    : LMI_SystemSoftwareCollection(env),
        "LMI_HostedSoftwareCollection"    : LMI_HostedSoftwareCollection(env),
        "LMI_MemberOfSoftwareCollection"  : LMI_MemberOfSoftwareCollection(env),
        "LMI_InstalledSoftwareIdentity"   : LMI_InstalledSoftwareIdentity(env),
        "LMI_SoftwareIdentityResource"    : LMI_SoftwareIdentityResource(env),
        "LMI_ResourceForSoftwareIdentity" :
                LMI_ResourceForSoftwareIdentity(env),
        "LMI_HostedSoftwareIdentityResource" :
                LMI_HostedSoftwareIdentityResource(env),
        "LMI_SoftwareInstallationService" : \
                LMI_SoftwareInstallationService(env),
        "LMI_SoftwareInstallationServiceCapabilities" : \
                LMI_SoftwareInstallationServiceCapabilities(env),
        "LMI_AssociatedSoftwareInstallationServiceCapabilities" : \
                LMI_AssociatedSoftwareInstallationServiceCapabilities(env),
        "LMI_HostedSoftwareInstallationService" : \
                LMI_HostedSoftwareInstallationService(env),
        "LMI_SoftwareInstallationServiceAffectsElement" : \
                LMI_SoftwareInstallationServiceAffectsElement(env),
        "LMI_SoftwareInstallationJob"     : LMI_SoftwareInstallationJob(env),
        "LMI_SoftwareInstCreation"        : LMI_SoftwareInstallationJob(env),
        "LMI_SoftwareInstModification"    : LMI_SoftwareInstallationJob(env),
        "LMI_SoftwareMethodResult"        : LMI_SoftwareMethodResult(env),
        "LMI_AffectedSoftwareJobElement"  : LMI_AffectedSoftwareJobElement(env),
        "LMI_AssociatedSoftwareJobMethodResult" : \
                LMI_AssociatedSoftwareJobMethodResult(env),
        "LMI_OwningSoftwareJobElement"    : LMI_OwningSoftwareJobElement(env)
    }

    # Initialization of indication manager -- running in separate thread as
    # daemon. That means it does not have to be cleaned up.
    im = IndicationManager.get_instance(
            env, "Software", "root/cimv2", queue=Queue())
    jobmanager.register_filters(im)

    return providers

def authorize_filter(env, fltr, ns, classes, owner):
    IndicationManager.get_instance().authorize_filter(
            env, fltr, ns, classes, owner)

def activate_filter (env, fltr, ns, classes, first_activation):
    IndicationManager.get_instance().activate_filter(
            env, fltr, ns, classes, first_activation)

def deactivate_filter(env, fltr, ns, classes, last_activation):
    IndicationManager.get_instance().deactivate_filter(
            env, fltr, ns, classes, last_activation)

def enable_indications(env):
    IndicationManager.get_instance().enable_indications(env)

def disable_indications(env):
    IndicationManager.get_instance().disable_indications(env)

def can_unload(_env):
    """
    Says, whether providers can be unloaded.
    """
    return True

def shutdown(_env):
    """
    Release resources upon cleanup.
    """
    YumDB.get_instance().clean_up()