Package ganeti :: Package storage :: Module drbd_info :: Class BaseShowInfo
[hide private]
[frames] | no frames]

Class BaseShowInfo

source code


Base class for parsing the `drbdsetup show` output.

Holds various common pyparsing expressions which are used by subclasses. Also provides caching of the constructed parser.

Instance Methods [hide private]

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
GetDevInfo(cls, show_data)
Parse details about a given DRBD minor.
source code
 
_TransformParseResult(cls, parse_result) source code
 
_GetShowParser(cls)
Return a parser for `drbd show` output.
source code
 
_ConstructShowParser(cls) source code
Class Variables [hide private]
  _PARSE_SHOW = None
  _lbrace = pyp.Literal("{").suppress()
  _rbrace = pyp.Literal("}").suppress()
  _lbracket = pyp.Literal("[").suppress()
  _rbracket = pyp.Literal("]").suppress()
  _semi = pyp.Literal(";").suppress()
  _colon = pyp.Literal(":").suppress()
  _number = pyp.Word(pyp.nums).setParseAction(lambda s, l, t: in...
  _comment = pyp.Literal("#")+ pyp.Optional(pyp.restOfLine)
  _defa = pyp.Literal("_is_default").suppress()
  _dbl_quote = pyp.Literal('"').suppress()
  _keyword = pyp.Word(pyp.alphanums+ "-")
  _value = pyp.Word(pyp.alphanums+ "_-/.:")
  _quoted = _dbl_quote+ pyp.CharsNotIn('"')+ _dbl_quote
  _ipv4_addr = pyp.Optional(pyp.Literal("ipv4")).suppress()+ pyp...
  _ipv6_addr = pyp.Optional(pyp.Literal("ipv6")).suppress()+ pyp...
  _meta_value = _value ^ _quoted+ _lbracket+ _number+ _rbracket
  _device_value = pyp.Literal("minor").suppress()+ _number
  _stmt = ~ _rbrace+ _keyword+ ~ _lbrace+ pyp.Optional(_ipv4_add...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

GetDevInfo(cls, show_data)
Class Method

source code 

Parse details about a given DRBD minor.

This returns, if available, the local backing device (as a path) and the local and remote (ip, port) information from a string containing the output of the `drbdsetup show` command as returned by DRBD8Dev._GetShowData.

This will return a dict with keys:

  • local_dev
  • meta_dev
  • meta_index
  • local_addr
  • remote_addr

_GetShowParser(cls)
Class Method

source code 

Return a parser for `drbd show` output.

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


Class Variable Details [hide private]

_number

Value:
pyp.Word(pyp.nums).setParseAction(lambda s, l, t: int(t [0]))

_ipv4_addr

Value:
pyp.Optional(pyp.Literal("ipv4")).suppress()+ pyp.Word(pyp.nums+ ".")+\
 _colon+ _number

_ipv6_addr

Value:
pyp.Optional(pyp.Literal("ipv6")).suppress()+ pyp.Optional(_lbracket)+\
 pyp.Word(pyp.hexnums+ ":")+ pyp.Optional(_rbracket)+ _colon+ _number

_stmt

Value:
~ _rbrace+ _keyword+ ~ _lbrace+ pyp.Optional(_ipv4_addr ^ _ipv6_addr ^\
 _value ^ _quoted ^ _meta_value ^ _device_value)+ pyp.Optional(_defa)+\
 _semi+ pyp.Optional(pyp.restOfLine).suppress()