[zypp-commit] <cmpi-zypp> master : Implement SUSE_SoftwareInstallationService

ref: refs/heads/master commit c7c51514407edc09a5d85bdc3dcc103334f6531c Author: Michael Calmer <mc@suse.de> Date: Fri Jan 30 14:13:06 2009 +0100 Implement SUSE_SoftwareInstallationService In the first step SUSE_SoftwareInstallationService is implemented as instance provider only --- mof/CMakeLists.txt | 2 + mof/SUSE_SoftwareInstallationService.mof | 23 ++++ mof/SUSE_SoftwareInstallationService.sfcb.reg | 5 + mof/deploy.mof | 1 + src/CMakeLists.txt | 2 + src/SUSE_SoftwareInstallationServiceProvider.cc | 127 +++++++++++++++++++++++ src/SUSE_SoftwareInstallationServiceProvider.h | 22 ++++ 7 files changed, 182 insertions(+), 0 deletions(-) diff --git a/mof/CMakeLists.txt b/mof/CMakeLists.txt index beb2bc3..920ae3d 100644 --- a/mof/CMakeLists.txt +++ b/mof/CMakeLists.txt @@ -10,6 +10,8 @@ INSTALL( FILES SUSE_MemberOfCollection.mof SUSE_HostedCollection.sfcb.reg SUSE_HostedCollection.mof + SUSE_SoftwareInstallationService.mof + SUSE_SoftwareInstallationService.sfcb.reg deploy.mof DESTINATION ${CMPIZYPP_DATA_DIR}/ ) diff --git a/mof/SUSE_SoftwareInstallationService.mof b/mof/SUSE_SoftwareInstallationService.mof new file mode 100644 index 0000000..4e7f5b9 --- /dev/null +++ b/mof/SUSE_SoftwareInstallationService.mof @@ -0,0 +1,23 @@ +//#pragma namespace ("root/cimv2") + + +// ------------------------------------------------------------------- +// ******************************************************************* +// Classes +// ******************************************************************* +// ------------------------------------------------------------------- + + + +// =================================================================== +// SUSE_SoftwareInstallationService +// =================================================================== + +[ Provider("cmpi:cmpi-zypp"), + Description ("A Class which provide a SoftwareInstallationService.") +] +class SUSE_SoftwareInstallationService : CIM_SoftwareInstallationService +{ +}; + + diff --git a/mof/SUSE_SoftwareInstallationService.sfcb.reg b/mof/SUSE_SoftwareInstallationService.sfcb.reg new file mode 100644 index 0000000..d5c1928 --- /dev/null +++ b/mof/SUSE_SoftwareInstallationService.sfcb.reg @@ -0,0 +1,5 @@ +[SUSE_SoftwareInstallationService] + provider: SUSE_SoftwareInstallationServiceProvider + location: cmpi-zypp + type: instance + namespace: root/cimv2 diff --git a/mof/deploy.mof b/mof/deploy.mof index bdda0bc..d6df3a7 100644 --- a/mof/deploy.mof +++ b/mof/deploy.mof @@ -4,4 +4,5 @@ #pragma include ("SUSE_SystemSpecificCollection.mof") #pragma include ("SUSE_MemberOfCollection.mof") #pragma include ("SUSE_HostedCollection.mof") +#pragma include ("SUSE_SoftwareInstallationService.mof") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7d95d11..f25077f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,6 +14,7 @@ SET( CMPIZYPP_SRCS SUSE_SystemSpecificCollectionProvider.cc SUSE_MemberOfCollectionProvider.cc SUSE_HostedCollectionProvider.cc + SUSE_SoftwareInstallationServiceProvider.cc ) SET( CMPIZYPP_HEADERS SUSE_Common.h @@ -24,6 +25,7 @@ SET( CMPIZYPP_HEADERS SUSE_MemberOfCollectionProvider.h SUSE_HostedCollectionProvider.h SUSE_AssocFilter.h + SUSE_SoftwareInstallationServiceProvider.h ) ADD_LIBRARY(cmpi-zypp SHARED ${CMPIZYPP_SRCS}) diff --git a/src/SUSE_SoftwareInstallationServiceProvider.cc b/src/SUSE_SoftwareInstallationServiceProvider.cc new file mode 100644 index 0000000..d1912c1 --- /dev/null +++ b/src/SUSE_SoftwareInstallationServiceProvider.cc @@ -0,0 +1,127 @@ + +#include <iostream> + +#include <cmpi/cmpimacs.h> +#include <cmpi/cmpidt.h> +#include <cmpi/CmpiResult.h> +#include <cmpi/CmpiBroker.h> +#include <cmpi/CmpiArray.h> +#include <cmpi/CmpiBooleanData.h> + +#include <zypp/base/String.h> +#include <zypp/base/LogTools.h> + +#include "SUSE_zypp.h" +#include "SUSE_Common.h" +#include "SUSE_SoftwareInstallationServiceProvider.h" + +using namespace zypp; +using std::endl; + +namespace cmpizypp +{ + namespace + { + const char * _ClassName = "SUSE_SoftwareInstallationService"; + const char * _Name = "ZYPP"; + } // namespace + + +SUSE_SoftwareInstallationServiceProviderClass::SUSE_SoftwareInstallationServiceProviderClass( const CmpiBroker & mbp, const CmpiContext & ctx ) + : CmpiBaseMI( mbp, ctx ) + , CmpiInstanceMI( mbp, ctx ) +{ +} + +CmpiStatus SUSE_SoftwareInstallationServiceProviderClass::enumInstanceNames( const CmpiContext& ctx, CmpiResult& rslt, const CmpiObjectPath & cop ) +{ + _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstanceNames() called",_ClassName)); + + CmpiObjectPath csop = get_this_computersystem(*broker, ctx, cop); + const char *sccn = csop.getKey("CreationClassName"); + const char *sn = csop.getKey("Name"); + + CmpiObjectPath op( cop.getNameSpace(), _ClassName ); + op.setKey( "SystemCreationClassName", sccn); + op.setKey( "SystemName", sn); + op.setKey( "CreationClassName", _ClassName); + op.setKey( "Name", _Name); + rslt.returnData( op ); + + rslt.returnDone(); + _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstanceNames() exited",_ClassName)); + return CmpiStatus(CMPI_RC_OK); +} + +CmpiStatus SUSE_SoftwareInstallationServiceProviderClass::enumInstances( const CmpiContext & ctx, CmpiResult & rslt, const CmpiObjectPath & cop, const char** properties ) +{ + _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstances() called",_ClassName)); + + CmpiObjectPath op( cop.getNameSpace(), _ClassName ); + CmpiInstance ci( op ); + + CmpiObjectPath csop = get_this_computersystem(*broker, ctx, cop); + const char *sccn = csop.getKey("CreationClassName"); + const char *sn = csop.getKey("Name"); + + const char * keys[] = { "SystemCreationClassName", "SystemName", "CreationClassName", "Name" }; + ci.setPropertyFilter( properties, keys ); + + ci.setProperty( "SystemCreationClassName", sccn ); + ci.setProperty( "SystemName", sn ); + ci.setProperty( "CreationClassName", _ClassName ); + ci.setProperty( "Name", _Name ); + + rslt.returnData( ci ); + + rslt.returnDone(); + _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstances() exited",_ClassName)); + return CmpiStatus(CMPI_RC_OK); +} + + +CmpiStatus SUSE_SoftwareInstallationServiceProviderClass::getInstance( const CmpiContext &ctx, CmpiResult &rslt, const CmpiObjectPath &cop, const char **properties ) +{ + _CMPIZYPP_TRACE(1,("--- %s CMPI GetInstance() called",_ClassName)); + + const char *lsccn = cop.getKey("SystemCreationClassName"); + const char *lsn = cop.getKey("SystemName"); + const char *lccn = cop.getKey("CreationClassName"); + const char *ln = cop.getKey("Name"); + + CmpiObjectPath csop = get_this_computersystem(*broker, ctx, cop); + const char *sccn = csop.getKey("CreationClassName"); + const char *sn = csop.getKey("Name"); + + if( lsccn== NULL || lsn == NULL || lccn == NULL || ln == NULL || + ::strcmp(lccn, _ClassName) != 0 || ::strcmp(ln, _Name) != 0 || + ::strcmp(lsccn, sccn) != 0 || ::strcmp(lsn, sn) != 0) + { + CmpiStatus rc( CMPI_RC_ERR_FAILED, "Could not find this instance." ); + _CMPIZYPP_TRACE(1,("--- %s CMPI GetInstance() failed : %s", _ClassName, rc.msg())); + return rc; + } + + CmpiObjectPath op( cop.getNameSpace(), _ClassName ); + CmpiInstance ci( op ); + + const char * keys[] = { "SystemCreationClassName", "SystemName", "CreationClassName", "Name" }; + ci.setPropertyFilter( properties, keys ); + + ci.setProperty( "SystemCreationClassName", sccn ); + ci.setProperty( "SystemName", sn ); + ci.setProperty( "CreationClassName", _ClassName ); + ci.setProperty( "Name", _Name ); + + rslt.returnData( ci ); + + rslt.returnDone(); + _CMPIZYPP_TRACE(1,("--- %s CMPI GetInstance() exited",_ClassName)); + return CmpiStatus(CMPI_RC_OK); +} + +} // namespace cmpizypp + +CMProviderBase( SUSE_SoftwareInstallationServiceProvider ); + +CMInstanceMIFactory( cmpizypp::SUSE_SoftwareInstallationServiceProviderClass, SUSE_SoftwareInstallationServiceProvider ); diff --git a/src/SUSE_SoftwareInstallationServiceProvider.h b/src/SUSE_SoftwareInstallationServiceProvider.h new file mode 100644 index 0000000..4d8714f --- /dev/null +++ b/src/SUSE_SoftwareInstallationServiceProvider.h @@ -0,0 +1,22 @@ +#ifndef SUSE_SOFTWAREINSTALLATIONSERVICEPROVIDER_H +#define SUSE_SOFTWAREINSTALLATIONSERVICEPROVIDER_H + +#include <cmpi/CmpiInstanceMI.h> + +namespace cmpizypp +{ + /** + */ + class SUSE_SoftwareInstallationServiceProviderClass : public CmpiInstanceMI + { + public: + SUSE_SoftwareInstallationServiceProviderClass( 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 ); + }; + +} // namespace cmpizypp + +#endif // SUSE_SOFTWAREINSTALLATIONSERVICEPROVIDER_H -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org
participants (1)
-
Michael Calmer