Logo Search packages:      
Sourcecode: ganeti version File versions  Download package

def lib::bdev::DRBD8::_GetShowParser (   cls  )  [private]

Return a parser for `drbd show` output.

This will either create or return an already-create parser for the
output of the command `drbd show`.

Definition at line 1690 of file bdev.py.

01690                          :
    """Return a parser for `drbd show` output.

    This will either create or return an already-create parser for the
    output of the command `drbd show`.

    """
    if cls._PARSE_SHOW is not None:
      return cls._PARSE_SHOW

    # pyparsing setup
    lbrace = pyp.Literal("{").suppress()
    rbrace = pyp.Literal("}").suppress()
    semi = pyp.Literal(";").suppress()
    # this also converts the value to an int
    number = pyp.Word(pyp.nums).setParseAction(lambda s, l, t: int(t[0]))

    comment = pyp.Literal ("#") + pyp.Optional(pyp.restOfLine)
    defa = pyp.Literal("_is_default").suppress()
    dbl_quote = pyp.Literal('"').suppress()

    keyword = pyp.Word(pyp.alphanums + '-')

    # value types
    value = pyp.Word(pyp.alphanums + '_-/.:')
    quoted = dbl_quote + pyp.CharsNotIn('"') + dbl_quote
    addr_port = (pyp.Word(pyp.nums + '.') + pyp.Literal(':').suppress() +
                 number)
    # meta device, extended syntax
    meta_value = ((value ^ quoted) + pyp.Literal('[').suppress() +
                  number + pyp.Word(']').suppress())

    # a statement
    stmt = (~rbrace + keyword + ~lbrace +
            (addr_port ^ value ^ quoted ^ meta_value) +
            pyp.Optional(defa) + semi +
            pyp.Optional(pyp.restOfLine).suppress())

    # an entire section
    section_name = pyp.Word(pyp.alphas + '_')
    section = section_name + lbrace + pyp.ZeroOrMore(pyp.Group(stmt)) + rbrace

    bnf = pyp.ZeroOrMore(pyp.Group(section ^ stmt))
    bnf.ignore(comment)

    cls._PARSE_SHOW = bnf

    return bnf

  @classmethod
  def _GetDevInfo(cls, minor):


Generated by  Doxygen 1.6.0   Back to index