commit d0772774a2e4754b1e645dc3611e4ebe3a9f0c9b
Author: Michael Calmer
Date: Tue Jan 20 17:36:57 2009 +0100
Implement SUSE_MemberOfCollection
---
mof/CMakeLists.txt | 2 +
mof/SUSE_MemberOfCollection.mof | 22 ++
mof/SUSE_MemberOfCollection.sfcb.reg | 5 +
mof/SUSE_SystemSpecificCollection.mof | 2 +-
mof/deploy.mof | 1 +
src/CMakeLists.txt | 2 +
src/SUSE_MemberOfCollectionProvider.cc | 478 ++++++++++++++++++++++++++++++++
src/SUSE_MemberOfCollectionProvider.h | 42 +++
8 files changed, 553 insertions(+), 1 deletions(-)
diff --git a/mof/CMakeLists.txt b/mof/CMakeLists.txt
index 4c4e3af..32db98c 100644
--- a/mof/CMakeLists.txt
+++ b/mof/CMakeLists.txt
@@ -6,6 +6,8 @@ INSTALL( FILES
SUSE_InstalledSoftwareIdentity.sfcb.reg
SUSE_SystemSpecificCollection.mof
SUSE_SystemSpecificCollection.sfcb.reg
+ SUSE_MemberOfCollection.sfcb.reg
+ SUSE_MemberOfCollection.mof
deploy.mof
DESTINATION ${CMPIZYPP_DATA_DIR}/
)
diff --git a/mof/SUSE_MemberOfCollection.mof b/mof/SUSE_MemberOfCollection.mof
new file mode 100644
index 0000000..dfd0b5f
--- /dev/null
+++ b/mof/SUSE_MemberOfCollection.mof
@@ -0,0 +1,22 @@
+//#pragma namespace ("root/cimv2")
+
+
+// -------------------------------------------------------------------
+// *******************************************************************
+// Classes
+// *******************************************************************
+// -------------------------------------------------------------------
+
+
+
+// ===================================================================
+// SUSE_MemberOfCollection
+// ===================================================================
+
+[ Provider("cmpi:cmpi-zypp"),
+ Description ("Association between SystemSpecificCollection and SoftwareIdentity")
+]
+class SUSE_MemberOfCollection : CIM_MemberOfCollection
+{ };
+
+
diff --git a/mof/SUSE_MemberOfCollection.sfcb.reg b/mof/SUSE_MemberOfCollection.sfcb.reg
new file mode 100644
index 0000000..7a5c1ab
--- /dev/null
+++ b/mof/SUSE_MemberOfCollection.sfcb.reg
@@ -0,0 +1,5 @@
+[SUSE_MemberOfCollection]
+ provider: SUSE_MemberOfCollectionProvider
+ location: cmpi-zypp
+ type: instance association
+ namespace: root/cimv2
diff --git a/mof/SUSE_SystemSpecificCollection.mof b/mof/SUSE_SystemSpecificCollection.mof
index c66857d..a8fe4d2 100644
--- a/mof/SUSE_SystemSpecificCollection.mof
+++ b/mof/SUSE_SystemSpecificCollection.mof
@@ -10,7 +10,7 @@
// ===================================================================
-// SUSE_InstalledSoftwareIdentity
+// SUSE_SystemSpecificCollection
// ===================================================================
[ Provider("cmpi:cmpi-zypp"),
diff --git a/mof/deploy.mof b/mof/deploy.mof
index 0082284..9538a66 100644
--- a/mof/deploy.mof
+++ b/mof/deploy.mof
@@ -2,4 +2,5 @@
#pragma include ("SUSE_SoftwareIdentity.mof")
#pragma include ("SUSE_InstalledSoftwareIdentity.mof")
#pragma include ("SUSE_SystemSpecificCollection.mof")
+#pragma include ("SUSE_MemberOfCollection.mof")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fc44900..0f6e553 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -12,6 +12,7 @@ SET( CMPIZYPP_SRCS
SUSE_SoftwareIdentityProvider.cc
SUSE_InstalledSoftwareIdentityProvider.cc
SUSE_SystemSpecificCollectionProvider.cc
+ SUSE_MemberOfCollectionProvider.cc
)
SET( CMPIZYPP_HEADERS
SUSE_Common.h
@@ -19,6 +20,7 @@ SET( CMPIZYPP_HEADERS
SUSE_SoftwareIdentityProvider.h
SUSE_InstalledSoftwareIdentityProvider.h
SUSE_SystemSpecificCollectionProvider.h
+ SUSE_MemberOfCollectionProvider.h
)
ADD_LIBRARY(cmpi-zypp SHARED ${CMPIZYPP_SRCS})
diff --git a/src/SUSE_MemberOfCollectionProvider.cc b/src/SUSE_MemberOfCollectionProvider.cc
new file mode 100644
index 0000000..8724fe3
--- /dev/null
+++ b/src/SUSE_MemberOfCollectionProvider.cc
@@ -0,0 +1,478 @@
+
+#include <iostream>
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#include "SUSE_zypp.h"
+#include "SUSE_Common.h"
+#include "SUSE_SoftwareIdentityProvider.h"
+#include "SUSE_MemberOfCollectionProvider.h"
+
+using namespace zypp;
+using std::endl;
+
+namespace cmpizypp
+{
+ namespace
+ {
+ const char * _ClassName = "SUSE_MemberOfCollection";
+ const char * _RefLeft = "Collection";
+ const char * _RefRight = "Member";
+ const char * _RefLeftClass = "CIM_Collection";
+ const char * _RefRightClass = "CIM_ManagedElement";
+
+ } // namespace
+
+ SUSE_MemberOfCollectionProviderClass::SUSE_MemberOfCollectionProviderClass( const CmpiBroker & mbp, const CmpiContext & ctx )
+ : CmpiBaseMI( mbp, ctx )
+ , CmpiInstanceMI( mbp, ctx )
+ , CmpiAssociationMI( mbp, ctx )
+ {
+ }
+
+ CmpiStatus SUSE_MemberOfCollectionProviderClass::enumInstanceNames( const CmpiContext& ctx, CmpiResult& rslt, const CmpiObjectPath & cop )
+ {
+ _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstanceNames() called",_ClassName));
+
+ // zypp init
+ zypp::scoped_ptr<ZyppAC> zyppac;
+ try
+ {
+ zyppac.reset( new ZyppAC() );
+ }
+ catch ( const zypp::Exception & err )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, ZyppAC::exceptionString( err, "Could not list software identities: " ).c_str() );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstanceNames() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ CmpiObjectPath op(cop.getNameSpace(), _RefLeftClass); // CIM_SystemSpecificCollection
+ if( op.isNull() )
+ {
+ CmpiStatus st( CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed.");
+ _CMPIZYPP_TRACE(1,("--- enumInstanceNames() failed: %s", st.msg() ) );
+ return st;
+ }
+ CmpiEnumeration en = broker->enumInstanceNames( ctx, op );
+ if( en.isNull() )
+ {
+ CmpiStatus st( CMPI_RC_ERR_FAILED, "EnumInstanceNames failed.");
+ _CMPIZYPP_TRACE(1,("--- enumInstanceNames() failed: %s", st.msg() ) );
+ return st;
+ }
+
+ CmpiObjectPath rop( cop.getNameSpace(), _ClassName );
+
+ while( en.hasNext() )
+ {
+ CmpiData data = en.getNext();
+
+ ResPool pool( zyppac->pool() );
+ for_( it, pool.begin(), pool.end() )
+ {
+ if( (*it).status().isInstalled() )
+ continue;
+
+ CmpiObjectPath iop = SUSE_SoftwareIdentityProviderClass::makeSoftwareIdentityOP(*it, *zyppac, cop);
+ CmpiInstance ci( rop );
+ if( ci.isNull() )
+ {
+ return CmpiStatus(CMPI_RC_ERR_FAILED, "Create CmpiInstance failed.");
+ }
+ ci.setProperty( _RefRight, iop );
+ ci.setProperty( _RefLeft, data );
+
+ CmpiObjectPath tmp = ci.getObjectPath();
+ tmp.setNameSpace(cop.getNameSpace());
+ rslt.returnData(tmp);
+ }
+ }
+
+ rslt.returnDone();
+ _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstanceNames() exited",_ClassName));
+ return CmpiStatus(CMPI_RC_OK);
+ }
+
+ CmpiStatus SUSE_MemberOfCollectionProviderClass::enumInstances( const CmpiContext & ctx, CmpiResult & rslt, const CmpiObjectPath & cop, const char** properties )
+ {
+ _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstances() called",_ClassName));
+
+ // zypp init
+ zypp::scoped_ptr<ZyppAC> zyppac;
+ try
+ {
+ zyppac.reset( new ZyppAC() );
+ }
+ catch ( const zypp::Exception & err )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, ZyppAC::exceptionString( err, "Could not list software identities: " ).c_str() );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstances() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ CmpiObjectPath op(cop.getNameSpace(), _RefLeftClass); // CIM_SystemSpecificCollection
+ if( op.isNull() )
+ {
+ CmpiStatus st( CMPI_RC_ERR_FAILED, "Create CMPIObjectPath failed.");
+ _CMPIZYPP_TRACE(1,("--- enumInstanceNames() failed: %s", st.msg() ) );
+ return st;
+ }
+ CmpiEnumeration en = broker->enumInstanceNames( ctx, op );
+ if( en.isNull() )
+ {
+ CmpiStatus st( CMPI_RC_ERR_FAILED, "EnumInstanceNames failed.");
+ _CMPIZYPP_TRACE(1,("--- enumInstanceNames() failed: %s", st.msg() ) );
+ return st;
+ }
+
+ CmpiObjectPath rop( cop.getNameSpace(), _ClassName );
+
+ while( en.hasNext() )
+ {
+ CmpiData data = en.getNext();
+
+ ResPool pool( zyppac->pool() );
+ for_( it, pool.begin(), pool.end() )
+ {
+ if( (*it).status().isInstalled() )
+ continue;
+
+ CmpiObjectPath iop = SUSE_SoftwareIdentityProviderClass::makeSoftwareIdentityOP(*it, *zyppac, cop);
+ CmpiInstance ci( rop );
+ if( ci.isNull() )
+ {
+ return CmpiStatus(CMPI_RC_ERR_FAILED, "Create CmpiInstance failed.");
+ }
+ ci.setProperty( _RefRight, iop );
+ ci.setProperty( _RefLeft, data );
+
+ rslt.returnData(ci);
+ }
+ }
+
+ rslt.returnDone();
+ _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstances() exited",_ClassName));
+ return CmpiStatus(CMPI_RC_OK);
+ }
+
+
+ CmpiStatus SUSE_MemberOfCollectionProviderClass::getInstance( const CmpiContext &ctx, CmpiResult &rslt, const CmpiObjectPath &cop, const char **properties )
+ {
+ _CMPIZYPP_TRACE(1,("--- %s CMPI GetInstance() called",_ClassName));
+
+ CmpiInstance ci = assoc_get_inst( *broker, ctx, cop, _ClassName, _RefLeft, _RefRight);
+
+ rslt.returnData( ci );
+ rslt.returnDone();
+ _CMPIZYPP_TRACE(1,("--- %s CMPI GetInstance() exited",_ClassName));
+ return CmpiStatus(CMPI_RC_OK);
+ }
+
+
+
+ CmpiStatus SUSE_MemberOfCollectionProviderClass::associators( const CmpiContext& ctx, CmpiResult& rslt,
+ const CmpiObjectPath& cop, const char* assocClass, const char* resultClass,
+ const char* role, const char* resultRole, const char** properties )
+ {
+ _CMPIZYPP_TRACE(1,("--- %s CMPI associators() called",_ClassName));
+
+ CmpiObjectPath op( cop.getNameSpace(), _ClassName );
+
+ if ( !assocClass || op.classPathIsA( assocClass ) )
+ {
+ if ( assoc_check_parameter_const( cop, _RefLeft, _RefRight, _RefLeftClass, _RefRightClass,
+ resultClass, role, resultRole ) )
+ {
+ if ( cop.classPathIsA(_RefLeftClass) ) // CIM_SystemSpecificCollection
+ {
+ // we need to implement our own handling,
+ // because we need to search for SUSE_SoftwareIdentity
+ CmpiInstance cis( broker->getInstance( ctx, cop, NULL ) ); // source instance
+
+ if( !cis.instanceIsA(_RefLeftClass) )
+ {
+ return CmpiStatus(CMPI_RC_ERR_FAILED, "Create references failed.");
+ }
+
+ // zypp init
+ zypp::scoped_ptr<ZyppAC> zyppac;
+ try
+ {
+ zyppac.reset( new ZyppAC() );
+ }
+ catch ( const zypp::Exception & err )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, ZyppAC::exceptionString( err, "Could not list software identities: " ).c_str() );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstanceNames() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ ResPool pool( zyppac->pool() );
+ for_( it, pool.begin(), pool.end() )
+ {
+ if( (*it).status().isInstalled() )
+ continue;
+
+ CmpiInstance ci = SUSE_SoftwareIdentityProviderClass::makeSoftwareIdentityInstance(*it, *zyppac, cop, properties);
+ rslt.returnData(ci);
+ }
+ }
+ else // ( cop.classPathIsA(_RefRightClass) ) //SUSE_SoftwareIdentity
+ {
+ if(! assoc_create_refs_1toN_ST( *broker, ctx, rslt, cop, _ClassName,
+ _RefRight, _RefLeft, _RefRightClass, _RefLeftClass, 1, 1) )
+ {
+ CmpiStatus st(CMPI_RC_ERR_FAILED, "Create references failed.");
+ _CMPIZYPP_TRACE(1,("--- CMPI referenceNames() failed."));
+ return st;
+ }
+ }
+
+ }
+ }
+
+ rslt.returnDone();
+ _CMPIZYPP_TRACE(1,("--- %s CMPI associators() exited",_ClassName));
+ return CmpiStatus(CMPI_RC_OK);
+ }
+
+ CmpiStatus SUSE_MemberOfCollectionProviderClass::associatorNames( const CmpiContext& ctx, CmpiResult& rslt,
+ const CmpiObjectPath& cop, const char* assocClass, const char* resultClass,
+ const char* role, const char* resultRole )
+ {
+ _CMPIZYPP_TRACE(1,("--- %s CMPI associatorNames() called",_ClassName));
+
+ CmpiObjectPath op( cop.getNameSpace(), _ClassName );
+
+ if ( !assocClass || op.classPathIsA( assocClass ) )
+ {
+ if ( assoc_check_parameter_const( cop, _RefLeft, _RefRight, _RefLeftClass, _RefRightClass,
+ resultClass, role, resultRole ) )
+ {
+ if ( cop.classPathIsA(_RefLeftClass) ) // CIM_SystemSpecificCollection
+ {
+ // we need to implement our own handling,
+ // because we need to search for SUSE_SoftwareIdentity
+ CmpiInstance cis( broker->getInstance( ctx, cop, NULL ) ); // source instance
+
+ if( !cis.instanceIsA(_RefLeftClass) )
+ {
+ return CmpiStatus(CMPI_RC_ERR_FAILED, "Create references failed.");
+ }
+
+ // zypp init
+ zypp::scoped_ptr<ZyppAC> zyppac;
+ try
+ {
+ zyppac.reset( new ZyppAC() );
+ }
+ catch ( const zypp::Exception & err )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, ZyppAC::exceptionString( err, "Could not list software identities: " ).c_str() );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstanceNames() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ ResPool pool( zyppac->pool() );
+ for_( it, pool.begin(), pool.end() )
+ {
+ if( (*it).status().isInstalled() )
+ continue;
+
+ CmpiObjectPath iop = SUSE_SoftwareIdentityProviderClass::makeSoftwareIdentityOP(*it, *zyppac, cop);
+/*
+ CmpiObjectPath tmp = (CmpiObjectPath)data;
+ tmp.setNameSpace(cop.getNameSpace());
+*/
+ rslt.returnData(iop);
+ }
+ }
+ else // ( cop.classPathIsA(_RefRightClass) ) //SUSE_SoftwareIdentity
+ {
+ if(! assoc_create_refs_1toN_ST( *broker, ctx, rslt, cop, _ClassName,
+ _RefRight, _RefLeft, _RefRightClass, _RefLeftClass, 0, 1) )
+ {
+ CmpiStatus st(CMPI_RC_ERR_FAILED, "Create references failed.");
+ _CMPIZYPP_TRACE(1,("--- CMPI referenceNames() failed."));
+ return st;
+ }
+ }
+
+ USR << op <getInstance( ctx, cop, NULL ) ); // source instance
+
+ if( !cis.instanceIsA(_RefLeftClass) )
+ {
+ return CmpiStatus(CMPI_RC_ERR_FAILED, "Create references failed.");
+ }
+
+ CmpiObjectPath rop( cop.getNameSpace(), _ClassName ); // associations op
+
+ // zypp init
+ zypp::scoped_ptr<ZyppAC> zyppac;
+ try
+ {
+ zyppac.reset( new ZyppAC() );
+ }
+ catch ( const zypp::Exception & err )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, ZyppAC::exceptionString( err, "Could not list software identities: " ).c_str() );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstanceNames() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ ResPool pool( zyppac->pool() );
+ for_( it, pool.begin(), pool.end() )
+ {
+ if( (*it).status().isInstalled() )
+ continue;
+
+ CmpiObjectPath iop = SUSE_SoftwareIdentityProviderClass::makeSoftwareIdentityOP(*it, *zyppac, cop);
+ CmpiInstance ci( rop );
+ if( ci.isNull() )
+ {
+ return CmpiStatus(CMPI_RC_ERR_FAILED, "Create CmpiInstance failed.");
+ }
+ ci.setProperty( _RefRight, iop );
+ ci.setProperty( _RefLeft, cop );
+ rslt.returnData(ci);
+ }
+ }
+ else //( cop.classPathIsA(_RefRightClass) ) //SUSE_SoftwareIdentity
+ {
+ if(! assoc_create_refs_1toN_ST( *broker, ctx, rslt, cop, _ClassName,
+ _RefRight, _RefLeft, _RefRightClass, _RefLeftClass, 1, 0) )
+ {
+ CmpiStatus st(CMPI_RC_ERR_FAILED, "Create references failed.");
+ _CMPIZYPP_TRACE(1,("--- CMPI referenceNames() failed."));
+ return st;
+ }
+ }
+
+ USR << op <getInstance( ctx, cop, NULL ) ); // source instance
+
+ if( !cis.instanceIsA(_RefLeftClass) )
+ {
+ return CmpiStatus(CMPI_RC_ERR_FAILED, "Create references failed.");
+ }
+
+ CmpiObjectPath rop( cop.getNameSpace(), _ClassName ); // associations op
+
+ // zypp init
+ zypp::scoped_ptr<ZyppAC> zyppac;
+ try
+ {
+ zyppac.reset( new ZyppAC() );
+ }
+ catch ( const zypp::Exception & err )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, ZyppAC::exceptionString( err, "Could not list software identities: " ).c_str() );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstanceNames() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ ResPool pool( zyppac->pool() );
+ for_( it, pool.begin(), pool.end() )
+ {
+ if( (*it).status().isInstalled() )
+ continue;
+
+ CmpiObjectPath iop = SUSE_SoftwareIdentityProviderClass::makeSoftwareIdentityOP(*it, *zyppac, cop);
+ CmpiInstance ci( rop );
+ if( ci.isNull() )
+ {
+ return CmpiStatus(CMPI_RC_ERR_FAILED, "Create CmpiInstance failed.");
+ }
+ ci.setProperty( _RefRight, iop );
+ ci.setProperty( _RefLeft, cop );
+
+ CmpiObjectPath tmp = ci.getObjectPath();
+ tmp.setNameSpace(cop.getNameSpace());
+ rslt.returnData(tmp);
+ }
+ }
+ else // ( cop.classPathIsA(_RefRightClass) ) //SUSE_SoftwareIdentity
+ {
+ if(! assoc_create_refs_1toN_ST( *broker, ctx, rslt, cop, _ClassName,
+ _RefRight, _RefLeft, _RefRightClass, _RefLeftClass, 0, 0) )
+ {
+ CmpiStatus st(CMPI_RC_ERR_FAILED, "Create references failed.");
+ _CMPIZYPP_TRACE(1,("--- CMPI referenceNames() failed."));
+ return st;
+ }
+ }
+
+ USR << op <
+#include
+
+namespace cmpizypp
+{
+ /**
+ */
+ class SUSE_MemberOfCollectionProviderClass : public CmpiInstanceMI, public CmpiAssociationMI
+ {
+ public:
+ SUSE_MemberOfCollectionProviderClass( const CmpiBroker & mbp, const CmpiContext & ctx );
+
+ virtual CmpiStatus enumInstanceNames( const CmpiContext& ctx, CmpiResult& rslt, const CmpiObjectPath & cop );
+ virtual CmpiStatus enumInstances( const CmpiContext & ctx, CmpiResult & rslt, const CmpiObjectPath & cop, const char** properties );
+ virtual CmpiStatus getInstance( const CmpiContext &ctx, CmpiResult &rslt, const CmpiObjectPath &cop, const char **properties );
+
+ virtual CmpiStatus associators
+ (const CmpiContext& ctx, CmpiResult& rslt,
+ const CmpiObjectPath& cop, const char* assocClass, const char* resultClass,
+ const char* role, const char* resultRole, const char** properties);
+
+ virtual CmpiStatus associatorNames
+ (const CmpiContext& ctx, CmpiResult& rslt,
+ const CmpiObjectPath& cop, const char* assocClass, const char* resultClass,
+ const char* role, const char* resultRole);
+
+ virtual CmpiStatus references
+ (const CmpiContext& ctx, CmpiResult& rslt,
+ const CmpiObjectPath& cop, const char* resultClass, const char* role,
+ const char** properties);
+
+ virtual CmpiStatus referenceNames
+ (const CmpiContext& ctx, CmpiResult& rslt,
+ const CmpiObjectPath& cop, const char* resultClass, const char* role);
+ };
+
+} // namespace cmpizypp
+
+#endif // SUSE_MEMBEROFCOLLECTIONPROVIDERCLASS_H
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org