cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] conga/luci site/luci/Extensions/StorageReport. ...
@ 2006-10-09 17:03 kupcevic
  0 siblings, 0 replies; 9+ messages in thread
From: kupcevic @ 2006-10-09 17:03 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic at sourceware.org	2006-10-09 17:03:17

Modified files:
	luci/site/luci/Extensions: StorageReport.py 
	luci/storage   : form-macros 

Log message:
	luci storage: GoTo links to move up/down block device hierarchy

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/StorageReport.py.diff?cvsroot=cluster&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/form-macros.diff?cvsroot=cluster&r1=1.9&r2=1.10

--- conga/luci/site/luci/Extensions/StorageReport.py	2006/10/09 17:01:19	1.11
+++ conga/luci/site/luci/Extensions/StorageReport.py	2006/10/09 17:03:17	1.12
@@ -1669,6 +1669,7 @@
         for name in old_props:
             new_props['content_variable_' + d['id'] + '_' + name] = old_props[name]
         d['props'] = new_props
+        d['is_source'] = False
         
         # content's color and icon
         color = 'black'
@@ -1678,9 +1679,15 @@
             icon_name = get_fs_icon(d['xml'].getAttribute('fs_type'))
         elif type == 'mapper_source':
             mapper_type = d['xml'].getAttribute('mapper_type')
+            mapper_id = d['xml'].getAttribute('mapper_id')
+            pretty_mapper_type, dummy1, dummy2 = get_pretty_mapper_info(mapper_type)
             dummy1, dummy2, icon_name = get_mapper_icons(mapper_type)
             if mapper_type == MAPPER_VG_TYPE:
                 color = '#a43737'
+            d['is_source'] = True
+            d['mapper_type'] = mapper_type
+            d['mapper_id'] = mapper_id
+            d['pretty_mapper_type'] = pretty_mapper_type
         elif type == 'none':
             pass
         elif type == 'hidden':
--- conga/luci/storage/form-macros	2006/10/09 16:16:11	1.9
+++ conga/luci/storage/form-macros	2006/10/09 17:03:17	1.10
@@ -589,20 +589,21 @@
      <span tal:omit-tag=""
            tal:repeat="bd_data mapper/targets">
       <div tal:attributes="id    bd_data/path;
-                            class string:invisible"> 
+                           class string:invisible"> 
        <div metal:use-macro="here/form-macros/macros/display-BD"/>
       </div>
      </span>
      <span tal:omit-tag=""
            tal:repeat="bd_data mapper/new_targets">
       <div tal:attributes="id    bd_data/path;
-                            class string:invisible"> 
+                           class string:invisible"> 
        <div metal:use-macro="here/form-macros/macros/display-BD"/>
       </div>
      </span>
      <span tal:omit-tag=""
            tal:repeat="bd_data mapper/sources">
-      <div tal:attributes="id    bd_data/path;
+      <div tal:define="displaying_source python:True" 
+           tal:attributes="id    bd_data/path;
                            class string:invisible"> 
        <div metal:use-macro="here/form-macros/macros/display-BD"/>
       </div>
@@ -1419,6 +1420,15 @@
            <span tal:omit-tag=""
                  tal:condition="not: bd_data/new">
             <span tal:replace="bd_data/pretty_type"/> '<span tal:replace="bd_data/pretty_name"/>' - <span tal:replace="bd_data/path"/>
+            <span tal:omit-tag=""
+                  tal:condition="displaying_source|nothing">
+             <br/>
+             <a tal:define="tmp_URL context/storage/index_html/absolute_url;
+                            URL python:tmp_URL + '?storagename=' + storagename + '&pagetype=62'"
+                tal:attributes="href python:URL + '&mapper_type=' + bd_data['mapper_type'] + '&mapper_id=' + bd_data['mapper_id'] + '&bd_path=' + bd_data['path']"
+                style="font-size: xx-small;"
+                tal:content="python: 'Go to ' + bd_data['pretty_mapper_type']"></a>
+            </span>
            </span>
            <span tal:omit-tag=""
                  tal:condition="bd_data/new">
@@ -1485,6 +1495,18 @@
                                       value cont/id"/>
                <span tal:replace="cont/name"/>
               </span>
+              <span tal:omit-tag="" 
+                    tal:define="cont python:conts[0]" 
+                    tal:condition="not: displaying_source|nothing">
+               <span tal:condition="cont/is_source">
+                <br/>
+                <a tal:define="tmp_URL context/storage/index_html/absolute_url;
+                               URL python:tmp_URL + '?storagename=' + storagename + '&pagetype=52'"
+                   tal:attributes="href python:URL + '&mapper_type=' + cont['mapper_type'] + '&mapper_id=' + cont['mapper_id']"
+                   style="font-size: xx-small;"
+                   tal:content="python: 'Go to ' + cont['pretty_mapper_type']"></a>
+               </span>
+              </span>
              </td>
              <td style="min-width: 30px;">
               &nbsp;



^ permalink raw reply	[flat|nested] 9+ messages in thread
* [Cluster-devel] conga/luci site/luci/Extensions/StorageReport. ...
@ 2006-10-09 19:11 kupcevic
  0 siblings, 0 replies; 9+ messages in thread
From: kupcevic @ 2006-10-09 19:11 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic at sourceware.org	2006-10-09 19:11:59

Modified files:
	luci/site/luci/Extensions: StorageReport.py 
	luci/storage   : form-macros 

Log message:
	luci storage: hide submit/reset buttons if nothing to modify

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/StorageReport.py.diff?cvsroot=cluster&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/form-macros.diff?cvsroot=cluster&r1=1.10&r2=1.11

--- conga/luci/site/luci/Extensions/StorageReport.py	2006/10/09 17:03:17	1.12
+++ conga/luci/site/luci/Extensions/StorageReport.py	2006/10/09 19:11:59	1.13
@@ -481,6 +481,8 @@
     if type == MAPPER_VG_TYPE:
         link_snapshots(mapper_ret)
     
+    mapper_ret['need_apply_button'] = mutable_props(mapper_ret['props'])
+    
     return mapper_ret
 
 
@@ -643,6 +645,8 @@
     
     mapper_ret['actions'] = []
     
+    mapper_ret['need_apply_button'] = True
+
     return mapper_ret
 
 
@@ -1523,6 +1527,16 @@
                     actions.append(action)
     data['actions'] = actions
     
+    need_apply_butt = mutable_props(data['props'])
+    if need_apply_butt == False:
+        if len(data['contents']) > 1:
+            need_apply_butt = True
+        elif len(data['contents']) == 1:
+            need_apply_butt = mutable_props(data['contents'][0]['props'])
+        else:
+            need_apply_butt = False
+    data['need_apply_button'] = need_apply_butt
+    
     return data
 
 
@@ -1621,6 +1635,14 @@
 
 
 
+def mutable_props(props):
+    for name in props:
+        type = props[name]['type']
+        if type == 'int' or type == 'text' or type == 'select':
+            return True
+    return False
+
+
 
 def get_content_data_internal(session, bd_xml):
     c_xml = None
--- conga/luci/storage/form-macros	2006/10/09 17:03:17	1.10
+++ conga/luci/storage/form-macros	2006/10/09 19:11:59	1.11
@@ -1580,27 +1580,34 @@
         </td>
         <td align="right"
             tal:define="validate_url  context/validate_html/absolute_url">
-         <input tal:attributes="type    string:button; 
-                                name    string:action_type; 
-                                value   string:Reset; 
-                                onclick python:'return reset_bd_form(this.form, \'' + select_content_id + '\', \'' + content_span_id + '\')'"
-                class="form_button"/>
-         <input tal:condition="bd_data/new" 
-                tal:define="prompt_msg  python:'Do you really want to create ' + bd_data['pretty_type'] + '?'" 
-                tal:attributes="id      apply_button_id;
-                                type    string:button; 
-                                name    string:action_type; 
-                                value   string:Create; 
-                                onclick python:'return validate_and_submit_form(\'' + validate_url + '\', \'' + bd_form_id + '\', \'' + apply_button_id + '\', \'' + prompt_msg + '\')'"
-                class="form_button"/>
-         <input tal:condition="not: bd_data/new" 
-                tal:define="prompt_msg  python:'Do you really want to apply changes to ' + bd_data['pretty_type'] + ' \\\'' + bd_data['pretty_name'] + '\\\'?'" 
-                tal:attributes="id      apply_button_id; 
-                                type    string:button; 
-                                name    string:action_type; 
-                                value   string:Apply; 
-                                onclick python:'return validate_and_submit_form(\'' + validate_url + '\', \'' + bd_form_id + '\', \'' + apply_button_id + '\', \'' + prompt_msg + '\')'"
-                class="form_button"/>
+         <span tal:omit-tag=""
+               tal:condition="not: bd_data/need_apply_button">
+          &nbsp;
+         </span>
+         <span tal:omit-tag="" 
+               tal:condition="bd_data/need_apply_button">
+          <input tal:attributes="type    string:button; 
+                                 name    string:action_type; 
+                                 value   string:Reset; 
+                                 onclick python:'return reset_bd_form(this.form, \'' + select_content_id + '\', \'' + content_span_id + '\')'"
+                 class="form_button"/>
+          <input tal:condition="bd_data/new" 
+                 tal:define="prompt_msg  python:'Do you really want to create ' + bd_data['pretty_type'] + '?'" 
+                 tal:attributes="id      apply_button_id;
+                                 type    string:button; 
+                                 name    string:action_type; 
+                                 value   string:Create; 
+                                 onclick python:'return validate_and_submit_form(\'' + validate_url + '\', \'' + bd_form_id + '\', \'' + apply_button_id + '\', \'' + prompt_msg + '\')'"
+                 class="form_button"/>
+          <input tal:condition="not: bd_data/new" 
+                 tal:define="prompt_msg  python:'Do you really want to apply changes to ' + bd_data['pretty_type'] + ' \\\'' + bd_data['pretty_name'] + '\\\'?'" 
+                 tal:attributes="id      apply_button_id; 
+                                 type    string:button; 
+                                 name    string:action_type; 
+                                 value   string:Apply; 
+                                 onclick python:'return validate_and_submit_form(\'' + validate_url + '\', \'' + bd_form_id + '\', \'' + apply_button_id + '\', \'' + prompt_msg + '\')'"
+                 class="form_button"/>
+         </span>
         </td>
         </tr>
         </table>
@@ -1712,19 +1719,26 @@
           </span>
          </td>
          <td align="right">
-          <input type="button"
-                 name="action_type"
-                 value="Reset"
-                 onclick="return reset_form(this.form)"
-                 class="form_button"/>
-          <input tal:define="prompt_msg    python:'Do you really want to apply changes to ' + mapper['pretty_type'] + ' \\\'' + mapper['pretty_name'] + '\\\'?';
-                             validate_url  context/validate_html/absolute_url" 
-                 tal:attributes="id      apply_button_id; 
-                                 type    string:button; 
-                                 name    string:action_type; 
-                                 value   string:Apply; 
-                                 onclick python:'return validate_and_submit_form(\'' + validate_url + '\', \'' + mapper_form_id + '\', \'' + apply_button_id + '\', \'' + prompt_msg + '\')'"
-                 class="form_button"/>
+          <span tal:omit-tag=""
+                tal:condition="not: mapper/need_apply_button">
+           &nbsp;
+          </span>
+          <span tal:omit-tag=""
+                tal:condition="mapper/need_apply_button">
+           <input type="button"
+                  name="action_type"
+                  value="Reset"
+                  onclick="return reset_form(this.form)"
+                  class="form_button"/>
+           <input tal:define="prompt_msg    python:'Do you really want to apply changes to ' + mapper['pretty_type'] + ' \\\'' + mapper['pretty_name'] + '\\\'?';
+                              validate_url  context/validate_html/absolute_url" 
+                  tal:attributes="id      apply_button_id; 
+                                  type    string:button; 
+                                  name    string:action_type; 
+                                  value   string:Apply; 
+                                  onclick python:'return validate_and_submit_form(\'' + validate_url + '\', \'' + mapper_form_id + '\', \'' + apply_button_id + '\', \'' + prompt_msg + '\')'"
+                  class="form_button"/>
+          </span>
          </td>
         </tr>
        </table>



^ permalink raw reply	[flat|nested] 9+ messages in thread
* [Cluster-devel] conga/luci site/luci/Extensions/StorageReport. ...
@ 2006-10-14 20:01 kupcevic
  0 siblings, 0 replies; 9+ messages in thread
From: kupcevic @ 2006-10-14 20:01 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic at sourceware.org	2006-10-14 20:01:52

Modified files:
	luci/site/luci/Extensions: StorageReport.py 
	luci/storage   : form-macros 

Log message:
	luci storage: since cylinders work properly in VGs only, don't display them, by default, at other mappers' views

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/StorageReport.py.diff?cvsroot=cluster&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/form-macros.diff?cvsroot=cluster&r1=1.11&r2=1.12

--- conga/luci/site/luci/Extensions/StorageReport.py	2006/10/09 19:11:59	1.13
+++ conga/luci/site/luci/Extensions/StorageReport.py	2006/10/14 20:01:52	1.14
@@ -481,6 +481,15 @@
     if type == MAPPER_VG_TYPE:
         link_snapshots(mapper_ret)
     
+    # cylinders work properly for VGs only, for now
+    mapper_ret['graphical_view'] = type == MAPPER_VG_TYPE
+    if mapper_ret['graphical_view']:
+        mapper_ret['mappings-view_css_classnames'] = {'graphical_view' : 'visible',
+                                                      'textual_view'   : 'invisible'}
+    else:
+        mapper_ret['mappings-view_css_classnames'] = {'graphical_view' : 'invisible',
+                                                      'textual_view'   : 'visible'}
+    
     mapper_ret['need_apply_button'] = mutable_props(mapper_ret['props'])
     
     return mapper_ret
--- conga/luci/storage/form-macros	2006/10/09 19:11:59	1.11
+++ conga/luci/storage/form-macros	2006/10/14 20:01:52	1.12
@@ -433,7 +433,8 @@
                <li tal:define="bd_data            source;
                                prefix             python:mapper['mapper_id'] + '_source_' + bd_data['path'] + '_';
                                properties_span_id python:prefix + 'properties_span_id'">
-                <span tal:attributes="id properties_span_id">
+                <span tal:define="displaying_source python:True" 
+                      tal:attributes="id properties_span_id">
                  <div metal:use-macro="here/form-macros/macros/display-BD"/>
                 </span>
                </li>
@@ -504,12 +505,14 @@
     
     <input type="checkbox" 
            id="graphics_checkbox_id"
-           checked=""
+           tal:attributes="checked mapper/graphical_view"
            onchange="var s = (this.checked)?'graphical_view':'textual_view'; singleVisibleSpan('mappings_view', s);"/>
      Graphical View
-    <span id="mappings_view">
+    <span id="mappings_view"
+          tal:define="mappings_view_classnames mapper/mappings-view_css_classnames">
     
-    <div id="graphical_view" class="visible"
+    <div id="graphical_view" 
+         tal:attributes="class mappings_view_classnames/graphical_view" 
          tal:define="global bd_path request/bd_path|nothing">
      <span tal:omit-tag=""
            tal:condition="not: bd_path">
@@ -522,7 +525,8 @@
                              height  string:180"></iframe>
     </div>
     
-    <div id="textual_view" class="invisible">
+    <div id="textual_view" 
+         tal:attributes="class mappings_view_classnames/textual_view">
     <br/>
     <div>
      <h3>



^ permalink raw reply	[flat|nested] 9+ messages in thread
* [Cluster-devel] conga/luci site/luci/Extensions/StorageReport. ...
@ 2006-10-15  5:09 kupcevic
  0 siblings, 0 replies; 9+ messages in thread
From: kupcevic @ 2006-10-15  5:09 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic at sourceware.org	2006-10-15 05:09:46

Modified files:
	luci/site/luci/Extensions: StorageReport.py 
	luci/storage   : form-macros mappings_provider 

Log message:
	luci storage: cylinders' improvements (path tooltip, 'click me' directions, legend)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/StorageReport.py.diff?cvsroot=cluster&r1=1.14&r2=1.15
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/form-macros.diff?cvsroot=cluster&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/mappings_provider.diff?cvsroot=cluster&r1=1.2&r2=1.3

--- conga/luci/site/luci/Extensions/StorageReport.py	2006/10/14 20:01:52	1.14
+++ conga/luci/site/luci/Extensions/StorageReport.py	2006/10/15 05:09:46	1.15
@@ -1822,27 +1822,34 @@
     high_list = {}
     
     # upper cyl
-    upper_cyl = {'offset'   : 0,
-                 'cyls'     : [],
-                 'highs'    : [],
-                 'js'       : [],
-                 'color'    : 'blue'}
+    upper_cyl = {'offset'     : 0,
+                 'cyls'       : [],
+                 'highs'      : [],
+                 'js'         : [],
+                 'color'      : 'blue', 
+                 'color_css'  : '#0192db', 
+                 'description': mapper_data['pretty_targets_name']}
+    if mapper_data['mapper_type'] == MAPPER_PT_TYPE:
+        upper_cyl['description'] = 'Physical ' + upper_cyl['description']
+    
     offset = 0
     for t in mapper_data['targets_all']:
         if t['mapper_type'] == MAPPER_PT_TYPE:
             if t['props']['partition_type']['value'] == 'logical':
                 continue
         data = {}
-        data['bd']     = t
-        data['id']     = t['path']
+        data['bd']        = t
+        data['id']        = t['path']
         beg = offset
         end = beg + int(t['props']['size']['value'])
-        data['beg']    = beg
-        data['end']    = end
-        data['color']  = 'blue'
+        data['beg']       = beg
+        data['end']       = end
+        data['color']     = 'blue'
+        data['color_css'] = '#0192db'
         if mapper_data['mapper_type'] == MAPPER_PT_TYPE:
             if t['props']['partition_type']['value'] == 'extended' and not t['new']:
-                data['color'] = 'black'
+                data['color']     = 'black'
+                data['color_css'] = 'black'
         upper_cyl['cyls'].append(data)
         offset = end
     
@@ -1861,8 +1868,8 @@
                                    'id'   : h_id,
                                    'type' : 'select'})
         upper_cyl['js'].append([d['id'],
-                                [beg,
-                                 end]])
+                                [beg, end],
+                                d['bd']['pretty_name']])
         high_list[d['id']] = [h_id]
         
         # snapshots
@@ -1892,28 +1899,34 @@
     upper_cyl['js'] = str(upper_cyl['js']).replace('L,', ',').replace('L]', ']').replace('u\'', '\'').replace('L]', ']')
     
     # lower cylinder
-    lower_cyl = {'offset'   : 0,
-                 'cyls'     : [],
-                 'highs'    : [],
-                 'js'       : [],
-                 'color'    : 'red'}
+    lower_cyl = {'offset'     : 0,
+                 'cyls'       : [],
+                 'highs'      : [],
+                 'js'         : [],
+                 'color'      : 'red', 
+                 'color_css'  : '#a43737', 
+                 'description': mapper_data['pretty_sources_name']}
+    
     offset = 0
     for t in mapper_data['sources']:
         data = {}
-        data['bd']     = t
-        data['id']     = t['path']
+        data['bd']        = t
+        data['id']        = t['path']
         beg = offset
         end = beg + int(t['props']['size']['value'])
-        data['beg']    = beg
-        data['end']    = end
-        data['color']  = 'red'
+        data['beg']       = beg
+        data['end']       = end
+        data['color']     = 'red'
+        data['color_css'] = '#a43737'
         lower_cyl['cyls'].append(data)
         offset = end
     
     if mapper_data['mapper_type'] == MAPPER_PT_TYPE:
-        lower_cyl['cyls']  = []
-        lower_cyl['color'] = 'blue'
-        lower_cyl['offset'] = 9999999999999999999999999
+        lower_cyl['description'] = 'Logical ' + mapper_data['pretty_targets_name']
+        lower_cyl['cyls']        = []
+        lower_cyl['color']       = 'blue'
+        lower_cyl['color_css']   = '#0192db'
+        lower_cyl['offset']      = 9999999999999999999999999
         
         offset = 0
         for t in mapper_data['targets_all']:
@@ -1923,13 +1936,14 @@
             if part_beg < lower_cyl['offset']:
                 lower_cyl['offset'] = part_beg
             data = {}
-            data['bd']     = t
-            data['id']     = t['path']
+            data['bd']        = t
+            data['id']        = t['path']
             beg = offset
             end = beg + int(t['props']['size']['value'])
-            data['beg']    = beg
-            data['end']    = end
-            data['color']  = 'blue'
+            data['beg']       = beg
+            data['end']       = end
+            data['color']     = 'blue'
+            data['color_css'] = '#0192db'
             lower_cyl['cyls'].append(data)
             offset = end
             
@@ -1956,8 +1970,8 @@
                                    'id'   : h_id,
                                    'type' : 'select'})
         lower_cyl['js'].append([d['id'],
-                                [beg,
-                                 end]])
+                                [beg, end],
+                                d['bd']['pretty_name']])
         high_list[d['id']] = [h_id]
     lower_cyl['js'] = str(lower_cyl['js']).replace('L,', ',').replace('L]', ']').replace('u\'', '\'').replace('L]', ']')
     
--- conga/luci/storage/form-macros	2006/10/14 20:01:52	1.12
+++ conga/luci/storage/form-macros	2006/10/15 05:09:46	1.13
@@ -522,14 +522,14 @@
      <iframe style="border: none;"
              tal:attributes="src     python:'mappings_provider?storagename=' + storagename + '&mapper_id=' + mapper['mapper_id'] + '&selected_path=' + bd_path;
                              width   string:700px;
-                             height  string:180"></iframe>
+                             height  string:195"></iframe>
     </div>
     
     <div id="textual_view" 
          tal:attributes="class mappings_view_classnames/textual_view">
     <br/>
     <div>
-     <h3>
+     <h3 style="font-size: small;">
       <span tal:omit-tag="" 
             tal:define="targets mapper/targets_all">
        <span tal:omit-tag="" 
@@ -551,7 +551,7 @@
     </div>
     <br/>
     <div>
-     <h3>
+     <h3 style="font-size: small;">
       <span tal:omit-tag="" 
             tal:define="sources mapper/sources">
        <span tal:omit-tag="" 
@@ -1431,7 +1431,7 @@
                             URL python:tmp_URL + '?storagename=' + storagename + '&pagetype=62'"
                 tal:attributes="href python:URL + '&mapper_type=' + bd_data['mapper_type'] + '&mapper_id=' + bd_data['mapper_id'] + '&bd_path=' + bd_data['path']"
                 style="font-size: xx-small;"
-                tal:content="python: 'Go to ' + bd_data['pretty_mapper_type']"></a>
+                tal:content="python: 'Go to ' + bd_data['pretty_mapper_type'] + ' view'"></a>
             </span>
            </span>
            <span tal:omit-tag=""
--- conga/luci/storage/mappings_provider	2006/10/07 01:04:01	1.2
+++ conga/luci/storage/mappings_provider	2006/10/15 05:09:46	1.3
@@ -136,14 +136,44 @@
          var y = Y;
          for (var i=0; i<c_data.length; i++) {
             var elem = c_data[i];
-            var id = elem[0];
+            var id   = elem[0];
             var beg  = elem[1][0];
             var end  = elem[1][1];
             if (x > beg && x < end)
                select_subcyl(id, h_data);
          }
       }
-
+      
+      
+      
+      
+      
+      function cyl_over(msg_board, X, Y, c_data, h_data) {
+         if (Y < 0 || Y > 40) {
+            msg_board.style.visibility = 'invisible';
+            return;
+         }
+         var x = X - ellipse(Y);
+         var y = Y;
+         for (var i=0; i<c_data.length; i++) {
+            var elem = c_data[i];
+            var beg  = elem[1][0];
+            var end  = elem[1][1];
+            if (x > beg && x < end) {
+               var descr = elem[2];
+               msg_board.innerHTML        = descr;
+               msg_board.style.width      = (descr.length + 1) + 'ex';
+               msg_board.style.left       = X - 35;
+               msg_board.style.top        = Y + 15;
+               msg_board.style.visibility = 'visible';
+               return;
+            }
+         }
+         msg_board.style.visibility = 'invisible';
+      }
+      
+      
+      
 
 
    </script>
@@ -176,16 +206,37 @@
 
 
 
-<span>
+<div>
+   
+   
+   
+
+   
+   
    
    <!-- upper cylinder -->
    <div tal:define="cyl       mapp_info/upper_cyl;
                     X_offset  python:X_offset + cyl['offset']"
         tal:condition="cyl/cyls"
-        tal:attributes="style python:here.add_commas('position:absolute', here.add_commas('left: ' + str(X_offset), 'top: ' + str(Y_offset)))">
+        tal:attributes="style  python:here.add_commas('position:absolute', here.add_commas('left: ' + str(X_offset), 'top: ' + str(Y_offset)))">
+    
+    <!-- description -->
+    <div tal:define="style_1         python:here.add_commas('left: -1em', 'top: -1.5ex');
+                     style_2         python:here.add_commas(style_1, 'position: absolute');
+                     style_3         python:here.add_commas(style_2, 'width: ' + str(cyl_width))"
+         tal:attributes="style style_3">
+     <div tal:define="style_1         python:here.add_commas('font-size: xx-small', 'text-align: left');
+                      style_2         python:here.add_commas(style_1, 'white-space: nowrap');
+                      style_3         python:here.add_commas(style_2, 'color: ' + cyl['color_css'])"
+          tal:attributes="style style_3">
+      <span tal:replace="cyl/description"/>:
+     </div>
+    </div>
     
     <div tal:define="one_temp_assignment  python:here.add_commas('position:absolute', here.add_commas('left: ' + str(curve_width), 'top: 0'))"
          tal:attributes="onmousedown  python:'cyl_click(event.clientX-' + str(curve_width) + '-' + str(X_offset) + ', event.clientY-' + str(Y_offset) + ', ' + cyl['js'] + ', ' + mapp_info['js'] + ')';
+                         onmousemove  python:'cyl_over(document.getElementById(\'upper_msg_board\'), event.clientX-' + str(curve_width) + '-' + str(X_offset) + ', event.clientY-' + str(Y_offset) + ', ' + cyl['js'] + ', ' + mapp_info['js'] + ')';
+                         onmouseout   python:'document.getElementById(\'upper_msg_board\').style.visibility = \'hidden\'';
                          style        python:here.add_commas('cursor: pointer', one_temp_assignment);
                          id           string:upper_cylinder">
      
@@ -198,20 +249,38 @@
       <div metal:use-macro="here/mappings_macros/macros/draw-highlights"/>
      </span>
      
+     <div id="upper_msg_board"
+          style="position: absolute; border: 2px solid black; padding: 2px; background-color: lightyellow; visibility: hidden; z-index: 100; white-space: nowrap;">
+     </div>
      
     </div>
    </div>
  
-
+   
    <!-- lower cylinder -->
    <div tal:define="cyl             mapp_info/lower_cyl;
                     lower_Y_offset  python:Y_offset + 80;
                     X_offset        python:X_offset + cyl['offset']"
         tal:condition="cyl/cyls"
-        tal:attributes="style python:here.add_commas('position:absolute', here.add_commas('left: ' + str(X_offset), 'top: ' + str(lower_Y_offset)))">
+        tal:attributes="style  python:here.add_commas('position:absolute', here.add_commas('left: ' + str(X_offset), 'top: ' + str(lower_Y_offset)))">
     
+    <!-- description -->
+    <div tal:define="style_1         python:here.add_commas('left: -1em', 'top: -1.5ex');
+                     style_2         python:here.add_commas(style_1, 'position: absolute');
+                     style_3         python:here.add_commas(style_2, 'width: ' + str(cyl_width))"
+         tal:attributes="style style_3">
+     <div tal:define="style_1         python:here.add_commas('font-size: xx-small', 'text-align: left');
+                      style_2         python:here.add_commas(style_1, 'white-space: nowrap');
+                      style_3         python:here.add_commas(style_2, 'color: ' + cyl['color_css'])"
+          tal:attributes="style style_3">
+      <span tal:replace="cyl/description"/>:
+     </div>
+    </div>
+     
     <div tal:define="one_temp_assignment  python:here.add_commas('position:absolute', here.add_commas('left: ' + str(curve_width), 'top: 0'))"
          tal:attributes="onmousedown  python:'cyl_click(event.clientX-' + str(curve_width) + '-' + str(X_offset) + ', event.clientY-' + str(lower_Y_offset) + ', ' + cyl['js'] + ', ' + mapp_info['js'] + ')'; 
+                         onmousemove  python:'cyl_over(document.getElementById(\'lower_msg_board\'), event.clientX-' + str(curve_width) + '-' + str(X_offset) + ', event.clientY-' + str(lower_Y_offset) + ', ' + cyl['js'] + ', ' + mapp_info['js'] + ')';
+                         onmouseout   python:'document.getElementById(\'lower_msg_board\').style.visibility = \'hidden\'';
                          style        python:here.add_commas('cursor: pointer', one_temp_assignment);
                          id           string:lower_cylinder">
      
@@ -224,12 +293,29 @@
       <div metal:use-macro="here/mappings_macros/macros/draw-highlights"/>
      </span>
      
+     <div id="lower_msg_board"
+          style="position: absolute; border: 2px solid black; padding: 2px; background-color: lightyellow; visibility: hidden; z-index: 100; white-space: nowrap;">
+     </div>
      
     </div>
    </div>
- 
-
-</span>
+   
+   
+   <!-- select me message -->
+   <div tal:define="cyl             mapp_info/lower_cyl;
+                    Y_offset        python:Y_offset + 80 + 40 + 10;
+                    X_offset        python:X_offset;
+                    style_1         python:here.add_commas('left: ' + str(X_offset), 'top: ' + str(Y_offset));
+                    style_2         python:here.add_commas('position: absolute', style_1);
+                    style_3         python:here.add_commas(style_2, 'width: ' + str(cyl_width))"
+        tal:attributes="style style_3">
+    <div style="font-size: x-small; text-align: center;">
+     Click cylinders to view properties, unselect all to view <span tal:replace="mapper/pretty_type"/>'s properties
+    </div>
+   </div>
+   
+   
+</div>
 
 
 



^ permalink raw reply	[flat|nested] 9+ messages in thread
* [Cluster-devel] conga/luci site/luci/Extensions/StorageReport. ...
@ 2006-10-15  5:44 kupcevic
  0 siblings, 0 replies; 9+ messages in thread
From: kupcevic @ 2006-10-15  5:44 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic at sourceware.org	2006-10-15 05:44:03

Modified files:
	luci/site/luci/Extensions: StorageReport.py 
	luci/storage   : mappings_provider 

Log message:
	luci storage: add 'new logical volume' button to VG view

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/StorageReport.py.diff?cvsroot=cluster&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/mappings_provider.diff?cvsroot=cluster&r1=1.3&r2=1.4

--- conga/luci/site/luci/Extensions/StorageReport.py	2006/10/15 05:09:46	1.15
+++ conga/luci/site/luci/Extensions/StorageReport.py	2006/10/15 05:44:03	1.16
@@ -476,6 +476,15 @@
                   'msg'  : 'Are you sure you want to remove ' + pretty_type + ' \\\'' + pretty_name + '\\\'?',
                   'link' : ''}
         actions.append(action)
+    if type == MAPPER_VG_TYPE:
+        for nt in mapper_ret['new_targets']:
+            if nt['props']['snapshot']['value'] == 'false':
+                if nt['new']:
+                    action = {'name' : 'New Logical Volume',
+                              'msg'  : '',
+                              'link' : './?' + PAGETYPE + '=' + VIEW_BD + '&' + PT_MAPPER_ID + '=' + mapper_ret['mapper_id'] + '&' + PT_MAPPER_TYPE + '=' + mapper_ret['mapper_type'] + '&' + PT_PATH + '=' + nt['path']}
+                    actions.append(action)
+                    break
     mapper_ret['actions'] = actions
     
     if type == MAPPER_VG_TYPE:
--- conga/luci/storage/mappings_provider	2006/10/15 05:09:46	1.3
+++ conga/luci/storage/mappings_provider	2006/10/15 05:44:03	1.4
@@ -250,7 +250,7 @@
      </span>
      
      <div id="upper_msg_board"
-          style="position: absolute; border: 2px solid black; padding: 2px; background-color: lightyellow; visibility: hidden; z-index: 100; white-space: nowrap;">
+          style="position: absolute; border: 2px solid black; padding: 2px; background-color: lightyellow; visibility: hidden; z-index: 100; white-space: nowrap; font-size: small;">
      </div>
      
     </div>
@@ -294,7 +294,7 @@
      </span>
      
      <div id="lower_msg_board"
-          style="position: absolute; border: 2px solid black; padding: 2px; background-color: lightyellow; visibility: hidden; z-index: 100; white-space: nowrap;">
+          style="position: absolute; border: 2px solid black; padding: 2px; background-color: lightyellow; visibility: hidden; z-index: 100; white-space: nowrap; font-size: small;">
      </div>
      
     </div>



^ permalink raw reply	[flat|nested] 9+ messages in thread
* [Cluster-devel] conga/luci site/luci/Extensions/StorageReport. ...
@ 2006-10-15 22:34 kupcevic
  0 siblings, 0 replies; 9+ messages in thread
From: kupcevic @ 2006-10-15 22:34 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic at sourceware.org	2006-10-15 22:34:54

Modified files:
	luci/site/luci/Extensions: StorageReport.py Variable.py 
	                           conga_storage_constants.py 
	                           storage_adapters.py 
	luci/storage   : form-chooser form-macros 

Log message:
	luci storage:
	- add "add sources" button to mappers' view
	- add "add sources" form

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/StorageReport.py.diff?cvsroot=cluster&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/Variable.py.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_storage_constants.py.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/storage_adapters.py.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/form-chooser.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/form-macros.diff?cvsroot=cluster&r1=1.13&r2=1.14

--- conga/luci/site/luci/Extensions/StorageReport.py	2006/10/15 05:44:03	1.16
+++ conga/luci/site/luci/Extensions/StorageReport.py	2006/10/15 22:34:54	1.17
@@ -4,7 +4,7 @@
 from xml.dom import minidom
 
 
-from Variable import parse_variable, Variable
+from Variable import parse_variable, Variable, VariableList
 from ricci_defines import *
 from PropsObject import PropsObject
 from conga_storage_constants import *
@@ -476,11 +476,16 @@
                   'msg'  : 'Are you sure you want to remove ' + pretty_type + ' \\\'' + pretty_name + '\\\'?',
                   'link' : ''}
         actions.append(action)
+    if type == MAPPER_VG_TYPE or type == MAPPER_MDRAID_TYPE or type == MAPPER_ATARAID_TYPE or type == MAPPER_MULTIPATH_TYPE:
+        action = {'name' : 'Add ' + mapper_ret['pretty_sources_name'], 
+                  'msg'  : '',
+                  'link' : './?' + PAGETYPE + '=' + ADD_SOURCES + '&' + PT_MAPPER_ID + '=' + mapper_ret['mapper_id'] + '&' + PT_MAPPER_TYPE + '=' + mapper_ret['mapper_type']}
+        actions.append(action)
     if type == MAPPER_VG_TYPE:
         for nt in mapper_ret['new_targets']:
             if nt['props']['snapshot']['value'] == 'false':
                 if nt['new']:
-                    action = {'name' : 'New Logical Volume',
+                    action = {'name' : 'New ' + mapper_ret['pretty_target_name'], 
                               'msg'  : '',
                               'link' : './?' + PAGETYPE + '=' + VIEW_BD + '&' + PT_MAPPER_ID + '=' + mapper_ret['mapper_id'] + '&' + PT_MAPPER_TYPE + '=' + mapper_ret['mapper_type'] + '&' + PT_PATH + '=' + nt['path']}
                     actions.append(action)
@@ -491,7 +496,7 @@
         link_snapshots(mapper_ret)
     
     # cylinders work properly for VGs only, for now
-    mapper_ret['graphical_view'] = type == MAPPER_VG_TYPE
+    mapper_ret['graphical_view'] = type != MAPPER_PT_TYPE
     if mapper_ret['graphical_view']:
         mapper_ret['mappings-view_css_classnames'] = {'graphical_view' : 'visible',
                                                       'textual_view'   : 'invisible'}
@@ -709,6 +714,17 @@
             return 'BAD: Invalid number of ' + data['pretty_sources_name'] + ' selected'
         props = data['props']
         pass
+    elif object_type == 'add_sources':
+        data = get_mapper_data(self, storage_report, mapper_id)
+        # find sources
+        sources_num = 0
+        for v in request.keys():
+            if v.find('source_bd_') == 0:
+                if request[v] == 'on':
+                    sources_num += 1
+        if sources_num == 0 or sources_num > len(data['new_sources']):
+            return 'BAD: Invalid number of ' + data['pretty_sources_name'] + ' selected'
+        pass
     
     if props != None:
         res = check_props(self, props, request)
@@ -1420,6 +1436,90 @@
     
     
     
+    elif object_type == 'add_sources':
+        mapper_data = get_mapper_data(self, storage_report, mapper_id)
+        mapper_xml = mapper_data['xml'].cloneNode(True)
+        new_sources = []
+        #return mapper_xml.toprettyxml()
+        
+        if action_type == 'Apply':
+            # find sources
+            for v in request.keys():
+                if v.find('source_bd_') == 0:
+                    if request[v] == 'on':
+                        path = v[len('source_bd_'):]
+                        for ns in mapper_data['new_sources']:
+                            if ns['path'] == path:
+                                new_sources.append(ns['xml'].cloneNode(True))
+            #return mapper_xml.toprettyxml()
+            doc = minidom.Document()
+            batch = doc.createElement("batch")
+            module = doc.createElement("module")
+            module.setAttribute("name", "storage")
+            req = doc.createElement("request")
+            req.setAttribute("API_version", "1.0")
+            req.setAttribute("sequence", "11")
+            f_call = doc.createElement("function_call")
+            f_call.setAttribute('name', 'add_mapper_sources')
+            f_call.appendChild(Variable('mapper_type', mapper_type).export_xml(doc))
+            f_call.appendChild(Variable('mapper_id', mapper_id).export_xml(doc))
+            f_call.appendChild(Variable('mapper_state_ind', mapper_xml.getAttribute('state_ind')).export_xml(doc))
+            f_call.appendChild(VariableList('bds', new_sources, [], VARIABLE_TYPE_LIST_XML).export_xml(doc))
+            
+            req.appendChild(f_call)
+            module.appendChild(req)
+            batch.appendChild(module)
+            
+            #return batch.toprettyxml()
+            
+            res = ricci.process_batch(batch, False)
+            if res.getAttribute('status') != '0':
+                invalidate_storage_report(request.SESSION, storagename)
+                err_msg = 'Error adding sources to ' + mapper_type + ' ' + mapper_id + '\n' + res.toprettyxml()
+                return err_msg
+            module_r = None
+            for node in res.childNodes:
+                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
+                    if node.nodeName == 'module':
+                        module_r = node
+            if module_r == None:
+                raise 'missing <module/> in <batch/>'
+            if module_r.getAttribute('status') != '0':
+                raise 'error retrieving storage report'
+            resp_r = None
+            for node in module_r.childNodes:
+                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
+                    if node.nodeName == RESPONSE_TAG:
+                        resp_r = node
+            if resp_r == None:
+                raise 'missing <response/> in <module/>'
+            fr_r = None
+            for node in resp_r.childNodes:
+                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
+                    if node.nodeName == FUNC_RESP_TAG:
+                        fr_r = node
+            if fr_r == None:
+                raise 'missing <function_response/> in <response/>'
+            mapper_var = None
+            for node in fr_r.childNodes:
+                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
+                    if node.nodeName == VARIABLE_TAG:
+                        if node.getAttribute('name') == 'mapper':
+                            mapper_var = node
+            if mapper_var == None:
+                raise 'missing <var name="mapper"/> in <function_response/>'
+            mapper_xml = None
+            for node in mapper_var.childNodes:
+                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
+                    if node.nodeName == 'mapper':
+                        mapper_xml = node.cloneNode(True)
+            mapper_id = mapper_xml.getAttribute('mapper_id')
+            pass
+        pass
+    
+    
+    
+    
     
     
     invalidate_storage_report(request.SESSION, storagename)
@@ -1441,6 +1541,8 @@
             goto_url += '&pagetype=' + VIEW_MAPPER
     elif object_type == 'mapper_template':
         goto_url += '&pagetype=' + VIEW_MAPPER
+    elif object_type == 'add_sources':
+        goto_url += '&pagetype=' + VIEW_MAPPER
     goto_url += '&' + PT_MAPPER_TYPE  + '=' + mapper_type
     goto_url += '&' + PT_MAPPER_ID  + '=' + mapper_id
     redirect_html = '<head>\n'
--- conga/luci/site/luci/Extensions/Variable.py	2006/05/30 20:17:21	1.1
+++ conga/luci/site/luci/Extensions/Variable.py	2006/10/15 22:34:54	1.2
@@ -262,12 +262,13 @@
         elem.setAttribute('type', self.type())
         
         l = self.get_value()
-        for i in range(len(l)):
-            x = l[i]
-            e2 = doc.createElement(VARIABLE_TYPE_LISTENTRY)
-            e2.setAttribute('value', str(x))
-            e2.setAttribute('list_index', str(i))
-            elem.appendChild(e2)
+        for x in l:
+            if self.type() == VARIABLE_TYPE_LIST_XML:
+                elem.appendChild(x.cloneNode(True))
+            else:
+                e2 = doc.createElement(VARIABLE_TYPE_LISTENTRY)
+                e2.setAttribute('value', str(x))
+                elem.appendChild(e2)
         for mod in self.__mods:
             elem.setAttribute(str(mod), str(self.__mods[mod]))
         return elem
--- conga/luci/site/luci/Extensions/conga_storage_constants.py	2006/10/09 17:01:19	1.7
+++ conga/luci/site/luci/Extensions/conga_storage_constants.py	2006/10/15 22:34:54	1.8
@@ -70,7 +70,7 @@
 
 
 CREATE_MAPPER = '101'
-
+ADD_SOURCES   = '102'
 
 
 
--- conga/luci/site/luci/Extensions/storage_adapters.py	2006/10/09 17:01:19	1.5
+++ conga/luci/site/luci/Extensions/storage_adapters.py	2006/10/15 22:34:54	1.6
@@ -180,7 +180,7 @@
   srs_p['cfg_type'] = "nodes"
   srs_p['absolute_url'] = url + '?' + PAGETYPE + '=' + VIEW_MAPPERS + '&' + STONAME + '=' + hostname + '&' + PT_MAPPER_TYPE + '=' + mapper_type
   srs_p['Description'] = pretty_names_desc
-  if (pagetype_req == VIEW_MAPPERS or pagetype_req == VIEW_MAPPER or pagetype_req == CREATE_MAPPER or pagetype_req == VIEW_BD) and mapper_type_req == mapper_type:
+  if (pagetype_req == VIEW_MAPPERS or pagetype_req == VIEW_MAPPER or pagetype_req == ADD_SOURCES or pagetype_req == CREATE_MAPPER or pagetype_req == VIEW_BD) and mapper_type_req == mapper_type:
     srs_p['show_children'] = True
   else:
     srs_p['show_children'] = False
@@ -222,7 +222,7 @@
     sr['absolute_url'] = url + '?' + PAGETYPE + '=' + VIEW_MAPPER + '&' + STONAME + '=' + hostname + '&' + PT_MAPPER_TYPE + '=' + mapper_type + '&' + PT_MAPPER_ID + '=' + sr_id
     sr['Description'] = pretty_name_desc
     
-    if (pagetype_req == VIEW_MAPPER or pagetype_req == VIEW_BD) and mapper_id_req == sr_id:
+    if (pagetype_req == VIEW_MAPPER or pagetype_req == ADD_SOURCES or pagetype_req == VIEW_BD) and mapper_id_req == sr_id:
       sr['currentItem'] = True
     else:
       sr['currentItem'] = False
--- conga/luci/storage/form-chooser	2006/10/09 16:16:11	1.4
+++ conga/luci/storage/form-chooser	2006/10/15 22:34:54	1.5
@@ -70,6 +70,10 @@
       <div metal:use-macro="here/form-macros/macros/create-mapper-form"/>
     </span>
 
+    <span tal:omit-tag="" tal:condition="python: pagetype == '102' and storage_report != None">
+      <div metal:use-macro="here/form-macros/macros/add-sources-form"/>
+    </span>
+
   </metal:choose-form>
 
   </body>
--- conga/luci/storage/form-macros	2006/10/15 05:09:46	1.13
+++ conga/luci/storage/form-macros	2006/10/15 22:34:54	1.14
@@ -777,6 +777,135 @@
 
 
 
+  <div metal:define-macro="add-sources-form" 
+       tal:define="mapper                  python:here.get_mapper_data(storage_report, request['mapper_id']); 
+                   prefix                  python:'add_sources_to_' + mapper['mapper_id'] + '_'; 
+                   properties_span_id      string:; 
+                   add_sources_form_id     python:prefix + 'form_id'; 
+                   add_sources_button_id   python:prefix + 'button_id'; 
+                   form_submit_button_id   add_sources_button_id">
+   <div metal:use-macro="here/form-macros/macros/forms-css"/>
+   <div metal:use-macro="here/form-macros/macros/form-scripts"/>
+   <span tal:omit-tag="" 
+         tal:condition="not: mapper/new_sources">
+    There is no available <span tal:replace="mapper/pretty_sources_name"/> to be added to <span tal:replace="mapper/pretty_type"/> '<span tal:replace="mapper/pretty_name"/>'. 
+     <br/>
+     <br/>
+    <a tal:define="go_to_mapper_url  python:'./?pagetype=52&mapper_type=' + mapper['mapper_type'] + '&mapper_id=' + mapper['mapper_id'] + '&storagename=' + storagename" 
+           tal:attributes="href go_to_mapper_url">
+     Go Back to <span tal:replace="mapper/pretty_type"/>
+    </a>
+   </span>
+   <form tal:condition="mapper/new_sources" 
+         tal:attributes="id      add_sources_form_id; 
+                         method  string:get">
+    <input tal:attributes="type  string:hidden; 
+                           name  string:pagetype; 
+                           value string:commit_changes"/>
+    <input tal:attributes="type  string:hidden; 
+                           name  string:object_type; 
+                           value string:add_sources"/>
+    <input tal:attributes="type  string:hidden; 
+                           name  string:mapper_type; 
+                           value mapper/mapper_type"/>
+    <input tal:attributes="type  string:hidden; 
+                           name  string:mapper_id; 
+                           value mapper/mapper_id"/>
+    <input tal:attributes="type  string:hidden; 
+                           name  string:storagename; 
+                           value storagename"/>
+    <table class="props-form-table">
+     <tr class="props-form-header">
+      <th colspan="2"
+          tal:attributes="style python:here.add_commas('font-size: large', 'color: ' + mapper['color'])">
+       <table>
+        <tr>
+         <td style="min-width: 30px;">
+          <img tal:condition="mapper/icon"
+               tal:attributes="src mapper/icon"
+               height="29px"
+               width="29px"/>
+         </td>
+         <td style="width: 100%;">
+          Adding new <span tal:replace="mapper/pretty_sources_name"/> to <span tal:replace="mapper/pretty_type"/> '<span tal:replace="mapper/pretty_name"/>'
+         </td>
+         <td style="min-width: 30px;">
+          &nbsp;
+         </td>
+        </tr>
+       </table>
+      </th>
+     </tr>
+     <tr class="props-form-body">
+      <td style="height: 100%;">
+       <table class="props-inner-table">
+        <th colspan="2">
+         <span tal:condition="python:len(mapper['new_sources']) == 1">
+          Select <span tal:replace="mapper/pretty_source_name"/> to add
+         </span>
+         <span tal:condition="python:len(mapper['new_sources']) > 1">
+          Select one or more <span tal:replace="mapper/pretty_sources_name"/> to add
+         </span>
+        </th>
+        <span tal:omit-tag=""
+              tal:define="bds mapper/new_sources"
+              tal:repeat="bd bds">
+         <tr>
+          <td>
+           <input tal:attributes="type string:checkbox; 
+                                  name python:'source_bd_' + bd['path']"/>
+          </td>
+          <td tal:define="bytes  bd/props/size/value;
+                          dummy  python:here.bytes_to_value_units(bytes);
+                          size   python:dummy[0];
+                          units  python:dummy[1]">
+           <span tal:replace="bd/path"/> (<span tal:replace="size"/> <span tal:replace="units"/> - <span tal:replace="bd/pretty_type"/>)
+          </td>
+         </tr>
+        </span>
+        <tr>
+         <td colspan="2"
+             style="height: 100%;">
+          &nbsp;
+         </td>
+        </tr>
+       </table>
+      </td>
+      <td>
+       &nbsp;
+      </td>
+     </tr>
+     <tr class="props-form-footer">
+      <td colspan="2">
+       <table style="width: 100%;">
+        <tr>
+         <td align="left">
+          &nbsp;
+         </td>
+         <td align="right">
+          <input tal:define="go_to_mapper_url  python:'./?pagetype=52&mapper_type=' + mapper['mapper_type'] + '&mapper_id=' + mapper['mapper_id'] + '&storagename=' + storagename" 
+                 tal:attributes="type    string:button; 
+                                 name    string:cancel_button; 
+                                 value   string:Cancel; 
+                                 onclick python:'window.location.assign(\'' + go_to_mapper_url + '\')'"
+                 class="form_button"/>
+          <input tal:define="prompt_msg    python:'Do you really want to add selected ' + mapper['pretty_sources_name'] + ' to \\\'' + mapper['pretty_name'] + '\\\'?';
+                             validate_url  context/validate_html/absolute_url" 
+                 tal:attributes="id      add_sources_button_id; 
+                                 type    string:button; 
+                                 name    string:action_type; 
+                                 value   string:Add; 
+                                 onclick python:'return validate_and_submit_form(\'' + validate_url + '\', \'' + add_sources_form_id + '\', \'' + add_sources_button_id + '\', \'' + prompt_msg + '\')'"
+                 class="form_button"/>
+         </td>
+        </tr>
+       </table>
+      </td>
+     </tr>
+    </table>
+   </form>
+  </div>
+
 
 
 
@@ -1755,5 +1884,6 @@
 
 
 
+
   </body>
 </html>



^ permalink raw reply	[flat|nested] 9+ messages in thread
* [Cluster-devel] conga/luci site/luci/Extensions/StorageReport. ...
@ 2006-10-16  7:39 kupcevic
  0 siblings, 0 replies; 9+ messages in thread
From: kupcevic @ 2006-10-16  7:39 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic at sourceware.org	2006-10-16 07:39:27

Modified files:
	luci/site/luci/Extensions: StorageReport.py Variable.py 
	                           ricci_communicator.py 
	luci/storage   : form-macros 
Added files:
	luci/storage   : check-batch 

Log message:
	luci storage:
	- use async calls to commit storage changes
	- detailed error reporting during commits

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/StorageReport.py.diff?cvsroot=cluster&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/Variable.py.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_communicator.py.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/check-batch.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/form-macros.diff?cvsroot=cluster&r1=1.14&r2=1.15

--- conga/luci/site/luci/Extensions/StorageReport.py	2006/10/15 22:34:54	1.17
+++ conga/luci/site/luci/Extensions/StorageReport.py	2006/10/16 07:39:27	1.18
@@ -10,7 +10,7 @@
 from conga_storage_constants import *
 from HelperFunctions import *
 
-from ricci_communicator import get_ricci_communicator
+from ricci_communicator import get_ricci_communicator, batch_status, extract_module_status
 
 
 
@@ -811,14 +811,10 @@
     return [valid, var_name, msg]
 
 
-# TODO: implement
-def apply(self, ricci, storage_report, request, main_URL):
+
+def apply(self, ricci, storage_report, request):
     if validate(self, storage_report, request) != 'OK':
-        return 'Internal error: input not validated!!!'
-    
-    #return 'size has to be within limits'
-    #return request
-    #return main_URL
+        raise 'Internal error: input not validated!!!'
     
     session = request.SESSION
     
@@ -833,6 +829,8 @@
         path = request[PT_PATH]
     
     
+    batch_id = ''
+    
     if object_type == 'bd':
         bd_data = get_bd_data(self, storage_report, mapper_id, path)
         bd_xml = bd_data['xml'].cloneNode(True)
@@ -853,11 +851,8 @@
             module.appendChild(req)
             batch.appendChild(module)
             
-            res = ricci.process_batch(batch, False)
-            if res.getAttribute('status') != '0':
-                invalidate_storage_report(request.SESSION, storagename)
-                err_msg = 'Error removing ' + path + '\n' + res.toprettyxml()
-                return err_msg
+            res = ricci.process_batch(batch, True)
+            batch_id = res.getAttribute('batch_id')
             pass
         
         
@@ -978,51 +973,10 @@
             module.appendChild(req)
             batch.appendChild(module)
             
-            res = ricci.process_batch(batch, False)
-            if res.getAttribute('status') != '0':
-                invalidate_storage_report(request.SESSION, storagename)
-                err_msg = 'Error modifying ' + path + '\n' + res.toprettyxml()
-                return err_msg
-            module_r = None
-            for node in res.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == 'module':
-                        module_r = node
-            if module_r == None:
-                raise 'missing <module/> in <batch/>'
-            if module_r.getAttribute('status') != '0':
-                raise 'error retrieving storage report'
-            resp_r = None
-            for node in module_r.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == RESPONSE_TAG:
-                        resp_r = node
-            if resp_r == None:
-                raise 'missing <response/> in <module/>'
-            fr_r = None
-            for node in resp_r.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == FUNC_RESP_TAG:
-                        fr_r = node
-            if fr_r == None:
-                raise 'missing <function_response/> in <response/>'
-            bd_var = None
-            for node in fr_r.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == VARIABLE_TAG:
-                        if node.getAttribute('name') == 'bd':
-                            bd_var = node
-            if bd_var == None:
-                raise 'missing <var name="bd"/> in <function_response/>'
-            bd_xml = None
-            for node in bd_var.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == BD_TYPE:
-                        bd_xml = node.cloneNode(True)
-            path = bd_xml.getAttribute('path')
+            res = ricci.process_batch(batch, True)
+            batch_id = res.getAttribute('batch_id')
             pass
-        pass
-    
+        
     
     
     elif object_type == 'bd_template':
@@ -1149,51 +1103,10 @@
             module.appendChild(req)
             batch.appendChild(module)
             
-            res = ricci.process_batch(batch, False)
-            if res.getAttribute('status') != '0':
-                invalidate_storage_report(request.SESSION, storagename)
-                err_msg = 'Error creating new ' + path + '\n' + res.toprettyxml()
-                return err_msg
-            module_r = None
-            for node in res.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == 'module':
-                        module_r = node
-            if module_r == None:
-                raise 'missing <module/> in <batch/>'
-            if module_r.getAttribute('status') != '0':
-                raise 'error retrieving storage report'
-            resp_r = None
-            for node in module_r.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == RESPONSE_TAG:
-                        resp_r = node
-            if resp_r == None:
-                raise 'missing <response/> in <module/>'
-            fr_r = None
-            for node in resp_r.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == FUNC_RESP_TAG:
-                        fr_r = node
-            if fr_r == None:
-                raise 'missing <function_response/> in <response/>'
-            bd_var = None
-            for node in fr_r.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == VARIABLE_TAG:
-                        if node.getAttribute('name') == 'bd':
-                            bd_var = node
-            if bd_var == None:
-                raise 'missing <var name="bd"/> in <function_response/>'
-            bd_xml = None
-            for node in bd_var.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == BD_TYPE:
-                        bd_xml = node.cloneNode(True)
-            path = bd_xml.getAttribute('path')
+            res = ricci.process_batch(batch, True)
+            batch_id = res.getAttribute('batch_id')
             pass
-        pass
-    
+        
     
     
     elif object_type == 'mapper':
@@ -1217,13 +1130,11 @@
             module.appendChild(req)
             batch.appendChild(module)
             
-            res = ricci.process_batch(batch, False)
-            if res.getAttribute('status') != '0':
-                invalidate_storage_report(request.SESSION, storagename)
-                err_msg = 'Error removing ' + mapper_id + '\n' + res.toprettyxml()
-                return err_msg
+            res = ricci.process_batch(batch, True)
+            batch_id = res.getAttribute('batch_id')
             pass
         
+        
         elif action_type == 'Apply':
             # props
             props_xml = None
@@ -1274,51 +1185,10 @@
             module.appendChild(req)
             batch.appendChild(module)
             
-            res = ricci.process_batch(batch, False)
-            if res.getAttribute('status') != '0':
-                invalidate_storage_report(request.SESSION, storagename)
-                err_msg = 'Error modifying ' + mapper_id + '\n' + res.toprettyxml()
-                return err_msg
-            module_r = None
-            for node in res.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == 'module':
-                        module_r = node
-            if module_r == None:
-                raise 'missing <module/> in <batch/>'
-            if module_r.getAttribute('status') != '0':
-                raise 'error retrieving storage report'
-            resp_r = None
-            for node in module_r.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == RESPONSE_TAG:
-                        resp_r = node
-            if resp_r == None:
-                raise 'missing <response/> in <module/>'
-            fr_r = None
-            for node in resp_r.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == FUNC_RESP_TAG:
-                        fr_r = node
-            if fr_r == None:
-                raise 'missing <function_response/> in <response/>'
-            mapper_var = None
-            for node in fr_r.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == VARIABLE_TAG:
-                        if node.getAttribute('name') == 'mapper':
-                            mapper_var = node
-            if mapper_var == None:
-                raise 'missing <var name="mapper"/> in <function_response/>'
-            mapper_xml = None
-            for node in mapper_var.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == MAPPER_TYPE:
-                        mapper_xml = node.cloneNode(True)
-            path = mapper_xml.getAttribute('mapper_id')
+            res = ricci.process_batch(batch, True)
+            batch_id = res.getAttribute('batch_id')
             pass
-        pass
-    
+        
     
     
     elif object_type == 'mapper_template':
@@ -1388,51 +1258,10 @@
             module.appendChild(req)
             batch.appendChild(module)
             
-            res = ricci.process_batch(batch, False)
-            if res.getAttribute('status') != '0':
-                invalidate_storage_report(request.SESSION, storagename)
-                err_msg = 'Error creating new ' + mapper_type + '\n' + res.toprettyxml()
-                return err_msg
-            module_r = None
-            for node in res.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == 'module':
-                        module_r = node
-            if module_r == None:
-                raise 'missing <module/> in <batch/>'
-            if module_r.getAttribute('status') != '0':
-                raise 'error retrieving storage report'
-            resp_r = None
-            for node in module_r.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == RESPONSE_TAG:
-                        resp_r = node
-            if resp_r == None:
-                raise 'missing <response/> in <module/>'
-            fr_r = None
-            for node in resp_r.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == FUNC_RESP_TAG:
-                        fr_r = node
-            if fr_r == None:
-                raise 'missing <function_response/> in <response/>'
-            mapper_var = None
-            for node in fr_r.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == VARIABLE_TAG:
-                        if node.getAttribute('name') == 'mapper':
-                            mapper_var = node
-            if mapper_var == None:
-                raise 'missing <var name="mapper"/> in <function_response/>'
-            mapper_xml = None
-            for node in mapper_var.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == 'mapper':
-                        mapper_xml = node.cloneNode(True)
-            mapper_id = mapper_xml.getAttribute('mapper_id')
+            res = ricci.process_batch(batch, True)
+            batch_id = res.getAttribute('batch_id')
             pass
-        pass
-    
+        
     
     
     
@@ -1470,88 +1299,129 @@
             module.appendChild(req)
             batch.appendChild(module)
             
-            #return batch.toprettyxml()
-            
-            res = ricci.process_batch(batch, False)
-            if res.getAttribute('status') != '0':
-                invalidate_storage_report(request.SESSION, storagename)
-                err_msg = 'Error adding sources to ' + mapper_type + ' ' + mapper_id + '\n' + res.toprettyxml()
-                return err_msg
-            module_r = None
-            for node in res.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == 'module':
-                        module_r = node
-            if module_r == None:
-                raise 'missing <module/> in <batch/>'
-            if module_r.getAttribute('status') != '0':
-                raise 'error retrieving storage report'
-            resp_r = None
-            for node in module_r.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == RESPONSE_TAG:
-                        resp_r = node
-            if resp_r == None:
-                raise 'missing <response/> in <module/>'
-            fr_r = None
-            for node in resp_r.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == FUNC_RESP_TAG:
-                        fr_r = node
-            if fr_r == None:
-                raise 'missing <function_response/> in <response/>'
-            mapper_var = None
-            for node in fr_r.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == VARIABLE_TAG:
-                        if node.getAttribute('name') == 'mapper':
-                            mapper_var = node
-            if mapper_var == None:
-                raise 'missing <var name="mapper"/> in <function_response/>'
-            mapper_xml = None
-            for node in mapper_var.childNodes:
-                if node.nodeType == xml.dom.Node.ELEMENT_NODE:
-                    if node.nodeName == 'mapper':
-                        mapper_xml = node.cloneNode(True)
-            mapper_id = mapper_xml.getAttribute('mapper_id')
+            res = ricci.process_batch(batch, True)
+            batch_id = res.getAttribute('batch_id')
             pass
         pass
     
     
-    
-    
-    
-    
-    invalidate_storage_report(request.SESSION, storagename)
-    
-    goto_url = main_URL + '?storagename=' + storagename
-    if object_type == 'bd_template':
-        goto_url += '&pagetype=' + VIEW_BD
-        goto_url += '&' + PT_PATH + '=' + path
-    elif object_type == 'bd':
-        if action_type == 'Remove':
-            goto_url += '&pagetype=' + VIEW_MAPPER
-        else:
-            goto_url += '&pagetype=' + VIEW_BD
-            goto_url += '&' + PT_PATH + '=' + request[PT_PATH]
-    elif object_type == 'mapper':
-        if action_type == 'Remove':
-            goto_url += '&pagetype=' + VIEW_MAPPERS
+    if batch_id == '':
+        raise 'unsupported function'
+    else:
+        invalidate_storage_report(request.SESSION, storagename)
+        return batch_id;
+
+
+def get_storage_batch_result(self, 
+                             storagename, 
+                             ricci, 
+                             index_html_URL, 
+                             batch_id):
+    error     = True               # ricci reported failure or no ricci
+    completed = False              # no batch, or batch done (defined if no error)
+    url       = index_html_URL     # redirect URL
+    msg       = 'Unknown error occured'
+    
+    if ricci == None:
+        # ricci down
+        error   = True
+        url     = url
+        msg     = 'Unable to contact ' + storagename
+    else:
+        batch = 'no batch'
+        try:
+            batch = ricci.batch_report(batch_id)
+        except:
+            pass
+        if batch == 'no batch':
+            error = True
+            url   = url
+            msg   = 'Ricci on ' + storagename + ' responded with error. No detailed info available.'
+        elif batch == None:
+            # no such batch
+            error     = False
+            completed = True
+            url      += '?' + STONAME + '=' + storagename + '&' + PAGETYPE + '=' + STORAGE
+            msg       = 'No such batch'
         else:
-            goto_url += '&pagetype=' + VIEW_MAPPER
-    elif object_type == 'mapper_template':
-        goto_url += '&pagetype=' + VIEW_MAPPER
-    elif object_type == 'add_sources':
-        goto_url += '&pagetype=' + VIEW_MAPPER
-    goto_url += '&' + PT_MAPPER_TYPE  + '=' + mapper_type
-    goto_url += '&' + PT_MAPPER_ID  + '=' + mapper_id
-    redirect_html = '<head>\n'
-    redirect_html += ' <meta http-equiv="Refresh" content="0;url=' + goto_url + '"/>\n'
-    redirect_html += '</head>\n'
-    redirect_html += '<body>\n'
-    #redirect_html += 'Reloading Storage Info...\n'
-    redirect_html += '</body>'
-    return redirect_html
+            DEFAULT_ERROR = 'extract_module_status() failed'
+            code, err_msg = DEFAULT_ERROR, ''
+            try:
+                code, err_msg = extract_module_status(batch, 1)
+            except:
+                pass
+            if code == DEFAULT_ERROR:
+                error = True
+                url  += '?' + STONAME + '=' + storagename + '&' + PAGETYPE + '=' + STORAGE
+                msg   = 'Ricci on ' + storagename + ' sent malformed response'
+            elif code == -101 or code == -102:
+                # in progress
+                error     = False
+                completed = False
+                msg   = 'Task still in progress'
+            elif code == -103:
+                # module removed from scheduler
+                error = True
+                url  += '?' + STONAME + '=' + storagename + '&' + PAGETYPE + '=' + STORAGE
+                msg   = 'Ricci on ' + storagename + ' removed request from scheduler. File bug report against ricci.' 
+            elif code == -104:
+                # module failure
+                error = True
+                url  += '?' + STONAME + '=' + storagename + '&' + PAGETYPE + '=' + STORAGE
+                msg   = 'Ricci on ' + storagename + ' failed to execute storage module; reinstall it.'
+            elif code == -2:
+                # API error
+                error = True
+                url  += '?' + STONAME + '=' + storagename + '&' + PAGETYPE + '=' + STORAGE
+                msg   = 'Luci server used invalid API to communicate with ' + storagename + '. File a bug report against luci.'
+            elif code == -1:
+                # undefined error
+                error = True
+                url  += '?' + STONAME + '=' + storagename + '&' + PAGETYPE + '=' + STORAGE
+                msg   = 'Reason for failure (as reported by ' + storagename + '): ' + err_msg
+            elif code == 0:
+                # no error
+                error     = False
+                completed = True
+                # TODO: implement proper redirect
+                url       = get_commit_redirect(url,
+                                                storagename,
+                                                batch)
+                msg       = 'Done successfully'
+            elif code == 1:
+                # mid-air
+                error  = True
+                url   += '?' + STONAME + '=' + storagename + '&' + PAGETYPE + '=' + STORAGE
+                msg    = 'Mid-Air collision (storage on ' + storagename + ' has changed since last probe). '
+            elif code == 2:
+                # validation error
+                error  = True
+                url   += '?' + STONAME + '=' + storagename + '&' + PAGETYPE + '=' + STORAGE
+                msg    = 'Validation error. File bug report against Luci.'
+            elif code == 3:
+                # unmount error
+                error  = True
+                url   += '?' + STONAME + '=' + storagename + '&' + PAGETYPE + '=' + STORAGE
+                msg    = 'Unmount failure: ' + err_msg
+            elif code == 4:
+                # clvmd error
+                error  = True
+                url   += '?' + STONAME + '=' + storagename + '&' + PAGETYPE + '=' + STORAGE
+                msg    = 'clvmd (clustered LVM daemon) is not running on ' + storagename + '. Start it and try again.'
+            elif code == 5:
+                # not quorate
+                error  = True
+                url   += '?' + STONAME + '=' + storagename + '&' + PAGETYPE + '=' + STORAGE
+                msg    = 'Cluster quorum is required, and yet cluster is not quorate. Start cluster, and try again.'
+            elif code > 5:
+                error  = True
+                url   += '?' + STONAME + '=' + storagename + '&' + PAGETYPE + '=' + STORAGE
+                msg    = err_msg
+    
+    return {'error'        : error,
+            'completed'    : completed,
+            'redirect_url' : url,
+            'msg'          : msg}
 
 
 
@@ -1561,6 +1431,74 @@
 
 
 
+def get_commit_redirect(main_url, 
+                        storagename, 
+                        batch_xml):
+    module_r = None
+    for node in batch_xml.childNodes:
+        if node.nodeType == xml.dom.Node.ELEMENT_NODE:
+            if node.nodeName == 'module':
+                module_r = node
+    if module_r == None:
+        raise 'missing <module/> in <batch/>'
+    resp_r = None
+    for node in module_r.childNodes:
+        if node.nodeType == xml.dom.Node.ELEMENT_NODE:
+            if node.nodeName == RESPONSE_TAG:
+                resp_r = node
+    if resp_r == None:
+        raise 'missing <response/> in <module/>'
+    fr_r = None
+    for node in resp_r.childNodes:
+        if node.nodeType == xml.dom.Node.ELEMENT_NODE:
+            if node.nodeName == FUNC_RESP_TAG:
+                fr_r = node
+    if fr_r == None:
+        raise 'missing <function_response/> in <response/>'
+    vars = {}
+    for node in fr_r.childNodes:
+        try:
+            var = parse_variable(node)
+            vars[var.get_name()] = var
+        except:
+            pass
+        pass
+    
+    
+    mapper_id   = ''
+    mapper_type = ''
+    bd_path     = ''
+    if 'mapper' in vars:
+        mapper      = vars['mapper'].get_value()
+        mapper_type = mapper.getAttribute('mapper_type')
+        mapper_id   = mapper.getAttribute('mapper_id')
+    if 'bd' in vars:
+        bd          = vars['bd'].get_value()
+        bd_path     = bd.getAttribute('path')
+        mapper_type = bd.getAttribute('mapper_type')
+        mapper_id   = bd.getAttribute('mapper_id')
+    
+    url  = main_url + '?'
+    url += STONAME + '=' + storagename
+    if mapper_type != '':
+        url += '&' + PT_MAPPER_TYPE + '=' + mapper_type
+    if mapper_id != '':
+        url += '&' + PT_MAPPER_ID + '=' + mapper_id
+    if bd_path != '':
+        url += '&' + PT_PATH + '=' + bd_path
+    
+    if mapper_type == '':
+        url += '&' + PAGETYPE + '=' + STORAGE
+    elif bd_path != '':
+        url += '&' + PAGETYPE + '=' + VIEW_BD
+    else:
+        url += '&' + PAGETYPE + '=' + VIEW_MAPPER
+    
+    return url
+                        
+                        
+
+
 def get_bd_data_internal(session, bd_xml, mapper_xml):
     data = {}
     
--- conga/luci/site/luci/Extensions/Variable.py	2006/10/16 04:26:19	1.3
+++ conga/luci/site/luci/Extensions/Variable.py	2006/10/16 07:39:27	1.4
@@ -49,12 +49,12 @@
         value = []
         for kid in node.childNodes:
             if kid.nodeType == xml.dom.Node.ELEMENT_NODE:
-                value.append(kid)
+                value.append(kid.cloneNode(True))
         return VariableList(attrs_dir['name'], value, mods, VARIABLE_TYPE_LIST_XML)
     elif attrs_dir['type'] == VARIABLE_TYPE_XML:
         for kid in node.childNodes:
             if kid.nodeType == xml.dom.Node.ELEMENT_NODE:
-                value = kid
+                value = kid.cloneNode(True)
                 break
     elif attrs_dir['type'] == VARIABLE_TYPE_INT:
         value = int(attrs_dir['value'])
--- conga/luci/site/luci/Extensions/ricci_communicator.py	2006/10/16 04:26:19	1.8
+++ conga/luci/site/luci/Extensions/ricci_communicator.py	2006/10/16 07:39:27	1.9
@@ -297,7 +297,7 @@
 #          -102 - scheduled
 #          -103 - removed from schedule
 #          -104 - failed to execute module
-#
+# 
 #          >-3  - module executed. Following codes are defined:
 #             -2   - API error
 #             -1   - undefined error occured (msg not necesarily very informative)
/cvs/cluster/conga/luci/storage/check-batch,v  -->  standard output
revision 1.1
--- conga/luci/storage/check-batch
+++ -	2006-10-16 07:39:28.551973000 +0000
@@ -0,0 +1,60 @@
+<span tal:omit-tag="" 
+      tal:define="global storagename request/storagename; 
+                  global batch_id    request/batch_id"/>
+<span tal:omit-tag="" 
+      tal:define="stosystemss                   context/systems/storage/objectItems; 
+                  global allowed_systems        python:here.allowed_systems(user, stosystemss); 
+                  global access_to_host_allowed python:here.access_to_host_allowed(storagename, allowed_systems)"/>
+<span tal:omit-tag="" 
+      tal:define="global ricci  python:here.get_ricci_communicator(storagename, allowed_systems)"/>
+
+
+
+<span tal:omit-tag=""
+      tal:condition="not: access_to_host_allowed">
+FAILURE
+<span tal:replace="structure context/storage/index_html/absolute_url"/>
+You are not authorized to modify storage system <span tal:replace="structure storagename"/>!!!
+</span>
+
+
+<span tal:omit-tag=""
+      tal:condition="access_to_host_allowed">
+ <span tal:omit-tag=""
+       tal:define="index_html_URL   context/storage/index_html/absolute_url;
+                   dummy            python:here.get_storage_batch_result(storagename, ricci, index_html_URL, batch_id);
+                   error            dummy/error; 
+                   completed        dummy/completed; 
+                   redirect_url     dummy/redirect_url; 
+                   msg              dummy/msg">
+  
+  <span tal:omit-tag=""
+        tal:condition="not: error">
+   <span tal:omit-tag=""
+         tal:condition="completed">
+DONE
+<span tal:replace="structure redirect_url"/>
+<span tal:replace="structure msg"/>
+   </span>
+
+   <span tal:omit-tag=""
+         tal:condition="not: completed">
+NOT_DONE
+<span tal:replace="structure redirect_url"/>
+<span tal:replace="structure msg"/>
+   </span>
+  </span>
+
+
+  <span tal:omit-tag=""
+        tal:condition="error">
+FAILURE
+<span tal:replace="structure redirect_url"/>
+<span tal:replace="structure msg"/>
+  </span>
+
+
+
+
+ </span>
+</span>
--- conga/luci/storage/form-macros	2006/10/15 22:34:54	1.14
+++ conga/luci/storage/form-macros	2006/10/16 07:39:27	1.15
@@ -99,6 +99,87 @@
 
 
 <div metal:define-macro="commit-changes">
+   <span tal:omit-tag="" 
+        tal:define="batch_id     python:here.apply(ricci, storage_report, request); 
+                    check_URL    context/storage/check-batch/absolute_url; 
+                    check_url    python:check_URL + '?storagename=' + storagename + '&batch_id=' + batch_id">
+   <div metal:use-macro="here/form-macros/macros/display-commiting-changes"/>
+   <form id="urls_form">
+    <input tal:attributes="type  string:hidden;
+                           name  string:check_url;
+                           value check_url"/>
+   </form>
+  </span>
+
+
+<script language="javascript" type="text/javascript">
+
+function strip_left(txt) {
+   for (i=0; i<txt.length; i++) {
+      if (txt[i] == " " || txt[i] == "\n")
+         continue;
+      return txt.substr(i);
+   }
+   return txt;
+}
+function check_batch_callback() {
+  if (xmlHttp_object.readyState == 4) {
+    var err_url = (window.location + '').split("?")[1].split("&");
+    for (i=0; i<err_url.length; i++) {
+      var t = err_url[i];
+      if (t.indexOf("storagename=") == 0) {
+        err_url = './?' + t + '&pagetype=44';
+        break;
+      }
+    }
+    if (xmlHttp_object.status == 200) {
+      var msg = xmlHttp_object.responseText;
+      msg = strip_left(msg);
+      var res = msg.split('\n');
+      if (res[0] == "DONE") {
+         window.location = res[1];
+      } else if (res[0] == "NOT_DONE") {
+         setTimeout("initiate_check_batch()", 3000);
+      } else {
+         var m = '';
+         if (res[0] == "FAILURE") {
+           err_url = res[1];
+           m = res[2];
+         } else {
+           m = msg;
+         }
+         alert('An error has occured while commiting changes:\n\n' + m);
+         window.location = err_url;
+      }
+    } else {
+      alert("Error retrieving data from Luci server:\n\nTransfer error:\nStorage server might (not) have completed successfuly.\nVerify by yourself.");
+      window.location = err_url;
+    }
+  }
+}
+function initiate_check_batch() {
+  form = document.getElementById("urls_form");
+  for (i=0; i<form.length; i++) {
+    elem = form.elements[i];
+    name = elem.name;
+    value = elem.value;
+    if (name == 'check_url') {
+      initiate_async_get(value, check_batch_callback);
+      return;
+    }
+  }
+}
+setTimeout("initiate_check_batch()", 1000);
+
+</script>
+
+</div>
+
+
+
+
+
+<div metal:define-macro="display-commiting-changes">
    <table style="width: 100%;">
     <tr>
      <td align="center">
@@ -111,11 +192,6 @@
      </td>
     </tr>
    </table>
-
-  <span tal:define="main_URL context/storage/index_html/absolute_url" 
-        tal:replace="structure python:here.apply(ricci, storage_report, request, main_URL)">
-   here.apply() response
-  </span>
 </div>
 
 



^ permalink raw reply	[flat|nested] 9+ messages in thread
* [Cluster-devel] conga/luci site/luci/Extensions/StorageReport. ...
@ 2006-10-16 15:30 kupcevic
  0 siblings, 0 replies; 9+ messages in thread
From: kupcevic @ 2006-10-16 15:30 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	kupcevic at sourceware.org	2006-10-16 15:30:02

Modified files:
	luci/site/luci/Extensions: StorageReport.py 
	luci/storage   : form-macros 

Log message:
	luci storage:
	- order properties
	- other minor GUI nits

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/StorageReport.py.diff?cvsroot=cluster&r1=1.18&r2=1.19
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/form-macros.diff?cvsroot=cluster&r1=1.15&r2=1.16

--- conga/luci/site/luci/Extensions/StorageReport.py	2006/10/16 07:39:27	1.18
+++ conga/luci/site/luci/Extensions/StorageReport.py	2006/10/16 15:30:01	1.19
@@ -256,9 +256,10 @@
         session.set(SESSION_STORAGE_XML_REPORT, {})
     # return cached report if existing
     if session[SESSION_STORAGE_XML_REPORT].has_key(storagename):
-        if session[SESSION_STORAGE_XML_REPORT][storagename] != None:
+        tmp_report = session[SESSION_STORAGE_XML_REPORT][storagename]
+        if tmp_report != None:
             print 'using cached storage_xml_report'
-            return StorageReport(session[SESSION_STORAGE_XML_REPORT][storagename])
+            return StorageReport(tmp_report)
     
     
     # retrieve storage report using ricci
@@ -460,6 +461,7 @@
     mapper_ret['mapper_id'] = mapper_id
     mapper_ret['mapper_type'] = type
     mapper_ret['props'] = props
+    mapper_ret['props_ordered'] = get_ordered_props(props)
     mapper_ret['targets'] = targets
     mapper_ret['new_targets'] = new_targets
     mapper_ret['sources'] = sources
@@ -655,6 +657,7 @@
     mapper_ret['mapper_id'] = mapper_id
     mapper_ret['mapper_type'] = type
     mapper_ret['props'] = props
+    mapper_ret['props_ordered'] = get_ordered_props(props)
     #mapper_ret['removable'] = removable
     mapper_ret['targets'] = targets
     mapper_ret['new_targets'] = new_targets
@@ -1550,6 +1553,7 @@
     data['pretty_name'] = pretty_name
     data['description'] = description
     data['props'] = props
+    data['props_ordered'] = get_ordered_props(props)
     data['path'] = path
     data['mapper_type'] = mapper_type
     data['mapper_id'] = mapper_id
@@ -1641,7 +1645,7 @@
             d_value = value
             validation_data['min_length'] = var.getAttribute('min_length')
             validation_data['max_length'] = var.getAttribute('max_length')
-            validation_data['illegal_chars'] = var.getAttribute('illegal_chars')
+            validation_data['illegal_chars'] = var.getAttribute('illegal_chars').replace('\'', '\\\'').replace('&lt;', '<').replace('&gt;', '>').replace('&quot;', '\\\"').replace('&amp;', '&')
             validation_data['reserved_words'] = var.getAttribute('reserved_words')
         elif type == VARIABLE_TYPE_INT_SEL or type == VARIABLE_TYPE_STRING_SEL:
             d_type = 'select'
@@ -1668,30 +1672,81 @@
                         d_value += node.getAttribute('value') + ', '
             if d_value != '':
                 d_value = d_value[:len(d_value)-2]
+        elif type == 'hidden':
+            d_type = 'hidden'
+            d_value = str(value)
         else:
             d_type = 'label'
             d_value = value
         
-        if not mutable and d_type != 'label':
+        if not mutable and d_type != 'label' and d_type != 'hidden':
             d_type = 'label'
             d_value = str(value)
             pass
         
+        hidden = False
+        if type == 'hidden' or name in ['partition_begin', 'snapshot']:
+            hidden = True
+        
         if name == 'removable':
             removable = value == 'true'
         elif name == 'path':
             pass
         else:
-            data[name] = {'type'        : d_type,
-                          'value'       : d_value,
+            data[name] = {'name'        : name,
                           'pretty_name' : get_pretty_prop_name(name),
+                          'type'        : d_type,
+                          'value'       : d_value,
                           'units'       : d_units,
-                          'validation'  : validation_data}
+                          'validation'  : validation_data,
+                          'hidden'      : hidden}
         pass
     
     return (removable, data)
 
 
+def get_ordered_props(props):
+    names   = []
+    sizes   = []
+    mounts  = []
+    min_max = []
+    uuids   = []
+    rest    = []
+    for prop_name in props:
+        prop = props[prop_name]
+        # names
+        if 'name' in prop_name or 'label' in prop_name or 'vendor' == prop_name or 'model' == prop_name:
+            names.append(prop)
+        # sizes
+        elif 'size' in prop_name or 'extents' in prop_name or 'percent' in prop_name:
+            sizes.append(prop)
+        # mounts
+        elif 'mount' in prop_name or 'fstab' in prop_name:
+            mounts.append(prop)
+        # min_max
+        elif 'min' in prop_name or 'max' in prop_name:
+            min_max.append(prop)
+        elif 'uuid' in prop_name:
+            uuids.append(prop)
+        else:
+            rest.append(prop)
+            
+    ordered = []
+    for prop in names:
+        ordered.append(prop)
+    for prop in sizes:
+        ordered.append(prop)
+    for prop in mounts:
+        ordered.append(prop)
+    for prop in min_max:
+        ordered.append(prop)
+    for prop in rest:
+        ordered.append(prop)
+    for prop in uuids:
+        ordered.append(prop)
+    return ordered
+
+
 
 def mutable_props(props):
     for name in props:
@@ -1747,8 +1802,11 @@
         old_props = d['props']
         new_props = {}
         for name in old_props:
-            new_props['content_variable_' + d['id'] + '_' + name] = old_props[name]
+            new_name = 'content_variable_' + d['id'] + '_' + name
+            new_props[new_name] = old_props[name]
+            new_props[new_name]['name'] = new_name
         d['props'] = new_props
+        d['props_ordered'] = get_ordered_props(new_props)
         d['is_source'] = False
         
         # content's color and icon
--- conga/luci/storage/form-macros	2006/10/16 07:39:27	1.15
+++ conga/luci/storage/form-macros	2006/10/16 15:30:02	1.16
@@ -370,7 +370,10 @@
  </style>
 </div>
 <div tal:omit-tag="" metal:define-macro="li-collapse-handler">
- <a onClick="this.parentNode.className = (this.parentNode.className == 'opened') ? 'closed' : 'opened';"><img src="tree_transparent.gif"/></a>
+ <a onClick="this.parentNode.className = (this.parentNode.className == 'opened') ? 'closed' : 'opened';">
+  <img src="tree_transparent.gif"
+       style="cursor: pointer;"/>
+ </a>
 </div>
 
 
@@ -766,7 +769,7 @@
      <tr class="props-form-body">
       <td>
        <table class="props-inner-table"
-              tal:define="props mapper/props">
+              tal:define="props mapper/props_ordered">
         <div metal:use-macro="here/form-macros/macros/display-props-tableless"/>
        </table>
       </td>
@@ -990,12 +993,13 @@
    <span tal:omit-tag=""
          tal:define="predefines_test python:'display-props: ' + str(props) + prefix + properties_span_id"/>
    <span tal:omit-tag="" 
-          tal:repeat="p props">
-     <tr tal:define="prop python:props[p];
-                     prop_pr_name prop/pretty_name">
+         tal:repeat="prop props">
+     <tr tal:define="p            prop/name; 
+                     prop_pr_name prop/pretty_name"
+         tal:condition="not: prop/hidden">
       <td tal:content="prop_pr_name"/>
-      <td tal:define="prop_type prop/type;
-                      prop_units prop/units">
+      <td tal:define="prop_type   prop/type;
+                      prop_units  prop/units">
        <table>
         <tr>
          <td>
@@ -1122,7 +1126,7 @@
    <span tal:omit-tag=""
          tal:define="predefines_test python:'display-content: ' + str(cont) + properties_span_id"/>
    <span tal:omit-tag="" 
-         tal:define="props cont/props">
+         tal:define="props cont/props_ordered">
     <table class="props-inner-table">
      <div metal:use-macro="here/form-macros/macros/display-props-tableless"/>
     </table>
@@ -1659,7 +1663,7 @@
       <tr class="props-form-body">
        <td>
         <span tal:omit-tag="" 
-              tal:define="props bd_data/props">
+              tal:define="props bd_data/props_ordered">
          <table class="props-inner-table">
           <div metal:use-macro="here/form-macros/macros/display-props-tableless"/>
          </table>
@@ -1882,7 +1886,7 @@
      <tr class="props-form-body">
       <td>
        <table class="props-inner-table"
-              tal:define="props mapper/props">
+              tal:define="props mapper/props_ordered">
         <div metal:use-macro="here/form-macros/macros/display-props-tableless"/>
        </table>
       </td>



^ permalink raw reply	[flat|nested] 9+ messages in thread
* [Cluster-devel] conga/luci site/luci/Extensions/StorageReport. ...
@ 2007-05-30 22:04 rmccabe
  0 siblings, 0 replies; 9+ messages in thread
From: rmccabe @ 2007-05-30 22:04 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	EXPERIMENTAL
Changes by:	rmccabe at sourceware.org	2007-05-30 22:04:34

Modified files:
	luci/site/luci/Extensions: StorageReport.py 
	luci/storage   : form-macros 

Log message:
	Do not redefine built-ins

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/StorageReport.py.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.23.2.4&r2=1.23.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/storage/form-macros.diff?cvsroot=cluster&only_with_tag=EXPERIMENTAL&r1=1.20&r2=1.20.4.1

--- conga/luci/site/luci/Extensions/StorageReport.py	2007/05/18 02:36:59	1.23.2.4
+++ conga/luci/site/luci/Extensions/StorageReport.py	2007/05/30 22:04:33	1.23.2.5
@@ -23,8 +23,7 @@
 
 from LuciZope import bytes_to_value_prefunits, get_systems_statuses
 
-from ricci_communicator import get_ricci_communicator, \
-	batch_status, extract_module_status
+from ricci_communicator import extract_module_status
 
 
 SESSION_STORAGE_XML_REPORT = 'storage_xml_report_dir'
@@ -74,12 +73,12 @@
         return self.__report.cloneNode(True)
 
 
-    def get_mappers(self, type=''):
+    def get_mappers(self, mapper_type=''):
         l = []
-        if type == '':
+        if mapper_type == '':
             l = self.__mappers
-        elif type in self.__mapp_dir:
-            l = self.__mapp_dir[type]
+        elif mapper_type in self.__mapp_dir:
+            l = self.__mapp_dir[mapper_type]
         r = []
         for s in l:
             r.append(s.cloneNode(True))
@@ -88,39 +87,39 @@
 
     def get_mappers_dir(self):
         r = {}
-        for type in self.__mapp_dir:
+        for mapper_type in self.__mapp_dir:
             l = []
-            for m in self.__mapp_dir[type]:
+            for m in self.__mapp_dir[mapper_type]:
                 l.append(m.cloneNode(True))
-            r[type] = l
+            r[mapper_type] = l
         return r
 
 
-    def get_mapper(self, id):
-        if id == '':
+    def get_mapper(self, mapper_id):
+        if mapper_id == '':
             raise Exception, 'empty mapper_id!!!'
         for m in self.__mappers:
-            if m.getAttribute('mapper_id') == id:
+            if m.getAttribute('mapper_id') == mapper_id:
                 return m.cloneNode(True)
         return None
 
 
     def get_mapper_temps_dir(self):
         r = {}
-        for type in self.__m_temps_dir:
+        for mapper_type in self.__m_temps_dir:
             l = []
-            for m in self.__m_temps_dir[type]:
+            for m in self.__m_temps_dir[mapper_type]:
                 l.append(m.cloneNode(True))
-            r[type] = l
+            r[mapper_type] = l
         return r
 
 
-    def get_mapper_temps(self, type=''):
+    def get_mapper_temps(self, mapper_type=''):
         l = []
-        if type == '':
+        if mapper_type == '':
             l = self.__m_temps
-        elif type in self.__m_temps_dir:
-            l = self.__m_temps_dir[type]
+        elif mapper_type in self.__m_temps_dir:
+            l = self.__m_temps_dir[mapper_type]
         r = []
         for s in l:
             r.append(s.cloneNode(True))
@@ -371,12 +370,12 @@
     mappers_dir = storage_report.get_mappers_dir()
     for mapp_type in mappers_dir:
         for m_xml in mappers_dir[mapp_type]:
-            id = m_xml.getAttribute('mapper_id')
+            mapper_id = m_xml.getAttribute('mapper_id')
             if mapp_type not in ret_dir:
                 ret_dir[mapp_type] = {}
                 ret_dir[mapp_type]['mappers'] = []
                 ret_dir[mapp_type]['mapper_template'] = None
-            ret_dir[mapp_type]['mappers'].append(get_mapper_data(self, storage_report, id))
+            ret_dir[mapp_type]['mappers'].append(get_mapper_data(self, storage_report, mapper_id))
     # templates
     for mapp_type in storage_report.get_mapper_temps_dir():
         if mapp_type not in ret_dir:
@@ -425,12 +424,12 @@
     for s_xml in storage_report.get_sources(mapper):
         sources.append(get_bd_data_internal(session, s_xml, mapper))
 
-    type = mapper.getAttribute('mapper_type')
-    pretty_type, pretty_target_name, pretty_source_name = get_pretty_mapper_info(type)
-    pretty_name = mapper_id.replace('%s:' % type, '').replace('/dev/', '')
+    mapper_type = mapper.getAttribute('mapper_type')
+    pretty_type, pretty_target_name, pretty_source_name = get_pretty_mapper_info(mapper_type)
+    pretty_name = mapper_id.replace('%s:' % mapper_type, '').replace('/dev/', '')
     pretty_targets_name = '%ss' % pretty_target_name
     pretty_sources_name = '%ss' % pretty_source_name
-    icon_name, dummy1, dummy2 = get_mapper_icons(type)
+    icon_name, dummy1, dummy2 = get_mapper_icons(mapper_type)
     color = 'black'
 
     mapper_ret = {}
@@ -441,7 +440,7 @@
     mapper_ret['pretty_source_name'] = pretty_source_name
     mapper_ret['pretty_sources_name'] = pretty_sources_name
     mapper_ret['mapper_id'] = mapper_id
-    mapper_ret['mapper_type'] = type
+    mapper_ret['mapper_type'] = mapper_type
     mapper_ret['props'] = props
     mapper_ret['props_ordered'] = get_ordered_props(props)
     mapper_ret['targets'] = targets
@@ -460,12 +459,12 @@
                   'msg'  : 'Are you sure you want to remove %s \\\'%s\\\'?' % (pretty_type, pretty_name),
                   'link' : ''}
         actions.append(action)
-    if type == MAPPER_VG_TYPE or type == MAPPER_MDRAID_TYPE or type == MAPPER_ATARAID_TYPE or type == MAPPER_MULTIPATH_TYPE:
+    if mapper_type == MAPPER_VG_TYPE or mapper_type == MAPPER_MDRAID_TYPE or mapper_type == MAPPER_ATARAID_TYPE or mapper_type == MAPPER_MULTIPATH_TYPE:
         action = {'name' : 'Add %s' % mapper_ret['pretty_sources_name'],
                   'msg'  : '',
                   'link' : './?%s=%s&%s=%s&%s=%s' % (PAGETYPE, ADD_SOURCES, PT_MAPPER_ID, mapper_ret['mapper_id'], PT_MAPPER_TYPE, mapper_ret['mapper_type'])}
         actions.append(action)
-    if type == MAPPER_VG_TYPE:
+    if mapper_type == MAPPER_VG_TYPE:
         for nt in mapper_ret['new_targets']:
             if nt['props']['snapshot']['value'] == 'false':
                 if nt['new']:
@@ -480,11 +479,11 @@
                     break
     mapper_ret['actions'] = actions
 
-    if type == MAPPER_VG_TYPE:
+    if mapper_type == MAPPER_VG_TYPE:
         link_snapshots(mapper_ret)
 
     # cylinders work properly for VGs only, for now
-    mapper_ret['graphical_view'] = type != MAPPER_PT_TYPE
+    mapper_ret['graphical_view'] = mapper_type != MAPPER_PT_TYPE
     if mapper_ret['graphical_view']:
         mapper_ret['mappings-view_css_classnames'] = {'graphical_view' : 'visible',
                                                       'textual_view'   : 'invisible'}
@@ -554,13 +553,13 @@
         # TODO: place logical into extended
 
         # sort partitions
-        sorted = []
+        p_sorted = []
         while len(targets_all) != 0:
             smallest_num = 100000000000000000000
             smallest_bd = None
             smallest_index = 0
             i = 0
-            for i in range(len(targets_all)):
+            for i in xrange(len(targets_all)):
                 bd = targets_all[i]
                 begin = int(bd['props']['partition_begin']['value'])
                 if begin < smallest_num:
@@ -568,8 +567,8 @@
                     smallest_bd = bd
                     smallest_index = i
             targets_all.pop(smallest_index)
-            sorted.append(smallest_bd)
-        targets_all = sorted
+            p_sorted.append(smallest_bd)
+        targets_all = p_sorted
     else:
         for t in mdata['targets']:
             targets_all.append(t)
@@ -608,12 +607,12 @@
     for s_xml in storage_report.get_sources(mapper):
         sources.append(get_bd_data_internal(session, s_xml, mapper))
 
-    type = mapper.getAttribute('mapper_type')
-    pretty_type, pretty_target_name, pretty_source_name = get_pretty_mapper_info(type)
-    pretty_name = mapper_id.replace('%s:' % type, '').replace('/dev/', '')
+    mapper_type = mapper.getAttribute('mapper_type')
+    pretty_type, pretty_target_name, pretty_source_name = get_pretty_mapper_info(mapper_type)
+    pretty_name = mapper_id.replace('%s:' % mapper_type, '').replace('/dev/', '')
     pretty_targets_name = '%ss' % pretty_target_name
     pretty_sources_name = '%ss' % pretty_source_name
-    icon_name, dummy1, dummy2 = get_mapper_icons(type)
+    icon_name, dummy1, dummy2 = get_mapper_icons(mapper_type)
     color = 'black'
 
     min_sources = '0'
@@ -636,7 +635,7 @@
     mapper_ret['pretty_source_name'] = pretty_source_name
     mapper_ret['pretty_sources_name'] = pretty_sources_name
     mapper_ret['mapper_id'] = mapper_id
-    mapper_ret['mapper_type'] = type
+    mapper_ret['mapper_type'] = mapper_type
     mapper_ret['props'] = props
     mapper_ret['props_ordered'] = get_ordered_props(props)
     #mapper_ret['removable'] = removable
@@ -719,10 +718,11 @@
             return '%s %s' % (res[1], res[2])
 
     return 'OK'
+
 def check_props(self, props, request):
     valid = True
     var_name = ''
-    msg = 'no message - BUG :('
+    msg = 'no message - BUG'
 
     for prop_name in props:
         if prop_name in request:
@@ -737,13 +737,13 @@
                         var_name = prop_name
                         valid = False
                         break
-                    min = int(prop['validation']['min'])
-                    max = int(prop['validation']['max'])
+                    min_val = int(prop['validation']['min'])
+                    max_val = int(prop['validation']['max'])
                     step = int(prop['validation']['step'])
                     r_val = (req_value / step) * step
-                    if r_val > max or r_val < min:
+                    if r_val > max_val or r_val < min_val:
                         msg = '%s has to be within range %d-%d %s' \
-                          % (prop['pretty_name'], min, max, prop['units'])
+                          % (prop['pretty_name'], min_val, max_val, prop['units'])
                         var_name = prop_name
                         valid = False
                         break
@@ -756,15 +756,15 @@
                         valid = False
                         break
                     dummy, units = bytes_to_value_prefunits(self, prop['value'])
-                    min  = float(convert_bytes(prop['validation']['min'], units))
-                    max  = float(convert_bytes(prop['validation']['max'], units))
+                    min_val  = float(convert_bytes(prop['validation']['min'], units))
+                    max_val  = float(convert_bytes(prop['validation']['max'], units))
                     step = float(convert_bytes(prop['validation']['step'], units))
                     if step < 0.000001:
                         step = 0.000001
                     r_val = (req_value / step) * step
-                    if r_val > max or r_val < min:
+                    if r_val > max_val or r_val < min_val:
                         msg = '%s has to be within range %d-%d %s' \
-                          % (prop['pretty_name'], min, max, units)
+                          % (prop['pretty_name'], min_val, max_val, units)
                         var_name = prop_name
                         valid = False
                         break
@@ -798,7 +798,7 @@
 
 
 
-def apply(self, ricci, storage_report, request):
+def apply_storage_changes(self, ricci, storage_report, request):
     if validate(self, storage_report, request) != 'OK':
         raise Exception, 'Internal error: input not validated!!!'
 
@@ -862,16 +862,16 @@
                                     else:
                                         dummy, units = bytes_to_value_prefunits(self,
                                                                                 bd_data['props'][var_name]['value'])
-                                        min  = int(bd_data['props'][var_name]['validation']['min'])
-                                        max  = int(bd_data['props'][var_name]['validation']['max'])
+                                        min_val  = int(bd_data['props'][var_name]['validation']['min'])
+                                        max_val  = int(bd_data['props'][var_name]['validation']['max'])
                                         step = int(bd_data['props'][var_name]['validation']['step'])
                                         val_units = float(request[var_name])
                                         val = int(val_units * get_units_multiplier(units))
                                         val = (val / step) * step
-                                        if val < min:
-                                            val = min
-                                        if val > max:
-                                            val = max
+                                        if val < min_val:
+                                            val = min_val
+                                        if val > max_val:
+                                            val = max_val
                                     node.setAttribute('value', str(val))
                                 else:
                                     node.setAttribute('value', request[var_name])
@@ -908,16 +908,16 @@
                                     else:
                                         dummy, units = bytes_to_value_prefunits(self,
                                                                                 selected_content_data['props'][req_name]['value'])
-                                        min  = int(selected_content_data['props'][req_name]['validation']['min'])
-                                        max  = int(selected_content_data['props'][req_name]['validation']['max'])
+                                        min_val  = int(selected_content_data['props'][req_name]['validation']['min'])
+                                        max_val  = int(selected_content_data['props'][req_name]['validation']['max'])
                                         step = int(selected_content_data['props'][req_name]['validation']['step'])
                                         val_units = float(request[req_name])
                                         val = int(val_units * get_units_multiplier(units))
                                         val = (val / step) * step
-                                        if val < min:
-                                            val = min
-                                        if val > max:
-                                            val = max
+                                        if val < min_val:
+                                            val = min_val
+                                        if val > max_val:
+                                            val = max_val
                                     node.setAttribute('value', str(val))
                                 else:
                                     node.setAttribute('value', request[req_name])
@@ -989,16 +989,16 @@
                                     else:
                                         dummy, units = bytes_to_value_prefunits(self,
                                                                                 bd_data['props'][var_name]['value'])
-                                        min  = int(bd_data['props'][var_name]['validation']['min'])
-                                        max  = int(bd_data['props'][var_name]['validation']['max'])
+                                        min_val  = int(bd_data['props'][var_name]['validation']['min'])
+                                        max_val  = int(bd_data['props'][var_name]['validation']['max'])
                                         step = int(bd_data['props'][var_name]['validation']['step'])
                                         val_units = float(request[var_name])
                                         val = int(val_units * get_units_multiplier(units))
                                         val = (val / step) * step
-                                        if val < min:
-                                            val = min
-                                        if val > max:
-                                            val = max
+                                        if val < min_val:
+                                            val = min_val
+                                        if val > max_val:
+                                            val = max_val
                                     node.setAttribute('value', str(val))
                                 else:
                                     node.setAttribute('value', request[var_name])
@@ -1036,16 +1036,16 @@
                                         else:
                                             dummy, units = bytes_to_value_prefunits(self,
                                                                                     selected_content_data['props'][req_name]['value'])
-                                            min  = int(selected_content_data['props'][req_name]['validation']['min'])
-                                            max  = int(selected_content_data['props'][req_name]['validation']['max'])
+                                            min_val  = int(selected_content_data['props'][req_name]['validation']['min'])
+                                            max_val  = int(selected_content_data['props'][req_name]['validation']['max'])
                                             step = int(selected_content_data['props'][req_name]['validation']['step'])
                                             val_units = float(request[req_name])
                                             val = int(val_units * get_units_multiplier(units))
                                             val = (val / step) * step
-                                            if val < min:
-                                                val = min
-                                            if val > max:
-                                                val = max
+                                            if val < min_val:
+                                                val = min_val
+                                            if val > max_val:
+                                                val = max_val
                                         node.setAttribute('value', str(val))
                                     else:
                                         node.setAttribute('value', request[req_name])
@@ -1137,16 +1137,16 @@
                                     else:
                                         dummy, units = bytes_to_value_prefunits(self,
                                                                                 mapper_data['props'][var_name]['value'])
-                                        min  = int(mapper_data['props'][var_name]['validation']['min'])
-                                        max  = int(mapper_data['props'][var_name]['validation']['max'])
+                                        min_val  = int(mapper_data['props'][var_name]['validation']['min'])
+                                        max_val  = int(mapper_data['props'][var_name]['validation']['max'])
                                         step = int(mapper_data['props'][var_name]['validation']['step'])
                                         val_units = float(request[var_name])
                                         val = int(val_units * get_units_multiplier(units))
                                         val = (val / step) * step
-                                        if val < min:
-                                            val = min
-                                        if val > max:
-                                            val = max
+                                        if val < min_val:
+                                            val = min_val
+                                        if val > max_val:
+                                            val = max_val
                                     node.setAttribute('value', str(val))
                                 else:
                                     node.setAttribute('value', request[var_name])
@@ -1197,16 +1197,16 @@
                                     else:
                                         dummy, units = bytes_to_value_prefunits(self,
                                                                                 mapper_data['props'][var_name]['value'])
-                                        min  = int(mapper_data['props'][var_name]['validation']['min'])
-                                        max  = int(mapper_data['props'][var_name]['validation']['max'])
+                                        min_val  = int(mapper_data['props'][var_name]['validation']['min'])
+                                        max_val  = int(mapper_data['props'][var_name]['validation']['max'])
                                         step = int(mapper_data['props'][var_name]['validation']['step'])
                                         val_units = float(request[var_name])
                                         val = int(val_units * get_units_multiplier(units))
                                         val = (val / step) * step
-                                        if val < min:
-                                            val = min
-                                        if val > max:
-                                            val = max
+                                        if val < min_val:
+                                            val = min_val
+                                        if val > max_val:
+                                            val = max_val
                                     node.setAttribute('value', str(val))
                                 else:
                                     node.setAttribute('value', request[var_name])
@@ -1456,11 +1456,11 @@
                 fr_r = node
     if fr_r is None:
         raise Exception, 'missing <function_response/> in <response/>'
-    vars = {}
+    rvars = {}
     for node in fr_r.childNodes:
         try:
             var = parse_variable(node)
-            vars[var.get_name()] = var
+            rvars[var.get_name()] = var
         except:
             pass
 
@@ -1468,12 +1468,12 @@
     mapper_id   = ''
     mapper_type = ''
     bd_path     = ''
-    if 'mapper' in vars:
-        mapper      = vars['mapper'].get_value()
+    if 'mapper' in rvars:
+        mapper      = rvars['mapper'].get_value()
         mapper_type = mapper.getAttribute('mapper_type')
         mapper_id   = mapper.getAttribute('mapper_id')
-    if 'bd' in vars:
-        bd          = vars['bd'].get_value()
+    if 'bd' in rvars:
+        bd          = rvars['bd'].get_value()
         bd_path     = bd.getAttribute('path')
         mapper_type = bd.getAttribute('mapper_type')
         mapper_id   = bd.getAttribute('mapper_id')
@@ -1626,7 +1626,7 @@
     for name in var_xmls:
         var = var_xmls[name]
         mutable = var.getAttribute('mutable') == 'true'
-        type = var.getAttribute('type')
+        var_type = var.getAttribute('type')
         value = var.getAttribute('value')
 
         d_units = ''
@@ -1636,23 +1636,23 @@
             d_units = '%'
 
         validation_data = {}
-        if type == VARIABLE_TYPE_INT:
+        if var_type == VARIABLE_TYPE_INT:
             d_type = 'int'
             d_value = value
-            min  = var.getAttribute('min')
-            max  = var.getAttribute('max')
+            min_val  = var.getAttribute('min')
+            max_val  = var.getAttribute('max')
             step = var.getAttribute('step')
-            validation_data['min']  = str(min)
-            validation_data['max']  = str(max)
+            validation_data['min']  = str(min_val)
+            validation_data['max']  = str(max_val)
             validation_data['step'] = str(step)
-        elif type == VARIABLE_TYPE_STRING:
+        elif var_type == VARIABLE_TYPE_STRING:
             d_type = 'text'
             d_value = value
             validation_data['min_length'] = var.getAttribute('min_length')
             validation_data['max_length'] = var.getAttribute('max_length')
             validation_data['illegal_chars'] = var.getAttribute('illegal_chars').replace('\'', '\\\'').replace('&lt;', '<').replace('&gt;', '>').replace('&quot;', '\\\"').replace('&amp;', '&')
             validation_data['reserved_words'] = var.getAttribute('reserved_words')
-        elif type == VARIABLE_TYPE_INT_SEL or type == VARIABLE_TYPE_STRING_SEL:
+        elif var_type == VARIABLE_TYPE_INT_SEL or var_type == VARIABLE_TYPE_STRING_SEL:
             d_type = 'select'
             d_value = [value]
             for node in var.childNodes:
@@ -1661,14 +1661,14 @@
                         val = node.getAttribute('value')
                         if val not in d_value:
                             d_value.append(val)
-        elif type == VARIABLE_TYPE_BOOL:
+        elif var_type == VARIABLE_TYPE_BOOL:
             d_type = 'select'
             d_value = [value]
             if value == 'true':
                 d_value.append('false')
             else:
                 d_value.append('true')
-        elif type == VARIABLE_TYPE_LIST_INT or type == VARIABLE_TYPE_LIST_STR:
+        elif var_type == VARIABLE_TYPE_LIST_INT or var_type == VARIABLE_TYPE_LIST_STR:
             d_type = 'label'
             d_value = ''
             d_val_list = list()
@@ -1680,7 +1680,7 @@
             d_value = ''.join(d_val_list)
             if d_value != '':
                 d_value = d_value[:len(d_value)-2]
-        elif type == 'hidden':
+        elif var_type == 'hidden':
             d_type = 'hidden'
             d_value = str(value)
         else:
@@ -1692,7 +1692,7 @@
             d_value = str(value)
 
         hidden = False
-        if type == 'hidden' or name in ['partition_begin', 'snapshot']:
+        if var_type == 'hidden' or name in ['partition_begin', 'snapshot']:
             hidden = True
 
         if name == 'removable':
@@ -1756,8 +1756,8 @@
 
 def mutable_props(props):
     for name in props:
-        type = props[name]['type']
-        if type == 'int' or type == 'text' or type == 'select':
+        prop_type = props[name]['type']
+        if prop_type == 'int' or prop_type == 'text' or prop_type == 'select':
             return True
     return False
 
@@ -1787,9 +1787,9 @@
     current = {}
     removable, props = get_props_data_internal(session, c_xml)
     current['props'] = props
-    name, id = get_content_name_id(c_xml)
+    name, content_id = get_content_name_id(c_xml)
     current['name'] = name
-    current['id'] = id
+    current['id'] = content_id
     current['xml'] = c_xml.cloneNode(True)
 
     data = [current]
@@ -1797,9 +1797,9 @@
         available = {}
         removable, props = get_props_data_internal(session, a_xml)
         available['props'] = props
-        name, id = get_content_name_id(a_xml)
+        name, content_id = get_content_name_id(a_xml)
         available['name'] = name
-        available['id'] = id
+        available['id'] = content_id
         available['xml'] = a_xml.cloneNode(True)
 
         data.append(available)
@@ -1818,10 +1818,10 @@
         # content's color and icon
         color = 'black'
         icon_name = ''
-        type = d['xml'].getAttribute('type')
-        if type == 'filesystem':
+        content_type = d['xml'].getAttribute('type')
+        if content_type == 'filesystem':
             icon_name = get_fs_icon(d['xml'].getAttribute('fs_type'))
-        elif type == 'mapper_source':
+        elif content_type == 'mapper_source':
             mapper_type = d['xml'].getAttribute('mapper_type')
             mapper_id = d['xml'].getAttribute('mapper_id')
             pretty_mapper_type, dummy1, dummy2 = get_pretty_mapper_info(mapper_type)
@@ -1832,9 +1832,9 @@
             d['mapper_type'] = mapper_type
             d['mapper_id'] = mapper_id
             d['pretty_mapper_type'] = pretty_mapper_type
-        elif type == 'none':
+        elif content_type == 'none':
             pass
-        elif type == 'hidden':
+        elif content_type == 'hidden':
             pass
 
         d['color'] = color
@@ -1845,18 +1845,18 @@
 
 
 def get_content_name_id(c_xml):
-    name = 'BUG, call authorities :)'
-    id = c_xml.getAttribute('type')
-    if id == CONTENT_FS_TYPE:
+    name = 'Unknown type'
+    content_id = c_xml.getAttribute('type')
+    if content_id == CONTENT_FS_TYPE:
         fs_type = c_xml.getAttribute('fs_type')
-        id = '%s_%s' % (id, fs_type)
+        content_id = '%s_%s' % (content_id, fs_type)
         name = get_pretty_fs_name(fs_type)
-    elif id == CONTENT_NONE_TYPE:
+    elif content_id == CONTENT_NONE_TYPE:
         name = 'Empty'
-    elif id == CONTENT_MS_TYPE:
+    elif content_id == CONTENT_MS_TYPE:
         mapper_type = c_xml.getAttribute('mapper_type')
         mapper_id = c_xml.getAttribute('mapper_id')
-        id = '%s_%s_%s' % (id, mapper_type, mapper_id.replace(':', '__colon__'))
+        content_id = '%s_%s_%s' % (content_id, mapper_type, mapper_id.replace(':', '__colon__'))
         if mapper_type == MAPPER_SYS_TYPE:
             pass
         elif mapper_type == MAPPER_VG_TYPE:
@@ -1875,12 +1875,12 @@
             pass
         else:
             name = 'Source of %s' % mapper_type
-    elif id == CONTENT_HIDDEN_TYPE:
+    elif content_id == CONTENT_HIDDEN_TYPE:
         name = 'Extended Partition'
     else:
-        name = "Unknown type"
+        name = 'Unknown type'
 
-    return name, id
+    return name, content_id
 
 
 
@@ -2076,8 +2076,8 @@
 
     # transform list of highlights
     high_list_js = [[mapper_data['mapper_id'], []]]
-    for id in high_list:
-        high_list_js.append([id, high_list[id]])
+    for hl_id in high_list:
+        high_list_js.append([hl_id, high_list[hl_id]])
     high_list_js = str(high_list_js).replace('L,', ',').replace('L]', ']').replace('u\'', '\'').replace('L]', ']')
 
     # put everything together
--- conga/luci/storage/form-macros	2006/12/06 22:34:09	1.20
+++ conga/luci/storage/form-macros	2007/05/30 22:04:34	1.20.4.1
@@ -100,7 +100,7 @@
 
 <div metal:define-macro="commit-changes">
    <span tal:omit-tag="" 
-        tal:define="batch_id     python:here.apply(ricci, storage_report, request); 
+        tal:define="batch_id     python:here.apply_storage_changes(ricci, storage_report, request); 
                     check_URL    context/storage/check-batch/absolute_url; 
                     check_url    python:check_URL + '?storagename=' + storagename + '&batch_id=' + batch_id">
    <div metal:use-macro="here/form-macros/macros/display-commiting-changes"/>



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-05-30 22:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-09 17:03 [Cluster-devel] conga/luci site/luci/Extensions/StorageReport. kupcevic
  -- strict thread matches above, loose matches on Subject: below --
2006-10-09 19:11 kupcevic
2006-10-14 20:01 kupcevic
2006-10-15  5:09 kupcevic
2006-10-15  5:44 kupcevic
2006-10-15 22:34 kupcevic
2006-10-16  7:39 kupcevic
2006-10-16 15:30 kupcevic
2007-05-30 22:04 rmccabe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).