From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 13 Sep 2006 17:50:23 -0000 Subject: [Cluster-devel] conga/luci cluster/form-macros cluster/resourc ... Message-ID: <20060913175023.23385.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: conga Changes by: rmccabe at sourceware.org 2006-09-13 17:50:22 Modified files: luci/cluster : form-macros resource-form-macros resource_form_handlers.js luci/homebase : homebase_common.js luci_homebase.css luci/site/luci/Extensions: cluster_adapters.py Log message: service stuff.. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.58&r2=1.59 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource-form-macros.diff?cvsroot=cluster&r1=1.9&r2=1.10 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource_form_handlers.js.diff?cvsroot=cluster&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/homebase_common.js.diff?cvsroot=cluster&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/luci_homebase.css.diff?cvsroot=cluster&r1=1.21&r2=1.22 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.63&r2=1.64 --- conga/luci/cluster/form-macros 2006/09/11 22:22:00 1.58 +++ conga/luci/cluster/form-macros 2006/09/13 17:50:22 1.59 @@ -1097,6 +1097,10 @@ global sinfo python: here.getServiceInfo(sstat, modelb,request); global running sinfo/running | nothing;" /> + + var uuid_list = ; + +
@@ -1144,25 +1148,26 @@

Service Composition

-
-
+
+
- + tal:replace="structure python: '
'" /> -
+ class python: (res['max_depth'] == 0 and 'invisible' or ('rc_indent' + str(res['indent_ctr'] - 1))) + ' expander'"> [-] - Hide Children -
+ Hide Children +

--- conga/luci/cluster/resource-form-macros 2006/09/11 22:22:00 1.9 +++ conga/luci/cluster/resource-form-macros 2006/09/13 17:50:22 1.10 @@ -65,10 +65,11 @@
-
+

Select a Resource Type -

-
+

+ +

-

+

-
 
-
+

@@ -279,7 +285,7 @@ -

+

@@ -312,11 +318,17 @@ tmp_URL context/cluster/index_html/absolute_url; global processURL python: tmp_URL+'?pagetype=35&clustername='+cluname" /> -
File System Resource Configuration
+

File System Resource Configuration

+ + + + @@ -415,7 +427,7 @@ -
+

@@ -426,7 +438,7 @@ -

+

@@ -453,11 +465,17 @@ tmp_URL context/cluster/index_html/absolute_url; global processURL python: tmp_URL+'?pagetype=35&clustername='+cluname" /> -
GFS Resource Configuration
+

GFS Resource Configuration

+ + + + @@ -525,7 +543,7 @@ -
+

@@ -536,7 +554,7 @@ -

+

@@ -564,11 +582,17 @@ tmp_URL context/cluster/index_html/absolute_url; global processURL python: tmp_URL+'?pagetype=35&clustername='+cluname" /> -
NFS Mount Resource Configuration
+

NFS Mount Resource Configuration

+ + + + @@ -649,7 +673,7 @@ -
+

@@ -660,7 +684,7 @@ -

+

@@ -684,11 +708,17 @@ tmp_URL context/cluster/index_html/absolute_url; global processURL python: tmp_URL+'?pagetype=35&clustername='+cluname" /> -
NFS Client Resource Configuration
+

NFS Client Resource Configuration

+ + + + @@ -731,7 +761,7 @@ -
+

@@ -742,7 +772,7 @@ -

+

@@ -762,11 +792,17 @@ tmp_URL context/cluster/index_html/absolute_url; global processURL python: tmp_URL+'?pagetype=35&clustername='+cluname" /> -
NFS Export Resource Configuration
+

NFS Export Resource Configuration

+ + + + @@ -793,7 +829,7 @@ -
+

@@ -804,7 +840,7 @@ -

+

@@ -825,11 +861,17 @@ tmp_URL context/cluster/index_html/absolute_url; global processURL python: tmp_URL+'?pagetype=35&clustername='+cluname" /> -
Script Resource Configuration
+

Script Resource Configuration

+ + + + @@ -864,7 +906,7 @@ -
+

@@ -875,7 +917,7 @@ -

+

@@ -897,14 +939,20 @@ tmp_URL context/cluster/index_html/absolute_url; global processURL python: tmp_URL+'?pagetype=35&clustername='+cluname" /> -
Samba Server Configuration -
+

+ + + + @@ -939,7 +987,7 @@ -
+

@@ -950,7 +998,7 @@ -

+

--- conga/luci/cluster/resource_form_handlers.js 2006/09/11 22:22:00 1.6 +++ conga/luci/cluster/resource_form_handlers.js 2006/09/13 17:50:22 1.7 @@ -21,7 +21,9 @@ if (!swap_out_cont || !swap_in_cont || !swap_in_elem) return (-1); - var temp = swap_in_cont.replaceChild(swap_in_elem, swap_in_cont.firstChild); + if (swap_in_cont.id) + swap_in_elem.id = swap_in_cont.id; + var temp = swap_in_cont.parentNode.replaceChild(swap_in_elem, swap_in_cont); swap_out_cont.appendChild(temp); } @@ -145,54 +147,67 @@ } function add_child_resource(form) { - if (!form || !form.tree_level || + if (!form || !form.tree_level || !form.parent_uuid || !form.uuid || !is_valid_int(form.tree_level.value, 0, null)) { return (-1); } - var ilevel = Number(form.tree_level.value); + + var ilevel = Number(form.tree_level.value) + 1; var sdiv = document.getElementById('resskel'); if (!sdiv) return (-1); - var pdiv = form.parentNode; - var regex = eval('/rc_indent' + ilevel + '$/'); - while (pdiv && !pdiv.className.match(regex)) { - if (pdiv.className == 'service_comp_list') - break; - pdiv = pdiv.parentNode; - } - if (!pdiv) + var pdiv = document.getElementById(form.uuid.value); + if (!pdiv) { + alert('failed to find ' + form.uuid.value); return (-1); + } - var divs = pdiv.getElementsByTagName('div'); - var target = null; - - ++ilevel; - regex = eval('/rc_indent' + ilevel + '$/'); - for (var i = 0 ; i < divs.length ; i++) { - if (divs[i].className.match(regex)) { - target = divs[i] + var forms = pdiv.getElementsByTagName('form'); + var child_div = null; + for (var i = 0 ; i < forms.length ; i++) { + if (forms[i].parent_uuid && + forms[i].parent_uuid.value == form.uuid.value) + { + child_div = document.getElementById(forms[i].uuid.value); break; } } - if (!target) { - alert('need to append'); - target = document.createElement('div'); - target.className = 'service_comp rc_indent' + ilevel; - pdiv.appendChild(target); - } - var node = sdiv.cloneNode(1); node.id = null; node.className = null; ielem = node.getElementsByTagName('input'); if (!ielem) return (-1); + + var new_uuid = uuid_list.pop(); for (var i = 0 ; i < ielem.length ; i++) { if (ielem[i].getAttribute('name') == 'tree_level') ielem[i].value = ilevel; + else if (ielem[i].getAttribute('name') == 'parent_uuid') + ielem[i].value = form.uuid.value; + else if (ielem[i].getAttribute('name') == 'uuid') { + if (!new_uuid) { + alert('You have too many pending children. Update first.'); + return (-1); + } + ielem[i].value = new_uuid; + } } - target.appendChild(node); + + if (!child_div) { + /* enable parent collapse */ + child_div = document.createElement('div'); + } else { + wrap_div = document.createElement('div'); + child_div.appendChild(wrap_div); + child_div = wrap_div; + } + child_div.id = new_uuid; + child_div.className = 'service_comp rc_indent' + ilevel; + + child_div.appendChild(node); + pdiv.appendChild(child_div); } --- conga/luci/homebase/homebase_common.js 2006/09/08 22:54:32 1.8 +++ conga/luci/homebase/homebase_common.js 2006/09/13 17:50:22 1.9 @@ -2,21 +2,26 @@ if (!image) return (-1); - var span = image.parentNode.getElementsByTagName('span'); - if (span && span.length > 0) - span = span[0]; - else - span = null; - - var div = null; - divc = image.parentNode.parentNode.parentNode.getElementsByTagName('div'); - for (var i = 0 ; i < divc.length ; i++) { - if (divc[i].className.match(/service_comp/)) { - div = divc[i]; + var span = null; + var pdiv = image.parentNode; + var spanc = pdiv.getElementsByTagName('span'); + if (!spanc) + return (-1); + for (var i = 0 ; i < spanc.length ; i++) { + if (spanc[i].className.match(/expander/)) { + span = spanc[i]; break; } } + if (!span) + return (-1); + var div = image.parentNode.parentNode.nextSibling; + while (div) { + if (div.tagName && div.tagName.match(/^DIV$/i) && div.className.match(/expander/)) + break; + div = div.nextSibling; + } if (!div) return (-1); @@ -24,18 +29,14 @@ image.src = 'arrow_right.png'; image.name = 'arrow_right'; image.alt = '[-]'; - if (span) - span.innerHTML = 'Show Children'; - div.style.visibility = 'hidden'; - div.style.display = 'none'; + span.innerHTML = 'Show Children'; + div.className = 'invisible expander service_comp'; } else { image.src = 'arrow_down.png'; image.name = 'arrow_down'; image.alt = '[+]'; - if (span) - span.innerHTML = 'Hide Children'; - div.style.visibility = 'inherit'; - div.style.display = 'block'; + span.innerHTML = 'Hide Children'; + div.className = 'expander service_comp'; } } --- conga/luci/homebase/luci_homebase.css 2006/09/11 22:22:01 1.21 +++ conga/luci/homebase/luci_homebase.css 2006/09/13 17:50:22 1.22 @@ -146,7 +146,7 @@ margin-bottom: .25em; } -div.hbSubmit { +div.hbSubmit,p.hbSubmit { margin-top: .5em; margin-bottom: .5em; margin-right: .5em; @@ -381,10 +381,11 @@ margin-bottom: .25em ! important; } -#service_comp_list { +div.service_comp_list { background: #dee7ec; max-width: 700px; padding: 1em; + margin-top: 0; } div.reschoose { --- conga/luci/site/luci/Extensions/cluster_adapters.py 2006/09/08 22:54:32 1.63 +++ conga/luci/site/luci/Extensions/cluster_adapters.py 2006/09/13 17:50:22 1.64 @@ -6,6 +6,7 @@ from ricci_communicator import * import time import Products.ManagedSystem +from Products.Archetypes.utils import make_uuid from Ip import Ip from Clusterfs import Clusterfs from Fs import Fs @@ -919,15 +920,15 @@ #set up struct for service config page baseurl = req['URL'] cluname = req['clustername'] - map = {} + hmap = {} servicename = req['servicename'] for item in status: if item['type'] == "service": if item['name'] == servicename: - map['name'] = servicename + hmap['name'] = servicename starturls = list() if item['running'] == "true": - map['running'] = "true" + hmap['running'] = "true" #In this case, determine where it can run... innermap = {} nodename = item['nodename'] @@ -956,7 +957,7 @@ starturl['url'] = baseurl + "?" + "clustername=" + cluname +"&servicename=" + servicename + "&pagetype=" + SERVICE_START + "&nodename=" + node.getName() starturls.append(starturl) innermap['links'] = starturls - map['innermap'] = innermap + hmap['innermap'] = innermap #Now build hashes for resources under service. #first get service by name from model @@ -965,15 +966,16 @@ if svc != None: indent_ctr = 0 children = svc.getChildren() - + root_uuid = make_uuid('resource') for child in children: - recurse_resources(child, resource_list, indent_ctr) + recurse_resources(root_uuid, child, resource_list, indent_ctr) - map['resource_list'] = resource_list - - return map + hmap['resource_list'] = resource_list + hmap['root_uuid'] = root_uuid + hmap['uuid_list'] = map(lambda x: make_uuid('resource'), range(30)) + return hmap -def recurse_resources(child, resource_list, indent_ctr, parent=None): +def recurse_resources(parent_uuid, child, resource_list, indent_ctr, parent=None): #First, add the incoming child as a resource #Next, check for children of it #Call yourself on every children @@ -992,6 +994,8 @@ #Note: Final version needs all resource attrs rc_map['attrs'] = child.getAttributes() + rc_map['uuid'] = make_uuid('resource') + rc_map['parent_uuid'] = parent_uuid new_indent_ctr = indent_ctr + 1 @@ -999,7 +1003,7 @@ kids = child.getChildren() child_depth = 0 for kid in kids: - child_depth = recurse_resources(kid, resource_list, new_indent_ctr, child) + child_depth = recurse_resources(rc_map['uuid'], kid, resource_list, new_indent_ctr, child) rc_map['max_depth'] = child_depth return child_depth + 1