CVSROOT:        /cvs/cluster
Module name:    conga
Branch:         RHEL5
Changes by:     [EMAIL PROTECTED]       2007-08-08 21:20:37

Modified files:
        luci/cluster   : validate_xvm_key.js 
        luci/plone-custom: conga_ajax.js 

Log message:
        Fix 230451, pass 5
        - luci frontend support for managing fence_xvm keys, pass 2

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_xvm_key.js.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.2.1&r2=1.1.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/plone-custom/conga_ajax.js.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2.2.1&r2=1.2.2.2

--- conga/luci/cluster/validate_xvm_key.js      2007/08/08 21:18:46     1.1.2.1
+++ conga/luci/cluster/validate_xvm_key.js      2007/08/08 21:20:37     1.1.2.2
@@ -0,0 +1,119 @@
+/*
+** Copyright (C) 2007 Red Hat, Inc.
+**
+** This program is free software; you can redistribute
+** it and/or modify it under the terms of version 2 of the
+** GNU General Public License as published by the
+** Free Software Foundation.
+*/
+
+function get_cluster_members(host_list) {
+       var url = '/luci/cluster?pagetype=1000';
+       var node_num = 0;
+
+       var hclu_elem = document.getElementById('host_cluster_name');
+       if (hclu_elem) {
+               ++node_num;
+               url += '&node' + node_num + '=' + hclu_elem.value;
+       }
+       var vclu_elem = document.getElementById('virt_cluster_name');
+       if (vclu_elem) {
+               ++node_num;
+               url += '&node' + node_num + '=' + vclu_elem.value;
+       }
+    initiate_async_get(url, cluster_member_callback);
+}
+
+function cluster_member_callback() {
+       return check_ajax_xml(xmlHttp_object, cluster_member_check);
+}
+
+function validate_xvm_dist_form(form) {
+       return form.submit();
+}
+
+function cluster_member_check(ret_status, obj) {
+       if (ret_status === null) {
+               /* Not ready */
+               return;
+       }
+
+       if (ret_status !== true) {
+               /* A communication error occurred. */
+               alert(obj);
+               return;
+       }
+
+       var err = get_ricci_response_status(obj.responseXML);
+       if (err !== null && err.length > 0) {
+               alert(err.join('\n'));
+               return;
+       }
+
+       obj = obj.responseXML;
+       var clusters = [];
+       var dict_tags = obj.firstChild.getElementsByTagName('dict');
+       for (var i = 0 ; i < dict_tags.length ; i++) {
+               try {
+                       var cnode_names = [];
+                       var tag_name = dict_tags[i].getAttribute('name');
+                       var cnodes = 
dict_tags[i].getElementsByTagName('clusternode');
+
+                       for (var j = 0 ; j < cnodes.length ; j++) {
+                               
cnode_names.push(cnodes[j].getAttribute('value'));
+                       }
+                       clusters.push([ tag_name, cnode_names ]);
+               } catch (e) {
+                       continue;
+               }
+       }
+
+       var form_elem = document.getElementById('fence_config_form');
+       var xvm_submit_elem = document.getElementById('fence_config_submit');
+       var xvm_div_elem = document.getElementById('fence_xvm_hosts');
+       var xvm_hidden_elem = document.getElementById('fence_xvm_config');
+
+       if (!form_elem || !xvm_submit_elem || !xvm_div_elem || 
!xvm_hidden_elem) {
+               alert('Server error: required form elements are missing.');
+               return;
+       }
+
+       for (var i = 0 ; i < clusters.length ; i++) {
+               var cnode_list = clusters[i][1];
+
+               var div = document.createElement('div');
+               var p = document.createElement('p');
+               var span = document.createElement('strong');
+               var ul = document.createElement('ul');
+
+               p.className = 'cluster';
+               span.className = 'cluster';
+               span.textContent = 'Cluster: ' + clusters[i][0];
+
+               p.appendChild(span);
+               div.appendChild(p);
+
+               for (var j = 0 ; j < cnode_list.length ; j++) {
+                       var li = document.createElement('li');
+                       var input = document.createElement('input');
+                       var lispan = document.createElement('span');
+                       input.type = 'checkbox';
+                       input.name = '__NODE_HOSTNAME__';
+                       input.value = cnode_list[j];
+                       input.checked = 'checked';
+                       lispan.textContent = cnode_list[j];
+                       li.appendChild(input);
+                       li.appendChild(lispan);
+                       ul.appendChild(li);
+               }
+               div.appendChild(ul);
+               xvm_div_elem.appendChild(div);
+       }
+
+       var fc_elem = document.getElementById('fence_xvm_init');
+       if (fc_elem) {
+               form_elem.pagetype.value = '60';
+               fc_elem.className = 'invisible';
+               xvm_hidden_elem.className = 'systemsTable';
+       }
+}
--- conga/luci/plone-custom/conga_ajax.js       2007/08/08 21:18:46     1.2.2.1
+++ conga/luci/plone-custom/conga_ajax.js       2007/08/08 21:20:37     1.2.2.2
@@ -0,0 +1,96 @@
+/*
+** Copyright (C) 2007 Red Hat, Inc.
+**
+** This program is free software; you can redistribute
+** it and/or modify it under the terms of version 2 of the
+** GNU General Public License as published by the
+** Free Software Foundation.
+*/
+
+var xmlHttp_object = false;
+
+function initiate_async_get(url, callback_function) {
+       xmlHttp_object = false;
+
+       if (!xmlHttp_object && typeof XMLHttpRequest != 'undefined') {
+               try {
+                       xmlHttp_object = new XMLHttpRequest();
+               } catch (e0) {
+                       try {
+                               xmlHttp_object = new 
ActiveXObject("Msxml2.XMLHTTP");
+                       } catch (e) {
+                               try {
+                                       xmlHttp_object = new 
ActiveXObject("Microsoft.XMLHTTP");
+                               } catch (e2) {
+                                       xmlHttp_object = false;
+                               }
+                       }
+               }
+       }
+
+       if (xmlHttp_object) {
+               xmlHttp_object.open("GET", url, true);
+               xmlHttp_object.onreadystatechange = callback_function;
+               xmlHttp_object.send(null);
+       } else {
+               alert("Unable to communicate with the luci server.");
+       }
+}
+
+function get_ajax_msgs(obj, tag_name) {
+       try {
+               var msgs = []
+               var msg_list = obj.getElementsByTagName(tag_name);
+               for (var i = 0 ; i < msg_list.length ; i++) {
+                       var msg_txt = msg_list[i].getAttribute('value');
+                       msgs.push(msg_txt);
+               }
+               return msgs;
+       } catch (e) {
+               return null;
+       }
+       return null;
+}
+
+function check_ajax_xml(xmlobj, handler_func) {
+       if (xmlobj.readyState != 4) {
+               return null;
+       }
+
+       if (xmlobj.status == 200) {
+               if (xmlobj.responseXML) {
+                       return handler_func(true, xmlobj);
+               } else {
+                       return handler_func(false, 'Error retrieving data from 
server');
+               }
+       } else {
+               return handler_func(false, 'Error retrieving data from server: 
' + xmlobj.status);
+       }
+}
+
+function get_ricci_response_status(obj) {
+       if (!obj) {
+               return [ 'No response from server' ]
+       }
+
+       var rlist = obj.getElementsByTagName('result');
+       for (var i = 0 ; i < rlist.length ; i++) {
+               var elem_name = null;
+
+               try {
+                       elem_name = rlist[i].getAttribute('name');
+                       if (elem_name != 'success') {
+                               continue;
+                       } else {
+                               var result = rlist[i].getAttribute('value');
+                               if (result == 'true') {
+                                       return null;
+                               }
+                               break;
+                       }
+               } catch (e) {
+                       continue;
+               }
+       }
+       return get_ajax_msgs(obj, 'errors');
+}

Reply via email to