summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortim.potter <tim.potter>2006-04-26 16:15:23 +0000
committertim.potter <tim.potter>2006-04-26 16:15:23 +0000
commit8a1395b41e3a35e6198eac43489cfe55374b028f (patch)
tree7c8a2f2b0d8b97b58f6e30a115fd4bb2e19950a7
parent6f43ce52942d82dd4297544622e3586328beefdf (diff)
downloadtog-pegasus-TASK-PEP250_RPMProvider-branch.zip
tog-pegasus-TASK-PEP250_RPMProvider-branch.tar.gz
tog-pegasus-TASK-PEP250_RPMProvider-branch.tar.xz
TITLE: RPM Provider DESCRIPTION: Checking in initial code, for review.
-rw-r--r--src/Providers/ManagedSystem/Makefile5
-rw-r--r--src/Providers/ManagedSystem/RPM/Makefile65
-rw-r--r--src/Providers/ManagedSystem/RPM/RPMProvider.cpp867
-rw-r--r--src/Providers/ManagedSystem/RPM/RPMProvider.h240
-rw-r--r--src/Providers/ManagedSystem/RPM/RPMProvider.mof114
-rw-r--r--src/Providers/ManagedSystem/RPM/RPMProviderMain.cpp50
-rw-r--r--src/Providers/ManagedSystem/RPM/RPMProviderR.mof80
-rw-r--r--src/Providers/ManagedSystem/RPM/RPMProviderUtils.cpp428
-rw-r--r--src/Providers/ManagedSystem/RPM/RPMProviderUtils.h100
-rw-r--r--src/Providers/ManagedSystem/RPM/RPMProviderUtils_Linux.cpp37
-rw-r--r--src/Providers/ManagedSystem/RPM/RPMProviderUtils_Unknown.cpp37
-rw-r--r--src/Providers/ManagedSystem/RPM/RPMWrapper.cpp74
-rw-r--r--src/Providers/ManagedSystem/RPM/RPMWrapper.h59
13 files changed, 2155 insertions, 1 deletions
diff --git a/src/Providers/ManagedSystem/Makefile b/src/Providers/ManagedSystem/Makefile
index 17063c7..47a03c9 100644
--- a/src/Providers/ManagedSystem/Makefile
+++ b/src/Providers/ManagedSystem/Makefile
@@ -79,5 +79,8 @@ ifeq ($(PEGASUS_OS_TYPE),VMS)
DNSService/tests/testclient
endif
-include $(ROOT)/mak/recurse.mak
+ifeq ($(OS),linux)
+ DIRS += RPM
+endif
+include $(ROOT)/mak/recurse.mak
diff --git a/src/Providers/ManagedSystem/RPM/Makefile b/src/Providers/ManagedSystem/RPM/Makefile
new file mode 100644
index 0000000..8208c99
--- /dev/null
+++ b/src/Providers/ManagedSystem/RPM/Makefile
@@ -0,0 +1,65 @@
+#//%2006////////////////////////////////////////////////////////////////////////
+#//
+#// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
+#// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
+#// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
+#// IBM Corp.; EMC Corporation, The Open Group.
+#// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
+#// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
+#// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
+#// EMC Corporation; VERITAS Software Corporation; The Open Group.
+#//
+#// Permission is hereby granted, free of charge, to any person obtaining a copy
+#// of this software and associated documentation files (the "Software"), to
+#// deal in the Software without restriction, including without limitation the
+#// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+#// sell copies of the Software, and to permit persons to whom the Software is
+#// furnished to do so, subject to the following conditions:
+#//
+#// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
+#// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
+#// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+#// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+#// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+#// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+#// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+#// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#//
+#//==============================================================================
+#//
+#// Author: Tim Potter <tpot@hp.com>
+#//
+#//%////////////////////////////////////////////////////////////////////////////
+
+ROOT = ../../../..
+
+DIR = Providers/ManagedSystem/RPM
+
+include $(ROOT)/mak/config.mak
+
+LIBRARY = RPMProvider
+
+EXTRA_INCLUDES =
+
+SOURCES = \
+ RPMProvider.cpp \
+ RPMProviderMain.cpp \
+ RPMProviderUtils.cpp \
+ RPMWrapper.cpp
+
+LIBRARIES = \
+ pegprovider \
+ pegclient \
+ pegcommon
+
+DYNAMIC_LIBRARIES = \
+ -lpegcommon \
+ -lpegprovider
+
+ifeq ($(OS),linux)
+ EXTRA_LIBRARIES += -lrpm
+endif
+
+include $(ROOT)/mak/dynamic-library.mak
+
+tests:
diff --git a/src/Providers/ManagedSystem/RPM/RPMProvider.cpp b/src/Providers/ManagedSystem/RPM/RPMProvider.cpp
new file mode 100644
index 0000000..1a3b433
--- /dev/null
+++ b/src/Providers/ManagedSystem/RPM/RPMProvider.cpp
@@ -0,0 +1,867 @@
+//%2006////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
+// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
+// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation, The Open Group.
+// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
+// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
+// EMC Corporation; VERITAS Software Corporation; The Open Group.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
+// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
+// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//=============================================================================
+//
+// Author: Tim Potter <tpot@hp.com>
+//
+//%////////////////////////////////////////////////////////////////////////////
+
+#include <Pegasus/Provider/CIMInstanceProvider.h>
+
+PEGASUS_USING_PEGASUS;
+PEGASUS_USING_STD;
+
+#include <fcntl.h>
+#include <syslog.h>
+
+#include "RPMProvider.h"
+#include "RPMProviderUtils.h"
+
+RPMProvider::RPMProvider()
+{
+}
+
+RPMProvider::~RPMProvider()
+{
+}
+
+void RPMProvider::initialize(CIMOMHandle &handle)
+{
+ // Initialise RPM database
+
+ if (rpmReadConfigFiles(NULL, NULL) != 0)
+ throw CIMException(CIM_ERR_FAILED, "rpmReadConfigFiles() failed");
+
+ if (rpmdbOpen(NULL, &_db, O_RDONLY, 0644) != 0)
+ throw CIMException(CIM_ERR_FAILED, "rpmdbOpen() failed");
+}
+
+void RPMProvider::terminate()
+{
+ // Clean up RPM database
+
+ rpmdbClose(_db);
+
+ delete this;
+}
+
+// Return arrays of package objects
+
+Array<CIMInstance>
+RPMProvider::enumeratePackageInstances()
+{
+ Array<CIMInstance> instances;
+
+ IterWrapper iter(rpmdbInitIterator(_db, RPMTAG_NAME, NULL, 0));
+
+ if (iter.isNull())
+ return instances;
+
+ for (Header h = rpmdbNextIterator(iter); h;
+ h = Header(rpmdbNextIterator(iter))) {
+
+ instances.append(packageInstanceFromHeader(h));
+ }
+
+ return instances;
+}
+
+Array<CIMObjectPath>
+RPMProvider::enumeratePackageInstanceNames()
+{
+ Array<CIMObjectPath> paths;
+
+ IterWrapper iter(rpmdbInitIterator(_db, RPMTAG_NAME, NULL, 0));
+
+ if (iter.isNull())
+ return paths;
+
+ for (Header h = rpmdbNextIterator(iter); h; h = rpmdbNextIterator(iter)) {
+ paths.append(packageObjectPathFromHeader(h));
+ }
+
+ return paths;
+}
+
+// Return arrays of file objects
+
+Array<CIMInstance>
+RPMProvider::enumerateFileInstances()
+{
+ Array<CIMInstance> instances;
+
+ IterWrapper iter(rpmdbInitIterator(_db, RPMTAG_BASENAMES, NULL, 0));
+
+ if (iter.isNull())
+ return instances;
+
+ for (Header h = rpmdbNextIterator(iter); h; h = rpmdbNextIterator(iter)) {
+ Array<CIMInstance> files(fileInstancesFromHeader(h));
+
+ for (Uint32 i = 0; i < files.size(); i++)
+ instances.append(files[i]);
+ }
+
+ return instances;
+}
+
+Array<CIMObjectPath>
+RPMProvider::enumerateFileInstanceNames()
+{
+ Array<CIMObjectPath> paths;
+
+ IterWrapper iter(rpmdbInitIterator(_db, RPMTAG_BASENAMES, NULL, 0));
+
+ if (iter.isNull())
+ return paths;
+
+ for (Header h = rpmdbNextIterator(iter); h; h = rpmdbNextIterator(iter)) {
+ Array<CIMObjectPath> files(fileObjectPathsFromHeader(h));
+
+ for (Uint32 i = 0; i < files.size(); i++)
+ paths.append(files[i]);
+ }
+
+ return paths;
+}
+
+// Return arrays of product objects
+
+Array<CIMInstance>
+RPMProvider::enumerateProductInstances()
+{
+ Array<CIMInstance> instances;
+
+ IterWrapper iter (rpmdbInitIterator(_db, RPMTAG_NAME, NULL, 0));
+
+ if (iter.isNull())
+ return instances;
+
+ for (Header h = rpmdbNextIterator(iter); h; h = rpmdbNextIterator(iter)) {
+ instances.append(productInstanceFromHeader(h));
+ }
+
+ return instances;
+}
+
+Array<CIMObjectPath>
+RPMProvider::enumerateProductInstanceNames()
+{
+ Array<CIMObjectPath> paths;
+
+ IterWrapper iter(rpmdbInitIterator(_db, RPMTAG_NAME, NULL, 0));
+
+ if (iter.isNull())
+ return paths;
+
+ for (Header h = rpmdbNextIterator(iter); h; h = rpmdbNextIterator(iter)) {
+ paths.append(productObjectPathFromHeader(h));
+ }
+
+ return paths;
+}
+
+// Return the value of the string Name property for an object reference
+
+static String
+nameFromReference(const CIMObjectPath &ref)
+{
+ Array<CIMKeyBinding> kb(ref.getKeyBindings());
+
+ for (Uint32 i = 0; i < kb.size(); i++) {
+ if (kb[i].getName() == "Name") {
+ if (kb[i].getType() == CIMKeyBinding::STRING) {
+ return kb[i].getValue();
+ }
+ }
+ }
+
+ return String::EMPTY;
+}
+
+// getInstance helpers
+
+void
+RPMProvider::getPackageInstance(const OperationContext &context,
+ const CIMObjectPath &ref,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ InstanceResponseHandler &handler)
+{
+ String name(nameFromReference(ref));
+
+ if (name == String::EMPTY)
+ return;
+
+ IterWrapper iter(rpmdbInitIterator
+ (_db, RPMTAG_NAME, (const char *)name.getCString(), 0));
+
+ if (iter.isNull())
+ throw CIMException(CIM_ERR_NOT_FOUND);
+
+ Header h = rpmdbNextIterator(iter);
+ CIMInstance package = packageInstanceFromHeader(h);
+
+ if (package.getPath() != ref)
+ throw CIMException(CIM_ERR_NOT_FOUND);
+
+ handler.processing();
+ handler.deliver(package);
+ handler.complete();
+}
+
+void
+RPMProvider::getFileInstance(const OperationContext&context,
+ const CIMObjectPath&ref,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList&propertyList,
+ InstanceResponseHandler &handler)
+{
+ String name(nameFromReference(ref).getCString());
+
+ if (name == String::EMPTY)
+ return;
+
+ IterWrapper iter(rpmdbInitIterator
+ (_db, RPMTAG_NAME, (const char *)name.getCString(), 0));
+
+ if (iter.isNull())
+ throw CIMException(CIM_ERR_NOT_FOUND);
+
+ Header h = rpmdbNextIterator(iter);
+
+ Array<CIMInstance> files = fileInstancesFromHeader(h);
+
+ for (Uint32 i = 0; i < files.size(); i++) {
+ if (files[i].getPath() == ref) {
+ handler.processing();
+ handler.deliver(files[i]);
+ handler.complete();
+ return;
+ }
+ }
+
+ throw CIMException(CIM_ERR_NOT_FOUND);
+}
+
+void
+RPMProvider::getProductInstance(const OperationContext &context,
+ const CIMObjectPath& ref,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ InstanceResponseHandler &handler)
+{
+ String name(nameFromReference(ref));
+
+ if (name == String::EMPTY)
+ return;
+
+ IterWrapper iter(rpmdbInitIterator
+ (_db, RPMTAG_NAME, (const char *)name.getCString(), 0));
+
+ if (iter.isNull())
+ throw CIMException(CIM_ERR_NOT_FOUND);
+
+ Header h = rpmdbNextIterator(iter);
+ CIMInstance product = productInstanceFromHeader(h);
+
+ if (product.getPath() != ref)
+ throw CIMException(CIM_ERR_NOT_FOUND);
+
+ handler.processing();
+ handler.deliver(product);
+ handler.complete();
+}
+
+//
+// Instance provider methods
+//
+
+void
+RPMProvider::getInstance(const OperationContext &context,
+ const CIMObjectPath &ref,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ InstanceResponseHandler &handler)
+{
+ if (ref.getClassName() == PackageClassName)
+ return getPackageInstance(context, ref, includeQualifiers,
+ includeClassOrigin, propertyList, handler);
+
+ if (ref.getClassName() == FileClassName)
+ return getFileInstance(context, ref, includeQualifiers,
+ includeClassOrigin, propertyList, handler);
+
+ if (ref.getClassName() == ProductClassName)
+ return getProductInstance(context, ref, includeQualifiers,
+ includeClassOrigin, propertyList, handler);
+
+ throw CIMException(CIM_ERR_NOT_FOUND);
+}
+
+void
+RPMProvider::enumerateInstances(const OperationContext &context,
+ const CIMObjectPath &ref,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ InstanceResponseHandler &handler)
+{
+ handler.processing();
+
+ if (ref.getClassName() == PackageClassName)
+ handler.deliver(enumeratePackageInstances());
+
+ if (ref.getClassName() == FileClassName)
+ handler.deliver(enumerateFileInstances());
+
+ if (ref.getClassName() == ProductClassName)
+ handler.deliver(enumerateProductInstances());
+
+ handler.complete();
+}
+
+void
+RPMProvider::enumerateInstanceNames(const OperationContext &context,
+ const CIMObjectPath &ref,
+ ObjectPathResponseHandler &handler)
+{
+ handler.processing();
+
+ if (ref.getClassName() == PackageClassName)
+ handler.deliver(enumeratePackageInstanceNames());
+
+ if (ref.getClassName() == FileClassName)
+ handler.deliver(enumerateFileInstanceNames());
+
+ if (ref.getClassName() == ProductClassName)
+ handler.deliver(enumerateProductInstanceNames());
+
+ handler.complete();
+}
+
+// Write operations are not supported
+
+void
+RPMProvider::modifyInstance(const OperationContext &context,
+ const CIMObjectPath &ref,
+ const CIMInstance &instanceObject,
+ const Boolean includeQualifiers,
+ const CIMPropertyList &propertyList,
+ ResponseHandler &handler)
+{
+ throw CIMNotSupportedException("RPMProvider "
+ "does not support modifyInstance");
+}
+
+void
+RPMProvider::createInstance(const OperationContext &context,
+ const CIMObjectPath &ref,
+ const CIMInstance &instanceObject,
+ ObjectPathResponseHandler &handler)
+{
+ throw CIMNotSupportedException("RPMProvider "
+ "does not support createInstance");
+}
+
+void
+RPMProvider::deleteInstance(const OperationContext &context,
+ const CIMObjectPath &ref,
+ ResponseHandler &handler)
+{
+ throw CIMNotSupportedException("RPMProvider "
+ "does not support deleteInstance");
+}
+
+//
+// Association provider methods
+//
+
+// Given a PG_RPMPackage instance name, return all the PG_RPMFileCheck
+// instances associated with it.
+
+void
+RPMProvider::packageAssociators(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &associationClass,
+ const CIMName &resultClass,
+ const String &role,
+ const String &resultRole,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ ObjectResponseHandler &handler)
+{
+ String name(nameFromReference(objectName));
+
+ if (name == String::EMPTY)
+ return;
+
+ IterWrapper iter(rpmdbInitIterator
+ (_db, RPMTAG_NAME, (const char *)name.getCString(), 0));
+
+ if (iter.isNull())
+ return;
+
+ handler.processing();
+
+ for (Header h = rpmdbNextIterator(iter); h; h = rpmdbNextIterator(iter)) {
+
+ // Check for package match
+
+ CIMInstance package = packageInstanceFromHeader(h);
+
+ if (package.getPath() != objectName)
+ continue;
+
+ // Return associated files
+
+ Array<CIMInstance> files = fileInstancesFromHeader(h);
+
+ for (Uint32 i = 0; i < files.size(); i++)
+ handler.deliver(files[i]);
+ }
+
+ handler.complete();
+}
+
+// Given a PG_RPMFileCheck instance name, return the PG_RPMPackage
+// instance associated with it.
+
+void
+RPMProvider::fileAssociators(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &associationClass,
+ const CIMName &resultClass,
+ const String &role,
+ const String &resultRole,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ ObjectResponseHandler &handler)
+{
+ String name(nameFromReference(objectName));
+
+ if (name == String::EMPTY)
+ return;
+
+ IterWrapper iter(rpmdbInitIterator
+ (_db, RPMTAG_NAME, (const char *)name.getCString(), 0));
+
+ if (iter.isNull())
+ return;
+
+ handler.processing();
+
+ for (Header h = rpmdbNextIterator(iter); h; h = rpmdbNextIterator(iter)) {
+ Array<CIMObjectPath> files = fileObjectPathsFromHeader(h);
+
+ for (Uint32 i = 0; i < files.size(); i++) {
+ if (files[i] == objectName) {
+ handler.deliver(packageInstanceFromHeader(h));
+ break;
+ }
+ }
+ }
+
+ handler.complete();
+}
+
+// Return CIMObjectPath's for files associated with a package
+
+void
+RPMProvider::packageAssociatorNames(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &associationClass,
+ const CIMName &resultClass,
+ const String &role,
+ const String &resultRole,
+ ObjectPathResponseHandler &handler)
+{
+ String name(nameFromReference(objectName));
+
+ if (name == String::EMPTY)
+ return;
+
+ IterWrapper iter(rpmdbInitIterator
+ (_db, RPMTAG_NAME, (const char *)name.getCString(), 0));
+
+ if (iter.isNull())
+ return;
+
+ handler.processing();
+
+ for (Header h = rpmdbNextIterator(iter); h; h = rpmdbNextIterator(iter)) {
+
+ // Check for package match
+
+ CIMObjectPath package(packageObjectPathFromHeader(h));
+
+ if (package != objectName)
+ continue;
+
+ // Return associated files
+
+ Array<CIMObjectPath> files(fileObjectPathsFromHeader(h));
+
+ for (Uint32 i = 0; i < files.size(); i++)
+ handler.deliver(files[i]);
+ }
+
+ handler.complete();
+}
+
+// Return CIMObjectPath for package associated with a file
+
+void
+RPMProvider::fileAssociatorNames(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &associationClass,
+ const CIMName &resultClass,
+ const String &role,
+ const String &resultRole,
+ ObjectPathResponseHandler &handler)
+{
+ String name(nameFromReference(objectName));
+
+ if (name == String::EMPTY)
+ return;
+
+ IterWrapper iter(rpmdbInitIterator
+ (_db, RPMTAG_NAME, (const char *)name.getCString(), 0));
+
+ if (iter.isNull())
+ return;
+
+ handler.processing();
+
+ for (Header h = rpmdbNextIterator(iter); h; h = rpmdbNextIterator(iter)) {
+ Array<CIMInstance> files = fileInstancesFromHeader(h);
+
+ for (Uint32 i = 0; i < files.size(); i++) {
+ if (files[i].getPath() == objectName) {
+ handler.deliver(packageObjectPathFromHeader(h));
+ break;
+ }
+ }
+ }
+
+ handler.complete();
+}
+
+void
+RPMProvider::associators(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &associationClass,
+ const CIMName &resultClass,
+ const String &role,
+ const String &resultRole,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ ObjectResponseHandler &handler)
+{
+ if (objectName.getClassName() == PackageClassName)
+ return packageAssociators(context,
+ objectName,
+ associationClass,
+ resultClass,
+ role,
+ resultRole,
+ includeQualifiers,
+ includeClassOrigin,
+ propertyList,
+ handler);
+
+ if (objectName.getClassName() == FileClassName)
+ return fileAssociators(context,
+ objectName,
+ associationClass,
+ resultClass,
+ role,
+ resultRole,
+ includeQualifiers,
+ includeClassOrigin,
+ propertyList,
+ handler);
+}
+
+void
+RPMProvider::associatorNames(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &associationClass,
+ const CIMName &resultClass,
+ const String &role,
+ const String &resultRole,
+ ObjectPathResponseHandler &handler)
+{
+ if (objectName.getClassName() == PackageClassName)
+ return packageAssociatorNames(context,
+ objectName,
+ associationClass,
+ resultClass,
+ role,
+ resultRole,
+ handler);
+
+ if (objectName.getClassName() == FileClassName)
+ return fileAssociatorNames(context,
+ objectName,
+ associationClass,
+ resultClass,
+ role,
+ resultRole,
+ handler);
+}
+
+// Given a PG_RPMPackage instance name, return all the
+// PG_RPMAssociatedFile instances referenced by it.
+
+void
+RPMProvider::packageReferences(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &resultClass,
+ const String &role,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ ObjectResponseHandler &handler)
+{
+ String name(nameFromReference(objectName));
+
+ if (name == String::EMPTY)
+ return;
+
+ IterWrapper iter(rpmdbInitIterator
+ (_db, RPMTAG_NAME, (const char *)name.getCString(), 0));
+
+ if (iter.isNull())
+ return;
+
+ handler.processing();
+
+ for (Header h = rpmdbNextIterator(iter); h; h = rpmdbNextIterator(iter)) {
+
+ // Check for package match
+
+ CIMObjectPath package = packageObjectPathFromHeader(h);
+
+ if (package != objectName)
+ continue;
+
+ // Return associated files
+
+ Array<CIMInstance> files = fileReferencesFromHeader(h);
+
+ for (Uint32 i = 0; i < files.size(); i++)
+ handler.deliver(files[i]);
+ }
+
+ handler.complete();
+}
+
+// Given a PG_RPMFileCheck instance name, return the
+// PG_RPMAssociatedFile instance referenced by it.
+
+void
+RPMProvider::fileReferences(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &resultClass,
+ const String &role,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ ObjectResponseHandler &handler)
+{
+ String name(nameFromReference(objectName));
+
+ if (name == String::EMPTY)
+ return;
+
+ IterWrapper iter(rpmdbInitIterator
+ (_db, RPMTAG_NAME, (const char *)name.getCString(), 0));
+
+ if (iter.isNull())
+ return;
+
+ handler.processing();
+
+ for (Header h = rpmdbNextIterator(iter); h; h = rpmdbNextIterator(iter)) {
+
+ Array<CIMInstance> files = fileInstancesFromHeader(h);
+
+ for (Uint32 i = 0; i < files.size(); i++) {
+ if (files[i].getPath() == objectName) {
+ handler.deliver(packageReferenceFromHeader
+ (h, files[i].getPath()));
+ break;
+ }
+ }
+ }
+
+ handler.complete();
+}
+
+// Given a PG_RPMPackage instance name, return all the
+// PG_RPMAssociatedFile instance names referenced by it.
+
+void
+RPMProvider::packageReferenceNames(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &resultClass,
+ const String &role,
+ ObjectPathResponseHandler &handler)
+{
+ String name(nameFromReference(objectName));
+
+ if (name == String::EMPTY)
+ return;
+
+ IterWrapper iter(rpmdbInitIterator
+ (_db, RPMTAG_NAME, (const char *)name.getCString(), 0));
+
+ if (iter.isNull())
+ return;
+
+ handler.processing();
+
+ for (Header h = rpmdbNextIterator(iter); h; h = rpmdbNextIterator(iter)) {
+
+ // Check for package match
+
+ CIMObjectPath package = packageObjectPathFromHeader(h);
+
+ if (package != objectName)
+ continue;
+
+ // Return associated files
+
+ Array<CIMObjectPath> files = fileReferenceNamesFromHeader(h);
+
+ for (Uint32 i = 0; i < files.size(); i++)
+ handler.deliver(files[i]);
+ }
+
+ handler.complete();
+}
+
+// Given a PG_RPMFileCheck instance name, return the
+// PG_RPMAssociatedFile instance name referenced by it.
+
+void
+RPMProvider::fileReferenceNames(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &resultClass,
+ const String &role,
+ ObjectPathResponseHandler &handler)
+{
+ String name(nameFromReference(objectName));
+
+ if (name == String::EMPTY)
+ return;
+
+ IterWrapper iter(rpmdbInitIterator
+ (_db, RPMTAG_NAME, (const char *)name.getCString(), 0));
+
+ if (iter.isNull())
+ return;
+
+ handler.processing();
+
+ for (Header h = rpmdbNextIterator(iter); h; h = rpmdbNextIterator(iter)) {
+
+ Array<CIMInstance> files = fileInstancesFromHeader(h);
+
+ for (Uint32 i = 0; i < files.size(); i++) {
+ if (files[i].getPath() == objectName) {
+ handler.deliver(packageReferenceNameFromHeader
+ (h, files[i].getPath()));
+ break;
+ }
+ }
+ }
+
+ handler.complete();
+}
+
+void
+RPMProvider::references(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &resultClass,
+ const String &role,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ ObjectResponseHandler &handler)
+{
+ if (objectName.getClassName() == PackageClassName)
+ return packageReferences(context,
+ objectName,
+ resultClass,
+ role,
+ includeQualifiers,
+ includeClassOrigin,
+ propertyList,
+ handler);
+
+ if (objectName.getClassName() == FileClassName)
+ return fileReferences(context,
+ objectName,
+ resultClass,
+ role,
+ includeQualifiers,
+ includeClassOrigin,
+ propertyList,
+ handler);
+}
+
+void
+RPMProvider::referenceNames(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &resultClass,
+ const String &role,
+ ObjectPathResponseHandler &handler)
+{
+ if (objectName.getClassName() == PackageClassName)
+ return packageReferenceNames(context,
+ objectName,
+ resultClass,
+ role,
+ handler);
+
+ if (objectName.getClassName() == FileClassName)
+ return fileReferenceNames(context,
+ objectName,
+ resultClass,
+ role,
+ handler);
+}
diff --git a/src/Providers/ManagedSystem/RPM/RPMProvider.h b/src/Providers/ManagedSystem/RPM/RPMProvider.h
new file mode 100644
index 0000000..d324ef4
--- /dev/null
+++ b/src/Providers/ManagedSystem/RPM/RPMProvider.h
@@ -0,0 +1,240 @@
+//%2006////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
+// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
+// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation, The Open Group.
+// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
+// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
+// EMC Corporation; VERITAS Software Corporation; The Open Group.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
+// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
+// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//=============================================================================
+//
+// Author: Tim Potter <tpot@hp.com>
+//
+//%/////////////////////////////////////////////////////////////////////////
+
+#ifndef _RPMPROVIDER_H
+#define _RPMPROVIDER_H
+
+#include <Pegasus/Provider/CIMInstanceProvider.h>
+#include <Pegasus/Provider/CIMAssociationProvider.h>
+#include "RPMProviderUtils.h"
+
+class RPMProvider:
+ public CIMInstanceProvider,
+ public CIMAssociationProvider {
+
+ public:
+
+ RPMProvider();
+ ~RPMProvider();
+
+ // CIMProvider methods
+
+ void initialize(CIMOMHandle &handle);
+ void terminate();
+
+ // CIMInstanceProvider methods
+
+ void getInstance(const OperationContext &context,
+ const CIMObjectPath &ref,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ InstanceResponseHandler &handler);
+
+ void enumerateInstances(const OperationContext &context,
+ const CIMObjectPath &ref,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ InstanceResponseHandler &handler);
+
+ void enumerateInstanceNames(const OperationContext &context,
+ const CIMObjectPath &ref,
+ ObjectPathResponseHandler &handler);
+
+ void modifyInstance(const OperationContext &context,
+ const CIMObjectPath &ref,
+ const CIMInstance &instanceObject,
+ const Boolean includeQualifiers,
+ const CIMPropertyList &propertyList,
+ ResponseHandler &handler);
+
+ void createInstance(const OperationContext &context,
+ const CIMObjectPath &ref,
+ const CIMInstance &instanceObject,
+ ObjectPathResponseHandler &handler);
+
+ void deleteInstance(const OperationContext &context,
+ const CIMObjectPath &ref,
+ ResponseHandler &handler);
+
+ // CIMAssociationProvider methods
+
+ void associators(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &associationClass,
+ const CIMName &resultClass,
+ const String &role,
+ const String &resultRole,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ ObjectResponseHandler &handler);
+
+ void associatorNames(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &associationClass,
+ const CIMName &resultClass,
+ const String &role,
+ const String &resultRole,
+ ObjectPathResponseHandler &handler);
+
+ void references(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &resultClass,
+ const String &role,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ ObjectResponseHandler &handler);
+
+ void referenceNames(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &resultClass,
+ const String &role,
+ ObjectPathResponseHandler &handler);
+
+ private:
+
+ // Helpers for enumerateInstanceNames() and enumerateInstances()
+
+ Array<CIMObjectPath> enumeratePackageInstanceNames();
+ Array<CIMInstance> enumeratePackageInstances();
+
+ Array<CIMObjectPath> enumerateFileInstanceNames();
+ Array<CIMInstance> enumerateFileInstances();
+
+ Array<CIMObjectPath> enumerateProductInstanceNames();
+ Array<CIMInstance> enumerateProductInstances();
+
+ // Helpers for getInstance()
+
+ void getPackageInstance(const OperationContext &context,
+ const CIMObjectPath &ref,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ InstanceResponseHandler &handler);
+
+ void getFileInstance(const OperationContext &context,
+ const CIMObjectPath &ref,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ InstanceResponseHandler &handler);
+
+ void getProductInstance(const OperationContext &context,
+ const CIMObjectPath &ref,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ InstanceResponseHandler &handler);
+
+ // Helpers for associators() and associatorNames()
+
+ void packageAssociators(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &associationClass,
+ const CIMName &resultClass,
+ const String &role,
+ const String &resultRole,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ ObjectResponseHandler &handler);
+
+ void fileAssociators(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &associationClass,
+ const CIMName &resultClass,
+ const String &role,
+ const String &resultRole,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ ObjectResponseHandler &handler);
+
+ void packageAssociatorNames(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &associationClass,
+ const CIMName &resultClass,
+ const String &role,
+ const String &resultRole,
+ ObjectPathResponseHandler &handler);
+
+ void fileAssociatorNames(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &associationClass,
+ const CIMName &resultClass,
+ const String &role,
+ const String &resultRole,
+ ObjectPathResponseHandler &handler);
+
+ // Helpers for references() and referenceNames()
+
+ void packageReferences(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &resultClass,
+ const String &role,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ ObjectResponseHandler &handler);
+
+ void fileReferences(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &resultClass,
+ const String &role,
+ const Boolean includeQualifiers,
+ const Boolean includeClassOrigin,
+ const CIMPropertyList &propertyList,
+ ObjectResponseHandler &handler);
+
+ void packageReferenceNames(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &resultClass,
+ const String &role,
+ ObjectPathResponseHandler &handler);
+
+ void fileReferenceNames(const OperationContext &context,
+ const CIMObjectPath &objectName,
+ const CIMName &resultClass,
+ const String &role,
+ ObjectPathResponseHandler &handler);
+
+ // Handle on RPM db
+
+ rpmdb _db;
+};
+
+#endif // _RPMPROVIDER_H
diff --git a/src/Providers/ManagedSystem/RPM/RPMProvider.mof b/src/Providers/ManagedSystem/RPM/RPMProvider.mof
new file mode 100644
index 0000000..03a20d6
--- /dev/null
+++ b/src/Providers/ManagedSystem/RPM/RPMProvider.mof
@@ -0,0 +1,114 @@
+// ===================================================================
+// PG_RPMPackage
+// ===================================================================
+
+[Version("1.0"), Description(
+ "An instance of PG_RPMPackage represents an installed RPM package.")]
+
+class PG_RPMPackage : CIM_SoftwareElement {
+
+ // [Key] uint16 TargetOperatingSystem
+ // [Key] uint16 SoftwareElementState
+ // [Key] string SoftwareElementID
+ // [Key] string Version
+ // [Key] string Name
+ // uint16 OperationalStatus[]
+ // string StatusDescriptions[]
+ // datetime InstallDate
+ // string ElementName
+ // string Caption
+ // string Description
+
+};
+
+// ===================================================================
+// PG_RPMFileCheck
+// ===================================================================
+
+[Version("1.0"), Description(
+ "Each file that is installed by a RPM package has a PG_RPMFileCheck "
+ "instance associated with it.")]
+
+class PG_RPMFileCheck : CIM_FileSpecification {
+
+ // [Key] uint16 TargetOperatingSystem
+ // [Key] uint16 SoftwareElementState
+ // [Key] string SoftwareElementID
+ // [Key] string Version
+ // [Key] string CheckID
+ // [Key] string Name
+ // string FileName
+ // string MD5Checksum
+ // datetime CreateTimeStamp
+ // uint64 FileSize
+ // boolean CheckMode
+ // string ElementName
+ // string Caption
+ // string Description
+
+};
+
+// ===================================================================
+// PG_RPMAssociatedFile
+// ===================================================================
+
+[Association, Version("1.0"), Description(
+ "This association links a file installed by a RPM package, to the "
+ "package that installed it.")]
+
+class PG_RPMAssociatedFile : CIM_SoftwareElementChecks {
+
+ [Override("Check"), Description(
+ "The file installed by the RPM package.")]
+
+ PG_RPMFileCheck REF Check;
+
+ [Override("Element"), Description(
+ "The RPM package which installed the file.")]
+
+ PG_RPMPackage REF Element;
+
+};
+
+// ===================================================================
+// PG_RPMProduct
+// ===================================================================
+
+[Version("1.0"), Description(
+ "For each RPM package installed, a PG_RPMProduct instances is returned.")]
+
+class PG_RPMProduct : CIM_Product {
+
+ // [Key] string Version
+ // [Key] string IdentifyingNumber
+ // [Key] string Vendor
+ // [Key] string Name
+ // string ElementName
+ // string Caption
+ // string Description
+
+};
+
+// ===================================================================
+// PG_RPMProductProductDependency
+// ===================================================================
+
+[Association, Version("1.0"), Description(
+ "Instances of this class express the RPM dependency tree amongst "
+ "installed RPM packages.")]
+
+class PG_RPMProductProductDependency : CIM_ProductProductDependency {
+
+ [Override("DependentProduct"), Description(
+ "A reference to the RPM package that has the dependency.")]
+
+ PG_RPMProduct REF DependentProduct;
+
+ // uint16 TypeOfDependency
+
+ [Override("RequiredProduct"), Description(
+ "The product that the DependentProduct depends on.")]
+
+ PG_RPMProduct REF RequiredProduct;
+
+};
diff --git a/src/Providers/ManagedSystem/RPM/RPMProviderMain.cpp b/src/Providers/ManagedSystem/RPM/RPMProviderMain.cpp
new file mode 100644
index 0000000..1b7fc80
--- /dev/null
+++ b/src/Providers/ManagedSystem/RPM/RPMProviderMain.cpp
@@ -0,0 +1,50 @@
+//%2006////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
+// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
+// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation, The Open Group.
+// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
+// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
+// EMC Corporation; VERITAS Software Corporation; The Open Group.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
+// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
+// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//=============================================================================
+//
+// Author: Tim Potter <tpot@hp.com>
+//
+//%////////////////////////////////////////////////////////////////////////////
+
+#include <Pegasus/Provider/CIMProvider.h>
+
+PEGASUS_USING_PEGASUS;
+PEGASUS_USING_STD;
+
+#include "RPMProvider.h"
+
+const String RPMProviderName = "RPMProvider";
+
+extern "C"
+PEGASUS_EXPORT CIMProvider* PegasusCreateProvider(const String& providerName)
+{
+ if (providerName == RPMProviderName)
+ return new RPMProvider();
+
+ return NULL;
+}
diff --git a/src/Providers/ManagedSystem/RPM/RPMProviderR.mof b/src/Providers/ManagedSystem/RPM/RPMProviderR.mof
new file mode 100644
index 0000000..991155f
--- /dev/null
+++ b/src/Providers/ManagedSystem/RPM/RPMProviderR.mof
@@ -0,0 +1,80 @@
+instance of PG_ProviderModule
+{
+ Name = "RPMModule";
+ Location = "RPMProvider";
+ Vendor = "Hewlett-Packard";
+ Version = "0.0";
+ InterfaceType = "C++Default";
+ InterfaceVersion = "2.1.0";
+};
+
+instance of PG_Provider
+{
+ ProviderModuleName = "RPMModule";
+ Name = "RPMProvider";
+};
+
+instance of PG_ProviderCapabilities
+{
+ ProviderModuleName = "RPMModule";
+ ProviderName = "RPMProvider";
+ CapabilityID = "1";
+ ClassName = "PG_RPMPackage";
+ Namespaces = {
+ "root/cimv2"
+ };
+ ProviderType = {
+ 2 // Instance
+ };
+ SupportedProperties = NULL; // All properties
+ SupportedMethods = NULL; // All methods
+};
+
+instance of PG_ProviderCapabilities
+{
+ ProviderModuleName = "RPMModule";
+ ProviderName = "RPMProvider";
+ CapabilityID = "2";
+ ClassName = "PG_RPMFileCheck";
+ Namespaces = {
+ "root/cimv2"
+ };
+ ProviderType = {
+ 2 // Instance
+ };
+ SupportedProperties = NULL; // All properties
+ SupportedMethods = NULL; // All methods
+};
+
+instance of PG_ProviderCapabilities
+{
+ ProviderModuleName = "RPMModule";
+ ProviderName = "RPMProvider";
+ CapabilityID = "3";
+ ClassName = "PG_RPMAssociatedFile";
+ Namespaces = {
+ "root/cimv2"
+ };
+ ProviderType = {
+ 3 // Association
+ };
+ SupportedProperties = NULL; // All properties
+ SupportedMethods = NULL; // All methods
+};
+
+instance of PG_ProviderCapabilities
+{
+ ProviderModuleName = "RPMModule";
+ ProviderName = "RPMProvider";
+ CapabilityID = "4";
+ ClassName = "PG_RPMProduct";
+ Namespaces = {
+ "root/cimv2"
+ };
+ ProviderType = {
+ 2 // Instance
+ };
+ SupportedProperties = NULL; // All properties
+ SupportedMethods = NULL; // All methods
+};
+
diff --git a/src/Providers/ManagedSystem/RPM/RPMProviderUtils.cpp b/src/Providers/ManagedSystem/RPM/RPMProviderUtils.cpp
new file mode 100644
index 0000000..7ed9908
--- /dev/null
+++ b/src/Providers/ManagedSystem/RPM/RPMProviderUtils.cpp
@@ -0,0 +1,428 @@
+//%2006////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
+// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
+// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation, The Open Group.
+// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
+// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
+// EMC Corporation; VERITAS Software Corporation; The Open Group.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
+// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
+// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//=============================================================================
+//
+// Author: Tim Potter <tpot@hp.com>
+//
+//%////////////////////////////////////////////////////////////////////////////
+
+#include <Pegasus/Provider/CIMProvider.h>
+#include <Pegasus/Common/System.h>
+
+PEGASUS_USING_PEGASUS;
+PEGASUS_USING_STD;
+
+#include <sstream>
+#include "RPMProviderUtils.h"
+
+#include <stdlib.h>
+
+// Include operating system dependent
+
+#if defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU)
+#include "RPMProviderUtils_Linux.cpp"
+#else
+#include "RPMProviderUtils_Unknown.cpp"
+#endif
+
+// Constants
+
+const String PackageClassName = "PG_RPMPackage";
+const String FileClassName = "PG_RPMFileCheck";
+const String ProductClassName = "PG_RPMProduct";
+const String AssociatedFileClassName = "PG_RPMAssociatedFile";
+
+const CIMNamespaceName cimv2NameSpace = "root/cimv2";
+
+//
+// RPMPackage helpers
+//
+
+static void
+getHeaderNVR(Header h, String &name, String &version, String &release)
+{
+ const char *n, *v, *r;
+ headerNVR(h, &n, &v, &r);
+
+ name.assign(n);
+ version.assign(v);
+ release.assign(r);
+
+ headerFreeTag(h, n, RPM_STRING_TYPE);
+ headerFreeTag(h, v, RPM_STRING_TYPE);
+ headerFreeTag(h, r, RPM_STRING_TYPE);
+}
+
+CIMObjectPath
+packageObjectPathFromHeader(Header h)
+{
+ String name, version, release;
+ getHeaderNVR(h, name, version, release);
+
+ // Create keybindings
+
+ Array<CIMKeyBinding> kb;
+
+ kb.append(CIMKeyBinding("Name", name));
+ kb.append(CIMKeyBinding("Version", version));
+ kb.append(CIMKeyBinding("TargetOperatingSystem",
+ getTargetOperatingSystem()));
+ kb.append(CIMKeyBinding("SoftwareElementState", Uint16(Executable)));
+
+ stringstream sid;
+ sid << name << "-" << version << "-" << release;
+
+ kb.append(CIMKeyBinding("SoftwareElementID",
+ String(sid.str().c_str())));
+
+ return CIMObjectPath(System::getHostName(), cimv2NameSpace,
+ PackageClassName, kb);
+}
+
+CIMInstance
+packageInstanceFromHeader(Header h)
+{
+ String name, version, release;
+ getHeaderNVR(h, name, version, release);
+
+ // Create instance
+
+ CIMInstance instance(PackageClassName);
+
+ instance.addProperty(CIMProperty("Name", name));
+ instance.addProperty(CIMProperty("Version", version));
+ instance.addProperty(CIMProperty("TargetOperatingSystem",
+ getTargetOperatingSystem()));
+ instance.addProperty(CIMProperty("SoftwareElementState", Executable));
+
+ stringstream sid;
+ sid << name << "-" << version << "-" << release;
+
+ instance.addProperty(CIMProperty("SoftwareElementID",
+ String(sid.str().c_str())));
+
+ // Attach path
+
+ instance.setPath(packageObjectPathFromHeader(h));
+
+ return instance;
+}
+
+//
+// RPMFileCheck helpers
+//
+
+Array<CIMObjectPath>
+fileObjectPathsFromHeader(Header h)
+{
+ Array<CIMInstance> fileInstances(fileInstancesFromHeader(h));
+ Array<CIMObjectPath> filePaths;
+
+ for (Uint32 i = 0; i < fileInstances.size(); i++)
+ filePaths.append(fileInstances[i].getPath());
+
+ return filePaths;
+}
+
+Array<CIMInstance>
+fileInstancesFromHeader(Header h)
+{
+ Array<CIMInstance> result;
+
+ // Get list of filenames for this package
+
+ int_32 num_basenames, num_dirnames, num_dirindicies;
+ void *basenames, *dirnames, *dirindicies;
+ int_32 type;
+
+ rpmHeaderGetEntry(h, RPMTAG_BASENAMES, &type, &basenames, &num_basenames);
+
+ if (type != RPM_STRING_ARRAY_TYPE) {
+
+ // There are no files in this package, e.g the basesystem RPM
+
+ return result;
+ }
+
+ rpmHeaderGetEntry(h, RPMTAG_DIRNAMES, &type, &dirnames, &num_dirnames);
+
+ if (type != RPM_STRING_ARRAY_TYPE) {
+
+ // Type for DIRNAMES tag not an array of strings
+
+ return result;
+ }
+
+ rpmHeaderGetEntry(h, RPMTAG_DIRINDEXES, &type, &dirindicies,
+ &num_dirindicies);
+
+ if (type != RPM_INT32_TYPE) {
+
+ // Type for DIRINDEXES tag not an int32
+
+ return result;
+ }
+
+ if (num_basenames != num_dirindicies) {
+
+ // Inconsistent number of basenames and dirindicies
+
+ return result;
+ }
+
+ // Create keybindings template
+
+ String name, version, release;
+ getHeaderNVR(h, name, version, release);
+
+ Array<CIMKeyBinding> kb;
+
+ stringstream sid;
+ sid << name << "-" << version << "-" << release;
+
+ kb.append(CIMKeyBinding("SoftwareElementID", String(sid.str().c_str())));
+ kb.append(CIMKeyBinding("Name", name));
+ kb.append(CIMKeyBinding("Version", version));
+ kb.append(CIMKeyBinding("TargetOperatingSystem",
+ getTargetOperatingSystem()));
+ kb.append(CIMKeyBinding("SoftwareElementState", Uint16(Executable)));
+
+ for (int_32 i = 0; i < num_dirindicies; i++) {
+ Array<CIMKeyBinding> file_kb(kb);
+
+ stringstream filename;
+
+ int_32 ndx = ((int_32 *)dirindicies)[i];
+
+ if (ndx >= num_dirindicies) {
+
+ // dirindex to large for package
+
+ return result;
+ }
+
+ filename << ((char **)dirnames)[ndx] << ((char **)basenames)[i];
+
+ file_kb.append(CIMKeyBinding("CheckID",
+ String(filename.str().c_str())));
+
+ CIMInstance obj(FileClassName);
+
+ obj.addProperty(CIMProperty("SoftwareElementID",
+ String(sid.str().c_str())));
+ obj.addProperty(CIMProperty("Name", name));
+ obj.addProperty(CIMProperty("Version", version));
+ obj.addProperty(CIMProperty("TargetOperatingSystem",
+ getTargetOperatingSystem()));
+ obj.addProperty(CIMProperty("CheckID",
+ String(filename.str().c_str())));
+ obj.addProperty(CIMProperty("SoftwareElementState",
+ Uint16(Executable)));
+
+ obj.setPath(CIMObjectPath(System::getHostName(),
+ cimv2NameSpace,
+ obj.getClassName(),
+ file_kb));
+
+ result.append(obj);
+ }
+
+ headerFreeData(basenames, RPM_STRING_ARRAY_TYPE);
+ headerFreeData(dirnames, RPM_STRING_ARRAY_TYPE);
+ headerFreeData(dirindicies, RPM_INT32_TYPE);
+
+ return result;
+}
+
+//
+// RPMProduct helpers
+//
+
+static String
+getVendor(Header h)
+{
+ int_32 type, count;
+ char *value;
+ String vendor("Unknown");
+
+ if (rpmHeaderGetEntry(h, RPMTAG_VENDOR, &type, (void **)&value,
+ &count) == 1 && type == RPM_STRING_TYPE) {
+ vendor.assign(value);
+ headerFreeTag(h, value, RPM_STRING_TYPE);
+ }
+
+ return vendor;
+}
+
+CIMObjectPath
+productObjectPathFromHeader(Header h)
+{
+ String name, version, release;
+ getHeaderNVR(h, name, version, release);
+
+ // Create keybindings
+
+ Array<CIMKeyBinding> kb;
+
+ kb.append(CIMKeyBinding("Version", version));
+ kb.append(CIMKeyBinding("IdentifyingNumber", String("None")));
+ kb.append(CIMKeyBinding("Vendor", getVendor(h)));
+ kb.append(CIMKeyBinding("Name", name));
+
+ return CIMObjectPath(System::getHostName(), cimv2NameSpace,
+ PackageClassName, kb);
+}
+
+CIMInstance
+productInstanceFromHeader(Header h)
+{
+ String name, version, release;
+ getHeaderNVR(h, name, version, release);
+
+ // Create instance
+
+ CIMInstance instance(ProductClassName);
+
+ instance.addProperty(CIMProperty("Version", version));
+ instance.addProperty(CIMProperty("IdentifyingNumber", String("None")));
+ instance.addProperty(CIMProperty("Vendor", getVendor(h)));
+ instance.addProperty(CIMProperty("Name", name));
+
+ String description;
+ int_32 type, count;
+ char *value;
+
+ if (rpmHeaderGetEntry(h, RPMTAG_DESCRIPTION, &type, (void **)&value,
+ &count) == 1 && type == RPM_STRING_TYPE) {
+ description.assign(value);
+ headerFreeTag(h, value, RPM_STRING_TYPE);
+ }
+
+ instance.addProperty(CIMProperty("Description", description));
+
+ String elementName;
+
+ if (rpmHeaderGetEntry(h, RPMTAG_SUMMARY, &type, (void **)&value,
+ &count) == 1 && type == RPM_STRING_TYPE) {
+ elementName.assign(value);
+ headerFreeTag(h, value, RPM_STRING_TYPE);
+
+ }
+
+ instance.addProperty(CIMProperty("ElementName", elementName));
+
+ // Attach path
+
+ instance.setPath(productObjectPathFromHeader(h));
+
+ return instance;
+}
+
+//
+// Association provider helpers
+//
+
+CIMObjectPath
+packageReferenceNameFromHeader(Header h, const CIMObjectPath &file)
+{
+ CIMObjectPath element(packageObjectPathFromHeader(h));
+ Array<CIMKeyBinding> kb;
+
+ kb.append(CIMKeyBinding("Element", element));
+ kb.append(CIMKeyBinding("Check", file));
+
+ return CIMObjectPath(System::getHostName(), cimv2NameSpace,
+ AssociatedFileClassName, kb);
+}
+
+CIMInstance
+packageReferenceFromHeader(Header h, const CIMObjectPath &file)
+{
+ CIMObjectPath element(packageObjectPathFromHeader(h));
+
+ CIMInstance obj(AssociatedFileClassName);
+
+ obj.addProperty(CIMProperty("Element", element));
+ obj.addProperty(CIMProperty("Check", file));
+
+ obj.setPath(packageReferenceNameFromHeader(h, file));
+
+ return obj;
+}
+
+Array<CIMObjectPath>
+fileReferenceNamesFromHeader(Header h)
+{
+ CIMObjectPath package(packageObjectPathFromHeader(h));
+ Array<CIMObjectPath> filePaths(fileObjectPathsFromHeader(h)), result;
+
+ for (Uint32 i = 0; i < filePaths.size(); i++) {
+ Array<CIMKeyBinding> kb;
+
+ kb.append(CIMKeyBinding("Element", package));
+ kb.append(CIMKeyBinding("Check", filePaths[i]));
+
+ result.append(CIMObjectPath(System::getHostName(),
+ cimv2NameSpace,
+ AssociatedFileClassName,
+ kb));
+ }
+
+ return result;
+}
+
+Array<CIMInstance>
+fileReferencesFromHeader(Header h)
+{
+ CIMObjectPath package(packageObjectPathFromHeader(h));
+ Array<CIMObjectPath> files(fileObjectPathsFromHeader(h));
+
+ Array<CIMInstance> result;
+
+ for (Uint32 i = 0; i < files.size(); i++) {
+
+ Array<CIMKeyBinding> kb;
+
+ kb.append(CIMKeyBinding("Element", package));
+ kb.append(CIMKeyBinding("Check", files[i]));
+
+ CIMInstance obj(AssociatedFileClassName);
+
+ obj.addProperty(CIMProperty("Element", package));
+ obj.addProperty(CIMProperty("Check", files[i]));
+
+ obj.setPath(CIMObjectPath(System::getHostName(),
+ cimv2NameSpace,
+ obj.getClassName(),
+ kb));
+
+ result.append(obj);
+ }
+
+ return result;
+}
diff --git a/src/Providers/ManagedSystem/RPM/RPMProviderUtils.h b/src/Providers/ManagedSystem/RPM/RPMProviderUtils.h
new file mode 100644
index 0000000..5f31283
--- /dev/null
+++ b/src/Providers/ManagedSystem/RPM/RPMProviderUtils.h
@@ -0,0 +1,100 @@
+//%2006////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
+// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
+// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation, The Open Group.
+// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
+// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
+// EMC Corporation; VERITAS Software Corporation; The Open Group.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
+// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
+// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//=============================================================================
+//
+// Author: Tim Potter <tpot@hp.com>
+//
+//%////////////////////////////////////////////////////////////////////////////
+
+#ifndef _RPMPROVIDERUTILS_H
+#define _RPMPROVIDERUTILS_H
+
+#include <Pegasus/Common/CIMInstance.h>
+#include "RPMWrapper.h"
+
+// Include rpm C library headers
+
+extern "C" {
+#include <rpm/rpmdb.h>
+#include <rpm/rpmmacro.h>
+}
+
+// Constants
+
+extern const String PackageClassName;
+extern const String FileClassName;
+extern const String ProductClassName;
+
+enum SoftwareElementState {
+ Deployable, Installable, Executable, Running
+};
+
+enum OSType {
+ Unknown, Other, MACOS, ATTUNIX, DGUX, DECNT, Digital_Unix,
+ OpenVMS, HP_UX, AIX, MVS, OS400, OS2, JavaVM, MSDOS, WIN3x,
+ WIN95, WIN98, WINNT, WINCE, NCR3000, NetWare, OSF,
+ DCOS, Reliant_UNIX, SCO_UnixWare, SCO_OpenServer, Sequent,
+ IRIX, Solaris, SunOS, U6000, ASERIES, TandemNSK, TandemNT,
+ BS2000, LINUX, Lynx, XENIX, VM_ESA, Interactive_UNIX,
+ BSDUNIX, FreeBSD, NetBSD, GNU_Hurd, OS9, MACH_Kernel,
+ Inferno, QNX, EPOC, IxWorks, VxWorks, MiNT, BeOS, HP_MPE,
+ NextStep, PalmPilot, Rhapsody, Windows_2000, Dedicated,
+ OS_390, VSE, TPF, Windows_Me, Open_UNIX, OpenBDS, NotApplicable,
+ Windows_XP, zOS, Windows_2003, Windows_2003_64
+};
+
+//
+// Helper functions
+//
+
+// Misc
+
+Uint16 getTargetOperatingSystem();
+
+// Convert file headers to CIMObjectPath or CIMInstance objects
+
+CIMObjectPath packageObjectPathFromHeader(Header h);
+CIMInstance packageInstanceFromHeader(Header h);
+
+CIMObjectPath packageReferenceNameFromHeader(Header h,
+ const CIMObjectPath &file);
+CIMInstance packageReferenceFromHeader(Header h, const CIMObjectPath &file);
+
+CIMObjectPath productObjectPathFromHeader(Header h);
+CIMInstance productInstanceFromHeader(Header h);
+
+// Convert package headers to arrays of CIMObjectpath or CIMInstance
+// objects
+
+Array<CIMObjectPath> fileObjectPathsFromHeader(Header h);
+Array<CIMInstance> fileInstancesFromHeader(Header h);
+
+Array<CIMObjectPath> fileReferenceNamesFromHeader(Header h);
+Array<CIMInstance> fileReferencesFromHeader(Header h);
+
+#endif // _RPMPROVIDERUTILS_H
diff --git a/src/Providers/ManagedSystem/RPM/RPMProviderUtils_Linux.cpp b/src/Providers/ManagedSystem/RPM/RPMProviderUtils_Linux.cpp
new file mode 100644
index 0000000..550c529
--- /dev/null
+++ b/src/Providers/ManagedSystem/RPM/RPMProviderUtils_Linux.cpp
@@ -0,0 +1,37 @@
+//%2006////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
+// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
+// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation, The Open Group.
+// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
+// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
+// EMC Corporation; VERITAS Software Corporation; The Open Group.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
+// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
+// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//=============================================================================
+//
+// Author: Tim Potter <tpot@hp.com>
+//
+//%////////////////////////////////////////////////////////////////////////////
+
+Uint16 getTargetOperatingSystem()
+{
+ return Uint16(LINUX);
+}
diff --git a/src/Providers/ManagedSystem/RPM/RPMProviderUtils_Unknown.cpp b/src/Providers/ManagedSystem/RPM/RPMProviderUtils_Unknown.cpp
new file mode 100644
index 0000000..6c2305a
--- /dev/null
+++ b/src/Providers/ManagedSystem/RPM/RPMProviderUtils_Unknown.cpp
@@ -0,0 +1,37 @@
+//%2006////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
+// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
+// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation, The Open Group.
+// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
+// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
+// EMC Corporation; VERITAS Software Corporation; The Open Group.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
+// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
+// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//=============================================================================
+//
+// Author: Tim Potter <tpot@hp.com>
+//
+//%////////////////////////////////////////////////////////////////////////////
+
+Uint16 getTargetOperatingSystem()
+{
+ return Uint16(Unknown);
+}
diff --git a/src/Providers/ManagedSystem/RPM/RPMWrapper.cpp b/src/Providers/ManagedSystem/RPM/RPMWrapper.cpp
new file mode 100644
index 0000000..605432e
--- /dev/null
+++ b/src/Providers/ManagedSystem/RPM/RPMWrapper.cpp
@@ -0,0 +1,74 @@
+//%2006////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
+// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
+// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation, The Open Group.
+// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
+// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
+// EMC Corporation; VERITAS Software Corporation; The Open Group.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
+// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
+// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//=============================================================================
+//
+// Author: Tim Potter <tpot@hp.com>
+//
+//%/////////////////////////////////////////////////////////////////////////
+
+#include "RPMWrapper.h"
+
+// RAII wrapper for rpmdbMatchIterator object
+
+IterWrapper::IterWrapper(rpmdbMatchIterator iter) : _iter(iter)
+{
+}
+
+IterWrapper::~IterWrapper()
+{
+ if (_iter)
+ rpmdbFreeIterator(_iter);
+}
+
+// Compare two iterators
+
+IterWrapper &
+IterWrapper::operator=(IterWrapper rhs)
+{
+ if ((rpmdbMatchIterator)rhs == _iter)
+ return *this;
+
+ _iter = (rpmdbMatchIterator)rhs;
+
+ return *this;
+}
+
+// Cast as a rpmdbMatchIterator to act as an accessor
+
+IterWrapper::operator rpmdbMatchIterator()
+{
+ return _iter;
+}
+
+// Return true if iterator is NULL
+
+bool
+IterWrapper::isNull()
+{
+ return _iter == NULL;
+}
diff --git a/src/Providers/ManagedSystem/RPM/RPMWrapper.h b/src/Providers/ManagedSystem/RPM/RPMWrapper.h
new file mode 100644
index 0000000..bfd22c7
--- /dev/null
+++ b/src/Providers/ManagedSystem/RPM/RPMWrapper.h
@@ -0,0 +1,59 @@
+//%2006////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
+// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
+// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation, The Open Group.
+// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
+// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
+// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
+// EMC Corporation; VERITAS Software Corporation; The Open Group.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to
+// deal in the Software without restriction, including without limitation the
+// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+// sell copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
+// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
+// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//=============================================================================
+//
+// Author: Tim Potter <tpot@hp.com>
+//
+//%/////////////////////////////////////////////////////////////////////////
+
+#ifndef _RPMWRAPPER_H
+#define _RPMWRAPPER_H
+
+// Some simple RAII wrappers for rpmlib objects to avoid memory leaks
+
+extern "C" {
+#include <rpm/rpmdb.h>
+#include <rpm/rpmmacro.h>
+}
+
+class IterWrapper {
+
+public:
+ IterWrapper(rpmdbMatchIterator iter);
+ ~IterWrapper();
+
+ bool isNull(); // Did iterator creation fail?
+
+ IterWrapper &operator=(IterWrapper rhs); // Comparison operator
+ operator rpmdbMatchIterator(); // Cast as a rpmdbMatchIterator
+
+ private:
+ rpmdbMatchIterator _iter;
+};
+
+#endif // _RPMPROVIDER_H