All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sun.xml.ws.commons.virtualbox.IConsole Maven / Gradle / Ivy


package com.sun.xml.ws.commons.virtualbox;

import java.util.List;
import java.util.UUID;
import javax.xml.ws.WebServiceException;


/**
 * The IConsole interface represents an interface to control virtual
 *       machine execution.
 * 
 *       The console object that implements the IConsole interface is obtained
 *       from a session object after the session for the given machine has been
 *       opened using one of,ormethdods.
 * 
 *       Methods of the IConsole interface allow the caller to query the current
 *       virtual machine execution state, pause the machine or power it down, save
 *       the machine state or take a snapshot, attach and detach removable media
 *       and so on.
 * 
 */
public class IConsole {

    public final VboxPortType port;
    public final String _this;

    public IConsole(String _this, VboxPortType port) {
        
        this._this = _this;
        this.port = port;
    
    }

    /**
     * Machine object this console is sessioned with.
     * 
     */
    public IMachine getMachine() {
        try {
            String retVal = port.iConsoleGetMachine(_this);
            return new IMachine(retVal, port);
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Current execution state of the machine.
     * 
     */
    public MachineState getState() {
        try {
            MachineState retVal = port.iConsoleGetState(_this);
            return retVal;
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Virtual keyboard object.
     * 
     */
    public IKeyboard getKeyboard() {
        try {
            String retVal = port.iConsoleGetKeyboard(_this);
            return new IKeyboard(retVal, port);
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Virtual mouse object.
     * 
     */
    public IMouse getMouse() {
        try {
            String retVal = port.iConsoleGetMouse(_this);
            return new IMouse(retVal, port);
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Collection of USB devices currently attached to the virtual
     *         USB controller.
     * 
     */
    public List getUSBDevices() {
        try {
            ArrayOfIUSBDevice retVal = port.iConsoleGetUSBDevices(_this);
            return Helper.wrap(IUSBDevice.class, port, ((retVal == null)?null:retVal.getArray()));
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * List of USB devices currently attached to the remote VRDP client.
     *         Once a new device is physically attached to the remote host computer,
     *         it appears in this list and remains there until detached.
     * 
     */
    public List getRemoteUSBDevices() {
        try {
            ArrayOfIHostUSBDevice retVal = port.iConsoleGetRemoteUSBDevices(_this);
            return Helper.wrap(IHostUSBDevice.class, port, ((retVal == null)?null:retVal.getArray()));
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Collection of shared folders for the current session.  These folders
     *         are called transient shared folders because they are available to the
     *         guest OS running inside the associated virtual machine only for the
     *         duration of the session (as opposed towhich represent permanent shared
     *         folders). When the session is closed (e.g. the machine is powered down),
     *         these folders are automatically discarded.
     * 
     *         New shared folders are added to the collection using. Existing shared folders can be
     *         removed using.
     * 
     */
    public List getSharedFolders() {
        try {
            ArrayOfISharedFolder retVal = port.iConsoleGetSharedFolders(_this);
            return ((retVal == null)?null:retVal.getArray());
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Interface that provides information on Remote Display (VRDP) connection.
     * 
     */
    public IRemoteDisplayInfo getRemoteDisplayInfo() {
        try {
            IRemoteDisplayInfo retVal = port.iConsoleGetRemoteDisplayInfo(_this);
            return retVal;
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Starts the virtual machine execution using the current machine
     *         state (i.e. its current execution state, current settings and
     *         current hard disks).
     * 
     *         If the machine is powered off or aborted, the execution will
     *         start from the beginning (as if the real hardware were just
     *         powered on).
     * 
     *         If the machine is in thestate,
     *         it will continue its execution the point where the state has
     *         beem saved.
     * 
     * @return
     *     Progress object to track the operation completion.
     */
    public IProgress powerUp() {
        try {
            String retVal = port.iConsolePowerUp("_this");
            return new IProgress(retVal, port);
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Stops the virtual machine execution.
     *         After this operation completes, the machine will go to the
     *         PoweredOff state.
     * 
     */
    public void powerDown() {
        try {
            port.iConsolePowerDown("_this");
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Resets the virtual machine.
     * 
     */
    public void reset() {
        try {
            port.iConsoleReset("_this");
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Pauses the virtual machine execution.
     * 
     */
    public void pause() {
        try {
            port.iConsolePause("_this");
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Resumes the virtual machine execution.
     * 
     */
    public void resume() {
        try {
            port.iConsoleResume("_this");
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Send the ACPI power button event to the guest.
     * 
     */
    public void powerButton() {
        try {
            port.iConsolePowerButton("_this");
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Send the ACPI sleep button event to the guest.
     * 
     */
    public void sleepButton() {
        try {
            port.iConsoleSleepButton("_this");
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Check if the last power button event was handled by guest.
     * 
     * @return
     *     
     */
    public boolean getPowerButtonHandled() {
        try {
            boolean retVal = port.iConsoleGetPowerButtonHandled("_this");
            return retVal;
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Saves the current execution state of a running virtual machine
     *         and stops its executiuon.
     * 
     *         After this operation completes, the machine will go to the
     *         Saved state. Next time it is powered up, this state will
     *         be restored and the machine will continue its execution from
     *         the place where it was saved.
     * 
     *         This operation differs from taking a snapshot to the effect
     *         that it doesn't create new differencing hard disks. Also, once
     *         the machine is powered up from the state saved using this method,
     *         the saved state is deleted, so it will be impossible to return
     *         to this state later.
     * 
     * @return
     *     Progress object to track the operation completion.
     */
    public IProgress saveState() {
        try {
            String retVal = port.iConsoleSaveState("_this");
            return new IProgress(retVal, port);
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Associates the given saved state file to the virtual machine.
     * 
     *         On success, the machine will go to the Saved state. Next time it is
     *         powered up, it will be restored from the adopted saved state and
     *         continue execution from the place where the saved state file was
     *         created.
     * 
     *         The specified saved state file path may be full or relative to the
     *         folder the VM normally saves the state to (usually,).
     * 
     * @param savedStateFile
     *     Path to the saved state file to adopt.
     */
    public void adoptSavedState(String savedStateFile) {
        try {
            port.iConsoleAdoptSavedState("_this", savedStateFile);
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Discards (deletes) the saved state of the virtual machine
     *         previously created by. Next time the
     *         machine is powered up, a clean boot will occur.
     * 
     */
    public void discardSavedState() {
        try {
            port.iConsoleDiscardSavedState("_this");
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Gets the current activity type of a given device or device group.
     * 
     * @param type
     *     
     * @return
     *     
     */
    public DeviceActivity getDeviceActivity(DeviceType type) {
        try {
            DeviceActivity retVal = port.iConsoleGetDeviceActivity("_this", type);
            return retVal;
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Attaches a host USB device with the given UUID to the
     *         USB controller of the virtual machine.
     * 
     *         The device needs to be in one of the following states:,or,
     *         otherwise an error is immediately returned.
     * 
     *         When the device state is, an error may also
     *         be returned if the host computer refuses to release it for some reason.
     * 
     * @param id
     *     UUID of the host USB device to attach.
     */
    public void attachUSBDevice(UUID id) {
        try {
            port.iConsoleAttachUSBDevice("_this", id.toString());
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Detaches an USB device with the given UUID from the USB controller
     *         oif the virtual machine.
     * 
     *         After this method succeeds, the VirtualBox server reinitiates
     *         all USB filters as if the device were just physically attached
     *         to the host, but filters of this machine are ignored to avoid
     *         a possible automatic reattachment.
     * 
     * @param id
     *     UUID of the USB device to detach.
     * @return
     *     Detached USB device.
     */
    public IUSBDevice detachUSBDevice(UUID id) {
        try {
            String retVal = port.iConsoleDetachUSBDevice("_this", id.toString());
            return new IUSBDevice(retVal, port);
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Creates a transient new shared folder by associating the given logical
     *         name with the given host path, adds it to the collection of shared
     *         folders and starts sharing it. Refer to the description ofto read more about logical names.
     * 
     * @param writable
     *     Whether the share is writable or readonly
     * @param name
     *     Unique logical name of the shared folder.
     * @param hostPath
     *     Full path to the shared folder in the host file system.
     */
    public void createSharedFolder(String name, String hostPath, boolean writable) {
        try {
            port.iConsoleCreateSharedFolder("_this", name, hostPath, writable);
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Removes a transient shared folder with the given name previously
     *         created byfrom the collection of
     *         shared folders and stops sharing it.
     * 
     * @param name
     *     Logical name of the shared folder to remove.
     */
    public void removeSharedFolder(String name) {
        try {
            port.iConsoleRemoveSharedFolder("_this", name);
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Saves the current execution state and all settings of the
     *         machine and creates differencing images for all
     *         normal (non-independent) hard disks.
     * 
     *         This method can be called for a PoweredOff, Saved, Running or
     *         Paused virtual machine. When the machine is PoweredOff, an
     *         offlineis created,
     *         in all other cases -- an online snapshot.
     * 
     *         The taken snapshot is always based on theof the associated virtual machine and becomes
     *         a new current snapshot.
     * 
     * @param description
     *     Optional description of the snapshot.
     * @param name
     *     Short name for the snapshot.
     * @return
     *     Progress object to track the operation completion.
     */
    public IProgress takeSnapshot(String name, String description) {
        try {
            String retVal = port.iConsoleTakeSnapshot("_this", name, description);
            return new IProgress(retVal, port);
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * Starts discarding the specified snapshot. The execution state
     *         and settings of the associated machine stored in the snapshot
     *         will be deleted. The contents of all differencing hard disks of
     *         this snapshot will be merged with the contents of their
     *         dependent child hard disks to keep the, disks valid (in other
     *         words, all changes represented by hard disks being discarded
     *         will be propagated to their child hard disks). After that, this
     *         snapshot's differencing hard disks will be deleted. The parent
     *         of this snapshot will become a new parent for all its child
     *         snapshots.
     * 
     *         If the discarded snapshot is the current one, its parent
     *         snapshot will become a new current snapshot. The current machine
     *         state is not directly affected in this case, except that
     *         currently attached differencing hard disks based on hard disks
     *         of the discarded snapshot will be also merged as described
     *         above.
     * 
     *         If the discarded snapshot is the first one (the root snapshot)
     *         and it has exactly one child snapshot, this child snapshot will
     *         become the first snapshot after discarding. If there are no
     *         children at all (i.e. the first snapshot is the only snapshot of
     *         the machine), both the current and the first snapshot of the
     *         machine will be set to null. In all other cases, the first
     *         snapshot cannot be discarded.
     * 
     *         You cannot discard the snapshot if it
     *         stores(non-differencing)
     *         hard disks that have differencing hard disks based on them. Snapshots of
     *         such kind can be discarded only when every normal hard disk has either
     *         no children at all or exactly one child. In the former case, the normal
     *         hard disk simply becomes unused (i.e. not attached to any VM). In the
     *         latter case, it receives all the changes strored in the child hard disk,
     *         and then it replaces the child hard disk in the configuration of the
     *         corresponding snapshot or machine.
     * 
     *         Also, you cannot discard the snapshot if it stores hard disks
     *         (of any type) having differencing child hard disks that belong
     *         to other machines. Such snapshots can be only discarded after
     *         you discard all snapshots of other machines containing "foreign"
     *         child disks, or detach these "foreign" child disks from machines
     *         they are attached to.
     * 
     *         One particular example of the snapshot storing normal hard disks
     *         is the first snapshot of a virtual machine that had normal hard
     *         disks attached when taking the snapshot. Be careful when
     *         discarding such snapshots because this implicitly commits
     *         changes (made since the snapshot being discarded has been taken)
     *         to normal hard disks (as described above), which may be not what
     *         you want.
     * 
     *         The virtual machine is put to
     *         thestate until
     *         the discard operation is completed.
     * 
     * @param id
     *     UUID of the snapshot to discard.
     * @return
     *     Progress object to track the operation completion.
     */
    public IProgress discardSnapshot(UUID id) {
        try {
            String retVal = port.iConsoleDiscardSnapshot("_this", id.toString());
            return new IProgress(retVal, port);
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * This operation is similar tobut
     *         affects the current machine state. This means that the state stored in
     *         the current snapshot will become a new current state, and all current
     *         settings of the machine and changes stored in differencing hard disks
     *         will be lost.
     * 
     *         After this operation is successfully completed, new empty differencing
     *         hard disks are created for all normal hard disks of the machine.
     * 
     *         If the current snapshot of the machine is an online snapshot, the
     *         machine will go to the, so that the next time it is powered on, the execution
     *         state will be restored from the current snapshot.
     * 
     * @return
     *     Progress object to track the operation completion.
     */
    public IProgress discardCurrentState() {
        try {
            String retVal = port.iConsoleDiscardCurrentState("_this");
            return new IProgress(retVal, port);
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

    /**
     * This method is equivalent to
     *         doing(., ...) followed by.
     * 
     *         As a result, the machine will be fully restored from the
     *         snapshot preceeding the current snapshot, while both the current
     *         snapshot and the current machine state will be discarded.
     * 
     *         If the current snapshot is the first snapshot of the machine (i.e. it
     *         has the only snapshot), the current machine state will be
     *         discardeddiscarding the snapshot. In other words, the
     *         machine will be restored from its last snapshot, before discarding
     *         it. This differs from performing a singlecall (note that nowill be possible after it) to the
     *         effect that the latter will preserve the current state instead of
     *         discarding it.
     * 
     *         Unless explicitly mentioned otherwise, all remarks and
     *         limitations of the above two methods also apply to this method.
     * 
     * @return
     *     Progress object to track the operation completion.
     */
    public IProgress discardCurrentSnapshotAndState() {
        try {
            String retVal = port.iConsoleDiscardCurrentSnapshotAndState("_this");
            return new IProgress(retVal, port);
        } catch (com.sun.xml.ws.commons.virtualbox.InvalidObjectFaultMsg e) {
            throw new WebServiceException(e);
        } catch (com.sun.xml.ws.commons.virtualbox.RuntimeFaultMsg e) {
            throw new WebServiceException(e);
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy