[Ocfs2-tools-commits] manish commits r703 -
trunk/ocfs2console/ocfs2interface
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Sun Mar 20 05:33:15 CST 2005
Author: manish
Date: 2005-03-20 05:33:13 -0600 (Sun, 20 Mar 2005)
New Revision: 703
Added:
trunk/ocfs2console/ocfs2interface/fswidgets.py
trunk/ocfs2console/ocfs2interface/tune.py
Modified:
trunk/ocfs2console/ocfs2interface/Makefile
trunk/ocfs2console/ocfs2interface/clconfig.py
trunk/ocfs2console/ocfs2interface/format.py
trunk/ocfs2console/ocfs2interface/fsck.py
trunk/ocfs2console/ocfs2interface/main.py
trunk/ocfs2console/ocfs2interface/menu.py
Log:
Tunefs interface, factored out mkfs/tunefs common widgets into a separate file
Modified: trunk/ocfs2console/ocfs2interface/Makefile
===================================================================
--- trunk/ocfs2console/ocfs2interface/Makefile 2005-03-20 06:07:25 UTC (rev 702)
+++ trunk/ocfs2console/ocfs2interface/Makefile 2005-03-20 11:33:13 UTC (rev 703)
@@ -55,13 +55,15 @@
clconfig.py \
format.py \
fsck.py \
+ fswidgets.py \
general.py \
guiutil.py \
main.py \
menu.py \
nodemap.py \
process.py \
- toolbar.py
+ toolbar.py \
+ tune.py
PYLIB = $(LIBRARIES) $(PYSRC)
Modified: trunk/ocfs2console/ocfs2interface/clconfig.py
===================================================================
--- trunk/ocfs2console/ocfs2interface/clconfig.py 2005-03-20 06:07:25 UTC (rev 702)
+++ trunk/ocfs2console/ocfs2interface/clconfig.py 2005-03-20 11:33:13 UTC (rev 703)
@@ -47,7 +47,7 @@
border_width=5,
parent=frame)
- button = gtk.Button('Add')
+ button = gtk.Button(stock=gtk.STOCK_ADD)
vbbox.add(button)
dialog.show_all()
Modified: trunk/ocfs2console/ocfs2interface/format.py
===================================================================
--- trunk/ocfs2console/ocfs2interface/format.py 2005-03-20 06:07:25 UTC (rev 702)
+++ trunk/ocfs2console/ocfs2interface/format.py 2005-03-20 11:33:13 UTC (rev 703)
@@ -22,87 +22,10 @@
from guiutil import set_props, error_box, format_bytes
from process import Process
-if hasattr(gtk, 'ComboBox'):
- class BaseCombo(gtk.ComboBox):
- def __init__(self):
- self.store = gtk.ListStore(str)
- gtk.ComboBox.__init__(self, model=self.store)
+from fswidgets import BaseCombo, NumNodes, VolumeLabel, ClusterSize, BlockSize
- cell = gtk.CellRendererText()
- self.pack_start(cell)
- self.set_attributes(cell, text=0)
+base_command = ('mkfs.ocfs2', '-x')
- def get_choice(self):
- return self.store[self.get_active_iter()][0]
-
- def set_choices(self, choices):
- selected = False
-
- for choice, select in choices:
- iter = self.store.append((choice,))
-
- if select:
- self.set_active_iter(iter)
- selected = True
-
- if not selected:
- self.set_active(0)
-
-else:
- class BaseCombo(gtk.Combo):
- def __init__(self):
- gtk.Combo.__init__(self)
- self.entry.set_editable(False)
-
- def get_choice(self):
- return self.entry.get_text()
-
- def set_choices(self, choices):
- for choice, select in choices:
- item = gtk.ListItem(choice)
- item.show()
- self.list.add(item)
-
- if select:
- item.select()
-
-class ValueCombo(BaseCombo):
- def __init__(self, minimum, maximum):
- BaseCombo.__init__(self)
-
- choices = [('Auto', False)]
-
- size = minimum
- while size <= maximum:
- choices.append((format_bytes(size), False))
- size = size << 1
-
- self.set_choices(choices)
-
- def get_arg(self):
- text = self.get_choice()
-
- if text != 'Auto':
- s = text.replace(' ', '')
- s = s.replace('B', '')
- s = s.replace('bytes', '')
- return (self.arg, s)
- else:
- return None
-
-class NumNodes(gtk.SpinButton):
- def __init__(self):
- adjustment = gtk.Adjustment(4, 2, ocfs2.MAX_NODES, 1, 10)
- gtk.SpinButton.__init__(self, adjustment=adjustment)
-
- def get_arg(self):
- s = self.get_text()
-
- if s:
- return ('-n', s)
- else:
- return None
-
class Device(BaseCombo):
def fill(self, partitions, device):
self.set_choices([('%s (%s)' % p, p[0] == device) for p in partitions])
@@ -110,39 +33,15 @@
def get_device(self):
return self.get_choice().split(' ')[0]
-class VolumeLabel(gtk.Entry):
+ label = 'Device'
+
+class FormatVolumeLabel(VolumeLabel):
def __init__(self):
- gtk.Entry.__init__(self, max=ocfs2.MAX_VOL_LABEL_LEN)
+ VolumeLabel.__init__(self)
self.set_text('oracle')
- def get_arg(self):
- s = self.get_text()
+entries = (Device, FormatVolumeLabel, ClusterSize, NumNodes, BlockSize)
- if s:
- return ('-L', s)
- else:
- return None
-
-class ClusterSize(ValueCombo):
- def __init__(self):
- ValueCombo.__init__(self, ocfs2.MIN_CLUSTER_SIZE,
- ocfs2.MAX_CLUSTER_SIZE)
- self.arg = '-c'
-
-class BlockSize(ValueCombo):
- def __init__(self):
- ValueCombo.__init__(self, ocfs2.MIN_BLOCKSIZE,
- ocfs2.MAX_BLOCKSIZE)
- self.arg = '-b'
-
-entries = (
- ('Device', Device),
- ('Volume Label', VolumeLabel),
- ('Cluster Size', ClusterSize),
- ('Number of Nodes', NumNodes),
- ('Block Size', BlockSize)
-)
-
def format_partition(parent, device):
partitions = []
@@ -173,8 +72,8 @@
widgets = []
row = 0
- for desc, widget_type in entries:
- label = gtk.Label(desc + ':')
+ for widget_type in entries:
+ label = gtk.Label(widget_type.label + ':')
set_props(label, xalign=1.0)
table.attach(label, 0, 1, row, row + 1)
@@ -192,24 +91,27 @@
dialog.show_all()
- if dialog.run() != gtk.RESPONSE_OK:
- dialog.destroy()
- return False
+ while 1:
+ if dialog.run() != gtk.RESPONSE_OK:
+ dialog.destroy()
+ return False
- dev = widgets[0].get_device()
- msg = 'Are you sure you want to format %s?' % dev
+ dev = widgets[0].get_device()
+ msg = 'Are you sure you want to format %s?' % dev
- ask = gtk.MessageDialog(parent=dialog,
- flags=gtk.DIALOG_DESTROY_WITH_PARENT,
- type=gtk.MESSAGE_QUESTION,
- buttons=gtk.BUTTONS_YES_NO,
- message_format=msg)
+ ask = gtk.MessageDialog(parent=dialog,
+ flags=gtk.DIALOG_DESTROY_WITH_PARENT,
+ type=gtk.MESSAGE_QUESTION,
+ buttons=gtk.BUTTONS_YES_NO,
+ message_format=msg)
- if ask.run() != gtk.RESPONSE_YES:
- dialog.destroy()
- return False
+ if ask.run() == gtk.RESPONSE_YES:
+ break
+ else:
+ ask.destroy()
- command = ['mkfs.ocfs2']
+ command = list(base_command)
+
for widget in widgets[1:]:
arg = widget.get_arg()
Modified: trunk/ocfs2console/ocfs2interface/fsck.py
===================================================================
--- trunk/ocfs2console/ocfs2interface/fsck.py 2005-03-20 06:07:25 UTC (rev 702)
+++ trunk/ocfs2console/ocfs2interface/fsck.py 2005-03-20 11:33:13 UTC (rev 703)
@@ -29,7 +29,7 @@
else:
fsck_ok = True
-def fsck(parent, device, check=False):
+def fsck_volume(parent, device, check=False):
if check:
check_str = 'check'
else:
Added: trunk/ocfs2console/ocfs2interface/fswidgets.py
===================================================================
--- trunk/ocfs2console/ocfs2interface/fswidgets.py 2005-03-20 06:07:25 UTC (rev 702)
+++ trunk/ocfs2console/ocfs2interface/fswidgets.py 2005-03-20 11:33:13 UTC (rev 703)
@@ -0,0 +1,180 @@
+# OCFS2Console - GUI frontend for OCFS2 management and debugging
+# Copyright (C) 2002, 2005 Oracle. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 021110-1307, USA.
+
+import gtk
+
+import ocfs2
+
+from guiutil import set_props, format_bytes
+
+if hasattr(gtk, 'ComboBox'):
+ class BaseCombo(gtk.ComboBox):
+ def __init__(self):
+ self.store = gtk.ListStore(str)
+ gtk.ComboBox.__init__(self, model=self.store)
+
+ cell = gtk.CellRendererText()
+ self.pack_start(cell)
+ self.set_attributes(cell, text=0)
+
+ def get_choice(self):
+ return self.store[self.get_active_iter()][0]
+
+ def set_choices(self, choices):
+ selected = False
+
+ for choice, select in choices:
+ iter = self.store.append((choice,))
+
+ if select:
+ self.set_active_iter(iter)
+ selected = True
+
+ if not selected:
+ self.set_active(0)
+
+else:
+ class BaseCombo(gtk.Combo):
+ def __init__(self):
+ gtk.Combo.__init__(self)
+ self.entry.set_editable(False)
+
+ def get_choice(self):
+ return self.entry.get_text()
+
+ def set_choices(self, choices):
+ for choice, select in choices:
+ item = gtk.ListItem(choice)
+ item.show()
+ self.list.add(item)
+
+ if select:
+ item.select()
+
+class ValueCombo(BaseCombo):
+ def __init__(self, minimum, maximum):
+ BaseCombo.__init__(self)
+
+ choices = [('Auto', False)]
+
+ size = minimum
+ while size <= maximum:
+ choices.append((format_bytes(size), False))
+ size = size << 1
+
+ self.set_choices(choices)
+
+ def get_arg(self):
+ text = self.get_choice()
+
+ if text != 'Auto':
+ s = text.replace(' ', '')
+ s = s.replace('B', '')
+ s = s.replace('bytes', '')
+ return (self.arg, s)
+ else:
+ return None
+
+class NumNodes(gtk.SpinButton):
+ def __init__(self):
+ adjustment = gtk.Adjustment(4, 2, ocfs2.MAX_NODES, 1, 10)
+ gtk.SpinButton.__init__(self, adjustment=adjustment)
+
+ self.set_numeric(True)
+
+ label = 'Number of Nodes'
+
+ def get_arg(self):
+ s = self.get_text()
+
+ if s:
+ return ('-N', s)
+ else:
+ return None
+
+class VolumeLabel(gtk.Entry):
+ def __init__(self):
+ gtk.Entry.__init__(self, max=ocfs2.MAX_VOL_LABEL_LEN)
+
+ label = 'Volume Label'
+
+ def get_arg(self):
+ s = self.get_text()
+
+ if s:
+ return ('-L', s)
+ else:
+ return None
+
+class ClusterSize(ValueCombo):
+ def __init__(self):
+ ValueCombo.__init__(self, ocfs2.MIN_CLUSTER_SIZE,
+ ocfs2.MAX_CLUSTER_SIZE)
+ self.arg = '-C'
+
+ label = 'Cluster Size'
+
+class BlockSize(ValueCombo):
+ def __init__(self):
+ ValueCombo.__init__(self, ocfs2.MIN_BLOCKSIZE,
+ ocfs2.MAX_BLOCKSIZE)
+ self.arg = '-b'
+
+ label = 'Block Size'
+
+def main():
+ import types
+
+ widgets = []
+
+ symbols = globals()
+
+ for class_type in symbols.itervalues():
+ if isinstance(class_type, types.TypeType) and hasattr(class_type, 'label'):
+ widgets.append(class_type)
+
+ def dummy(*args):
+ gtk.main_quit()
+
+ window = gtk.Window()
+ window.connect('delete_event', dummy)
+
+ table = gtk.Table(rows=len(widgets), columns=2)
+ set_props(table, row_spacing=4,
+ column_spacing=4,
+ border_width=4,
+ parent=window)
+
+ row = 0
+
+ for widget_type in widgets:
+ label = gtk.Label()
+ label.set_text_with_mnemonic(widget_type.label + ':')
+ set_props(label, xalign=1.0)
+ table.attach(label, 0, 1, row, row + 1)
+
+ widget = widget_type()
+ table.attach(widget, 1, 2, row, row + 1)
+
+ row = row + 1
+
+ window.show_all()
+
+ gtk.main()
+
+if __name__ == '__main__':
+ main()
Modified: trunk/ocfs2console/ocfs2interface/main.py
===================================================================
--- trunk/ocfs2console/ocfs2interface/main.py 2005-03-20 06:07:25 UTC (rev 702)
+++ trunk/ocfs2console/ocfs2interface/main.py 2005-03-20 11:33:13 UTC (rev 703)
@@ -26,11 +26,12 @@
from about import about, process_gui_args
from process import Process
from format import format_partition
+from tune import tune_label, tune_nodes
from general import General
from nodemap import NodeMap
from browser import Browser
from clconfig import cluster_configurator
-from fsck import fsck
+from fsck import fsck_volume
COLUMN_DEVICE = 0
COLUMN_MOUNTPOINT = 1
@@ -200,11 +201,19 @@
format_partition(pv.toplevel, pv.get_device())
pv.refresh_partitions()
+def relabel(pv):
+ tune_label(pv.toplevel, pv.get_device())
+ pv.refresh_partitions()
+
+def node_num(pv):
+ tune_nodes(pv.toplevel, pv.get_device())
+ pv.refresh_partitions()
+
def check(pv):
- fsck(pv.toplevel, pv.get_device(), check=True)
+ fsck_volume(pv.toplevel, pv.get_device(), check=True)
def repair(pv):
- fsck(pv.toplevel, pv.get_device(), check=False)
+ fsck_volume(pv.toplevel, pv.get_device(), check=False)
def clconfig(pv):
cluster_configurator(pv.toplevel)
@@ -225,13 +234,14 @@
vbox = gtk.VBox()
window.add(vbox)
- menu = Menu(cleanup=cleanup, format=format, check=check, repair=repair,
- clconfig=clconfig, about=about)
+ symbols = globals()
+ menu = Menu(**symbols)
+
menubar = menu.get_widget(window, pv)
vbox.pack_start(menubar, expand=False, fill=False)
- toolbar = Toolbar(mount=mount, unmount=unmount, refresh=refresh)
+ toolbar = Toolbar(**symbols)
tb, buttons, pv.filter_entry = toolbar.get_widgets(pv)
vbox.pack_start(tb, expand=False, fill=False)
Modified: trunk/ocfs2console/ocfs2interface/menu.py
===================================================================
--- trunk/ocfs2console/ocfs2interface/menu.py 2005-03-20 06:07:25 UTC (rev 702)
+++ trunk/ocfs2console/ocfs2interface/menu.py 2005-03-20 11:33:13 UTC (rev 703)
@@ -38,22 +38,24 @@
if fsck_ok:
task_menu_fsck_data = (
- ('/Tasks/---', None, None, 0,
- '<Separator>'),
- ('/Tasks/Chec_k...', '<control>K', 'check'),
- ('/Tasks/_Repair...', '<control>R', 'repair'),
+ ('/Tasks/Chec_k...', '<control>K', 'check'),
+ ('/Tasks/_Repair...', '<control>R', 'repair'),
+ ('/Tasks/---', None, None, 0, '<Separator>')
)
else:
task_menu_fsck_data = ()
task_menu_head_data = (
('/_Tasks', None, None, 0, '<Branch>'),
- ('/Tasks/_Format...', '<control>F', 'format')
+ ('/Tasks/_Format...', '<control>F', 'format'),
+ ('/Tasks/---', None, None, 0, '<Separator>')
)
task_menu_tail_data = (
+ ('/Tasks/Change _Label...', None, 'relabel'),
+ ('/Tasks/Edit _Node Count...', None, 'node_num'),
('/Tasks/---', None, None, 0, '<Separator>'),
- ('/Tasks/_Cluster Config...', '<control>C', 'clconfig'),
+ ('/Tasks/_Cluster Config...', None, 'clconfig')
)
task_menu_data = task_menu_head_data + task_menu_fsck_data + task_menu_tail_data
Added: trunk/ocfs2console/ocfs2interface/tune.py
===================================================================
--- trunk/ocfs2console/ocfs2interface/tune.py 2005-03-20 06:07:25 UTC (rev 702)
+++ trunk/ocfs2console/ocfs2interface/tune.py 2005-03-20 11:33:13 UTC (rev 703)
@@ -0,0 +1,140 @@
+# OCFS2Console - GUI frontend for OCFS2 management and debugging
+# Copyright (C) 2005 Oracle. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 021110-1307, USA.
+
+import gtk
+
+import ocfs2
+
+from guiutil import set_props, error_box, format_bytes
+from process import Process
+
+from fswidgets import NumNodes, VolumeLabel
+
+base_command = ('tunefs.ocfs2', '-x')
+
+class TuneVolumeLabel(VolumeLabel):
+ def __init__(self, device=None):
+ VolumeLabel.__init__(self)
+
+ if device:
+ try:
+ super = ocfs2.get_super(device)
+ self.set_text(super.s_label)
+ except ocfs2.error:
+ pass
+
+ title = 'Changing Label'
+ action = 'Changing label'
+
+ empty_ok = True
+
+class TuneNumNodes(NumNodes):
+ def __init__(self, device=None):
+ NumNodes.__init__(self)
+
+ if device:
+ super = ocfs2.get_super(device)
+ self.set_range(super.s_max_nodes, ocfs2.MAX_NODES)
+
+ title = 'Edit Node Count'
+ action = 'Changing node count'
+
+ empty_ok = False
+
+def tune_action(widget_type, parent, device):
+ try:
+ widget = widget_type(device)
+ except ocfs2.error:
+ error_box(parent, 'Could not get current %s for device $s' %
+ (widget_type.label.lower(), device))
+ return False
+
+ dialog = gtk.Dialog(parent=parent, title=widget_type.title,
+ buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OK, gtk.RESPONSE_OK))
+
+ table = gtk.Table(rows=1, columns=2)
+ set_props(table, row_spacing=4,
+ column_spacing=4,
+ border_width=4,
+ parent=dialog.vbox)
+
+ label = gtk.Label(widget_type.label + ':')
+ set_props(label, xalign=1.0)
+ table.attach(label, 0, 1, 0, 1)
+
+ table.attach(widget, 1, 2, 0, 1)
+
+ widget.grab_focus()
+
+ dialog.show_all()
+
+ while 1:
+ if dialog.run() != gtk.RESPONSE_OK:
+ dialog.destroy()
+ return False
+
+ new_label = widget.get_text()
+
+ if not new_label:
+ if widget_type.empty_ok:
+ msg = ('Are you sure you want to clear the %s on %s?' %
+ (widget_type.lower(), device))
+
+ ask = gtk.MessageDialog(parent=dialog,
+ flags=gtk.DIALOG_DESTROY_WITH_PARENT,
+ type=gtk.MESSAGE_QUESTION,
+ buttons=gtk.BUTTONS_YES_NO,
+ message_format=msg)
+
+ if ask.run() == gtk.RESPONSE_YES:
+ break
+ else:
+ ask.destroy()
+ else:
+ error_box(dialog, '%s cannot be empty.' %
+ widget_type.lower().ucfirst())
+ else:
+ break
+
+ command = list(base_command)
+ command.extend(widget.get_arg())
+
+ dialog.destroy()
+
+ tunefs = Process(command, widget_type.title, widget_type.action + '...',
+ parent)
+ success, output, k = tunefs.reap()
+
+ if not success:
+ error_box(parent, 'File system tune error: %s' % output)
+ return False
+
+ return True
+
+def tune_label(parent, device):
+ tune_action(TuneVolumeLabel, parent, device)
+
+def tune_nodes(parent, device):
+ tune_action(TuneNumNodes, parent, device)
+
+def main():
+ tune_label(None, None)
+ tune_nodes(None, None)
+
+if __name__ == '__main__':
+ main()
More information about the Ocfs2-tools-commits
mailing list