import argparse
import base64
+import errno
import os
import random
import sys
from qemu import qmp
+# This script has not seen many patches or careful attention in quite
+# some time. If you would like to improve it, please review the design
+# carefully and add docstrings at that point in time. Until then:
+
+# pylint: disable=missing-docstring
+
+
class QemuGuestAgent(qmp.QEMUMonitorProtocol):
def __getattr__(self, name):
def wrapper(**kwds):
return '\n'.join(msgs)
- def __gen_ipv4_netmask(self, prefixlen):
+ @classmethod
+ def __gen_ipv4_netmask(cls, prefixlen):
mask = int('1' * prefixlen + '0' * (32 - prefixlen), 2)
return '.'.join([str(mask >> 24),
str((mask >> 16) & 0xff),
def _cmd_ifconfig(client, args):
+ assert not args
print(client.ifconfig())
def _cmd_info(client, args):
+ assert not args
print(client.info())
def _cmd_shutdown(client, args):
+ assert not args
client.shutdown()
def _cmd_halt(client, args):
+ assert not args
client.shutdown('halt')
def _cmd_reboot(client, args):
+ assert not args
client.shutdown('reboot')
try:
client = QemuGuestAgentClient(address)
except OSError as err:
- import errno
-
print(err)
if err.errno == errno.ECONNREFUSED:
print('Hint: qemu is not running?')