diff options
author | Michal Minar <miminar@redhat.com> | 2013-03-26 12:13:58 +0100 |
---|---|---|
committer | Michal Minar <miminar@redhat.com> | 2013-03-26 12:13:58 +0100 |
commit | ac7afb0853192b789908910fa505841d842dd689 (patch) | |
tree | 3bda21bb53f312393591eff3ce5e38c0ccc566af /src | |
parent | c3c0fe84506667805b54d845370c77b0ac7328c7 (diff) | |
download | openlmi-providers-ac7afb0853192b789908910fa505841d842dd689.tar.gz openlmi-providers-ac7afb0853192b789908910fa505841d842dd689.tar.xz openlmi-providers-ac7afb0853192b789908910fa505841d842dd689.zip |
added LMI_SoftwareInstallationServiceCapabilities provider
Diffstat (limited to 'src')
3 files changed, 522 insertions, 0 deletions
diff --git a/src/software/openlmi/software/LMI_SoftwareInstallationServiceCapabilities.py b/src/software/openlmi/software/LMI_SoftwareInstallationServiceCapabilities.py new file mode 100644 index 0000000..9b88de6 --- /dev/null +++ b/src/software/openlmi/software/LMI_SoftwareInstallationServiceCapabilities.py @@ -0,0 +1,292 @@ +# 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_SoftwareInstallationServiceCapabilities + +Instruments the CIM class LMI_SoftwareInstallationServiceCapabilities + +""" + +import pywbem +from pywbem.cim_provider2 import CIMProvider2 + +from openlmi.common import cmpi_logging +from openlmi.software.core import InstallationServiceCapabilities + +class LMI_SoftwareInstallationServiceCapabilities(CIMProvider2): + """Instrument the CIM class LMI_SoftwareInstallationServiceCapabilities + + A subclass of capabilities that defines the capabilities of a + SoftwareInstallationService. A single instance of + SoftwareInstallationServiceCapabilities is associated with a + SoftwareInstallationService using ElementCapabilities. + """ + + def __init__ (self, _env): + cmpi_logging.logger.debug('Initializing provider %s from %s' \ + % (self.__class__.__name__, __file__)) + self.values = InstallationServiceCapabilities.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) + """ + InstallationServiceCapabilities.check_path(env, + model.path, "path") + return InstallationServiceCapabilities.get_instance(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({'InstanceID': None}) + + if keys_only: + model['InstanceID'] = \ + InstallationServiceCapabilities.get_path()['InstanceID'] + else: + model = InstallationServiceCapabilities.get_instance(model) + 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 cim_method_creategoalsettings(self, env, object_name, + param_supportedgoalsettings=None, + param_templategoalsettings=None): + """Implements LMI_SoftwareInstallationServiceCapabilities. \ + CreateGoalSettings() + + Method to create a set of supported SettingData elements, from two + sets of SettingData elements, provided by the caller. CreateGoal + should be used when the SettingData instances that represents the + goal will not persist beyond the execution of the client and where + those instances are not intended to be shared with other, + non-cooperating clients. Both TemplateGoalSettings and + SupportedGoalSettings are represented as strings containing + EmbeddedInstances of a CIM_SettingData subclass. These embedded + instances do not exist in the infrastructure supporting this + method but are maintained by the caller/client. This method + should return CIM_Error(s) representing that a single named + property of a setting (or other) parameter (either reference or + embedded object) has an invalid value or that an invalid + combination of named properties of a setting (or other) parameter + (either reference or embedded object) has been requested. If the + input TemplateGoalSettings is NULL or the empty string, this + method returns a default SettingData element that is supported by + this Capabilities element. If the TemplateGoalSettings specifies + values that cannot be supported, this method shall return an + appropriate CIM_Error and should return a best match for a + SupportedGoalSettings. The client proposes a goal using the + TemplateGoalSettings parameter and gets back Success if the + TemplateGoalSettings is exactly supportable. It gets back + "Alternative Proposed" if the output SupportedGoalSettings + represents a supported alternative. This alternative should be a + best match, as defined by the implementation. If the + implementation is conformant to a RegisteredProfile, then that + profile may specify the algorithms used to determine best match. A + client may compare the returned value of each property against the + requested value to determine if it is left unchanged, degraded or + upgraded. Otherwise, if the TemplateGoalSettings is not + applicable an "Invalid Parameter" error is returned. When a + mutually acceptable SupportedGoalSettings has been achieved, the + client may use the contained SettingData instances as input to + methods for creating a new object ormodifying an existing object. + Also the embedded SettingData instances returned in the + SupportedGoalSettings may be instantiated via CreateInstance, + either by a client or as a side-effect of the execution of an + extrinsic method for which the returned SupportedGoalSettings is + passed as an embedded instance. + + Keyword arguments: + env -- Provider Environment (pycimmb.ProviderEnvironment) + object_name -- A pywbem.CIMInstanceName or pywbem.CIMCLassName + specifying the object on which the method CreateGoalSettings() + should be invoked. + param_supportedgoalsettings -- The input parameter + SupportedGoalSettings (type pywbem.CIMInstance( + classname='CIM_SettingData', ...)) + SupportedGoalSettings are elements of class CIM_SettingData, or + a derived class. At most, one instance of each SettingData + subclass may be supplied. All SettingData instances provided + by this property are interpreted as a set, relative to this + Capabilities instance. To enable a client to provide + additional information towards achieving the + TemplateGoalSettings, an input set of SettingData instances + may be provided. If not provided, this property shall be set + to NULL on input.. Note that when provided, what property + values are changed, and how, is implementation dependent and + may be the subject of other standards. If provided, the input + SettingData instances must be ones that the implementation is + able to support relative to the ManagedElement associated via + ElementCapabilities. Typically, the input SettingData + instances are created by a previous instantiation of + CreateGoalSettings. If the input SupportedGoalSettings is not + supported by the implementation, then an "Invalid Parameter" + (5) error is returned by this call. In this case, a + corresponding CIM_ERROR should also be returned. On output, + this property is used to return the best supported match to + the TemplateGoalSettings. If the output SupportedGoalSettings + matches the input SupportedGoalSettings, then the + implementation is unable to improve further towards meeting + the TemplateGoalSettings. + + param_templategoalsettings -- The input parameter + TemplateGoalSettings (type pywbem.CIMInstance( + classname='CIM_SettingData', ...)) + If provided, TemplateGoalSettings are elements of class + CIM_SettingData, or a derived class, that is used as the + template to be matched. . At most, one instance of each + SettingData subclass may be supplied. All SettingData + instances provided by this property are interpreted as a set, + relative to this Capabilities instance. SettingData instances + that are not relevant to this instance are ignored. If not + provided, it shall be set to NULL. In that case, a SettingData + instance representing the default settings of the associated + ManagedElement is used. + + + Returns a two-tuple containing the return value (type pywbem.Uint16 + self.Values.CreateGoalSettings) + and a list of CIMParameter objects representing the output parameters + + Output parameters: + SupportedGoalSettings -- (type + pywbem.CIMInstance(classname='CIM_SettingData', ...)) + SupportedGoalSettings are elements of class CIM_SettingData, or + a derived class. At most, one instance of each SettingData + subclass may be supplied. All SettingData instances provided + by this property are interpreted as a set, relative to this + Capabilities instance. To enable a client to provide + additional information towards achieving the + TemplateGoalSettings, an input set of SettingData instances + may be provided. If not provided, this property shall be set + to NULL on input.. Note that when provided, what property + values are changed, and how, is implementation dependent and + may be the subject of other standards. If provided, the input + SettingData instances must be ones that the implementation is + able to support relative to the ManagedElement associated via + ElementCapabilities. Typically, the input SettingData + instances are created by a previous instantiation of + CreateGoalSettings. If the input SupportedGoalSettings is not + supported by the implementation, then an "Invalid Parameter" + (5) error is returned by this call. In this case, a + corresponding CIM_ERROR should also be returned. On output, + this property is used to return the best supported match to + the TemplateGoalSettings. If the output SupportedGoalSettings + matches the input SupportedGoalSettings, then the + implementation is unable to improve further towards meeting + the TemplateGoalSettings. + + + Possible Errors: + CIM_ERR_ACCESS_DENIED + CIM_ERR_INVALID_PARAMETER (including missing, duplicate, + unrecognized or otherwise incorrect parameters) + CIM_ERR_NOT_FOUND (the target CIM Class or instance does not + exist in the specified namespace) + CIM_ERR_METHOD_NOT_AVAILABLE (the CIM Server is unable to honor + the invocation request) + CIM_ERR_FAILED (some other unspecified error occurred) + """ + return (self.values.CreateGoalSettings.Not_Supported, []) + diff --git a/src/software/openlmi/software/cimom_entry.py b/src/software/openlmi/software/cimom_entry.py index 40ae357..f73c8cb 100644 --- a/src/software/openlmi/software/cimom_entry.py +++ b/src/software/openlmi/software/cimom_entry.py @@ -42,6 +42,8 @@ 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_SoftwareInstallationJob import \ LMI_SoftwareInstallationJob from openlmi.software.LMI_SoftwareMethodResult import \ @@ -73,6 +75,8 @@ def get_providers(env): LMI_HostedSoftwareIdentityResource(env), "LMI_SoftwareInstallationService" : \ LMI_SoftwareInstallationService(env), + "LMI_SoftwareInstallationServiceCapabilities" : \ + LMI_SoftwareInstallationServiceCapabilities(env), "LMI_SoftwareInstallationJob" : LMI_SoftwareInstallationJob(env), "LMI_SoftwareMethodResult" : LMI_SoftwareMethodResult(env), "LMI_AffectedSoftwareJobElement" : LMI_AffectedSoftwareJobElement(env), diff --git a/src/software/openlmi/software/core/InstallationServiceCapabilities.py b/src/software/openlmi/software/core/InstallationServiceCapabilities.py new file mode 100644 index 0000000..4fbc5ec --- /dev/null +++ b/src/software/openlmi/software/core/InstallationServiceCapabilities.py @@ -0,0 +1,226 @@ +# -*- 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 +LMI_SoftwareInstallationServiceCapabilities provider. +""" + +import pywbem + +from openlmi.common import cmpi_logging + +class Values(object): + class SupportedExtendedResourceTypes(object): + Unknown = pywbem.Uint16(0) + Other = pywbem.Uint16(1) + Not_Applicable = pywbem.Uint16(2) + Linux_RPM = pywbem.Uint16(3) + HP_UX_Depot = pywbem.Uint16(4) + Windows_MSI = pywbem.Uint16(5) + Solaris_Package = pywbem.Uint16(6) + Macintosh_Disk_Image = pywbem.Uint16(7) + Debian_linux_Package = pywbem.Uint16(8) + VMware_vSphere_Installation_Bundle = pywbem.Uint16(9) + VMware_Software_Bulletin = pywbem.Uint16(10) + HP_Smart_Component = pywbem.Uint16(11) + # DMTF_Reserved = .. + # Vendor_Reserved = 0x8000.. + _reverse_map = { + 0 : 'Unknown', + 1 : 'Other', + 2 : 'Not Applicable', + 3 : 'Linux RPM', + 4 : 'HP-UX Depot', + 5 : 'Windows MSI', + 6 : 'Solaris Package', + 7 : 'Macintosh Disk Image', + 8 : 'Debian linux Package', + 9 : 'VMware vSphere Installation Bundle', + 10 : 'VMware Software Bulletin', + 11 : 'HP Smart Component' + } + + class SupportedInstallOptions(object): + Defer_target_system_reset = pywbem.Uint16(2) + Force_installation = pywbem.Uint16(3) + Install = pywbem.Uint16(4) + Update = pywbem.Uint16(5) + Repair = pywbem.Uint16(6) + Reboot = pywbem.Uint16(7) + Password = pywbem.Uint16(8) + Uninstall = pywbem.Uint16(9) + Log = pywbem.Uint16(10) + SilentMode = pywbem.Uint16(11) + AdministrativeMode = pywbem.Uint16(12) + ScheduleInstallAt = pywbem.Uint16(13) + # DMTF_Reserved = .. + # Vendor_Specific = 32768..65535 + _reverse_map = { + 2 : 'Defer target/system reset', + 3 : 'Force installation', + 4 : 'Install', + 5 : 'Update', + 6 : 'Repair', + 7 : 'Reboot', + 8 : 'Password', + 9 : 'Uninstall', + 10 : 'Log', + 11 : 'SilentMode', + 12 : 'AdministrativeMode', + 13 : 'ScheduleInstallAt' + } + + class SupportedURISchemes(object): + data = pywbem.Uint16(2) + file = pywbem.Uint16(3) + ftp = pywbem.Uint16(4) + http = pywbem.Uint16(5) + https = pywbem.Uint16(6) + nfs = pywbem.Uint16(7) + tftp = pywbem.Uint16(8) + # DMTF_Reserved = .. + # Vendor_Specific = 0x8000..0xFFFF + _reverse_map = { + 2 : 'data', + 3 : 'file', + 4 : 'ftp', + 5 : 'http', + 6 : 'https', + 7 : 'nfs', + 8 : 'tftp' + } + + class SupportedAsynchronousActions(object): + None_supported = pywbem.Uint16(2) + Install_From_Software_Identity = pywbem.Uint16(3) + Install_from_ByteStream = pywbem.Uint16(4) + Install_from_URI = pywbem.Uint16(5) + _reverse_map = { + 2 : 'None supported', + 3 : 'Install From Software Identity', + 4 : 'Install from ByteStream', + 5 : 'Install from URI' + } + + class CreateGoalSettings(object): + Success = pywbem.Uint16(0) + Not_Supported = pywbem.Uint16(1) + Unknown = pywbem.Uint16(2) + Timeout = pywbem.Uint16(3) + Failed = pywbem.Uint16(4) + Invalid_Parameter = pywbem.Uint16(5) + Alternative_Proposed = pywbem.Uint16(6) + # DMTF_Reserved = .. + # Vendor_Specific = 32768..65535 + + class SupportedSynchronousActions(object): + None_supported = pywbem.Uint16(2) + Install_From_Software_Identity = pywbem.Uint16(3) + Install_from_ByteStream = pywbem.Uint16(4) + Install_from_URI = pywbem.Uint16(5) + _reverse_map = { + 2 : 'None supported', + 3 : 'Install From Software Identity', + 4 : 'Install from ByteStream', + 5 : 'Install from URI' + } + +@cmpi_logging.trace_function +def get_path(): + """@return instance name with prefilled properties""" + op = pywbem.CIMInstanceName( + classname="LMI_SoftwareInstallationServiceCapabilities", + namespace="root/cimv2") + op['InstanceID'] = "LMI:SoftwareInstallationServiceCapabilities" + return op + +@cmpi_logging.trace_function +def check_path(env, caps, prop_name): + """ + Checks instance name of SoftwareInstallationServiceCapabilities. + @param prop_name name of object name; used for error descriptions + """ + if not isinstance(caps, pywbem.CIMInstanceName): + raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER, + "\"%s\" must be a CIMInstanceName" % prop_name) + our_caps = get_path() + ch = env.get_cimom_handle() + if caps.namespace != our_caps.namespace: + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND, + 'Namespace of "%s" does not match "%s"' % ( + prop_name, our_caps.namespace)) + if not ch.is_subclass(our_caps.namespace, + sub=caps.classname, + super=our_caps.classname): + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND, + "Class of \"%s\" must be a sublass of %s" % ( + prop_name, our_caps.classname)) + if caps['InstanceID'] != our_caps['InstanceID']: + raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND, + "InstanceID of \"%s\" does not match \"%s\"" % + prop_name, our_caps['InstanceID']) + return True + +@cmpi_logging.trace_function +def check_path_property(env, op, prop_name): + """ + Checks, whether prop_name property of op object path is correct. + If not, an exception will be raised. + """ + if not prop_name in op: + raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER, + "Missing %s key property!" % prop_name) + return check_path(env, op[prop_name], prop_name) + +def get_instance(model=None): + """ + Makes instance of LMI_SoftwareInstallationServiceCapabilities or + fills given model with properties. + """ + path = get_path() + if model is None: + model = pywbem.CIMInstance( + "LMI_SoftwareInstallationServiceCapabilities", path=path) + model['InstanceID'] = path['InstanceID'] + + model['CanAddToCollection'] = True + model['Caption'] = 'Capabilities of LMI:SoftwareInstallationService' + model['Description'] = ('This instance provides information' + ' about LMI:SoftwareInstallationService\'s capabilities.') + model['SupportedAsynchronousActions'] = [ + Values.SupportedAsynchronousActions.Install_From_Software_Identity, + Values.SupportedAsynchronousActions.Install_from_URI] + model['SupportedExtendedResourceTypes'] = [ + Values.SupportedExtendedResourceTypes.Linux_RPM] + model['SupportedInstallOptions'] = [ + Values.SupportedInstallOptions.Install, + Values.SupportedInstallOptions.Update, + Values.SupportedInstallOptions.Uninstall, + Values.SupportedInstallOptions.Force_installation, + Values.SupportedInstallOptions.Repair] + model['SupportedSynchronousActions'] = [ + Values.SupportedSynchronousActions.None_supported] + model['SupportedTargetTypes'] = ['rpm', 'yum'] + model['SupportedURISchemes'] = [ + Values.SupportedURISchemes.file, + Values.SupportedURISchemes.ftp, + Values.SupportedURISchemes.http, + Values.SupportedURISchemes.https] + return model + |