diff options
author | Michal Minar <miminar@redhat.com> | 2013-03-26 12:02:53 +0100 |
---|---|---|
committer | Michal Minar <miminar@redhat.com> | 2013-03-26 12:14:53 +0100 |
commit | ceb48290224437c726f98461d6a1d81e2bf952ea (patch) | |
tree | c95611e4387e24667b8d60718b362a967b0dc049 /src/software/openlmi/software | |
parent | bd14a7433a9c3e747fefd00b087219283144825d (diff) | |
download | openlmi-providers-ceb48290224437c726f98461d6a1d81e2bf952ea.tar.gz openlmi-providers-ceb48290224437c726f98461d6a1d81e2bf952ea.tar.xz openlmi-providers-ceb48290224437c726f98461d6a1d81e2bf952ea.zip |
new association providers
new providers:
* LMI_AssociatedSoftwareInstallationServiceCapabilities
* LMI_HostedSoftwareInstallationService
Diffstat (limited to 'src/software/openlmi/software')
4 files changed, 508 insertions, 0 deletions
diff --git a/src/software/openlmi/software/LMI_AssociatedSoftwareInstallationServiceCapabilities.py b/src/software/openlmi/software/LMI_AssociatedSoftwareInstallationServiceCapabilities.py new file mode 100644 index 0000000..18d02ba --- /dev/null +++ b/src/software/openlmi/software/LMI_AssociatedSoftwareInstallationServiceCapabilities.py @@ -0,0 +1,231 @@ +# 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/>. + +"""Python Provider for LMI_AssociatedSoftwareInstallationServiceCapabilities + +Instruments the CIM class LMI_AssociatedSoftwareInstallationServiceCapabilities + +""" + +import pywbem +from pywbem.cim_provider2 import CIMProvider2 + +from openlmi.common import cmpi_logging +from openlmi.software.core import InstallationService +from openlmi.software.core import InstallationServiceCapabilities +from openlmi.software.core import AssociatedInstallationServiceCapabilities + +class LMI_AssociatedSoftwareInstallationServiceCapabilities(CIMProvider2): + """Instrument the CIM class \ + LMI_AssociatedSoftwareInstallationServiceCapabilities + + ElementCapabilities represents the association between ManagedElements + and their Capabilities. Note that the cardinality of the + ManagedElement reference is Min(1). This cardinality mandates the + instantiation of the ElementCapabilities association for the + referenced instance of Capabilities. ElementCapabilities describes the + existence requirements and context for the referenced instance of + ManagedElement. Specifically, the ManagedElement MUST exist and + provides the context for the Capabilities. + + """ + + def __init__ (self, _env): + cmpi_logging.logger.debug('Initializing provider %s from %s' \ + % (self.__class__.__name__, __file__)) + self.values = AssociatedInstallationServiceCapabilities.Values + + @cmpi_logging.trace_method + def get_instance(self, env, model): + """Return an instance. + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + model -- A template of the pywbem.CIMInstance to be returned. The + key properties are set on this instance to correspond to the + instanceName that was requested. The properties of the model + are already filtered according to the PropertyList from the + request. Only properties present in the model need to be + given values. If you prefer, you can set all of the + values, and the instance will be filtered for you. + + Possible Errors: + CIM_ERR_ACCESS_DENIED + CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized + or otherwise incorrect parameters) + CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM + Instance does not exist in the specified namespace) + CIM_ERR_FAILED (some other unspecified error occurred) + """ + InstallationService.check_path_property(env, model, "ManagedElement") + InstallationServiceCapabilities.check_path_property( + env, model, "Capabilities") + model['Characteristics'] = [ + self.values.Characteristics.Default, + self.values.Characteristics.Current] + return model + + @cmpi_logging.trace_method + def enum_instances(self, env, model, keys_only): + """Enumerate instances. + + The WBEM operations EnumerateInstances and EnumerateInstanceNames + are both mapped to this method. + This method is a python generator + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + model -- A template of the pywbem.CIMInstances to be generated. + The properties of the model are already filtered according to + the PropertyList from the request. Only properties present in + the model need to be given values. If you prefer, you can + always set all of the values, and the instance will be filtered + for you. + keys_only -- A boolean. True if only the key properties should be + set on the generated instances. + + Possible Errors: + CIM_ERR_FAILED (some other unspecified error occurred) + """ + model.path.update({'Capabilities': None, 'ManagedElement': None}) + + model['Capabilities'] = InstallationServiceCapabilities.get_path() + model['ManagedElement'] = InstallationService.get_path() + if not keys_only: + model['Characteristics'] = [ + self.values.Characteristics.Default, + self.values.Characteristics.Current] + yield model + + @cmpi_logging.trace_method + def set_instance(self, env, instance, modify_existing): + """Return a newly created or modified instance. + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + instance -- The new pywbem.CIMInstance. If modifying an existing + instance, the properties on this instance have been filtered by + the PropertyList from the request. + modify_existing -- True if ModifyInstance, False if CreateInstance + + Return the new instance. The keys must be set on the new instance. + + Possible Errors: + CIM_ERR_ACCESS_DENIED + CIM_ERR_NOT_SUPPORTED + CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized + or otherwise incorrect parameters) + CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only + valid if modify_existing is False, indicating that the operation + was CreateInstance) + CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid + if modify_existing is True, indicating that the operation + was ModifyInstance) + CIM_ERR_FAILED (some other unspecified error occurred) + """ + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) + + @cmpi_logging.trace_method + def delete_instance(self, env, instance_name): + """Delete an instance. + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + instance_name -- A pywbem.CIMInstanceName specifying the instance + to delete. + + Possible Errors: + CIM_ERR_ACCESS_DENIED + CIM_ERR_NOT_SUPPORTED + CIM_ERR_INVALID_NAMESPACE + CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized + or otherwise incorrect parameters) + CIM_ERR_INVALID_CLASS (the CIM Class does not exist in the specified + namespace) + CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM + Instance does not exist in the specified namespace) + CIM_ERR_FAILED (some other unspecified error occurred) + """ + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) + + @cmpi_logging.trace_method + def references(self, env, object_name, model, result_class_name, role, + result_role, keys_only): + """Instrument Associations. + + All four association-related operations (Associators, AssociatorNames, + References, ReferenceNames) are mapped to this method. + This method is a python generator + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + object_name -- A pywbem.CIMInstanceName that defines the source + CIM Object whose associated Objects are to be returned. + model -- A template pywbem.CIMInstance to serve as a model + of the objects to be returned. Only properties present on this + model need to be set. + result_class_name -- If not empty, this string acts as a filter on + the returned set of Instances by mandating that each returned + Instances MUST represent an association between object_name + and an Instance of a Class whose name matches this parameter + or a subclass. + role -- If not empty, MUST be a valid Property name. It acts as a + filter on the returned set of Instances by mandating that each + returned Instance MUST refer to object_name via a Property + whose name matches the value of this parameter. + result_role -- If not empty, MUST be a valid Property name. It acts + as a filter on the returned set of Instances by mandating that + each returned Instance MUST represent associations of + object_name to other Instances, where the other Instances play + the specified result_role in the association (i.e. the + name of the Property in the Association Class that refers to + the Object related to object_name MUST match the value of this + parameter). + keys_only -- A boolean. True if only the key properties should be + set on the generated instances. + + The following diagram may be helpful in understanding the role, + result_role, and result_class_name parameters. + +------------------------+ +-------------------+ + | object_name.classname | | result_class_name | + | ~~~~~~~~~~~~~~~~~~~~~ | | ~~~~~~~~~~~~~~~~~ | + +------------------------+ +-------------------+ + | +-----------------------------------+ | + | | [Association] model.classname | | + | object_name | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | + +--------------+ object_name.classname REF role | | + (CIMInstanceName) | result_class_name REF result_role +------+ + | |(CIMInstanceName) + +-----------------------------------+ + + Possible Errors: + CIM_ERR_ACCESS_DENIED + CIM_ERR_NOT_SUPPORTED + CIM_ERR_INVALID_NAMESPACE + CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized + or otherwise incorrect parameters) + CIM_ERR_FAILED (some other unspecified error occurred) + """ + ch = env.get_cimom_handle() + if ch.is_subclass(object_name.namespace, + sub=object_name.classname, + super='LMI_SoftwareInstallationServiceCapabilities') or \ + ch.is_subclass(object_name.namespace, + sub=object_name.classname, + super='LMI_SoftwareInstallationService'): + return self.simple_refs(env, object_name, model, + result_class_name, role, result_role, keys_only) diff --git a/src/software/openlmi/software/LMI_HostedSoftwareInstallationService.py b/src/software/openlmi/software/LMI_HostedSoftwareInstallationService.py new file mode 100644 index 0000000..04b136d --- /dev/null +++ b/src/software/openlmi/software/LMI_HostedSoftwareInstallationService.py @@ -0,0 +1,233 @@ +# -*- 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> +# + +"""Python Provider for LMI_HostedSoftwareInstallationService + +Instruments the CIM class LMI_HostedSoftwareInstallationService + +""" + +import pywbem +from pywbem.cim_provider2 import CIMProvider2 + +from openlmi.common import cmpi_logging +from openlmi.software.core import ComputerSystem, InstallationService + +class LMI_HostedSoftwareInstallationService(CIMProvider2): + """Instrument the CIM class LMI_HostedSoftwareInstallationService + + CIM_HostedService is an association between a Service and the System on + which the functionality is located. The cardinality of this + association is one-to-many. A System can host many Services. Services + are weak with respect to their hosting System. Heuristic: A Service is + hosted on the System where the LogicalDevices or SoftwareFeatures that + implement the Service are located. The model does not represent + Services hosted across multiple systems. The model is as an + ApplicationSystem that acts as an aggregation point for Services that + are each located on a single host. + + """ + + def __init__ (self, _env): + cmpi_logging.logger.debug('Initializing provider %s from %s' \ + % (self.__class__.__name__, __file__)) + + @cmpi_logging.trace_method + def get_instance(self, env, model): + """Return an instance. + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + model -- A template of the pywbem.CIMInstance to be returned. The + key properties are set on this instance to correspond to the + instanceName that was requested. The properties of the model + are already filtered according to the PropertyList from the + request. Only properties present in the model need to be + given values. If you prefer, you can set all of the + values, and the instance will be filtered for you. + + Possible Errors: + CIM_ERR_ACCESS_DENIED + CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized + or otherwise incorrect parameters) + CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM + Instance does not exist in the specified namespace) + CIM_ERR_FAILED (some other unspecified error occurred) + """ + InstallationService.check_path_property(env, model, 'Dependent') + ComputerSystem.check_path_property(env, model, 'Antecedent') + + model.path.update({"Antecedent":None, "Dependent":None}) + + model["Dependent"] = InstallationService.get_path() + model["Antecedent"] = ComputerSystem.get_path() + + return model + + @cmpi_logging.trace_method + def enum_instances(self, env, model, keys_only): + """Enumerate instances. + + The WBEM operations EnumerateInstances and EnumerateInstanceNames + are both mapped to this method. + This method is a python generator + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + model -- A template of the pywbem.CIMInstances to be generated. + The properties of the model are already filtered according to + the PropertyList from the request. Only properties present in + the model need to be given values. If you prefer, you can + always set all of the values, and the instance will be filtered + for you. + keys_only -- A boolean. True if only the key properties should be + set on the generated instances. + + Possible Errors: + CIM_ERR_FAILED (some other unspecified error occurred) + """ + model.path.update({'Dependent': None, 'Antecedent': None}) + + model["Antecedent"] = ComputerSystem.get_path() + model["Dependent"] = InstallationService.get_path() + + yield model + + @cmpi_logging.trace_method + def set_instance(self, env, instance, modify_existing): + """Return a newly created or modified instance. + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + instance -- The new pywbem.CIMInstance. If modifying an existing + instance, the properties on this instance have been filtered by + the PropertyList from the request. + modify_existing -- True if ModifyInstance, False if CreateInstance + + Return the new instance. The keys must be set on the new instance. + + Possible Errors: + CIM_ERR_ACCESS_DENIED + CIM_ERR_NOT_SUPPORTED + CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized + or otherwise incorrect parameters) + CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only + valid if modify_existing is False, indicating that the operation + was CreateInstance) + CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid + if modify_existing is True, indicating that the operation + was ModifyInstance) + CIM_ERR_FAILED (some other unspecified error occurred) + """ + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) + + @cmpi_logging.trace_method + def delete_instance(self, env, instance_name): + """Delete an instance. + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + instance_name -- A pywbem.CIMInstanceName specifying the instance + to delete. + + Possible Errors: + CIM_ERR_ACCESS_DENIED + CIM_ERR_NOT_SUPPORTED + CIM_ERR_INVALID_NAMESPACE + CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized + or otherwise incorrect parameters) + CIM_ERR_INVALID_CLASS (the CIM Class does not exist in the specified + namespace) + CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM + Instance does not exist in the specified namespace) + CIM_ERR_FAILED (some other unspecified error occurred) + """ + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_SUPPORTED) + + @cmpi_logging.trace_method + def references(self, env, object_name, model, result_class_name, role, + result_role, keys_only): + """Instrument Associations. + + All four association-related operations (Associators, AssociatorNames, + References, ReferenceNames) are mapped to this method. + This method is a python generator + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + object_name -- A pywbem.CIMInstanceName that defines the source + CIM Object whose associated Objects are to be returned. + model -- A template pywbem.CIMInstance to serve as a model + of the objects to be returned. Only properties present on this + model need to be set. + result_class_name -- If not empty, this string acts as a filter on + the returned set of Instances by mandating that each returned + Instances MUST represent an association between object_name + and an Instance of a Class whose name matches this parameter + or a subclass. + role -- If not empty, MUST be a valid Property name. It acts as a + filter on the returned set of Instances by mandating that each + returned Instance MUST refer to object_name via a Property + whose name matches the value of this parameter. + result_role -- If not empty, MUST be a valid Property name. It acts + as a filter on the returned set of Instances by mandating that + each returned Instance MUST represent associations of + object_name to other Instances, where the other Instances play + the specified result_role in the association (i.e. the + name of the Property in the Association Class that refers to + the Object related to object_name MUST match the value of this + parameter). + keys_only -- A boolean. True if only the key properties should be + set on the generated instances. + + The following diagram may be helpful in understanding the role, + result_role, and result_class_name parameters. + +------------------------+ +-------------------+ + | object_name.classname | | result_class_name | + | ~~~~~~~~~~~~~~~~~~~~~ | | ~~~~~~~~~~~~~~~~~ | + +------------------------+ +-------------------+ + | +-----------------------------------+ | + | | [Association] model.classname | | + | object_name | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | + +--------------+ object_name.classname REF role | | + (CIMInstanceName) | result_class_name REF result_role +------+ + | |(CIMInstanceName) + +-----------------------------------+ + + Possible Errors: + CIM_ERR_ACCESS_DENIED + CIM_ERR_NOT_SUPPORTED + CIM_ERR_INVALID_NAMESPACE + CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized + or otherwise incorrect parameters) + CIM_ERR_FAILED (some other unspecified error occurred) + """ + ch = env.get_cimom_handle() + + if ch.is_subclass(object_name.namespace, + sub=object_name.classname, + super='LMI_SoftwareInstallationService') or \ + ch.is_subclass(object_name.namespace, + sub=object_name.classname, + super='Linux_ComputerSystem'): + return self.simple_refs(env, object_name, model, + result_class_name, role, result_role, keys_only) diff --git a/src/software/openlmi/software/cimom_entry.py b/src/software/openlmi/software/cimom_entry.py index f73c8cb..b2ccf55 100644 --- a/src/software/openlmi/software/cimom_entry.py +++ b/src/software/openlmi/software/cimom_entry.py @@ -44,6 +44,11 @@ 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_SoftwareInstallationJob import \ LMI_SoftwareInstallationJob from openlmi.software.LMI_SoftwareMethodResult import \ @@ -77,6 +82,10 @@ def get_providers(env): LMI_SoftwareInstallationService(env), "LMI_SoftwareInstallationServiceCapabilities" : \ LMI_SoftwareInstallationServiceCapabilities(env), + "LMI_AssociatedSoftwareInstallationServiceCapabilities" : \ + LMI_AssociatedSoftwareInstallationServiceCapabilities(env), + "LMI_HostedSoftwareInstallationService" : \ + LMI_HostedSoftwareInstallationService(env), "LMI_SoftwareInstallationJob" : LMI_SoftwareInstallationJob(env), "LMI_SoftwareMethodResult" : LMI_SoftwareMethodResult(env), "LMI_AffectedSoftwareJobElement" : LMI_AffectedSoftwareJobElement(env), diff --git a/src/software/openlmi/software/core/AssociatedInstallationServiceCapabilities.py b/src/software/openlmi/software/core/AssociatedInstallationServiceCapabilities.py new file mode 100644 index 0000000..cb1b24e --- /dev/null +++ b/src/software/openlmi/software/core/AssociatedInstallationServiceCapabilities.py @@ -0,0 +1,35 @@ +# -*- 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 associated class +LMI_AssociatedInstallationServiceCapabilities. +""" + +import pywbem + +class Values(object): + class Characteristics(object): + Default = pywbem.Uint16(2) + Current = pywbem.Uint16(3) + # DMTF_Reserved = .. + # Vendor_Specific = 32768..65535 + _reverse_map = { + 2: 'Default', + 3: 'Current' + } |