Send Linux-ha-cvs mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Linux-ha-cvs digest..."


Today's Topics:

   1. Linux-HA CVS: cim by panjiam from 
      ([email protected])


----------------------------------------------------------------------

Message: 1
Date: Sun, 19 Mar 2006 20:25:56 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: cim by panjiam from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : panjiam
Host    : 
Project : linux-ha
Module  : cim

Dir     : linux-ha/cim


Modified Files:
        cluster_provider.c 


Log Message:
cluster config files update/creation
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/cim/cluster_provider.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- cluster_provider.c  22 Dec 2005 06:11:48 -0000      1.2
+++ cluster_provider.c  20 Mar 2006 03:25:55 -0000      1.3
@@ -37,220 +37,264 @@
 #include <clplumbing/cl_malloc.h>
 #include "cmpi_utils.h"
 #include "cluster_info.h"
+#include "utils.h"
 
-static const char * PROVIDER_ID = "cim-cluster";
-static CMPIBroker * G_broker    = NULL;
-static char G_classname []      = "HA_Cluster";
-static char G_instname  []      = "LinuxHACluster";
-static char G_caption   []      = "LinuxHA Cluster";
-
-struct key_name_pair {
-       const char * key;       /* hb config key */
-       const char * name;      /* CIM property name */
-};
-
-/* heartbeat config directives */
-static const struct key_name_pair G_keyname [] = {
-               {KEY_HBVERSION, "HBVersion"},
-               {KEY_HOST,      "Node"},
-               {KEY_HOPS,      "HOPFudge"},
-               {KEY_KEEPALIVE, "KeepAlive"},
-               {KEY_DEADTIME,  "DeadTime"},
-               {KEY_DEADPING,  "DeadPing"},
-               {KEY_WARNTIME,  "WarnTime"},
-               {KEY_INITDEAD,  "InitDead"},
-               {KEY_WATCHDOG,  "WatchdogTimer"},
-               {KEY_BAUDRATE,  "BaudRate"},
-               {KEY_UDPPORT,   "UDPPort"},
-               {KEY_FACILITY,  "LogFacility"},
-               {KEY_LOGFILE,   "LogFile"},
-               {KEY_DBGFILE,   "DebugFile"},
-               {KEY_FAILBACK,  "NiceFailBack"},
-               {KEY_AUTOFAIL,  "AutoFailBack"},
-               {KEY_STONITH,   "Stonith"},
-               {KEY_STONITHHOST,       "StonithHost"},
-               {KEY_CLIENT_CHILD,      "Respawn"},
-               {KEY_RT_PRIO,   "RTPriority"},
-               {KEY_GEN_METH,  "GenMethod"},
-               {KEY_REALTIME,  "RealTime"},
-               {KEY_DEBUGLEVEL,"DebugLevel"},
-               {KEY_NORMALPOLL,"NormalPoll"},
-               {KEY_APIPERM,   "APIAuth"},
-               {KEY_MSGFMT,    "MsgFmt"},
-               {KEY_LOGDAEMON, "UseLogd"},
-               {KEY_CONNINTVAL,"ConnLogdTime"},
-               {KEY_BADPACK,   "LogBadPack"},
-               {KEY_REGAPPHBD, "NormalPoll"},
-               {KEY_COREDUMP,  "CoreDump"},
-               {KEY_COREROOTDIR,       "CoreRootDir"},
-               {KEY_REL2,      "WithCrm"},
-               {0, 0}
-};
-
-static CMPIInstance *
-make_cluster_instance(CMPIObjectPath * op, CMPIStatus * rc);
-static int
-get_inst_cluster(CMPIContext * ctx, CMPIResult * rslt,
-                 CMPIObjectPath * cop, CMPIStatus * rc);
-static int
-enum_inst_cluster(CMPIContext * ctx, CMPIResult * rslt, CMPIObjectPath * cop,
-                  char ** properties, int enum_inst, CMPIStatus * rc);
-static int cleanup_cluster(void); 
+static const char *    PROVIDER_ID = "cim-hb";
+static CMPIBroker *    Broker    = NULL;
+static char            ClassName []  = "HA_Cluster";
+static char            InstName  []  = "LinuxHACluster";
+static char            Caption   []  = "LinuxHA Cluster";
+
+/* auth map */
+uint32_t        auth_valuemap [] = {0, 1, 2};
+const char *    auth_values   [] = {"sha1", "md5", "crc"};
+static uint32_t last_requested_state = 5; /* Not Changed */
+static const mapping_t ClusterMap [] = { MAPPING_HA_Cluster };
+
+static CMPIInstance * make_cluster_instance(CMPIObjectPath * op, 
+                       CMPIStatus * rc);
+
+static int      get_cluster(CMPIContext * ctx, CMPIResult * rslt,
+                       CMPIObjectPath * cop, CMPIStatus * rc);
+
+static int      enumerate_cluster(CMPIContext * ctx, CMPIResult * rslt, 
+                        CMPIObjectPath * cop, char ** properties,
+                        int enum_inst, CMPIStatus * rc);
+
+static uint32_t auth_value2map(const char * method);
+static const char *   auth_map2value(uint32_t map);
+
+static void     config_set_properties(CMPIInstance * ci, CMPIStatus * rc);
+static void     auth_set_properties(CMPIInstance * ci, CMPIStatus * rc);
+static void     crm_set_properties(CMPIInstance * ci, CMPIStatus * rc);
+
+/* set instance */
+static int     process_config_data(const mapping_t * property, 
+                       CIMTable * cfginfo, CMPIData cmpidata, 
+                       CMPIStatus * rc);
+
+static int      update_inst_cluster(CMPIContext * ctx, CMPIResult * rslt, 
+                        CMPIObjectPath * op, CMPIInstance * inst, 
+                        CMPIStatus * rc);
+static int      request_state_change(int state);
+static int      cleanup_cluster(void); 
 
 DeclareInstanceFunctions(Cluster);
 
-/* always only one cluster instance */
-static CMPIInstance *
-make_cluster_instance(CMPIObjectPath * op, CMPIStatus * rc)
+
+static uint32_t
+auth_value2map(const char * method) 
+{
+        int i;
+        for (i = 0; i < sizeof(auth_valuemap)/sizeof(uint32_t); i++) {
+                if ( strcmp(auth_values[i], method) == 0)  {
+                        return auth_valuemap[i];
+                }
+        }
+        return -1;
+}
+
+static const char *
+auth_map2value(uint32_t map)
 {
-        CMPIInstance * ci = NULL;
-        struct ci_table * info = NULL;
-        const struct key_name_pair * pair = G_keyname;
-        struct ci_table * crm_config;
+        int i;
+        for (i = 0; i < sizeof(auth_valuemap)/sizeof(uint32_t); i++) {
+                if ( map == auth_valuemap[i] ) {
+                        return auth_values[i];
+                }
+        }
+        return NULL;
+}
 
-        info = ci_get_cluster_config ();
+static void
+config_set_properties(CMPIInstance * ci, CMPIStatus * rc)
+{
+       CIMTable * info;
 
+        DEBUG_ENTER();
+       /* get cluster config values */
+        info = cim_get_hacf_config ();
         if ( info == NULL ) {
-                cl_log(LOG_ERR, "%s: couldn't get cluster's information", 
__FUNCTION__);
-               CMSetStatusWithChars(G_broker, rc, CMPI_RC_ERR_FAILED, 
-                                     "Could not get cluster information.");
+                cl_log(LOG_ERR, "%s:can not get cluster.", __FUNCTION__);
+               return;
+       }
+       dump_cim_table(info, 0);
+       cmpi_set_properties(Broker, ci, info, 
+                       ClusterMap, MAPDIM(ClusterMap), rc); 
+       DEBUG_LEAVE();
+       cim_table_free(info);
+}
+
+static void
+auth_set_properties(CMPIInstance * ci, CMPIStatus * rc)
+{
+       CIMTable * table = NULL;
+        uint32_t   num;
+        char*      method;
+       char*      key;
+
+       DEBUG_ENTER();
+        if ( (table = cim_get_cluster_auth()) == NULL  ){
+               cl_log(LOG_WARNING, "Can not get auth message");
+                 return;
+        }
+
+       dump_cim_table(table, 0);
+        method = cim_table_lookup_v(table, "authmethod").v.str;
+        key = cim_table_lookup_v(table, "authkey").v.str;
+
+        num = auth_value2map(method);
+        CMSetProperty(ci, "AuthMethod", &num, CMPI_uint32);
+        CMSetProperty(ci, "AuthKey", key, CMPI_chars);
+       
+       DEBUG_LEAVE();
+       cim_table_free(table);
+}
+
+static void
+crm_set_properties(CMPIInstance * ci, CMPIStatus * rc)
+{
+        CIMTable * crm_config;
+        char * it, * sc, * se;
+        char * nq, * rs, * hq;
+
+        if (( crm_config = cim_get(GET_CRM_CONFIG, NULL, NULL)) == NULL ) {
+               return;
+       }
+                
+        it = cim_table_lookup_v(crm_config, "transition_idle_timeout").v.str;
+        sc = cim_table_lookup_v(crm_config, "symmetric_cluster").v.str;
+        se = cim_table_lookup_v(crm_config, "stonith_enabled").v.str;
+        nq = cim_table_lookup_v(crm_config, "no_quorum_policy").v.str;
+        rs = cim_table_lookup_v(crm_config, 
"default_resource_stickiness").v.str;
+        hq = cim_table_lookup_v(crm_config, "have_quorum").v.str;
+                
+        if (it && sc && se && nq && rs && hq) {
+               CMSetProperty(ci, "TransitionIdleTimeout",     it, CMPI_chars);
+                CMSetProperty(ci, "SymmetricCluster",          sc, CMPI_chars);
+               CMSetProperty(ci, "StonithEnabled",            se, CMPI_chars);
+                CMSetProperty(ci, "NoQuorumPolicy",            nq, CMPI_chars);
+                CMSetProperty(ci, "DefaultResourceStickiness", rs, CMPI_chars);
+                CMSetProperty(ci, "HaveQuorum",                hq, CMPI_chars);
+       }
 
-                return NULL;
-        }
+       cim_table_free(crm_config);
+}
 
-        ci = CMNewInstance(G_broker, op, rc);
+/* always only one cluster instance */
+static CMPIInstance *
+make_cluster_instance(CMPIObjectPath * op, CMPIStatus * rc)
+{
+        CMPIInstance *         ci = NULL;
+       uint32_t               state = 0;
+       CIMTable *           table;
+
+       DEBUG_ENTER();
+        ci = CMNewInstance(Broker, op, rc);
         if ( CMIsNullObject(ci) ) {
                 cl_log(LOG_ERR, "%s: couldn't create instance", __FUNCTION__);
-               CMSetStatusWithChars(G_broker, rc, 
+               CMSetStatusWithChars(Broker, rc, 
                       CMPI_RC_ERR_FAILED, "Could not create instance.");
-
                 return NULL;
         }
 
-        while ( pair->key ) {
-                struct ci_data  data;
-                data = info->get_data(info, pair->key);
-                if ( data.value.string == NULL ){
-                        cl_log(LOG_WARNING, "couldn't find value for key %s", 
pair->key);
-                        pair ++;
-                        continue;
-                }
-                CMSetProperty(ci, pair->name, data.value.string, CMPI_chars);
-                pair ++;
-        }
-
-        CMSetProperty(ci, "CreationClassName", G_classname, CMPI_chars);
-        CMSetProperty(ci, "Name", G_instname, CMPI_chars);
-        CMSetProperty(ci, "Caption", G_caption, CMPI_chars);
-
-        if (( crm_config = ci_get_crm_config()) != NULL ) {
-                char * idle_timeout, * symmetric_cluster;
-                char * stonith_enabled, * no_quorum_policy;
-                char * res_stickiness, * have_quorum;
-                
-                idle_timeout =  crm_config->get_data(crm_config, 
-                                      "transition_idle_timeout").value.string;
-                symmetric_cluster = crm_config->get_data(crm_config,
-                                      "symmetric_cluster").value.string;
-                stonith_enabled = crm_config->get_data(crm_config, 
-                                       "stonith_enabled").value.string;
-                no_quorum_policy = crm_config->get_data(crm_config,
-                                       "no_quorum_policy").value.string;
-                res_stickiness = crm_config->get_data(crm_config,
-                                       
"default_resource_stickiness").value.string;
-                have_quorum = crm_config->get_data(crm_config,
-                                       "have_quorum").value.string;
-                
-                if ( idle_timeout )
-                        CMSetProperty(ci, "TransitionIdleTimeout", 
-                                      idle_timeout, CMPI_chars);
-                if (symmetric_cluster)
-                        CMSetProperty(ci, "SymmetricCluster", 
-                                      symmetric_cluster, CMPI_chars);
-                if ( stonith_enabled)
-                        CMSetProperty(ci, "StonithEnabled", 
-                                      stonith_enabled, CMPI_chars);
-                if ( no_quorum_policy)
-                        CMSetProperty(ci, "NoQuorumPolicy", 
-                                      no_quorum_policy, CMPI_chars);
-                if ( res_stickiness )
-                        CMSetProperty(ci, "DefaultResourceStickiness",
-                                      res_stickiness, CMPI_chars);
-                if ( have_quorum)
-                        CMSetProperty(ci, "HaveQuorum", have_quorum, 
CMPI_chars);
-
-                crm_config->free(crm_config);
-        }
-
-        info->free(info);
-
+        CMSetProperty(ci, "CreationClassName", ClassName, CMPI_chars);
+        CMSetProperty(ci, "Name", InstName, CMPI_chars);
+        CMSetProperty(ci, "Caption", Caption, CMPI_chars);
+
+       /* set config properties */
+       config_set_properties(ci, rc);
+
+        /* set auth properties */
+        auth_set_properties(ci, rc);
+
+       state = 3;      /* Disabled */
+        if( cim_get_hb_status() == HB_RUNNING) {
+               state = 2; /* Enabled */
+               /* set crm properties */
+               crm_set_properties(ci, rc); 
+       } 
+
+       CMSetProperty(ci, "EnabledState", &state, CMPI_uint32);
+       CMSetProperty(ci, "RequestedState", &last_requested_state, CMPI_uint32);
+
+       if ( (table = cim_get_software_identity() )){
+               char * hv;
+               hv = cim_table_lookup_v(table, "hbversion").v.str;
+               dump_cim_table(table, 0);
+               if (hv) {
+                       CMSetProperty(ci, "HBVersion", hv, CMPI_chars);
+               }
+       }
+       DEBUG_LEAVE();
         return ci;        
 }
 
+/* get a cluster instance */
 static int
-get_inst_cluster(CMPIContext * ctx, CMPIResult * rslt, 
+get_cluster(CMPIContext * ctx, CMPIResult * rslt, 
                  CMPIObjectPath * cop, CMPIStatus * rc)
 {
-        CMPIObjectPath* op = NULL;
-        CMPIString * cmpi_namespace = NULL;
-        char * namespace = NULL;
-        CMPIInstance * ci = NULL;
-        int ret = 0;
+        CMPIObjectPath * op = NULL;
+        CMPIString *     cmpi_namespace = NULL;
+        char *           namespace = NULL;
+        CMPIInstance *   ci = NULL;
+        int              ret = 0;
 
-        cmpi_namespace = CMGetNameSpace(cop, rc);
+        DEBUG_ENTER();
+       cmpi_namespace = CMGetNameSpace(cop, rc);
         namespace = CMGetCharPtr(cmpi_namespace);
         
-        op = CMNewObjectPath(G_broker, namespace, G_classname, rc);
+        op = CMNewObjectPath(Broker, namespace, ClassName, rc);
         if ( CMIsNullObject(op) ){
-               CMSetStatusWithChars(G_broker, rc, 
-                      CMPI_RC_ERR_FAILED, "Create object path failed");
                 ret = HA_FAIL;
+               CMSetStatusWithChars(Broker, rc, 
+                      CMPI_RC_ERR_FAILED, "Create object path failed");
                 goto out;
         }
-
+        /* make a cluster instance */
         ci = make_cluster_instance(op, rc);
         if ( CMIsNullObject(ci) ) {
                 ret = HA_FAIL;
                 goto out;
         }
         
+        /* return the instance */
         CMReturnInstance(rslt, ci);
         CMReturnDone(rslt);
-
         ret = HA_OK;
-
 out:
-        CMRelease(op);
+       DEBUG_LEAVE();
         return ret;
 }
 
+/* enumerate cluster instances or instance names */
 static int
-enum_inst_cluster(CMPIContext * ctx, CMPIResult * rslt, CMPIObjectPath * cop, 
+enumerate_cluster(CMPIContext * ctx, CMPIResult * rslt, CMPIObjectPath * cop, 
                   char ** properties, int enum_inst, CMPIStatus * rc)
 {
+        CMPIInstance *   ci = NULL;
+        CMPIObjectPath * op = NULL;
+        CMPIString *     cmpi_namespace = NULL;
+        char *           namespace = NULL;
+        int              ret = 0;
 
-        CMPIInstance* ci = NULL;
-        CMPIObjectPath* op = NULL;
-        CMPIString * cmpi_namespace = NULL;
-        char * namespace = NULL;
-        int ret = 0;
-
+       DEBUG_ENTER();
         cmpi_namespace = CMGetNameSpace(cop, rc);
         namespace = CMGetCharPtr(cmpi_namespace);
         
-        op = CMNewObjectPath(G_broker, namespace, G_classname, rc);
+        op = CMNewObjectPath(Broker, namespace, ClassName, rc);
         if ( CMIsNullObject(op) ){
-               CMSetStatusWithChars(G_broker, rc, 
+               CMSetStatusWithChars(Broker, rc, 
                       CMPI_RC_ERR_FAILED, "Create object path failed");
-
                 ret = HA_FAIL;
                 goto out;
         }
 
         if ( ! enum_inst ) {
                 /* enumerate instance names */
-               CMAddKey(op, "CreationClassName", G_classname, CMPI_chars);
-                CMAddKey(op, "Name",  G_instname, CMPI_chars);
+               CMAddKey(op, "CreationClassName", ClassName, CMPI_chars);
+                CMAddKey(op, "Name",  InstName, CMPI_chars);
                CMReturnObjectPath(rslt, op);
 
         } else {
@@ -266,17 +310,142 @@
         CMReturnDone(rslt);
         ret = HA_OK;
 out:
-        CMRelease(op);
+       DEBUG_LEAVE();
        return ret;
 }
 
 static int
-cleanup_cluster() {
+process_config_data(const mapping_t * property, CIMTable * cfginfo, 
+               CMPIData cmpidata, CMPIStatus * rc)
+{
+       const char * key = property->key;
+        const char * val = NULL;
+
+       DEBUG_ENTER();
+       if ( key == NULL ) {
+               return HA_FAIL;
+       }
+       if ( property->type == CMPI_chars ){
+               if ( cmpidata.value.string == NULL ) {
+                       return HA_FAIL;
+               }
+               val = CMGetCharPtr(cmpidata.value.string);
+               /* insert a data */
+               cim_table_strdup_replace(cfginfo, key, val);
+       } else if(property->type == CMPI_charsA) { /* array */
+               CMPIArray * array = cmpidata.value.array;
+               int         i;
+               int         len;
+               char        buf[MAXLEN] = "";
+
+               len = CMGetArrayCount(array, rc);
+               for ( i = 0; i < len; i++){
+                       char * option;
+                       cmpidata = CMGetArrayElementAt(array, i, rc);
+                       if (cmpidata.value.string && rc->rc==CMPI_RC_OK){
+                               option=CMGetCharPtr(cmpidata.value.string);
+                               strncat(buf, option, MAXLEN);
+                               strcat(buf, "\n");
+                       }
+               }
+               val = buf;
+               /* insert into table */
+               cim_table_strdup_replace(cfginfo, key, val);
+       }
+
+       cl_log(LOG_INFO, "process_config_data: %s:%s", key, val); 
+       DEBUG_LEAVE();
+}
+
+/* update cluster instance, this will result in modification to the 
+   ha.cf and authkeys */
+static int 
+update_inst_cluster(CMPIContext * ctx, CMPIResult * rslt,
+                   CMPIObjectPath * op, CMPIInstance * inst,
+                   CMPIStatus * rc)
+{
+        int          ret;
+        int          authnum;
+        const char * authkey;
+       const char * authmethod;
+       CIMTable * cfginfo;
+       CIMTable * authinfo;
+       CMPIData     cmpidata;
+       int             i;
+
+        /* ha.cf */
+       DEBUG_ENTER();
+       cfginfo = cim_get_hacf_config();
+       if ( cfginfo == NULL ) { /* ha.cf not exist yet */
+               cfginfo = cim_table_new();
+               if ( cfginfo == NULL ) {
+                       return HA_FAIL;
+               }
+       }
+
+       for ( i=0; i<sizeof(ClusterMap)/sizeof(mapping_t); i++) {
+               CMPIData cmpidata;
+               cmpidata = CMGetProperty(inst, ClusterMap[i].name, rc);
+               if ( rc->rc == CMPI_RC_OK ) {
+                       process_config_data(&ClusterMap[i], cfginfo, cmpidata, 
rc);
+                }
+        }
+
+       /* update the ha.cf file */        
+        ret = cim_set_cluster_config(cfginfo);
+       cim_table_free(cfginfo);
+
+       /* authkeys */
+       if ( (authinfo = cim_get_cluster_auth()) == NULL ) {
+               authinfo = cim_table_new();
+               if ( authinfo == NULL ) {
+                       return HA_FAIL;
+               }
+       }
+        
+       authnum = CMGetProperty(inst, "AuthMethod", rc).value.uint32;
+       if ( rc->rc == CMPI_RC_OK ) {
+               authmethod = auth_map2value(authnum);
+               cim_table_strdup_replace(authinfo, "authmethod", authmethod);
+       }
+        cmpidata = CMGetProperty(inst, "AuthKey", rc);
+       if ( rc->rc == CMPI_RC_OK ) {
+               authkey = CMGetCharPtr(cmpidata.value.string);
+               cim_table_strdup_replace(authinfo, "authkey", authkey);
+       }
+       
+       /* update the authkeys file */
+        ret = cim_set_cluster_auth(authinfo); 
+       cim_table_free(authinfo);
+       DEBUG_LEAVE();
+        return HA_OK;
+}
+
+/* clean up */
+static int
+cleanup_cluster () 
+{
         cl_log(LOG_INFO, "%s: clean up", __FUNCTION__);
         return HA_OK;
 }
 
 
+/* use
+       2: Enabled, 3: Disabled, 10: Reboot 
+   for  hb start    hb stop       hb restart 
+*/
+static int
+request_state_change(int state)
+{
+       int action [] = {0, 0, START_HB, STOP_HB, 0, /* 4 */
+                        0, 0, 0, 0, 0,              /* 9 */
+                        0, RESTART_HB};
+
+       last_requested_state = state;
+       cim_change_hb_state(action[state]);
+
+       return HA_OK;
+}
 
 /**********************************************
  * Instance Provider Interface
@@ -285,7 +454,6 @@
 static CMPIStatus 
 ClusterCleanup(CMPIInstanceMI * mi, CMPIContext * ctx)
 {
-
         cleanup_cluster();
         CMReturn(CMPI_RC_OK);
 }
@@ -295,12 +463,10 @@
                          CMPIResult * rslt, CMPIObjectPath *ref)
 {
         CMPIStatus rc = {CMPI_RC_OK, NULL};
-        if ( enum_inst_cluster(ctx, rslt, ref, NULL, 0, &rc) != HA_OK ) {
-                return rc;
-        }
-
-        CMReturn(CMPI_RC_OK);
-
+       PROVIDER_INIT_LOGGER();        
+        /* enumerate instance names */
+        enumerate_cluster(ctx, rslt, ref, NULL, FALSE, &rc);
+       return rc;
 }
 
 static CMPIStatus 
@@ -308,40 +474,37 @@
                      CMPIObjectPath* ref, char ** properties)
 {
         CMPIStatus rc = {CMPI_RC_OK, NULL};
-        init_logger(PROVIDER_ID);
-        if ( enum_inst_cluster(ctx, rslt, ref, properties, 1, &rc) == HA_OK ) {
-                CMReturn(CMPI_RC_OK);                
-        } else {
-                return rc;
-        }
-
+       PROVIDER_INIT_LOGGER();        
+        enumerate_cluster(ctx, rslt, ref, NULL, TRUE, &rc);
+       return rc;
 }
 
-
 static CMPIStatus 
 ClusterGetInstance(CMPIInstanceMI * mi, CMPIContext * ctx, CMPIResult * rslt,
                    CMPIObjectPath * cop, char ** properties)
 {
         CMPIStatus rc = {CMPI_RC_OK, NULL};
-        init_logger(PROVIDER_ID);
-
-        if ( get_inst_cluster(ctx, rslt, cop, &rc) == HA_OK ) {
-                CMReturn(CMPI_RC_OK);
-        } else {
-                return rc;
-        }
-
+        PROVIDER_INIT_LOGGER();
+        get_cluster(ctx, rslt, cop, &rc);
+       return rc;
 }
 
-
 static CMPIStatus 
 ClusterCreateInstance(CMPIInstanceMI * mi, CMPIContext * ctx, CMPIResult * 
rslt,
                       CMPIObjectPath * cop, CMPIInstance * ci)
 {
         CMPIStatus rc = {CMPI_RC_OK, NULL};
-        CMSetStatusWithChars(G_broker, &rc, 
-                        CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED");
-        return rc;
+
+       PROVIDER_INIT_LOGGER();
+       if ( cim_get_hacf_config() ) {
+               cl_log(LOG_WARNING, "Only one instance is allowed.");
+               CMSetStatusWithChars(Broker, &rc, 
+                        CMPI_RC_ERR_FAILED, "Only one instance is allowed.");
+       } else {
+               update_inst_cluster(ctx, rslt, cop, ci, &rc);
+               CMReturn(CMPI_RC_OK);
+       }
+       return rc;
 }
 
 
@@ -350,21 +513,19 @@
                    CMPIObjectPath * op, CMPIInstance * inst, char ** 
properties)
 {
         CMPIStatus rc = {CMPI_RC_OK, NULL};
-
-        CMSetStatusWithChars(G_broker, &rc, 
-                        CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED");
-        return rc;
-
+        /* initialize logger */
+        PROVIDER_INIT_LOGGER();
+        /* set instance */
+       update_inst_cluster(ctx, rslt, op, inst, &rc); 
+       CMReturn(CMPI_RC_OK);
 }
 
-
 static CMPIStatus 
 ClusterDeleteInstance(CMPIInstanceMI * mi,  CMPIContext * ctx, 
                       CMPIResult * rslt, CMPIObjectPath * cop)
 {
         CMPIStatus rc = {CMPI_RC_OK, NULL};
-
-        CMSetStatusWithChars(G_broker, &rc, 
+        CMSetStatusWithChars(Broker, &rc, 
                         CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED");
         return rc;
 }
@@ -374,8 +535,7 @@
                  CMPIObjectPath * ref, char * lang, char * query)
 {
         CMPIStatus rc = {CMPI_RC_OK, NULL};
-        
-        CMSetStatusWithChars(G_broker, &rc, 
+        CMSetStatusWithChars(Broker, &rc, 
                         CMPI_RC_ERR_NOT_SUPPORTED, "CIM_ERR_NOT_SUPPORTED");
         return rc;
 }
@@ -389,19 +549,23 @@
                     CMPIObjectPath * ref, const char * method_name,
                     CMPIArgs * in, CMPIArgs * out)
 {
-
-        CMPIString* class_name = NULL;
-        CMPIStatus rc = {CMPI_RC_OK, NULL};
-        CMPIValue valrc;
+        CMPIString *   class_name = NULL;
+        CMPIStatus     rc = {CMPI_RC_OK, NULL};
+       int             ret;
         
         class_name = CMGetClassName(ref, &rc);
 
-        if(strcasecmp(CMGetCharPtr(class_name), G_classname) == 0 &&
-           strcasecmp("RequestStatusChange", method_name) == 0 ){
-                cl_log(LOG_INFO, "%s: NOT IMPLEMENTED", __FUNCTION__);
+        if(strcasecmp(CMGetCharPtr(class_name), ClassName) == 0 &&
+           strcasecmp("RequestStateChange", method_name) == 0 ){
+               int state;
+               /* we ignore the TimeoutPeriod parameter */
+               state = CMGetArg(in, "RequestedState", &rc).value.uint32;
+               ret = request_state_change(state);
+
+               CMAddArg(out, "Job", NULL, CMPI_ref);
         }
 
-        CMReturnData(rslt, &valrc, CMPI_uint32);
+        CMReturnData(rslt, &ret, CMPI_uint32);
         CMReturnDone(rslt);
 
         CMReturn(CMPI_RC_OK);
@@ -419,5 +583,5 @@
 /*****************************************************
  * install interface
  ****************************************************/
-DeclareInstanceMI(Cluster, HA_ClusterProvider, G_broker);
-DeclareMethodMI(Cluster, HA_ClusterProvider, G_broker);
+DeclareInstanceMI(Cluster, HA_ClusterProvider, Broker);
+DeclareMethodMI(Cluster, HA_ClusterProvider, Broker);




------------------------------

_______________________________________________
Linux-ha-cvs mailing list
[email protected]
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs


End of Linux-ha-cvs Digest, Vol 28, Issue 48
********************************************

Reply via email to