Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
    def __init__(self,
                 vm,
                 name="org.qemu.guest_agent.0",
                 filename=None,
                 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 filename: Guest agent socket filename.
        @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 VAgentProtocolError: Raised if the no QMP greeting message is
                received and suppress_exceptions is False
        @raise VAgentNotSupportedError: Raised if json isn't available and
                suppress_exceptions is False
        """
        try:
            if not filename:
                filename = vm.get_virtio_port_filename(name)

            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
Ejemplo n.º 4
0
    def __init__(self, vm, name="org.qemu.guest_agent.0", filename=None,
                 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 filename: Guest agent socket filename.
        @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 VAgentProtocolError: Raised if the no QMP greeting message is
                received and suppress_exceptions is False
        @raise VAgentNotSupportedError: Raised if json isn't available and
                suppress_exceptions is False
        """
        try:
            if not filename:
                filename = vm.get_virtio_port_filename(name)

            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