summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadek Novacek <rnovacek@redhat.com>2012-07-25 15:14:35 +0200
committerRadek Novacek <rnovacek@redhat.com>2012-07-25 16:22:20 +0200
commit7af9250873ef0f7177f71c8f2faf549c051f7fe5 (patch)
treee5c195f20ffa73538a69420581c443e9b42cbb4a
parentfef70e4d67b3db1bd1d70ca419f253fb0786e20d (diff)
downloadopenlmi-providers-7af9250873ef0f7177f71c8f2faf549c051f7fe5.tar.gz
openlmi-providers-7af9250873ef0f7177f71c8f2faf549c051f7fe5.tar.xz
openlmi-providers-7af9250873ef0f7177f71c8f2faf549c051f7fe5.zip
service: convert to using KonkretCMPI
-rw-r--r--src/service/Linux_ServiceProvider.c334
-rw-r--r--src/service/Service.c343
-rw-r--r--src/service/ServiceUtils.c57
-rw-r--r--src/service/ServiceUtils.h11
-rw-r--r--src/service/util/serviceutil.c27
-rw-r--r--src/service/util/serviceutil.h6
6 files changed, 346 insertions, 432 deletions
diff --git a/src/service/Linux_ServiceProvider.c b/src/service/Linux_ServiceProvider.c
new file mode 100644
index 0000000..7cbf54b
--- /dev/null
+++ b/src/service/Linux_ServiceProvider.c
@@ -0,0 +1,334 @@
+#include <konkret/konkret.h>
+#include <stdint.h>
+#include "Linux_Service.h"
+#include "ServiceUtils.h"
+#include "util/serviceutil.h"
+
+static const CMPIBroker* _cb = NULL;
+
+static void Linux_ServiceInitialize()
+{
+}
+
+static CMPIStatus Linux_ServiceCleanup(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ CMPIBoolean term)
+{
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus Linux_ServiceEnumInstanceNames(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop)
+{
+ const char *ns = KNameSpace(cop);
+ SList *slist = NULL;
+
+ slist = Service_Find_All();
+ for (int i = 0; i < slist->cnt; i++) {
+ Linux_ServiceRef w;
+ Linux_ServiceRef_Init(&w, _cb, ns);
+ Linux_ServiceRef_Set_CreationClassName(&w, CreationClassName());
+ Linux_ServiceRef_Set_SystemCreationClassName(&w, SystemCreationClassName());
+ Linux_ServiceRef_Set_SystemName(&w, SystemName());
+ Linux_ServiceRef_Set_Name(&w, slist->name[i]);
+
+ KReturnObjectPath(cr, w);
+ }
+ Service_Free_SList(slist);
+
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus Linux_ServiceEnumInstances(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char** properties)
+{
+ CMPIStatus st;
+ CMPIEnumeration* e;
+ if (!(e = _cb->bft->enumerateInstanceNames(_cb, cc, cop, &st))) {
+ KReturn(ERR_FAILED);
+ }
+ CMPIData cd;
+ while (CMHasNext(e, &st)) {
+
+ cd = CMGetNext(e, &st);
+ if (st.rc || cd.type != CMPI_ref) {
+ KReturn(ERR_FAILED);
+ }
+
+ CMPIInstance *in = _cb->bft->getInstance(_cb, cc, cd.value.ref, properties, &st);
+ if (st.rc) {
+ KReturn(ERR_FAILED);
+ }
+ cr->ft->returnInstance(cr, in);
+ }
+ KReturn(OK);
+}
+
+static CMPIStatus Linux_ServiceGetInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char** properties)
+{
+ Linux_Service w;
+ Linux_Service_InitFromObjectPath(&w, _cb, cop);
+
+ void *enumhdl = Service_Begin_Enum(w.Name.chars);
+ Service servicebuf;
+ if (Service_Next_Enum(enumhdl, &servicebuf, w.Name.chars)) {
+ Linux_Service_Set_Status(&w, servicebuf.svStatus);
+ Linux_Service_Set_Started(&w, servicebuf.svStarted);
+
+ switch (servicebuf.svEnabledDefault) {
+ case ENABLED:
+ Linux_Service_Set_EnabledDefault(&w, Linux_Service_EnabledDefault_Enabled);
+ break;
+ case DISABLED:
+ Linux_Service_Set_EnabledDefault(&w, Linux_Service_EnabledDefault_Disabled);
+ break;
+ default:
+ Linux_Service_Set_EnabledDefault(&w, Linux_Service_EnabledDefault_Not_Applicable);
+ break;
+ }
+
+ KReturnInstance(cr, w);
+ }
+ KReturn(OK);
+}
+
+static CMPIStatus Linux_ServiceCreateInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const CMPIInstance* ci)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus Linux_ServiceModifyInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const CMPIInstance* ci,
+ const char** properties)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus Linux_ServiceDeleteInstance(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+static CMPIStatus Linux_ServiceExecQuery(
+ CMPIInstanceMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* lang,
+ const char* query)
+{
+ CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
+}
+
+CMInstanceMIStub(
+ Linux_Service,
+ Linux_Service,
+ _cb,
+ Linux_ServiceInitialize())
+
+static CMPIStatus Linux_ServiceMethodCleanup(
+ CMPIMethodMI* mi,
+ const CMPIContext* cc,
+ CMPIBoolean term)
+{
+ CMReturn(CMPI_RC_OK);
+}
+
+static CMPIStatus Linux_ServiceInvokeMethod(
+ CMPIMethodMI* mi,
+ const CMPIContext* cc,
+ const CMPIResult* cr,
+ const CMPIObjectPath* cop,
+ const char* meth,
+ const CMPIArgs* in,
+ CMPIArgs* out)
+{
+ return Linux_Service_DispatchMethod(
+ _cb, mi, cc, cr, cop, meth, in, out);
+}
+
+CMMethodMIStub(
+ Linux_Service,
+ Linux_Service,
+ _cb,
+ Linux_ServiceInitialize())
+
+KUint32 Linux_Service_RequestStateChange(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_ServiceRef* self,
+ const KUint16* RequestedState,
+ KRef* Job,
+ const KDateTime* TimeoutPeriod,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+
+ KSetStatus(status, ERR_NOT_SUPPORTED);
+ return result;
+}
+
+unsigned int Service_RunOperation(const char *service, const char *operation, CMPIStatus *status)
+{
+ char output[1024];
+ int res = Service_Operation(service, operation, output, sizeof(output));
+ if (res == 0) {
+ KSetStatus2(_cb, status, OK, output);
+ } else {
+ KSetStatus2(_cb, status, ERR_FAILED, output);
+ }
+ return res;
+}
+
+KUint32 Linux_Service_StartService(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_ServiceRef* self,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+ KUint32_Set(&result, Service_RunOperation(self->Name.chars, "start", status));
+ return result;
+}
+
+KUint32 Linux_Service_StopService(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_ServiceRef* self,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+ KUint32_Set(&result, Service_RunOperation(self->Name.chars, "stop", status));
+ return result;
+}
+
+KUint32 Linux_Service_ReloadService(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_ServiceRef* self,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+ KUint32_Set(&result, Service_RunOperation(self->Name.chars, "reload", status));
+ return result;
+}
+
+KUint32 Linux_Service_RestartService(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_ServiceRef* self,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+ KUint32_Set(&result, Service_RunOperation(self->Name.chars, "restart", status));
+ return result;
+}
+
+KUint32 Linux_Service_TryRestartService(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_ServiceRef* self,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+ KUint32_Set(&result, Service_RunOperation(self->Name.chars, "try-restart", status));
+ return result;
+}
+
+KUint32 Linux_Service_CondRestartService(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_ServiceRef* self,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+ KUint32_Set(&result, Service_RunOperation(self->Name.chars, "condrestart", status));
+ return result;
+}
+
+KUint32 Linux_Service_ReloadOrRestartService(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_ServiceRef* self,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+ KUint32_Set(&result, Service_RunOperation(self->Name.chars, "reload-or-restart", status));
+ return result;
+}
+
+KUint32 Linux_Service_ReloadOrTryRestartService(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_ServiceRef* self,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+ KUint32_Set(&result, Service_RunOperation(self->Name.chars, "reload-or-try-restart", status));
+ return result;
+}
+
+KUint32 Linux_Service_TurnServiceOn(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_ServiceRef* self,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+ KUint32_Set(&result, Service_RunOperation(self->Name.chars, "enable", status));
+ return result;
+}
+
+KUint32 Linux_Service_TurnServiceOff(
+ const CMPIBroker* cb,
+ CMPIMethodMI* mi,
+ const CMPIContext* context,
+ const Linux_ServiceRef* self,
+ CMPIStatus* status)
+{
+ KUint32 result = KUINT32_INIT;
+ KUint32_Set(&result, Service_RunOperation(self->Name.chars, "disable", status));
+ return result;
+}
+
+KONKRET_REGISTRATION(
+ "root/cimv2",
+ "Linux_Service",
+ "Linux_Service",
+ "instance method")
diff --git a/src/service/Service.c b/src/service/Service.c
deleted file mode 100644
index 8ab8591..0000000
--- a/src/service/Service.c
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Service.c
- *
- * Copyright (C) 2012 Red Hat, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * Based on Syslog_Service.c from sblim-cmpi-syslog written by
- * R Sharada <sharada@in.ibm.com>, Copyright (c) IBM Corp. 2003, 2009
- *
- * Red Hat Author(s): Vitezslav Crhonek <vcrhonek@redhat.com>
- *
- */
-
-#include <cmpidt.h>
-#include <cmpift.h>
-#include <cmpimacs.h>
-#include <string.h>
-
-#include "ServiceUtils.h"
-#include "util/serviceutil.h"
-#define LOCALCLASSNAME "Linux_Service"
-
-static const CMPIBroker *_broker;
-
-#ifdef CMPI_VER_100
-#define ServiceSetInstance ServiceModifyInstance
-#endif
-
-
-
-/* Instance MI Cleanup */
-CMPIStatus
-ServiceCleanup(CMPIInstanceMI *mi,
- const CMPIContext *ctx,
- CMPIBoolean terminate)
-{
- CMReturn(CMPI_RC_OK);
-}
-
-
-
-/* Instance MI Functions */
-CMPIStatus
-ServiceEnumInstanceNames(CMPIInstanceMI *mi,
- const CMPIContext *ctx,
- const CMPIResult *rslt,
- const CMPIObjectPath *ref)
-{
- CMPIObjectPath *op = NULL;
- CMPIStatus st = {CMPI_RC_OK,NULL};
- void *enumhdl = NULL;
- Service servicebuf;
- int i = 0;
- SList *slist = NULL;
-
- service_debug(stderr,"ServiceEnumInstanceNames() called, ctx %p, result %p, op %p", ctx, rslt, ref);
-
- memset(&servicebuf, '\0', sizeof(Service));
-
- slist = Service_Find_All();
-
- for(i = 0; i < slist->cnt; i++)
- {
- enumhdl = Service_Begin_Enum(slist->name[i]);
- if (enumhdl == NULL)
- {
- CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
- "Could not begin service names enumeration");
- Service_Free_SList(slist);
- return st;
- }
- else
- {
- if (Service_Next_Enum(enumhdl, &servicebuf, slist->name[i]))
- {
- // build object path from buffer
- op = makeServicePath(_broker,
- LOCALCLASSNAME,
- CMGetCharPtr(CMGetNameSpace(ref, NULL)),
- &servicebuf);
- if (CMIsNullObject(op))
- {
- CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
- "Could not construct object path");
- goto label;
- }
- CMReturnObjectPath(rslt, op);
- }
-label:
- CMReturnDone(rslt);
- Service_End_Enum(enumhdl);
- }
- }
-
- Service_Free_SList(slist);
- return st;
-}
-
-
-
-CMPIStatus
-ServiceEnumInstances(CMPIInstanceMI *mi,
- const CMPIContext *ctx,
- const CMPIResult *rslt,
- const CMPIObjectPath *ref,
- const char **properties)
-{
- CMPIInstance *in = NULL;
- CMPIStatus st = {CMPI_RC_OK,NULL};
- void *enumhdl = NULL;
- Service servicebuf;
- int i = 0;
- SList *slist = NULL;
-
- service_debug(stderr,"ServiceEnumInstances() called, ctx %p, result %p, op %p", ctx, rslt, ref);
-
- memset(&servicebuf, '\0', sizeof(Service));
-
- slist = Service_Find_All();
-
- for(i = 0; i < slist->cnt; i++)
- {
- enumhdl = Service_Begin_Enum(slist->name[i]);
- if (enumhdl == NULL)
- {
- CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
- "Could not begin service instances enumeration");
- Service_Free_SList(slist);
- return st;
- }
- else
- {
- if (Service_Next_Enum(enumhdl, &servicebuf, slist->name[i]))
- {
- // build object instance from buffer
- in = makeServiceInstance(_broker,
- LOCALCLASSNAME,
- CMGetCharPtr(CMGetNameSpace(ref, NULL)),
- &servicebuf);
- if (CMIsNullObject(in))
- {
- CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
- "Could not construct instance");
- goto label;
- }
- CMReturnInstance(rslt, in);
- }
-label:
- CMReturnDone(rslt);
- Service_End_Enum(enumhdl);
- }
- }
-
- Service_Free_SList(slist);
- return st;
-}
-
-
-
-CMPIStatus
-ServiceGetInstance(CMPIInstanceMI *mi,
- const CMPIContext *ctx,
- const CMPIResult *rslt,
- const CMPIObjectPath *cop,
- const char **properties)
-{
- CMPIInstance *in = NULL;
- CMPIStatus st = {CMPI_RC_OK,NULL};
- CMPIData nd;
- void *enumhdl = NULL;
- Service servicebuf;
- char *name = NULL;
- int i = 0;
-
- memset(&servicebuf, '\0', sizeof(Service));
-
- service_debug(stderr,"ServiceGetInstance() called, ctx %p, result %p, op %p", ctx, rslt, cop);
-
- nd = CMGetKey(cop, "Name", &st);
- name = CMGetCharPtr(nd.value.string);
-
- service_debug(stderr,"Name = %s", name);
-
- enumhdl = Service_Begin_Enum(name);
- if (enumhdl == NULL) {
- CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
- "Could not begin service instances enumeration");
- return st;
- } else {
- if (Service_Next_Enum(enumhdl,&servicebuf, name)) {
- if (strncmp(name, servicebuf.svName, 6)==0) {
- // build object instance from buffer
- in = makeServiceInstance(_broker,
- LOCALCLASSNAME,
- CMGetCharPtr(CMGetNameSpace(cop,NULL)),
- &servicebuf);
- if (CMIsNullObject(in)) {
- CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
- "Could not construct instance");
- goto label;
- }
- CMReturnInstance(rslt,in);
- }
- }
-label:
- CMReturnDone(rslt);
- Service_End_Enum(enumhdl);
- }
-
- return st;
-}
-
-
-
-/* Instance MI functions - not supported */
-CMPIStatus
-ServiceCreateInstance(CMPIInstanceMI *mi,
- const CMPIContext *ctx,
- const CMPIResult *rslt,
- const CMPIObjectPath *cop,
- const CMPIInstance *ci)
-{
- CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
-}
-
-
-
-CMPIStatus
-ServiceSetInstance(CMPIInstanceMI *mi,
- const CMPIContext *ctx,
- const CMPIResult *rslt,
- const CMPIObjectPath *cop,
- const CMPIInstance *ci,
- const char **properties)
-{
- CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
-}
-
-
-
-CMPIStatus
-ServiceDeleteInstance(CMPIInstanceMI *mi,
- const CMPIContext *ctx,
- const CMPIResult *rslt,
- const CMPIObjectPath *cop)
-{
- CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
-}
-
-CMPIStatus
-ServiceExecQuery(CMPIInstanceMI *mi,
- const CMPIContext *ctx,
- const CMPIResult *rslt,
- const CMPIObjectPath *cop,
- const char *lang,
- const char *query)
-{
- CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
-}
-
-
-
-/* Method MI Cleanup */
-CMPIStatus
-ServiceMethodCleanup(CMPIMethodMI *mi,
- const CMPIContext *ctx,
- CMPIBoolean terminate)
-{
- CMReturn(CMPI_RC_OK);
-}
-
-
-
-/* Method MI Functions */
-CMPIStatus
-ServiceInvokeMethod(CMPIMethodMI *mi,
- const CMPIContext *ctx,
- const CMPIResult *rslt,
- const CMPIObjectPath *cop,
- const char *method,
- const CMPIArgs *in,
- CMPIArgs *out)
-{
- CMPIStatus st = {CMPI_RC_OK,NULL};
- CMPIData dt;
- char typebuf[1000];
- char *name = NULL;
-
- memset(&typebuf, '\0', sizeof(typebuf));
-
- dt = CMGetKey(cop, "Name", &st);
- if (st.rc != CMPI_RC_OK)
- {
- CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
- "Could not get instance name");
-
- }
- else
- {
- name = CMGetCharPtr(dt.value.string);
- if (Service_Operation(name, method, typebuf, sizeof(typebuf)))
- {
- /* If the function returns 1, then failure */
- CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
- "Could not get instance type");
- }
- else
- {
- CMReturnData(rslt, typebuf, CMPI_chars);
- CMReturnDone(rslt);
- }
- }
-
- return st;
-}
-
-
-
-/* Instance MI Factory */
-CMInstanceMIStub(Service,
- Service,
- _broker,
- CMNoHook);
-
-
-
-/* Method MI Factory */
-CMMethodMIStub(Service,
- Service,
- _broker,
- CMNoHook);
diff --git a/src/service/ServiceUtils.c b/src/service/ServiceUtils.c
index 37bb081..fca8167 100644
--- a/src/service/ServiceUtils.c
+++ b/src/service/ServiceUtils.c
@@ -60,60 +60,3 @@ CreationClassName()
{
return ccn;
}
-
-
-
-CMPIObjectPath *
-makeServicePath(const CMPIBroker *broker,
- const char *classname,
- const char *namespace,
- Service *svc)
-{
- CMPIObjectPath *op = NULL;
-
- op = CMNewObjectPath(broker,
- (char*)namespace,
- (char*)classname,
- NULL);
- if (!CMIsNullObject(op))
- {
- CMAddKey(op, "CreationClassName", CreationClassName(), CMPI_chars);
- CMAddKey(op, "SystemCreationClassName", SystemCreationClassName(), CMPI_chars);
- CMAddKey(op, "SystemName", SystemName(), CMPI_chars);
- CMAddKey(op, "Name", svc->svName, CMPI_chars);
- }
-
- return op;
-}
-
-
-
-CMPIInstance *
-makeServiceInstance(const CMPIBroker *broker,
- const char * classname,
- const char * namespace,
- Service *svc)
-{
- CMPIInstance *in = NULL;
- CMPIObjectPath *op = CMNewObjectPath(broker,
- (char*) namespace,
- (char*) classname,
- NULL);
- if (!CMIsNullObject(op))
- {
- in = CMNewInstance(broker, op, NULL);
- if (!CMIsNullObject(in))
- {
- CMSetProperty(in, "CreationClassName", CreationClassName(), CMPI_chars);
- CMSetProperty(in, "SystemCreationClassName", SystemCreationClassName(), CMPI_chars);
- CMSetProperty(in, "SystemName", SystemName(), CMPI_chars);
- CMSetProperty(in, "Name", svc->svName, CMPI_chars);
- CMSetProperty(in, "Status", svc->svStatus, CMPI_chars);
- CMSetProperty(in, "Started", &svc->svStarted, CMPI_boolean);
- CMSetProperty(in, "EnabledDefault", (CMPIValue*) &(svc->svEnabledDefault), CMPI_uint16);
- }
- }
-
- return in;
-}
-
diff --git a/src/service/ServiceUtils.h b/src/service/ServiceUtils.h
index a79833c..c76bc3c 100644
--- a/src/service/ServiceUtils.h
+++ b/src/service/ServiceUtils.h
@@ -26,12 +26,13 @@
#ifndef SERVICEUTILS_H
#define SERVICEUTILS_H
-#include "util/serviceutil.h"
+char *
+SystemCreationClassName();
-CMPIObjectPath *
-makeServicePath(const CMPIBroker *broker, const char *classname, const char *namespace, Service *svc);
+char *
+SystemName();
-CMPIInstance *
-makeServiceInstance(const CMPIBroker *broker, const char *classname, const char *namespace, Service *svc);
+char *
+CreationClassName();
#endif
diff --git a/src/service/util/serviceutil.c b/src/service/util/serviceutil.c
index 829d0ec..a326ad7 100644
--- a/src/service/util/serviceutil.c
+++ b/src/service/util/serviceutil.c
@@ -207,7 +207,7 @@ Service_End_Enum(void *handle)
}
}
-int
+unsigned int
Service_Operation(const char *service, const char *method, char *result, int resultlen)
{
char cmdbuffer[OPERATION_BUFSIZE];
@@ -220,32 +220,9 @@ Service_Operation(const char *service, const char *method, char *result, int res
memset(&cmdout, '\0', sizeof(cmdout));
asprintf(&cmdout, "%s", "/tmp/Service_OperationXXXXXX");
- if (!strcasecmp(method, "startservice"))
- op="start";
- else if (!strcasecmp(method, "stopservice"))
- op="stop";
- else if (!strcasecmp(method, "reloadservice"))
- op="reload";
- else if (!strcasecmp(method, "restartservice"))
- op="restart";
- else if (!strcasecmp(method, "tryrestartservice"))
- op="try-restart";
- else if (!strcasecmp(method, "condrestartservice"))
- op="condrestart";
- else if (!strcasecmp(method, "reloadorrestartservice"))
- op="reload-or-restart";
- else if (!strcasecmp(method, "reloadortryrestartservice"))
- op="reload-or-try-restart";
- else if (!strcasecmp(method, "turnserviceon"))
- op="enable";
- else if (!strcasecmp(method, "turnserviceoff"))
- op="disable";
- else
- return -1;
-
if (op && ((fd = mkstemp(cmdout)) != -1))
{
- snprintf(cmdbuffer, OPERATION_BUFSIZE, "%s %s %s > %s", suscript, op, service, cmdout);
+ snprintf(cmdbuffer, OPERATION_BUFSIZE, "%s %s %s > %s", suscript, method, service, cmdout);
if (system(cmdbuffer) == 0)
{
/* we got some output? */
diff --git a/src/service/util/serviceutil.h b/src/service/util/serviceutil.h
index a4a9d11..74f4786 100644
--- a/src/service/util/serviceutil.h
+++ b/src/service/util/serviceutil.h
@@ -36,13 +36,15 @@
#define ARRAY_SIZE(name) (sizeof(name) / sizeof(name[0]))
+enum ServiceEnabledDefault { ENABLED = 2, DISABLED = 3, NOT_APPICABLE = 5};
+
struct _Service {
char *svSystemCCname;
char *svSystemname;
char *svCCname;
char *svName; /* "rsyslog", "httpd", ... */
char *svStatus; /* "Stopped", "OK" */
- int *svEnabledDefault; /* 5 - "Not Applicable", 2 - "Enabled", 3 - "Disabled" */
+ enum ServiceEnabledDefault svEnabledDefault;
int svStarted; /* 0, 1 */
int pid; /* PID */
};
@@ -62,6 +64,6 @@ void *Service_Begin_Enum(const char *service);
int Service_Next_Enum(void *handle, Service* svc, const char *service);
void Service_End_Enum(void *handle);
-int Service_Operation(const char *service, const char *method, char *result, int resultlen);
+unsigned int Service_Operation(const char *service, const char *method, char *result, int resultlen);
#endif