summaryrefslogtreecommitdiffstats
path: root/src/software
diff options
context:
space:
mode:
Diffstat (limited to 'src/software')
-rw-r--r--src/software/openlmi/software/LMI_ResourceForSoftwareIdentity.py6
-rw-r--r--src/software/openlmi/software/LMI_SoftwareIdentityResource.py27
-rw-r--r--src/software/openlmi/software/LMI_SoftwareInstallationJob.py53
-rw-r--r--src/software/openlmi/software/cimom_entry.py15
-rw-r--r--src/software/openlmi/software/core/ComputerSystem.py4
-rw-r--r--src/software/openlmi/software/core/Error.py2
-rw-r--r--src/software/openlmi/software/core/Identity.py86
-rw-r--r--src/software/openlmi/software/core/InstallationJob.py33
-rw-r--r--src/software/openlmi/software/core/InstallationService.py10
-rw-r--r--src/software/openlmi/software/core/SystemCollection.py4
-rw-r--r--src/software/openlmi/software/util/__init__.py30
-rw-r--r--src/software/openlmi/software/yumdb/__init__.py6
-rw-r--r--src/software/openlmi/software/yumdb/packageinfo.py9
-rw-r--r--src/software/openlmi/software/yumdb/process.py8
-rwxr-xr-xsrc/software/test/test_installed_software_identity.py3
15 files changed, 160 insertions, 136 deletions
diff --git a/src/software/openlmi/software/LMI_ResourceForSoftwareIdentity.py b/src/software/openlmi/software/LMI_ResourceForSoftwareIdentity.py
index e7815a7..42ef7dc 100644
--- a/src/software/openlmi/software/LMI_ResourceForSoftwareIdentity.py
+++ b/src/software/openlmi/software/LMI_ResourceForSoftwareIdentity.py
@@ -122,9 +122,9 @@ class LMI_ResourceForSoftwareIdentity(CIMProvider2):
repoid = model["AvailableSAP"]["Name"]
pkg_info = Identity.object_path2pkg(
model["ManagedElement"],
- kind='available',
- include_repos=repoid,
- exclude_repos='*',
+ kind='available',
+ include_repos=repoid,
+ exclude_repos='*',
repoid=repoid)
repos = ydb.filter_repositories('all', repoid=repoid)
if len(repos) < 1:
diff --git a/src/software/openlmi/software/LMI_SoftwareIdentityResource.py b/src/software/openlmi/software/LMI_SoftwareIdentityResource.py
index 1d1564a..1377520 100644
--- a/src/software/openlmi/software/LMI_SoftwareIdentityResource.py
+++ b/src/software/openlmi/software/LMI_SoftwareIdentityResource.py
@@ -52,6 +52,7 @@ class LMI_SoftwareIdentityResource(CIMProvider2):
def __init__ (self, _env):
cmpi_logging.logger.debug('Initializing provider %s from %s' \
% (self.__class__.__name__, __file__))
+ self.values = IdentityResource.Values
@cmpi_logging.trace_method
def get_instance(self, env, model):
@@ -74,13 +75,9 @@ class LMI_SoftwareIdentityResource(CIMProvider2):
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)
-
"""
-
- repo = IdentityResource.object_path2repo(
- env, model.path, kind='all')
- return IdentityResource.repo2model(
- repo, keys_only=False, model=model)
+ repo = IdentityResource.object_path2repo(env, model.path, kind='all')
+ return IdentityResource.repo2model(repo, keys_only=False, model=model)
@cmpi_logging.trace_method
def enum_instances(self, env, model, keys_only):
@@ -240,23 +237,20 @@ class LMI_SoftwareIdentityResource(CIMProvider2):
"""
out_params = []
if param_timeoutperiod is not None:
- return ( IdentityResource.Values.RequestStateChange. \
+ return ( self.values.RequestStateChange. \
Use_of_Timeout_Parameter_Not_Supported
, out_params)
if param_requestedstate not in {
- IdentityResource.Values.RequestStateChange. \
- RequestedState.Enabled,
- IdentityResource.Values.RequestStateChange. \
- RequestedState.Disabled }:
- return ( IdentityResource.Values.RequestStateChange. \
- Invalid_State_Transition
+ self.values.RequestStateChange.RequestedState.Enabled,
+ self.values.RequestStateChange.RequestedState.Disabled }:
+ return ( self.values.RequestStateChange.Invalid_State_Transition
, out_params)
with YumDB.get_instance() as ydb:
repo = IdentityResource.object_path2repo(env,
object_name, 'all')
- enable = param_requestedstate == IdentityResource.Values. \
- RequestStateChange.RequestedState.Enabled
+ enable = param_requestedstate == \
+ self.values.RequestStateChange.RequestedState.Enabled
cmpi_logging.logger.info("%s repository %s" % ("enabling"
if enable else "disabling", repo))
try:
@@ -271,7 +265,6 @@ class LMI_SoftwareIdentityResource(CIMProvider2):
cmpi_logging.logger.info(msg % (repo,
"enabled" if enable else "disabled"))
- rval = IdentityResource.Values.RequestStateChange. \
- Completed_with_No_Error
+ rval = self.values.RequestStateChange.Completed_with_No_Error
return (rval, out_params)
diff --git a/src/software/openlmi/software/LMI_SoftwareInstallationJob.py b/src/software/openlmi/software/LMI_SoftwareInstallationJob.py
index ee12aa0..ba0867f 100644
--- a/src/software/openlmi/software/LMI_SoftwareInstallationJob.py
+++ b/src/software/openlmi/software/LMI_SoftwareInstallationJob.py
@@ -1,15 +1,31 @@
+# -*- 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/>.
+
"""Python Provider for LMI_SoftwareInstallationJob
Instruments the CIM class LMI_SoftwareInstallationJob
-
"""
-import inspect
import pywbem
from pywbem.cim_provider2 import CIMProvider2
from openlmi.common import cmpi_logging
-from openlmi.software.core import Error, InstallationJob
+from openlmi.software.core import InstallationJob
from openlmi.software.yumdb import errors, YumDB
class LMI_SoftwareInstallationJob(CIMProvider2):
@@ -268,28 +284,11 @@ class LMI_SoftwareInstallationJob(CIMProvider2):
CIM_ERR_FAILED (some other unspecified error occurred)
"""
job = InstallationJob.object_path2job(object_name)
+ error = InstallationJob.job2error(job)
out_params = []
- if job.state == job.EXCEPTION:
- errortup = job.result_data
- callargs = inspect.getcallargs(Error.make_instance)
- if issubclass(errortup[0],
- (errors.RepositoryNotFound, errors.PackageNotFound)):
- callargs['status_code'] = Error.Values. \
- CIMStatusCode.CIM_ERR_NOT_FOUND
- if issubclass(errortup[0], errors.PackageNotFound):
- callargs['status_code_description'] = \
- "Package not found"
- else:
- callargs['status_code_description'] = \
- "Repository not found"
- elif issubclass(errortup[0], errors.PackageAlreadyInstalled):
- callargs['status_code'] = Error.Values. \
- CIMStatusCode.CIM_ERR_ALREADY_EXISTS
- callargs['message'] = getattr(errortup[1], 'message',
- str(errortup[1]))
- value = [Error.make_instance(**callargs)]
+ if error is not None:
param = pywbem.CIMParameter('Errors', type='instance',
- is_array=True, array_size=1, value=value)
+ is_array=True, array_size=1, value=[error])
out_params.append(param)
return (self.values.GetErrors.Success, out_params)
@@ -372,4 +371,10 @@ class LMI_SoftwareInstallationJob(CIMProvider2):
the invocation request)
CIM_ERR_FAILED (some other unspecified error occurred)
"""
- raise pywbem.CIMError(pywbem.CIM_ERR_METHOD_NOT_AVAILABLE)
+ job = InstallationJob.object_path2job(object_name)
+ error = InstallationJob.job2error(job)
+ out_params = []
+ if error is not None:
+ param = pywbem.CIMParameter('Errors', type='instance', value=error)
+ out_params.append(param)
+ return (self.values.GetErrors.Success, out_params)
diff --git a/src/software/openlmi/software/cimom_entry.py b/src/software/openlmi/software/cimom_entry.py
index 033e06f..a83f2b8 100644
--- a/src/software/openlmi/software/cimom_entry.py
+++ b/src/software/openlmi/software/cimom_entry.py
@@ -44,6 +44,14 @@ from openlmi.software.LMI_SoftwareInstallationService import \
LMI_SoftwareInstallationService
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 YumDB
def get_providers(env):
@@ -65,7 +73,12 @@ def get_providers(env):
LMI_HostedSoftwareIdentityResource(env),
"LMI_SoftwareInstallationService" : \
LMI_SoftwareInstallationService(env),
- "LMI_SoftwareInstallationJob" : LMI_SoftwareInstallationJob(env)
+ "LMI_SoftwareInstallationJob" : LMI_SoftwareInstallationJob(env),
+ "LMI_SoftwareMethodResult" : LMI_SoftwareMethodResult(env),
+ "LMI_AffectedSoftwareJobElement" : LMI_AffectedSoftwareJobElement(env),
+ "LMI_AssociatedSoftwareJobMethodResult" : \
+ LMI_AssociatedSoftwareJobMethodResult(env),
+ "LMI_OwningSoftwareJobElement" : LMI_OwningSoftwareJobElement(env)
}
return providers
diff --git a/src/software/openlmi/software/core/ComputerSystem.py b/src/software/openlmi/software/core/ComputerSystem.py
index 9cbf725..48b4500 100644
--- a/src/software/openlmi/software/core/ComputerSystem.py
+++ b/src/software/openlmi/software/core/ComputerSystem.py
@@ -23,6 +23,8 @@ Just a common functionality related to associated class Linux_ComputerSystem.
import pywbem
import socket
+from openlmi.common import cmpi_logging
+
def get_path(prefix='Linux'):
"""
@return object path of Linux_ComputerSystem
@@ -34,6 +36,7 @@ def get_path(prefix='Linux'):
op["Name"] = socket.gethostname()
return op
+@cmpi_logging.trace_function
def check_path(env, system, prop_name):
"""
Checks instance name of ComputerSystem.
@@ -70,6 +73,7 @@ def check_path(env, system, prop_name):
prop_name, our_system['Name'])
return True
+@cmpi_logging.trace_function
def check_path_property(env, op, prop_name):
"""
Checks, whether object path contains correct instance name of
diff --git a/src/software/openlmi/software/core/Error.py b/src/software/openlmi/software/core/Error.py
index ccf4715..210c00e 100644
--- a/src/software/openlmi/software/core/Error.py
+++ b/src/software/openlmi/software/core/Error.py
@@ -22,6 +22,7 @@ Just a common functionality related to class CIM_Error.
import pywbem
+from openlmi.common import cmpi_logging
from openlmi.software.core import InstallationService
class Values(object):
@@ -414,6 +415,7 @@ class Values(object):
130 : 'Unexpected Information'
}
+@cmpi_logging.trace_function
def make_instance(
status_code=Values.CIMStatusCode.CIM_ERR_FAILED,
error_type=Values.ErrorType.Software_Error,
diff --git a/src/software/openlmi/software/core/Identity.py b/src/software/openlmi/software/core/Identity.py
index b7e8020..eda0ab9 100644
--- a/src/software/openlmi/software/core/Identity.py
+++ b/src/software/openlmi/software/core/Identity.py
@@ -162,6 +162,7 @@ class Values(object):
@cmpi_logging.trace_function
def object_path2nevra(op, with_epoch='NOT_ZERO'):
+ """Get nevra out of object path. Also checks for validity."""
if not isinstance(op, pywbem.CIMInstanceName):
raise pywbem.CIMError(pywbem.CIM_ERR_INVALID_PARAMETER,
"op must be an instance of CIMInstanceName")
@@ -185,8 +186,8 @@ def object_path2nevra(op, with_epoch='NOT_ZERO'):
return util.make_nevra(
match.group('name'),
epoch,
- match.group('ver'),
- match.group('rel'),
+ match.group('version'),
+ match.group('release'),
match.group('arch'), with_epoch=with_epoch)
@cmpi_logging.trace_function
@@ -224,85 +225,46 @@ def object_path2pkg(op,
op["InstanceID"])
@cmpi_logging.trace_function
-def pkg2model(pkg_info, keys_only=True, model=None):
+def pkg2model(pkg, keys_only=True, model=None):
"""
+ @param pkg can either be an instance of PackageInfo or nevra as string
@param model if not None, will be filled with data, otherwise
a new instance of CIMInstance or CIMObjectPath is created
"""
- if not isinstance(pkg_info, PackageInfo):
- raise TypeError("pkg must be an instance of PackageInfo")
+ if not isinstance(pkg, (basestring, PackageInfo)):
+ raise TypeError("pkg must be an instance of PackageInfo or nevra")
+ if isinstance(pkg, basestring) and not keys_only:
+ raise ValueError("can not create instance out of nevra")
if model is None:
model = pywbem.CIMInstanceName("LMI_SoftwareIdentity",
namespace="root/cimv2")
if not keys_only:
model = pywbem.CIMInstance("LMI_SoftwareIdentity", path=model)
- if isinstance(model, pywbem.CIMInstance):
- def _set_key(k, value):
- """Sets the value of key property of cim instance"""
- model[k] = value
- model.path[k] = value #pylint: disable=E1103
- else:
- _set_key = model.__setitem__
- _set_key('InstanceID', 'LMI:SoftwareIdentity:'+pkg_info.nevra)
+ nevra = pkg if isinstance(pkg, basestring) else pkg.nevra
+ model['InstanceID'] = 'LMI:SoftwareIdentity:'+nevra
if not keys_only:
- #model['BuildNumber'] = pywbem.Uint16() # TODO
- model['Caption'] = pkg_info.summary
- #model['ClassificationDescriptions'] = ['',] # TODO
+ model.path['InstanceID'] = model['InstanceID'] #pylint: disable=E1103
+ model['Caption'] = pkg.summary
model['Classifications'] = [pywbem.Uint16(0)]
- #model['CommunicationStatus'] = \
- # self.Values.CommunicationStatus.<VAL> # TODO
- model['Description'] = pkg_info.description
- #model['DetailedStatus'] = self.Values.DetailedStatus.<VAL> # TODO
- model['ElementName'] = pkg_info.nevra
- #model['ExtendedResourceType'] = \
- #self.Values.ExtendedResourceType.<VAL> # TODO
- #model['HealthState'] = self.Values.HealthState.<VAL> # TODO
- #model['IdentityInfoType'] = ['',] # TODO
- #model['IdentityInfoValue'] = ['',] # TODO
- if pkg_info.installed:
- model['InstallDate'] = pywbem.CIMDateTime(pkg_info.install_time)
+ model['Description'] = pkg.description
+ model['ElementName'] = pkg.nevra
+ if pkg.installed:
+ model['InstallDate'] = pywbem.CIMDateTime(pkg.install_time)
else:
model['InstallDate'] = pywbem.CIMProperty(
'InstallDate', None, type='datetime')
model['IsEntity'] = True
- #model['IsLargeBuildNumber'] = bool(False) # TODO
- #model['Languages'] = ['',] # TODO
- #model['LargeBuildNumber'] = pywbem.Uint64() # TODO
- #model['MajorVersion'] = pywbem.Uint16() # TODO
- #model['Manufacturer'] = '' # TODO
- #model['MinExtendedResourceTypeBuildNumber'] = \
- #pywbem.Uint16() # TODO
- #model['MinExtendedResourceTypeMajorVersion'] = \
- #pywbem.Uint16() # TODO
- #model['MinExtendedResourceTypeMinorVersion'] = \
- #pywbem.Uint16() # TODO
- #model['MinExtendedResourceTypeRevisionNumber'] = \
- #pywbem.Uint16() # TODO
- #model['MinorVersion'] = pywbem.Uint16() # TODO
- model['Name'] = pkg_info.name
+ model['Name'] = pkg.name
try:
- model["Epoch"] = pywbem.Uint32(int(pkg_info.epoch))
+ model["Epoch"] = pywbem.Uint32(int(pkg.epoch))
except ValueError:
cmpi_logging.logger.error('Could not convert epoch "%s"'
- ' to integer for package \"%s\"!' % (pkg_info.epoch, pkg_info))
+ ' to integer for package \"%s\"!' % (pkg.epoch, pkg))
model["Epoch"] = pywbem.CIMProperty('Epoch', None, type='uint32')
- model['Version'] = pkg_info.version
- model['Release'] = pkg_info.release
- model['Architecture'] = pkg_info.arch
- #model['OperatingStatus'] = \
- #self.Values.OperatingStatus.<VAL> # TODO
- #model['OperationalStatus'] = \
- #[self.Values.OperationalStatus.<VAL>,] # TODO
- #model['OtherExtendedResourceTypeDescription'] = '' # TODO
- #model['PrimaryStatus'] = self.Values.PrimaryStatus.<VAL> # TODO
- #model['ReleaseDate'] = pywbem.CIMDateTime() # TODO
- #model['RevisionNumber'] = pywbem.Uint16() # TODO
- #model['SerialNumber'] = '' # TODO
- #model['Status'] = self.Values.Status.<VAL> # TODO
- #model['StatusDescriptions'] = ['',] # TODO
- #model['TargetOperatingSystems'] = ['',] # TODO
- #model['TargetOSTypes'] = [pywbem.Uint16(),] # TODO
+ model['Version'] = pkg.version
+ model['Release'] = pkg.release
+ model['Architecture'] = pkg.arch
model['TargetTypes'] = ['rpm', 'yum']
- model['VersionString'] = pkg_info.evra
+ model['VersionString'] = pkg.evra
return model
diff --git a/src/software/openlmi/software/core/InstallationJob.py b/src/software/openlmi/software/core/InstallationJob.py
index b758f6e..2ac1f10 100644
--- a/src/software/openlmi/software/core/InstallationJob.py
+++ b/src/software/openlmi/software/core/InstallationJob.py
@@ -25,6 +25,7 @@ import pywbem
import time
from openlmi.common import cmpi_logging
+from openlmi.software.core import Error
from openlmi.software.yumdb import errors, jobs
from openlmi.software.yumdb import YumDB
@@ -384,6 +385,7 @@ class Values(object):
3: 'Error'
}
+@cmpi_logging.trace_function
def _fill_nonkeys(job, model):
"""
Fills into the model of instance all non-key properties.
@@ -440,6 +442,7 @@ def _fill_nonkeys(job, model):
model["MethodName"] = pywbem.CIMProperty('MethodName',
type='string', value=None)
model['Name'] = job.metadata['name']
+ model['LocalOrUtcTime'] = Values.LocalOrUtcTime.UTC_Time
model['PercentComplete'] = pywbem.Uint16(
100 if job.state == job.COMPLETED else (
50 if job.state == job.RUNNING else
@@ -509,7 +512,7 @@ def object_path2job(op):
return YumDB.get_instance().get_job(instid)
except errors.JobNotFound:
raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND,
- 'Not such job "%s".' % op['InstanceID'])
+ 'No such job "%s".' % op['InstanceID'])
@cmpi_logging.trace_function
def modify_instance(instance):
@@ -577,3 +580,31 @@ def modify_instance(instance):
return job2model(job, keys_only=False, model=instance)
+@cmpi_logging.trace_function
+def job2error(job):
+ """
+ @return instance of CIM_Error if job is in EXCEPTION state,
+ None otherwise
+ """
+ if not isinstance(job, jobs.YumJob):
+ raise TypeError("job must be isntance of YumJob")
+ if job.state == job.EXCEPTION:
+ errortup = job.result_data
+ kwargs = {}
+ if issubclass(errortup[0],
+ (errors.RepositoryNotFound, errors.PackageNotFound)):
+ kwargs['status_code'] = Error.Values. \
+ CIMStatusCode.CIM_ERR_NOT_FOUND
+ if issubclass(errortup[0], errors.PackageNotFound):
+ kwargs['status_code_description'] = \
+ "Package not found"
+ else:
+ kwargs['status_code_description'] = \
+ "Repository not found"
+ elif issubclass(errortup[0], errors.PackageAlreadyInstalled):
+ kwargs['status_code'] = Error.Values. \
+ CIMStatusCode.CIM_ERR_ALREADY_EXISTS
+ kwargs['message'] = getattr(errortup[1], 'message',
+ str(errortup[1]))
+ value = Error.make_instance(**kwargs)
+ return value
diff --git a/src/software/openlmi/software/core/InstallationService.py b/src/software/openlmi/software/core/InstallationService.py
index 56063f1..2935849 100644
--- a/src/software/openlmi/software/core/InstallationService.py
+++ b/src/software/openlmi/software/core/InstallationService.py
@@ -30,11 +30,6 @@ from openlmi.software.core import SystemCollection
from openlmi.software.yumdb import errors
from openlmi.software.yumdb import YumDB
-#UNSUPPORTED_INSTALL_OPTIONS = {
-# { "Defer_target_system_reset", "Force_installation",
-# "Reboot", "Password", "Log", "Silent_Mode", "Administrative_Mode",
-# "Schedule_Install_At", "DMTF_Reserved" }
-
class InstallationError(Exception):
"""This exception shall be raised upon any error within
install_or_remove_package() function.
@@ -555,6 +550,7 @@ def get_path():
op["Name"] = "LMI:SoftwareInstallationService"
return op
+@cmpi_logging.trace_function
def check_path(env, service, prop_name):
"""
Checks instance name of SoftwareInstallationService.
@@ -585,6 +581,7 @@ def check_path(env, service, prop_name):
prop_name, key, service[key], our_service[key]))
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.
@@ -595,6 +592,7 @@ def check_path_property(env, op, prop_name):
"Missing %s key property!" % prop_name)
return check_path(env, op[prop_name], prop_name)
+@cmpi_logging.trace_function
def _check_target_and_collection(env, src_type, target, collection):
"""
Checks Target and Collection parameters of provider's installation
@@ -625,6 +623,7 @@ def _check_target_and_collection(env, src_type, target, collection):
if src_type == "identity" else
"Missing Target parameter.")
+@cmpi_logging.trace_function
def _install_or_remove_check_params(
env, src_type, source, target, collection,
install_options,
@@ -685,6 +684,7 @@ def _install_or_remove_check_params(
, values.InstallOptions.Force_installation in options
, values.InstallOptions.Repair in options)
+@cmpi_logging.trace_function
def install_or_remove_package(env, src_type, source, target, collection,
install_options,
install_options_values):
diff --git a/src/software/openlmi/software/core/SystemCollection.py b/src/software/openlmi/software/core/SystemCollection.py
index 6fced8e..2d07130 100644
--- a/src/software/openlmi/software/core/SystemCollection.py
+++ b/src/software/openlmi/software/core/SystemCollection.py
@@ -21,6 +21,8 @@ Common utilities concerning SystemSoftwareCollection provider.
import pywbem
+from openlmi.common import cmpi_logging
+
def get_path():
"""@return instance name with prefilled properties"""
op = pywbem.CIMInstanceName(
@@ -29,6 +31,7 @@ def get_path():
op['InstanceID'] = "LMI:SystemSoftwareCollection"
return op
+@cmpi_logging.trace_function
def check_path(env, collection, prop_name):
"""
Checks instance name of SystemSoftwareCollection.
@@ -58,6 +61,7 @@ def check_path(env, collection, prop_name):
prop_name, our_collection['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.
diff --git a/src/software/openlmi/software/util/__init__.py b/src/software/openlmi/software/util/__init__.py
index f42f25a..9b0ab01 100644
--- a/src/software/openlmi/software/util/__init__.py
+++ b/src/software/openlmi/software/util/__init__.py
@@ -28,16 +28,16 @@ import re
import signal
RE_EVRA = re.compile(
- r'^(?P<epoch>\d+):(?P<ver>[^-]+)-(?P<rel>.+)\.(?P<arch>[^.]+)$')
+ r'^(?P<epoch>\d+):(?P<version>[^-]+)-(?P<release>.+)\.(?P<arch>[^.]+)$')
RE_NEVRA = re.compile(
- r'^(?P<name>.+)-(?P<evra>(?P<epoch>\d+):(?P<ver>[^-]+)'
- r'-(?P<rel>.+)\.(?P<arch>[^.]+))$')
+ r'^(?P<name>.+)-(?P<evra>(?P<epoch>\d+):(?P<version>[^-]+)'
+ r'-(?P<release>.+)\.(?P<arch>[^.]+))$')
RE_NEVRA_OPT_EPOCH = re.compile(
- r'^(?P<name>.+)-(?P<evra>((?P<epoch>\d+):)?(?P<ver>[^-]+)'
- r'-(?P<rel>.+)\.(?P<arch>[^.]+))$')
+ r'^(?P<name>.+)-(?P<evra>((?P<epoch>\d+):)?(?P<version>[^-]+)'
+ r'-(?P<release>.+)\.(?P<arch>[^.]+))$')
RE_ENVRA = re.compile(
- r'^(?P<epoch>\d+):(?P<name>.+)-(?P<evra>(?P<ver>[^-]+)'
- r'-(?P<rel>.+)\.(?P<arch>[^.]+))$')
+ r'^(?P<epoch>\d+):(?P<name>.+)-(?P<evra>(?P<version>[^-]+)'
+ r'-(?P<release>.+)\.(?P<arch>[^.]+))$')
def _get_distname():
"""
@@ -121,16 +121,16 @@ def nevra2filter(nevra):
else:
raise TypeError("nevra must be either string or regexp match object")
epoch = match.group("epoch")
- if not epoch or match.group("epoch") == "(none)":
+ if not epoch or match.group("epoch").lower() == "(none)":
epoch = "0"
- return { "name" : match.group("name")
- , "epoch" : epoch
- , "version" : match.group("ver")
- , "release" : match.group("rel")
- , "arch" : match.group("arch")
+ return { "name" : match.group("name")
+ , "epoch" : epoch
+ , "version" : match.group("version")
+ , "release" : match.group("release")
+ , "arch" : match.group("arch")
}
-def make_nevra(name, epoch, ver, rel, arch, with_epoch='NOT_ZERO'):
+def make_nevra(name, epoch, version, release, arch, with_epoch='NOT_ZERO'):
"""
@param with_epoch may be one of:
"NOT_ZERO" - include epoch only if it's not zero
@@ -145,7 +145,7 @@ def make_nevra(name, epoch, ver, rel, arch, with_epoch='NOT_ZERO'):
estr = epoch
if len(estr):
estr += ":"
- return "%s-%s%s-%s.%s" % (name, estr, ver, rel, arch)
+ return "%s-%s%s-%s.%s" % (name, estr, version, release, arch)
def pkg2nevra(pkg, with_epoch='NOT_ZERO'):
"""
diff --git a/src/software/openlmi/software/yumdb/__init__.py b/src/software/openlmi/software/yumdb/__init__.py
index 13539bb..b5160b4 100644
--- a/src/software/openlmi/software/yumdb/__init__.py
+++ b/src/software/openlmi/software/yumdb/__init__.py
@@ -275,7 +275,7 @@ class YumDB(singletonmixin.Singleton):
'level=%d', self._session_level)
new_session_job = jobs.YumBeginSession()
self._worker.uplink.put(new_session_job)
- (_, reply) = self._worker.downlink.get()
+ reply = self._worker.downlink.get()
log_reply_error(new_session_job, reply)
self._worker.uplink.put(job)
self._expected.append(job.jobid)
@@ -381,8 +381,8 @@ class YumDB(singletonmixin.Singleton):
uplink = Queue()
downlink = Queue()
self._process = YumWorker(uplink, downlink,
- yum_kwargs=self._yum_kwargs,
- logging_config=YUM_WORKER_DEBUG_LOGGING_CONFIG)
+ yum_kwargs=self._yum_kwargs)
+ #logging_config=YUM_WORKER_DEBUG_LOGGING_CONFIG)
self._process.start()
cmpi_logging.logger.trace_info(
"YumDB: YumWorker started with pid=%s", self._process.pid)
diff --git a/src/software/openlmi/software/yumdb/packageinfo.py b/src/software/openlmi/software/yumdb/packageinfo.py
index a088993..bfacc5d 100644
--- a/src/software/openlmi/software/yumdb/packageinfo.py
+++ b/src/software/openlmi/software/yumdb/packageinfo.py
@@ -152,6 +152,15 @@ class PackageInfo(object):
for k, value in state.items():
setattr(self, k, value)
+ def __eq__(self, other):
+ return ( self.name == other.name
+ and self.version == other.version
+ and self.release == other.release
+ and self.arch == other.arch
+ and self.epoch == other.epoch
+ and ( (self.repoid is None or other.repoid is None)
+ or (self.repoid == other.repoid)))
+
def make_package_from_db(pkg):
"""
Create instance of PackageInfo from instance of
diff --git a/src/software/openlmi/software/yumdb/process.py b/src/software/openlmi/software/yumdb/process.py
index 5f43c35..0b0c4c1 100644
--- a/src/software/openlmi/software/yumdb/process.py
+++ b/src/software/openlmi/software/yumdb/process.py
@@ -77,8 +77,6 @@ def _get_package_filter_function(filters):
if match is not None:
for attr in ("name", "epoch", "version", "release", "arch"):
match_attr = attr
- if attr in {'version', 'release'}:
- match_attr = attr[:3]
filters[attr] = match.group(match_attr)
filters.pop('nevra', None)
filters.pop('envra', None)
@@ -174,8 +172,11 @@ def _needs_database(method):
"""
Wrapper for the job handler method.
"""
+ created_session = False
self._init_database() #pylint: disable=W0212
if self._session_level == 0: #pylint: disable=W0212
+ self._session_level = 1 #pylint: disable=W0212
+ created_session = True
self._lock_database() #pylint: disable=W0212
try:
LOG.debug("calling job handler %s with args=(%s)",
@@ -187,7 +188,8 @@ def _needs_database(method):
LOG.debug("job handler %s finished", method.__name__)
return result
finally:
- if self._session_level == 0: #pylint: disable=W0212
+ if created_session is True: #pylint: disable=W0212
+ self._session_level = 0 #pylint: disable=W0212
self._unlock_database() #pylint: disable=W0212
return _wrapper
diff --git a/src/software/test/test_installed_software_identity.py b/src/software/test/test_installed_software_identity.py
index b796156..ade841b 100755
--- a/src/software/test/test_installed_software_identity.py
+++ b/src/software/test/test_installed_software_identity.py
@@ -202,8 +202,7 @@ class TestInstalledSoftwareIdentity(base.SoftwareBaseTestCase):
with self.assertRaises(pywbem.CIMError) as cm:
self.conn.DeleteInstance(InstanceName=objpath)
- self.assertEqual(cm.exception.args[0],
- pywbem.CIM_ERR_NOT_FOUND)
+ self.assertEqual(cm.exception.args[0], pywbem.CIM_ERR_NOT_FOUND)
@base.mark_tedious
def test_get_system_referents(self):