add raid screen

modify raid data layout in install.xml
This commit is contained in:
Zhi Li
2010-08-18 09:26:51 +07:59
parent 4ad1c428e0
commit 684b5d21a4
4 changed files with 262 additions and 56 deletions

View File

@@ -120,12 +120,13 @@ p_node - xml node (parent node)'''
class Raid:
''' raid information '''
list = []
def __init__(self, raid_dev, raid_type, raid_size, raw_devs):
def __init__(self, dev, level, sz, a_devs, s_devs=[]):
''' Raid init function '''
self.raid_device = raid_dev
self.raid_type = raid_type
self.raid_size = raid_size
self.raw_devices = raw_devs
self.device = dev
self.level = level
self.size = sz
self.active_components = a_devs
self.spare_components = s_devs
Raid.list.append(self)
@staticmethod
@@ -146,25 +147,40 @@ class Raid:
if len(dev_res)>1: # matched
# dev_res[0] is ''
raid_dev = dev_res[1]
raid_type = dev_res[2]
raw_devs =[]
raid_level = dev_res[2]
act_cmpts =[]
for ss in dev_res[3].split():
raw_devs.append(ss[:ss.index('[')])
Raid(raid_dev, raid_type, '-1', raw_devs)
act_cmpts.append(ss[:ss.index('[')])
Raid(raid_dev, raid_level, '-1', act_cmpts)
@staticmethod
def add_component(node, l):
''' add component devices (in xml node) to list
node - xml node
l - list
'''
for sub in node.childNodes:
if sub.nodeType == sub.ELEMENT_NODE and sub.nodeName == 'component':
l.append(sub.firstChild.data.encode('ascii'))
@staticmethod
def init_from_xml(node):
''' create Raid instances from xml node '''
for e in node.childNodes:
if e.nodeType == e.ELEMENT_NODE and e.nodeName == 'raid':
raid_dev = e.attributes['raid-device'].value
raid_type = e.attributes['raid-type'].value
raid_size = e.attributes['raid-size'].value
raw_devs = []
raid_dev = e.attributes['device'].value
raid_level = e.attributes['level'].value
raid_size = e.attributes['size'].value
act_cmpts = []
spr_cmpts = []
for sub_e in e.childNodes:
if sub_e.nodeType == sub_e.ELEMENT_NODE and sub_e.nodeName == 'raw-device':
raw_devs.append(sub_e.firstChild.data.encode('ascii'))
Raid(raid_dev, raid_type, raid_size, raw_devs)
if sub_e.nodeType == sub_e.ELEMENT_NODE:
if sub_e.nodeName == 'active':
Raid.add_component(sub_e, act_cmpts)
elif sub_e.nodeName == 'spare':
Raid.add_component(sub_e, spr_cmpts)
Raid(raid_dev, raid_level, raid_size, act_cmpts, spr_cmpts)
@staticmethod
def to_xml(doc, p_node):
@@ -175,23 +191,33 @@ p_node - xml node (parent node) '''
for r in Raid.list:
rd = doc.createElement('raid')
rd_dev_attr = doc.createAttribute('raid-device')
rd_dev_attr.value = r.raid_device
rd_dev_attr = doc.createAttribute('device')
rd_dev_attr.value = r.device
rd.setAttributeNode(rd_dev_attr)
rd_type_attr = doc.createAttribute('raid-type')
rd_type_attr.value = r.raid_type
rd.setAttributeNode(rd_type_attr)
rd_level_attr = doc.createAttribute('level')
rd_level_attr.value = r.level
rd.setAttributeNode(rd_level_attr)
rd_size_attr = doc.createAttribute('raid-size')
rd_size_attr.value = r.raid_size
rd_size_attr = doc.createAttribute('size')
rd_size_attr.value = r.size
rd.setAttributeNode(rd_size_attr)
for raw_dev in r.raw_devices:
raw_dev_e = doc.createElement('raw-device')
raw_dev_tn = doc.createTextNode(raw_dev)
raw_dev_e.appendChild(raw_dev_tn)
rd.appendChild(raw_dev_e)
rd_act_elem = doc.createElement('active')
for act_c in r.active_components:
act_c_e = doc.createElement('component')
act_c_tn = doc.createTextNode(act_c)
act_c_e.appendChild(act_c_tn)
rd_act_elem.appendChild(act_c_e)
rd.appendChild(rd_act_elem)
rd_spr_elem = doc.createElement('spare')
for spr_c in r.spare_components:
spr_c_e = doc.createElement('component')
spr_c_tn = doc.createTextNode(spr_c)
spr_c_e.appendChild(act_c_tn)
rd_spr_elem.appendChild(spr_c_e)
rd.appendChild(rd_spr_elem)
raids.appendChild(rd)
@@ -200,8 +226,8 @@ p_node - xml node (parent node) '''
@staticmethod
def get_size(dev):
for r in Raid.list:
if r.raid_device == dev:
return r.raid_size
if r.device == dev:
return r.size
class MountPoint:
''' mount-points '''

View File

@@ -12,9 +12,14 @@
<partition device='sdb4' start='0' id='0' size='0'/>
</partitions>
<raids>
<raid raid-type='raid1' raid-size='-1' raid-device='md0'>
<raw-device>sda1</raw-device>
<raw-device>sdb1</raw-device>
<raid device='md0' size='-1' level='1'>
<active>
<component>sda1</component>
<component/>
</active>
<spare>
<component>sdb1</component>
</spare>
</raid>
</raids>
<mount-points>
@@ -26,7 +31,7 @@
<mount-point device='sdb4' directory='/' file-system='ext3' format='yes'/>
<mount-point device='md0' directory='' file-system='' format='no'/>
</mount-points>
<network domain='' secondary_dns='' ip='172.16.0.108' hostname='lizhi' mask='' primary_dns='' configuration='static' gateway=''/>
<network domain='' secondary_dns='' ip='172.115.155.144' hostname='lizhi' mask='' primary_dns='' configuration='static' gateway=''/>
<groups>
<group name='development' install='yes'>
<description>
@@ -42,12 +47,12 @@
<package name='make'/>
</mandatory>
<optional selection='all'>
<package name='ant' install='no'/>
<package name='ant' install='yes'/>
<package name='Archive-Zip' install='no'/>
<package name='autogen' install='no'/>
<package name='bin86' install='no'/>
<package name='bison' install='no'/>
<package name='byacc' install='no'/>
<package name='byacc' install='yes'/>
<package name='ccache' install='no'/>
<package name='Compress-Raw-Zlib' install='no'/>
<package name='Compress-Zlib' install='no'/>
@@ -82,7 +87,7 @@
<package name='subversion' install='no'/>
<package name='subversion-python' install='no'/>
<package name='swig' install='no'/>
<package name='trac' install='no'/>
<package name='trac' install='yes'/>
</optional>
</group>
<group name='office' install='yes'>
@@ -185,17 +190,17 @@
<package name='xkeyboard-config'/>
<package name='x11-fonts-chinese'/>
</mandatory>
<optional selection='all'>
<optional selection='manual'>
<package name='arts' install='no'/>
<package name='atk' install='no'/>
<package name='cairo' install='no'/>
<package name='emacs' install='no'/>
<package name='fcitx' install='no'/>
<package name='fcitx' install='yes'/>
<package name='fontconfig' install='no'/>
<package name='freetype' install='no'/>
<package name='fribidi' install='no'/>
<package name='gamin' install='no'/>
<package name='gd' install='no'/>
<package name='gd' install='yes'/>
<package name='gdk-pixbuf' install='no'/>
<package name='glib1' install='no'/>
<package name='glib2' install='no'/>
@@ -381,7 +386,7 @@
<package name='zip' install='yes'/>
</optional>
</group>
<group name='network_service' install='yes'>
<group name='network_service' install='no'>
<description>
网络服务类包括各种网络服务包。
网络服务类都是可选软件包,可以自由选择安装。
@@ -460,9 +465,9 @@
</group>
</groups>
<services>
<service start='no' package='netkit-rsh' script='inetd' name='rsh' number='S310'/>
<service start='disable' package='netkit-rsh' script='inetd' name='rsh' number='S310'/>
<service start='yes' package='openssh' script='sshd' name='ssh' number='S205'/>
<service start='no' package='proftpd' script='proftpd' name='ftpd' number='S280'/>
<service start='no' package='netkit-telnetd' script='inetd' name='telnet' number='S310'/>
<service start='disable' package='proftpd' script='proftpd' name='ftpd' number='S280'/>
<service start='yes' package='netkit-telnetd' script='inetd' name='telnet' number='S310'/>
</services>
</install>

View File

@@ -41,25 +41,36 @@
<element name='raids'>
<oneOrMore>
<element name="raid">
<attribute name="raid-device"/>
<attribute name="raid-type">
<attribute name="device"/>
<attribute name="level">
<choice>
<value>raid0</value>
<value>raid1</value>
<value>raid5</value>
<value>0</value>
<value>1</value>
<value>5</value>
</choice>
</attribute>
<attribute name="raid-size"/>
<oneOrMore>
<element name="raw-device">
<text/>
<attribute name="size"/>
<element name='active'>
<ref name='raid_components'/>
</element>
<optional>
<element name='spare'>
<ref name='raid_components'/>
</element>
</oneOrMore>
</optional>
</element>
</oneOrMore>
</element>
</define>
<define name='raid_components'>
<oneOrMore>
<element name="component">
<text/>
</element>
</oneOrMore>
</define>
<define name="mount-points">
<element name="mount-points">
<oneOrMore>

View File

@@ -17,7 +17,6 @@ row 4 | quit previous next |
<widget type='Frame' name='main'>
<grid_management rows='5' columns='3'>
<configure row='2' weight='1'/>
<configure column='0' weight='1'/>
<configure column='1' weight='3'/>
<configure column='2' weight='1'/>
</grid_management>
@@ -44,7 +43,7 @@ row 4 | quit previous next |
</widget>
<widget type='Text'>
<widget_attribute state='disabled'/>
<widget_attribute width='30' state='disabled'/>
<grid_location row='2' column='0' padx='10' pady='10' sticky='NSWE'/>
</widget>
@@ -607,6 +606,150 @@ row 4 | |
</widget>
</top_window>
<widget type='Frame' name='raid'>
<grid_management rows='3' columns='3'>
<configure row='0' weight='1'/>
<configure row='1' weight='1'/>
<configure column='0' weight='1'/>
<configure column='1' weight='1'/>
<configure column='2' weight='1'/>
</grid_management>
<grid_location row='2' column='1' columnspan='2' sticky='NSWE'/>
<widget type='Frame'>
<grid_management rows='2' columns='2'>
<configure row='1' weight='1'/>
<configure column='0' weight='1'/>
</grid_management>
<grid_location row='0' column='0' rowspan='3' sticky='NSWE'/>
<action>
<scroll scrolling='raid_raw.scroll' scrolled='raid_raw.list'/>
</action>
<widget type='Label'>
<widget_attribute text='Raw'/>
<grid_location row='0' column='0' sticky='W'/>
</widget>
<widget type='Listbox' name='raid_raw.list'>
<widget_attribute listvariable='raid_raw_devs'/>
<grid_location row='1' column='0' sticky='NWES'/>
<variable name='raid_raw_devs' type='StringVar'/>
</widget>
<widget type='Scrollbar' name='raid_raw.scroll'>
<widget_attribute orient='vertical'/>
<grid_location row='1' column='1' sticky='NS'/>
</widget>
</widget>
<!-- active dev list -->
<widget type='Frame'>
<grid_management rows='3' columns='2'>
<configure row='1' weight='1'/>
<configure row='2' weight='1'/>
<configure column='1' weight='1'/>
</grid_management>
<grid_location row='0' column='1' sticky='NWES'/>
<widget type='Label'>
<widget_attribute text='Active'/>
<grid_location row='0' column='1' sticky='W'/>
</widget>
<widget type='Button'>
<widget_attribute text='-&gt;'/>
<grid_location row='1' column='0' sticky='S'/>
</widget>
<widget type='Button'>
<widget_attribute text='&lt;-'/>
<grid_location row='2' column='0' sticky='N'/>
</widget>
<widget type='Listbox' name='raid_active.list'>
<widget_attribute listvariable='raid_active_devs'/>
<grid_location row='1' column='1' rowspan='2' sticky='NWES'/>
<variable name='raid_active_devs' type='StringVar'/>
</widget>
</widget>
<!-- spare dev list -->
<widget type='Frame'>
<grid_management rows='3' columns='2'>
<configure row='1' weight='1'/>
<configure row='2' weight='1'/>
<configure column='1' weight='1'/>
</grid_management>
<grid_location row='1' column='1' sticky='NWES'/>
<widget type='Label'>
<widget_attribute text='Spare'/>
<grid_location row='0' column='1' sticky='W'/>
</widget>
<widget type='Button'>
<widget_attribute text='-&gt;'/>
<grid_location row='1' column='0' sticky='S'/>
</widget>
<widget type='Button'>
<widget_attribute text='&lt;-'/>
<grid_location row='2' column='0' sticky='N'/>
</widget>
<widget type='Listbox' name='raid_spare.list'>
<widget_attribute listvariable='raid_spare_devs'/>
<grid_location row='1' column='1' rowspan='2' sticky='NWES'/>
<variable name='raid_spare_devs' type='StringVar'/>
</widget>
</widget>
<!-- radio button for raid level -->
<widget type='Frame'>
<grid_location row='2' column='1' />
<variable name='raid_level' type='StringVar'/>
<widget type='Label'>
<widget_attribute text='Level'/>
<grid_location row='0' column='0' sticky='W'/>
</widget>
<widget type='Radiobutton' name='raid_level_0'>
<widget_attribute text='Raid 0' variable='raid_level' value='0'/>
<grid_location row='1' column='0'/>
</widget>
<widget type='Radiobutton' name='raid_level_1'>
<widget_attribute text='Raid 1' variable='raid_level' value='1'/>
<grid_location row='2' column='0'/>
</widget>
<widget type='Radiobutton' name='raid_level_5'>
<widget_attribute text='Raid 5' variable='raid_level' value='5'/>
<grid_location row='3' column='0'/>
</widget>
</widget>
<!-- raid partitions -->
<widget type='Frame'>
<grid_management rows='3' columns='2'>
<configure row='1' weight='1'/>
<configure row='2' weight='1'/>
<configure column='1' weight='1'/>
</grid_management>
<grid_location row='0' column='2' rowspan='2'/>
<widget type='Label'>
<widget_attribute text='Device'/>
<grid_location row='0' column='1' sticky='W'/>
</widget>
<widget type='Button'>
<widget_attribute text='-&gt;'/>
<grid_location row='1' column='0' sticky='S'/>
</widget>
<widget type='Button'>
<widget_attribute text='&lt;-'/>
<grid_location row='2' column='0' sticky='N'/>
</widget>
<widget type='Listbox'>
<widget_attribute listvariable='raid_dev.list'/>
<grid_location row='1' column='1' rowspan='2'/>
<variable name='raid_dev.list' type='StringVar'/>
</widget>
</widget>
</widget>
<text key='#Copyright'>
<English>Copyright 2001-2010 Linx Technology Co., Ltd.</English>
<Chinese>北京凝思科技有限公司 版权所有</Chinese>
@@ -639,6 +782,11 @@ Linx Rocky Secure Operating System v4.2</English>
凝思磐石安全操作系统 v4.2</Chinese>
</text>
<text>
<English>Active</English>
<Chinese>活动</Chinese>
</text>
<text>
<English>Cancel</English>
<Chinese>取消</Chinese>
@@ -714,6 +862,11 @@ Linx Rocky Secure Operating System v4.2</English>
<Chinese>IP</Chinese>
</text>
<text>
<English>Level</English>
<Chinese>级别</Chinese>
</text>
<text>
<English>Linx</English>
<Chinese>凝思</Chinese>
@@ -774,6 +927,11 @@ Linx Rocky Secure Operating System v4.2</English>
<Chinese>退出</Chinese>
</text>
<text>
<English>Raw</English>
<Chinese>原始</Chinese>
</text>
<text>
<English>reset</English>
<Chinese>重置</Chinese>
@@ -809,6 +967,11 @@ Linx Rocky Secure Operating System v4.2</English>
<Chinese>软件组</Chinese>
</text>
<text>
<English>Spare</English>
<Chinese>空闲</Chinese>
</text>
<text>
<English>Subnet mask</English>
<Chinese>子网掩码</Chinese>
@@ -827,6 +990,7 @@ Linx Rocky Secure Operating System v4.2</English>
<sequence name='main'>
<widget name='welcome'/>
<widget name='serial number'/>
<widget name='raid'/>
<widget name='mount'/>
<widget name='network'/>
<widget name='software group'/>