Beispiel #1
0
class FilesystemDoc(_MachineBaseDocument):
    def __init__(self, app, **atts):
        _MachineBaseDocument.__init__(self, app, **atts)
        self.mtype = MachineTypeHandler(self.conn)

    def set_filesystem(self, filesystem):
        clause = Eq('filesystem', filesystem)
        self.clear_body()
        title = SectionTitle('Filesystem:  %s' % filesystem)
        attributes = dict(bgcolor='IndianRed', width='100%')
        title.attributes.update(attributes)
        self.body.append(title)
        self.body.append(Header('Filesystem Mounts', level=2))

        rows = self.cursor.select(table='filesystem_mounts',
                                  clause=clause,
                                  order=['ord'])
        fields = ['mnt_name', 'partition', 'ord', 'size']
        mounttable = self._make_table(fields, rows, bgcolor='DarkSeaGreen')
        self.body.append(mounttable)
        self.body.append(Ruler())
        self.body.append(Header('Fstab for %s' % filesystem, level=2))
        fstab = self.mtype.make_fstab(filesystem)
        self.body.append(Pre(fstab))
        self._make_footer_anchors('filesystem', filesystem)
Beispiel #2
0
class FilesystemDoc(_MachineBaseDocument):
    def __init__(self, app, **atts):
        _MachineBaseDocument.__init__(self, app, **atts)
        self.mtype = MachineTypeHandler(self.conn)
        
    def set_filesystem(self, filesystem):
        clause = Eq('filesystem', filesystem)
        self.clear_body()
        title = SectionTitle('Filesystem:  %s' % filesystem)
        attributes = dict(bgcolor='IndianRed', width='100%')
        title.attributes.update(attributes)
        self.body.append(title)
        self.body.append(Header('Filesystem Mounts', level=2))
        
        rows = self.cursor.select(table='filesystem_mounts', clause=clause,
                                  order=['ord'])
        fields = ['mnt_name', 'partition', 'ord', 'size']
        mounttable = self._make_table(fields, rows, bgcolor='DarkSeaGreen')
        self.body.append(mounttable)
        self.body.append(Ruler())
        self.body.append(Header('Fstab for %s' % filesystem, level=2))
        fstab = self.mtype.make_fstab(filesystem)
        self.body.append(Pre(fstab))
        self._make_footer_anchors('filesystem', filesystem)
Beispiel #3
0
class MachineTypeDoc(_MachineBaseDocument):
    def __init__(self, app, **atts):
        _MachineBaseDocument.__init__(self, app, **atts)
        self.mtype = MachineTypeHandler(self.conn)
        self.body.setAttribute('bgcolor', 'Salmon')

    def set_machine_type(self, machine_type):
        clause = Eq('machine_type', machine_type)
        self.clear_body()
        self.mtype.set_machine_type(machine_type)
        title = SimpleTitleElement('MachineType:  %s' % machine_type,
                                   bgcolor='IndianRed',
                                   width='100%')
        self.body.appendChild(title)

        rows = self.cursor.select(table='machine_disks', clause=clause)
        self._setup_section('Disks', ['diskname', 'device'], rows)
        modrows = self.cursor.select(table='machine_modules',
                                     clause=clause,
                                     order=['ord'])
        self._setup_section('Modules', ['module', 'ord'], modrows)
        famrows = self.cursor.select(table='machine_type_family',
                                     clause=clause,
                                     order='family')
        self._setup_section('Families', ['family'], famrows)
        scripts = self.cursor.select(table='machine_type_scripts',
                                     clause=clause,
                                     order='script')
        self._setup_section('Scripts', ['script'], scripts)
        vars_ = self.cursor.select(table='machine_type_variables',
                                   clause=clause,
                                   order=['trait', 'name'])
        self._setup_section('Variables', ['trait', 'name', 'value'], vars_)
        self._make_footer_anchors('machine_type', machine_type)

    def _setup_section(self, name, fields, rows):
        title = SimpleTitleElement(name)
        title.set_font(color='DarkViolet')
        td = TD()
        anchor = Anchor('new.%s.mtype' % name, 'new')
        td.appendChild(anchor)
        title.row.appendChild(td)
        self.body.appendChild(title)
        if len(rows):
            table = self._make_table(name,
                                     fields,
                                     rows,
                                     border=1,
                                     cellspacing=1)
            color_header(table, 'MediumOrchid2')
            self.body.appendChild(table)

    def _make_table(self, context, fields, rows, **atts):
        table = BaseElement('table', bgcolor='MediumOrchid3', **atts)
        table.context = context
        self._add_table_header(table, fields + ['command'])
        for row in rows:
            self._add_table_row(table, fields, row)
        return table

    def _add_table_row(self, table, fields, row):
        trow = TR()
        for field in fields:
            val = row[field]
            trow.appendChild(TxtTD(val))
        durl = 'delete.%s.%s' % (table.context, row[fields[0]])
        eurl = 'edit.%s.%s' % (table.context, row[fields[0]])
        delanchor = Anchor(durl, 'delete')
        editanchor = Anchor(eurl, 'edit')
        td = TD()
        td.appendChild(editanchor)
        td.appendChild(BR())
        td.appendChild(delanchor)
        trow.appendChild(td)
        #trow.appendChild(TxtTD(delanchor))
        table.appendChild(trow)
Beispiel #4
0
 def __init__(self, app, **atts):
     _MachineBaseDocument.__init__(self, app, **atts)
     self.mtype = MachineTypeHandler(self.conn)
     self.body.setAttribute('bgcolor', 'Salmon')
Beispiel #5
0
 def __init__(self, app, **atts):
     _MachineBaseDocument.__init__(self, app, **atts)
     self.mtype = MachineTypeHandler(self.conn)
Beispiel #6
0
 def __init__(self, app, **atts):
     _MachineBaseDocument.__init__(self, app, **atts)
     self.mtype = MachineTypeHandler(self.conn)
     self.body['bgcolor'] = 'Salmon'
Beispiel #7
0
class MachineTypeDoc(_MachineBaseDocument):
    def __init__(self, app, **atts):
        _MachineBaseDocument.__init__(self, app, **atts)
        self.mtype = MachineTypeHandler(self.conn)
        self.body['bgcolor'] = 'Salmon'

    def set_machine_type(self, machine_type):
        clause = Eq('machine_type', machine_type)
        self.clear_body()
        self.mtype.set_machine_type(machine_type)
        title = SectionTitle('Machine Type:  %s' % machine_type)
        title['bgcolor'] = 'IndianRed'
        title['width'] = '100%'
        self.body.append(title)

        rows = self.cursor.select(table='machine_disks', clause=clause)
        self._setup_section('Disks', ['diskname', 'device'], rows)
        modrows = self.cursor.select(table='machine_modules',
                                     clause=clause,
                                     order=['ord'])
        self._setup_section('Modules', ['module', 'ord'], modrows)
        famrows = self.cursor.select(table='machine_type_family',
                                     clause=clause,
                                     order='family')
        self._setup_section('Families', ['family'], famrows)
        scripts = self.cursor.select(table='machine_type_scripts',
                                     clause=clause,
                                     order='script')
        self._setup_section('Scripts', ['script'], scripts)
        vars_ = self.cursor.select(table='machine_type_variables',
                                   clause=clause,
                                   order=['trait', 'name'])
        self._setup_section('Variables', ['trait', 'name', 'value'], vars_)
        self._make_footer_anchors('machine_type', machine_type)

    def _setup_section(self, name, fields, rows):
        title = SectionTitle(name)
        title.set_font(color='DarkViolet')
        anchor = Anchor('new', href='new.%s.mtype' % name)
        title.row.append(TableCell(anchor))
        self.body.append(title)
        if len(rows):
            table = self._make_table(name,
                                     fields,
                                     rows,
                                     border=1,
                                     cellspacing=1)
            color_header(table, 'MediumOrchid2')
            self.body.append(table)

    def _make_table(self, context, fields, rows, **atts):
        table = Table(bgcolor='MediumOrchid3', **atts)
        table.context = context
        self._add_table_header(table, fields + ['command'])
        for row in rows:
            self._add_table_row(table, fields, row)
        return table

    def _add_table_row(self, table, fields, row):
        tablerow = TableRow()
        for field in fields:
            tablerow.append(TableCell(str(row[field])))
        durl = 'delete.%s.%s' % (table.context, row[fields[0]])
        eurl = 'edit.%s.%s' % (table.context, row[fields[0]])
        delanchor = Anchor('delete', href=durl)
        editanchor = Anchor('edit', href=eurl)
        cell = TableCell(editanchor)
        cell.append(Break())
        cell.append(delanchor)
        tablerow.append(cell)
        table.append(tablerow)
Beispiel #8
0
 def __init__(self, app, **atts):
     _MachineBaseDocument.__init__(self, app, **atts)
     self.mtype = MachineTypeHandler(self.conn)
     self.body['bgcolor'] = 'Salmon'
Beispiel #9
0
class MachineTypeDoc(_MachineBaseDocument):
    def __init__(self, app, **atts):
        _MachineBaseDocument.__init__(self, app, **atts)
        self.mtype = MachineTypeHandler(self.conn)
        self.body['bgcolor'] = 'Salmon'

    def set_machine_type(self, machine_type):
        clause = Eq('machine_type', machine_type)
        self.clear_body()
        self.mtype.set_machine_type(machine_type)
        title = SectionTitle('Machine Type:  %s' % machine_type)
        title['bgcolor'] = 'IndianRed'
        title['width'] = '100%'
        self.body.append(title)

        rows = self.cursor.select(table='machine_disks', clause=clause)
        self._setup_section('Disks', ['diskname', 'device'], rows)
        modrows =  self.cursor.select(table='machine_modules', clause=clause,
                                      order=['ord'])
        self._setup_section('Modules', ['module', 'ord'], modrows)
        famrows = self.cursor.select(table='machine_type_family', clause=clause,
                                     order='family')
        self._setup_section('Families', ['family'], famrows)
        scripts = self.cursor.select(table='machine_type_scripts', clause=clause,
                                     order='script')
        self._setup_section('Scripts', ['script'], scripts)
        vars_ = self.cursor.select(table='machine_type_variables', clause=clause,
                                   order=['trait', 'name'])
        self._setup_section('Variables', ['trait', 'name', 'value'], vars_)
        self._make_footer_anchors('machine_type', machine_type)

    def _setup_section(self, name, fields, rows):
        title = SectionTitle(name)
        title.set_font(color='DarkViolet')
        anchor = Anchor('new', href='new.%s.mtype' % name)
        title.row.append(TableCell(anchor))
        self.body.append(title)
        if len(rows):
            table = self._make_table(name, fields, rows, border=1, cellspacing=1)
            color_header(table, 'MediumOrchid2')
            self.body.append(table)
            
    def _make_table(self, context, fields, rows, **atts):
        table = Table(bgcolor='MediumOrchid3', **atts)
        table.context = context
        self._add_table_header(table, fields + ['command'])
        for row in rows:
            self._add_table_row(table, fields, row)
        return table

    def _add_table_row(self, table, fields, row):
        tablerow = TableRow()
        for field in fields:
            tablerow.append(TableCell(str(row[field])))
        durl = 'delete.%s.%s' % (table.context, row[fields[0]])
        eurl = 'edit.%s.%s' % (table.context, row[fields[0]])
        delanchor = Anchor('delete', href=durl)
        editanchor = Anchor('edit', href=eurl)
        cell = TableCell(editanchor)
        cell.append(Break())
        cell.append(delanchor)
        tablerow.append(cell)
        table.append(tablerow)
Beispiel #10
0
 def __init__(self, app, **atts):
     _MachineBaseDocument.__init__(self, app, **atts)
     self.mtype = MachineTypeHandler(self.conn)
Beispiel #11
0
 def __init__(self, app, **atts):
     _MachineBaseDocument.__init__(self, app, **atts)
     self.mtype = MachineTypeHandler(self.conn)
     self.body.setAttribute('bgcolor', 'Salmon')
Beispiel #12
0
class MachineTypeDoc(_MachineBaseDocument):
    def __init__(self, app, **atts):
        _MachineBaseDocument.__init__(self, app, **atts)
        self.mtype = MachineTypeHandler(self.conn)
        self.body.setAttribute('bgcolor', 'Salmon')

    def set_machine_type(self, machine_type):
        clause = Eq('machine_type', machine_type)
        self.clear_body()
        self.mtype.set_machine_type(machine_type)
        title = SimpleTitleElement('MachineType:  %s' % machine_type,
                                   bgcolor='IndianRed', width='100%')
        self.body.appendChild(title)

        rows = self.cursor.select(table='machine_disks', clause=clause)
        self._setup_section('Disks', ['diskname', 'device'], rows)
        modrows =  self.cursor.select(table='machine_modules', clause=clause,
                                      order=['ord'])
        self._setup_section('Modules', ['module', 'ord'], modrows)
        famrows = self.cursor.select(table='machine_type_family', clause=clause,
                                     order='family')
        self._setup_section('Families', ['family'], famrows)
        scripts = self.cursor.select(table='machine_type_scripts', clause=clause,
                                     order='script')
        self._setup_section('Scripts', ['script'], scripts)
        vars_ = self.cursor.select(table='machine_type_variables', clause=clause,
                                   order=['trait', 'name'])
        self._setup_section('Variables', ['trait', 'name', 'value'], vars_)
        self._make_footer_anchors('machine_type', machine_type)

    def _setup_section(self, name, fields, rows):
        title = SimpleTitleElement(name)
        title.set_font(color='DarkViolet')
        td = TD()
        anchor = Anchor('new.%s.mtype' % name, 'new')
        td.appendChild(anchor)
        title.row.appendChild(td)
        self.body.appendChild(title)
        if len(rows):
            table = self._make_table(name, fields, rows, border=1, cellspacing=1)
            color_header(table, 'MediumOrchid2')
            self.body.appendChild(table)
            
    def _make_table(self, context, fields, rows, **atts):
        table = BaseElement('table', bgcolor='MediumOrchid3', **atts)
        table.context = context
        self._add_table_header(table, fields + ['command'])
        for row in rows:
            self._add_table_row(table, fields, row)
        return table

    def _add_table_row(self, table, fields, row):
        trow = TR()
        for field in fields:
            val = row[field]
            trow.appendChild(TxtTD(val))
        durl = 'delete.%s.%s' % (table.context, row[fields[0]])
        eurl = 'edit.%s.%s' % (table.context, row[fields[0]])
        delanchor = Anchor(durl, 'delete')
        editanchor = Anchor(eurl, 'edit')
        td = TD()
        td.appendChild(editanchor)
        td.appendChild(BR())
        td.appendChild(delanchor)
        trow.appendChild(td)
        #trow.appendChild(TxtTD(delanchor))
        table.appendChild(trow)
Beispiel #13
0
class MachineTypeDoc(_MachineBaseDocument):
    def __init__(self, app, **atts):
        _MachineBaseDocument.__init__(self, app, **atts)
        self.mtype = MachineTypeHandler(self.conn)
        self.body.setAttribute("bgcolor", "Salmon")

    def set_machine_type(self, machine_type):
        clause = Eq("machine_type", machine_type)
        self.clear_body()
        self.mtype.set_machine_type(machine_type)
        title = SimpleTitleElement("MachineType:  %s" % machine_type, bgcolor="IndianRed", width="100%")
        self.body.appendChild(title)

        rows = self.cursor.select(table="machine_disks", clause=clause)
        self._setup_section("Disks", ["diskname", "device"], rows)
        modrows = self.cursor.select(table="machine_modules", clause=clause, order=["ord"])
        self._setup_section("Modules", ["module", "ord"], modrows)
        famrows = self.cursor.select(table="machine_type_family", clause=clause, order="family")
        self._setup_section("Families", ["family"], famrows)
        scripts = self.cursor.select(table="machine_type_scripts", clause=clause, order="script")
        self._setup_section("Scripts", ["script"], scripts)
        vars_ = self.cursor.select(table="machine_type_variables", clause=clause, order=["trait", "name"])
        self._setup_section("Variables", ["trait", "name", "value"], vars_)
        self._make_footer_anchors("machine_type", machine_type)

    def _setup_section(self, name, fields, rows):
        title = SimpleTitleElement(name)
        title.set_font(color="DarkViolet")
        td = TD()
        anchor = Anchor("new.%s.mtype" % name, "new")
        td.appendChild(anchor)
        title.row.appendChild(td)
        self.body.appendChild(title)
        if len(rows):
            table = self._make_table(name, fields, rows, border=1, cellspacing=1)
            color_header(table, "MediumOrchid2")
            self.body.appendChild(table)

    def _make_table(self, context, fields, rows, **atts):
        table = BaseElement("table", bgcolor="MediumOrchid3", **atts)
        table.context = context
        self._add_table_header(table, fields + ["command"])
        for row in rows:
            self._add_table_row(table, fields, row)
        return table

    def _add_table_row(self, table, fields, row):
        trow = TR()
        for field in fields:
            val = row[field]
            trow.appendChild(TxtTD(val))
        durl = "delete.%s.%s" % (table.context, row[fields[0]])
        eurl = "edit.%s.%s" % (table.context, row[fields[0]])
        delanchor = Anchor(durl, "delete")
        editanchor = Anchor(eurl, "edit")
        td = TD()
        td.appendChild(editanchor)
        td.appendChild(BR())
        td.appendChild(delanchor)
        trow.appendChild(td)
        # trow.appendChild(TxtTD(delanchor))
        table.appendChild(trow)