ganeti :: hypervisor :: hv_kvm :: QmpConnection :: Class QmpConnection
[hide private]
[frames] | no frames]

Class QmpConnection

source code


Connection to the QEMU Monitor using the QEMU Monitor Protocol (QMP).

Instance Methods [hide private]
 
__init__(self, monitor_filename)
Instantiates the MonitorSocket object.
source code
 
connect(self)
Connects to the QMP monitor.
source code
 
_ParseMessage(self, buf)
Extract and parse a QMP message from the given buffer.
source code
QmpMessage
_Recv(self)
Receives a message from QMP and decodes the received JSON object.
source code
 
_Send(self, message)
Encodes and sends a message to KVM using QMP.
source code
dict
Execute(self, command, arguments=None)
Executes a QMP command and returns the response of the server.
source code

Inherited from MonitorSocket: close

Inherited from MonitorSocket (private): _check_connection, _check_socket

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

Class Variables [hide private]
  _FIRST_MESSAGE_KEY = "QMP"
  _EVENT_KEY = "event"
  _ERROR_KEY = "error"
  RETURN_KEY = "return"
  _RETURN_KEY = "return"
  ACTUAL_KEY = "actual"
  _ACTUAL_KEY = "actual"
  _ERROR_CLASS_KEY = "class"
  _ERROR_DESC_KEY = "desc"
  _EXECUTE_KEY = "execute"
  _ARGUMENTS_KEY = "arguments"
  _CAPABILITIES_COMMAND = "qmp_capabilities"
  _MESSAGE_END_TOKEN = "\r\n"

Inherited from MonitorSocket (private): _SOCKET_TIMEOUT

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, monitor_filename)
(Constructor)

source code 

Instantiates the MonitorSocket object.

Parameters:
  • monitor_filename - the filename of the UNIX raw socket on which the monitor (QMP or simple one) is listening
Overrides: object.__init__
(inherited documentation)

connect(self)

source code 

Connects to the QMP monitor.

Connects to the UNIX socket and makes sure that we can actually send and receive data to the kvm instance via QMP.

Raises:
Overrides: MonitorSocket.connect

_ParseMessage(self, buf)

source code 

Extract and parse a QMP message from the given buffer.

Seeks for a QMP message in the given buf. If found, it parses it and returns it together with the rest of the characters in the buf. If no message is found, returns None and the whole buffer.

Raises:

_Recv(self)

source code 

Receives a message from QMP and decodes the received JSON object.

Returns: QmpMessage
the received message
Raises:

_Send(self, message)

source code 

Encodes and sends a message to KVM using QMP.

Parameters:
  • message (QmpMessage) - message to send to KVM
Raises:

Execute(self, command, arguments=None)

source code 

Executes a QMP command and returns the response of the server.

Parameters:
  • command (str) - the command to execute
  • arguments (dict) - dictionary of arguments to be passed to the command
Returns: dict
dictionary representing the received JSON object
Raises: