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])
2. Linux-HA CVS: cim by panjiam from
([email protected])
----------------------------------------------------------------------
Message: 1
Date: Mon, 10 Apr 2006 04:20:21 -0600 (MDT)
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/tests
Modified Files:
runtest.sh
Log Message:
updated test cases, HA_ResourceInstance not exist any longer
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/cim/tests/runtest.sh,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- runtest.sh 20 Mar 2006 03:31:30 -0000 1.7
+++ runtest.sh 10 Apr 2006 10:20:21 -0000 1.8
@@ -52,10 +52,8 @@
ASSOC_CLASSES="HA_ParticipatingNode
HA_InstalledSoftwareIdentity
HA_SubResource
- HA_ResourceInstance
HA_OperationOnResource
- HA_HostedResource
- HA_ResourceInstance"
+ HA_HostedResource"
ALL_CLASSES="$INST_CLASSES $ASSOC_CLASSES"
@@ -68,9 +66,9 @@
echo "HA_ParticipatingNode HA_HostedResource";;
HA_PrimitiveResource)
echo "HA_SubResource HA_HostedResource
- HA_ResourceInstance HA_OperationOnResource";;
+ HA_OperationOnResource";;
HA_MasterSlaveResource|HA_ResourceClone|HA_ResourceGroup)
- echo "HA_SubResource HA_ResourceInstance
+ echo "HA_SubResource
HA_OperationOnResource";;
HA_SoftwareIdentity)
echo "HA_InstalledSoftwareIdentity";;
------------------------------
Message: 2
Date: Mon, 10 Apr 2006 04:21:50 -0600 (MDT)
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:
cmpi_utils.c cmpi_utils.h
Log Message:
1. renamed functions, 2. added CMGetPropertyString
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/cim/cmpi_utils.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- cmpi_utils.c 20 Mar 2006 03:23:27 -0000 1.6
+++ cmpi_utils.c 10 Apr 2006 10:21:50 -0000 1.7
@@ -1,5 +1,5 @@
/*
- * assoc_utils.c: Utils for Association CMPI Providers
+ * assoc_utils.c: Utilities for CMPI Providers
*
* Author: Jia Ming Pan <[EMAIL PROTECTED]>
* Copyright (c) 2005 International Business Machines
@@ -26,6 +26,7 @@
#endif
#include <stdio.h>
#include <hb_api.h>
+#include <ha_msg.h>
#include <heartbeat.h>
#include <clplumbing/cl_log.h>
#include <glib.h>
@@ -40,32 +41,38 @@
CMPIObjectPath * lop, CMPIObjectPath * rop, CMPIStatus * rc);
int
-cmpi_set_properties(CMPIBroker * broker, CMPIInstance * inst, CIMTable * t,
- const mapping_t * map, int count, CMPIStatus * rc)
+cmpi_msg2inst(CMPIBroker * broker, CMPIInstance * inst, int mapid,
+ struct ha_msg *msg, CMPIStatus * rc)
{
- DEBUG_ENTER();
int i = 0;
- for ( i=0; i<count; i++) {
- cimdata_t data = cim_table_lookup_v(t, map[i].key);
- if(map[i].type == CMPI_chars) {
- /* set CMPI_chars */
- if(data.v.str==NULL) {
- cl_log(LOG_WARNING,
- "%s: data with key %s not found.",
- __FUNCTION__, map[i].key);
+ const struct map_t *map = NULL;
+
+ if ( (map = cim_query_map(mapid)) == NULL ) {
+ cl_log(LOG_ERR, "%s: map is NULL.", __FUNCTION__);
+ return HA_FAIL;
+ }
+
+ for ( i=0; i < map->len; i++) {
+ if(map->entry[i].type == CMPI_chars) {
+ const char *value;
+ value = cl_get_string(msg, map->entry[i].key);
+ if ( value == NULL ) {
+ cl_log(LOG_WARNING, "%s: key %s not found.",
+ __FUNCTION__, map->entry[i].key);
continue;
}
- CMSetProperty(inst,map[i].name,data.v.str,CMPI_chars);
- } else if ( map[i].type == CMPI_charsA ) {
+ cim_debug2(LOG_INFO, "%s: got %s:%s [CMPI_chars]",
+ map->entry[i].key, value, __FUNCTION__);
+
+ CMSetProperty(inst,map->entry[i].name,
+ cim_strdup(value),CMPI_chars);
+ } else if ( map->entry[i].type == CMPI_charsA ) {
/* set Array */
CMPIArray * array=NULL;
int j = 0, len = 0;
- char ** values;
- if(data.v.str==NULL) {
- cl_log(LOG_WARNING,
- "%s: data with key %s not found.",
- __FUNCTION__, map[i].key);
+ len = cl_msg_list_length(msg, map->entry[i].key);
+ if (len <= 0) {
continue;
}
array = CMNewArray(broker, len, CMPI_chars, rc);
@@ -73,48 +80,72 @@
DEBUG_LEAVE();
return HA_FAIL;
}
- values = split_string(data.v.str, &len, "\n");
for ( j = 0; j < len; j++ ) {
- CMSetArrayElementAt(array, j,
- &values[j], CMPI_chars);
+ char *value = NULL;
+ value = (char*)cl_msg_list_nth_data(msg,
+ map->entry[i].key, j);
+ if ( value == NULL ) {
+ continue;
+ }
+ CMSetArrayElementAt(array, j, &value,
CMPI_chars);
}
- CMSetProperty(inst, map[i].name, &array, CMPI_charsA);
- } else if (map[i].type == CMPI_uint32){
+
+ cim_debug2(LOG_INFO, "%s: got %s [CMPI_charsA]",
+ __FUNCTION__, map->entry[i].key);
+
+ CMSetProperty(inst, map->entry[i].name, &array,
CMPI_charsA);
+ } else if (map->entry[i].type == CMPI_uint32){
/* set CMPI_uint32 */
- CMSetProperty(inst, map[i].name,
- &data.v.uint32, CMPI_uint32);
}
}
- DEBUG_LEAVE();
return HA_OK;
}
-int
-cmpi_get_properties(CMPIInstance * inst, CIMTable * t, const mapping_t * map,
- int count, CMPIStatus * rc)
+
+int
+cmpi_inst2msg(CMPIInstance *inst, int mapid,
+ struct ha_msg *msg, CMPIStatus *rc)
{
- CMPIData cmpidata;
- DEBUG_ENTER();
int i = 0;
- for( i =0; i<count; i++){
- cmpidata = CMGetProperty(inst,map[i].name,rc);
- if (rc->rc!=CMPI_RC_OK){
- cl_log(LOG_WARNING,
- "Property %s missing.", map[i].name);
+ const struct map_t *map = cim_query_map(mapid);
+ CMPIData data;
+
+ DEBUG_ENTER();
+ if ( map == NULL ) {
+ return HA_FAIL;
+ }
+
+ for( i =0; i < map->len; i++){
+ if ( strncmp(map->entry[i].key , "", MAXLEN) == 0 ) {
+ continue;
+ }
+ data = CMGetProperty(inst, map->entry[i].name, rc);
+ if (rc->rc != CMPI_RC_OK){
+ cl_log(LOG_WARNING, "Property %s missing.",
+ map->entry[i].name);
continue;
}
- if ( cmpidata.type == CMPI_string) {
- char * value = CMGetCharPtr(cmpidata.value.string);
- cim_table_strdup_replace(t, map[i].key, value);
- } else if (cmpidata.type == CMPI_stringA){
- cl_log(LOG_ERR, "%s: Not support.", __FUNCTION__);
- } else if (cmpidata.type == CMPI_uint32){
+ if ( data.type == CMPI_string) {
+ char * value = CMGetCharPtr(data.value.string);
+ cl_msg_modstring(msg, map->entry[i].key, value);
+
+ } else if (data.type == CMPI_stringA){
+ CMPIArray * array = data.value.array;
+ int j, len = CMGetArrayCount(array, rc);
+ cl_msg_remove(msg, map->entry[i].key);
+ for (j=0; j<len; j++) {
+ char * value;
+ data = CMGetArrayElementAt(array, j, rc);
+ value = CMGetCharPtr(data.value.string);
+ cl_msg_list_add_string(msg,
+ map->entry[i].key, value);
+ }
+ } else if (data.type == CMPI_uint32){
cl_log(LOG_ERR, "%s: Not support.", __FUNCTION__);
}
}
- DEBUG_LEAVE();
return HA_OK;
}
@@ -539,8 +570,8 @@
left, right, left_op, right_op, rc);
CMReturnInstance(rslt, inst);
}
- } /* while */
- } /* while */
+ } /* for */
+ } /* for */
CMReturnDone(rslt);
DEBUG_LEAVE();
return HA_OK;
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/cim/cmpi_utils.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- cmpi_utils.h 20 Mar 2006 03:23:27 -0000 1.6
+++ cmpi_utils.h 10 Apr 2006 10:21:50 -0000 1.7
@@ -1,3 +1,25 @@
+/*
+ * cmpi_utils.h: CMPI utilities header
+ *
+ * Author: Jia Ming Pan <[EMAIL PROTECTED]>
+ * Copyright (c) 2005 International Business Machines
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
#ifndef _CMPI_UTILS_H
#define _CMPI_UTILS_H
@@ -33,11 +55,23 @@
v; \
})
+#define CMGetPropertyString(op,prop,rc) ({ \
+ CMPIString * s = CMGetProperty(op,prop,rc).value.string;\
+ char *v = NULL; \
+ if ( s == NULL ) { \
+ cl_log(LOG_ERR, "Property %s is missing.", prop);\
+ }else { \
+ v = CMGetCharPtr(s); \
+ } \
+ v; \
+ })
+
+
+int cmpi_msg2inst(CMPIBroker * broker, CMPIInstance * inst, int mapid,
+ struct ha_msg *msg, CMPIStatus * rc);
+int cmpi_inst2msg(CMPIInstance *inst, int mapid,
+ struct ha_msg *msg, CMPIStatus *rc);
-int cmpi_set_properties(CMPIBroker * broker, CMPIInstance * inst,
- CIMTable * t, const mapping_t * map, int count, CMPIStatus *
rc);
-int cmpi_get_properties(CMPIInstance * inst, CIMTable * t,
- const mapping_t * map, int count, CMPIStatus * rc);
/***********************************************************
* assocation functions
------------------------------
_______________________________________________
Linux-ha-cvs mailing list
[email protected]
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
End of Linux-ha-cvs Digest, Vol 29, Issue 59
********************************************