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: mgmt by zhenh from 
      ([email protected])
   2. Linux-HA CVS: mgmt by zhenh from 
      ([email protected])
   3. Linux-HA CVS: mgmt by zhenh from 
      ([email protected])


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

Message: 1
Date: Fri, 14 Apr 2006 02:50:22 -0600 (MDT)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: mgmt by zhenh from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : zhenh
Host    : 
Project : linux-ha
Module  : mgmt

Dir     : linux-ha/mgmt/daemon


Modified Files:
        mgmt_crm.c 


Log Message:
create the update xml with the parent object if need
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/mgmt/daemon/mgmt_crm.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -3 -r1.28 -r1.29
--- mgmt_crm.c  14 Apr 2006 04:25:02 -0000      1.28
+++ mgmt_crm.c  14 Apr 2006 08:50:22 -0000      1.29
@@ -98,7 +98,8 @@
 static void on_cib_connection_destroy(gpointer user_data);
 static char* failed_msg(crm_data_t* output, int rc);
 static const char* uname2id(const char* node);
-
+static resource_t* get_parent(resource_t* child);
+static int get_fix(const char* rsc_id, char* prefix, char* suffix);
 
 pe_working_set_t* cib_cached = NULL;
 int cib_cache_enable = FALSE;
@@ -227,6 +228,80 @@
        free_data_set(data_set);
        return NULL;
 }
+static resource_t* 
+get_parent(resource_t* child)
+{
+       GList* cur;
+       char* ret;
+       pe_working_set_t* data_set;
+       
+       data_set = get_data_set();
+       ret = cl_strdup(MSG_OK);
+       cur = data_set->resources;
+       while (cur != NULL) {
+               resource_t* rsc = (resource_t*)cur->data;
+               if(rsc->orphan == FALSE || rsc->role != RSC_ROLE_STOPPED) {
+                       GList* child_list = rsc->fns->children(rsc);
+                       if (g_list_find(child_list, child) != NULL) {
+                               free_data_set(data_set);
+                               return rsc;
+                       }
+               }
+               cur = g_list_next(cur);
+       }
+       free_data_set(data_set);
+       return NULL;
+}
+
+static int
+get_fix(const char* rsc_id, char* prefix, char* suffix)
+{
+       resource_t* rsc;
+       resource_t* parent;
+       pe_working_set_t* data_set;
+       char* colon;
+       char real_id[MAX_STRLEN];
+       char parent_type[MAX_STRLEN];
+               
+       data_set = get_data_set();
+       rsc = pe_find_resource(data_set->resources, rsc_id);    
+       if (rsc == NULL) {
+               return -1;
+       }
+       parent = get_parent(rsc);
+       if (parent == NULL) {
+               snprintf(prefix, MAX_STRLEN,"<primitive id=\"%s\">", rsc_id);
+               snprintf(suffix, MAX_STRLEN,"</primitive>");
+       }
+       else {
+               strncpy(real_id, rsc_id, MAX_STRLEN);
+               colon = strrchr(real_id, ':');
+               if (colon != NULL) {
+                       *colon = '\0';
+               }
+               switch (parent->variant) {
+                       case pe_group:
+                               strncpy(parent_type, "group", MAX_STRLEN);
+                               break;
+                       case pe_clone:
+                               strncpy(parent_type, "clone", MAX_STRLEN);
+                               break;
+                       case pe_master:
+                               strncpy(parent_type, "master_slave", 
MAX_STRLEN);
+                               break;
+                       case pe_unknown:
+                       case pe_native:
+                               free_data_set(data_set);
+                               return -1;
+               }
+               
+               snprintf(prefix, MAX_STRLEN,"<%s id=\"%s\"><primitive 
id=\"%s\">"
+               ,       parent_type,parent->id,real_id);
+               snprintf(suffix, MAX_STRLEN,"</primitive></%s>",parent_type);
+       }
+       free_data_set(data_set);
+       return 0;
+}
 
 /* mgmtd functions */
 int
@@ -1040,17 +1115,23 @@
        crm_data_t* output;
        char xml[MAX_STRLEN];
        char buf[MAX_STRLEN];
+       char prefix[MAX_STRLEN];
+       char suffix[MAX_STRLEN];
+       
+       if(get_fix(argv[1], prefix, suffix) == -1) {
+               return cl_strdup(MSG_FAIL);
+       }
 
        snprintf(xml, MAX_STRLEN,
-                "<primitive id=\"%s\">"
-                "<instance_attributes><attributes>", argv[1]);
+                "%s<instance_attributes><attributes>", prefix);
        for (i = 2; i < argc; i += 3) {
                snprintf(buf, MAX_STRLEN,
                        "<nvpair id=\"%s\" name=\"%s\" value=\"%s\"/>",
                        argv[i], argv[i+1], argv[i+2]);
                strncat(xml, buf, MAX_STRLEN);
        }
-       strncat(xml, "</attributes></instance_attributes></primitive>", 
MAX_STRLEN);
+       strncat(xml, "</attributes></instance_attributes>", MAX_STRLEN);
+       strncat(xml, suffix, MAX_STRLEN);
 
        cib_object = string2xml(xml);
        if(cib_object == NULL) {
@@ -1126,23 +1207,29 @@
        crm_data_t* output;
        char xml[MAX_STRLEN];
        char buf[MAX_STRLEN];
-
+       char prefix[MAX_STRLEN];
+       char suffix[MAX_STRLEN];
+       
+       if(get_fix(argv[1], prefix, suffix) == -1) {
+               return cl_strdup(MSG_FAIL);
+       }
+       
        snprintf(xml, MAX_STRLEN,
-                "<primitive id=\"%s\">"
-                " <operations>", argv[1]);
+                "%s<operations>", prefix);
        for (i = 2; i < argc; i += 4) {
                snprintf(buf, MAX_STRLEN,
                        "<op id=\"%s\" name=\"%s\" interval=\"%s\" 
timeout=\"%s\"/>",
                        argv[i], argv[i+1], argv[i+2], argv[i+3]);
                strncat(xml, buf, MAX_STRLEN);
        }
-       strncat(xml, "</operations></primitive>", MAX_STRLEN);
+       strncat(xml, "</operations>", MAX_STRLEN);
+       strncat(xml, suffix, MAX_STRLEN);
 
        cib_object = string2xml(xml);
        if(cib_object == NULL) {
                return cl_strdup(MSG_FAIL);
        }
-       mgmt_log(LOG_INFO, "xml:%s",xml);
+       mgmt_log(LOG_INFO, "zhenh xml:%s",xml);
        fragment = create_cib_fragment(cib_object, "resources");
 
        rc = cib_conn->cmds->update(




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

Message: 2
Date: Fri, 14 Apr 2006 03:03:21 -0600 (MDT)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: mgmt by zhenh from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : zhenh
Host    : 
Project : linux-ha
Module  : mgmt

Dir     : linux-ha/mgmt/daemon


Modified Files:
        mgmt_crm.c 


Log Message:
show the Master/Slave status of resource
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/mgmt/daemon/mgmt_crm.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -3 -r1.29 -r1.30
--- mgmt_crm.c  14 Apr 2006 08:50:22 -0000      1.29
+++ mgmt_crm.c  14 Apr 2006 09:03:20 -0000      1.30
@@ -998,7 +998,15 @@
                                ret = mgmt_msg_append(ret, "multi-running");
                                break;
                        }
-                       ret = mgmt_msg_append(ret, "running");          
+                       if( rsc->role==RSC_ROLE_SLAVE ) {
+                               ret = mgmt_msg_append(ret, "running(Slave)");   
        
+                       }
+                       else if( rsc->role==RSC_ROLE_MASTER) {
+                               ret = mgmt_msg_append(ret, "running(Master)");  
        
+                       }
+                       else {
+                               ret = mgmt_msg_append(ret, "running");          
+                       }
                        break;
                case pe_group:
                        ret = mgmt_msg_append(ret, "group");
@@ -1229,7 +1237,7 @@
        if(cib_object == NULL) {
                return cl_strdup(MSG_FAIL);
        }
-       mgmt_log(LOG_INFO, "zhenh xml:%s",xml);
+       mgmt_log(LOG_DEBUG, "xml:%s",xml);
        fragment = create_cib_fragment(cib_object, "resources");
 
        rc = cib_conn->cmds->update(




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

Message: 3
Date: Fri, 14 Apr 2006 03:04:06 -0600 (MDT)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: mgmt by zhenh from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : zhenh
Host    : 
Project : linux-ha
Module  : mgmt

Dir     : linux-ha/mgmt/client


Modified Files:
        haclient.zh_CN.po 


Log Message:
show the Master/Slave status of resource
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/mgmt/client/haclient.zh_CN.po,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- haclient.zh_CN.po   11 Apr 2006 07:17:48 -0000      1.3
+++ haclient.zh_CN.po   14 Apr 2006 09:04:06 -0000      1.4
@@ -597,3 +597,8 @@
 msgid "Failed in the authentication.\n User Name or Password may be wrong.\n 
or the user doesn't belong to haclient group"
 msgstr 
"用户认证失败,可能是用户或密码不对,或该用户不属于haclient组"
 
+msgid "running(Master)"
+msgstr "运行(主)"
+
+msgid "running(Slave)"
+msgstr "运行(从)"




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

_______________________________________________
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 87
********************************************

Reply via email to