def __init__(self, vm, name, serial_type, get_supported_cmds=False, suppress_exceptions=False): """ Connect to the guest agent socket, Also make sure the json module is available. @param vm: The VM object who has this GuestAgent. @param name: Guest agent identifier. @param serial_type: Specific which serial type (firtio or isa) guest agent will use. @param get_supported_cmds: Try to get supported cmd list when initiation. @param suppress_exceptions: If True, ignore VAgentError exception. @raise VAgentConnectError: Raised if the connection fails and suppress_exceptions is False @raise VAgentNotSupportedSerialError: Raised if the serial type is neither 'virtio' nor 'isa' and suppress_exceptions is False @raise VAgentNotSupportedError: Raised if json isn't available and suppress_exceptions is False """ try: if serial_type == "virtio": filename = vm.get_virtio_port_filename(name) elif serial_type == "isa": filename = vm.get_serial_console_filename(name) else: raise VAgentNotSupportedSerialError("Not supported serial type" "'%s'" % serial_type) Monitor.__init__(self, name, filename) # Make sure json is available try: json except NameError: raise VAgentNotSupportedError("guest agent requires the json" " module (Python 2.6 and up)") # Set a reference to the VM object that has this GuestAgent. self.vm = vm if get_supported_cmds: self._get_supported_cmds() except VAgentError, e: self._close_sock() if suppress_exceptions: logging.warn(e) else: raise
def testTwoNodes(self): d = "2 nodes\n" + \ "node 0 cpus: 0 2 4\n" + \ "node 0 size: 12 MB\n" + \ "node 1 cpus: 1 3 5\n" + \ "node 1 size: 34 MB\n" r = Monitor.parse_info_numa(d) self.assertEquals(r, [(12, set([0, 2, 4])), (34, set([1, 3, 5]))])
def testZeroNodes(self): d = "0 nodes\n" r = Monitor.parse_info_numa(d) self.assertEquals(r, [])