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 QmpConnection object.
source code
 
_check_socket(self) source code
 
_check_connection(self)
Make sure that the connection is established.
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
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_DATA_KEY = "data"
  _ERROR_DESC_KEY = "desc"
  _EXECUTE_KEY = "execute"
  _ARGUMENTS_KEY = "arguments"
  _CAPABILITIES_COMMAND = "qmp_capabilities"
  _MESSAGE_END_TOKEN = "\r\n"
  _SOCKET_TIMEOUT = 5
Method Details [hide private]

__init__(self, monitor_filename)
(Constructor)

source code 

Instantiates the QmpConnection object.

Parameters:
  • monitor_filename (string) - the filename of the UNIX raw socket on which the QMP monitor is listening

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:

_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: