Search in sources :

Example 1 with GraphicsInfo

use of org.ovirt.engine.core.common.businessentities.GraphicsInfo in project ovirt-engine by oVirt.

the class VncConsoleModel method invokeConsole.

private void invokeConsole() {
    final GraphicsInfo vncInfo = getEntity().getGraphicsInfos().get(GraphicsType.VNC);
    if (vncInfo == null) {
        // $NON-NLS-1$
        throw new IllegalStateException("Trying to invoke VNC console but VM GraphicsInfo is null.");
    }
    vncImpl.getOptions().setVmId(getEntity().getId());
    ConfigureConsoleOptionsParams parameters = new ConfigureConsoleOptionsParams(vncImpl.getOptions(), true);
    parameters.setEngineBaseUrl(FrontendUrlUtils.getRootURL());
    parameters.setConsoleClientResourcesUrl(dynamicMessages.consoleClientResourcesUrl());
    Frontend.getInstance().runQuery(QueryType.ConfigureConsoleOptions, parameters, new ShowErrorAsyncQuery(returnValue -> {
        ConsoleOptions configuredOptions = ((QueryReturnValue) returnValue).getReturnValue();
        // overriding global server settings by frontend settings
        configuredOptions.setRemapCtrlAltDelete(vncImpl.getOptions().isRemapCtrlAltDelete());
        vncImpl.setOptions(configuredOptions);
        vncImpl.getOptions().setTitle(getClientTitle());
        vncImpl.getOptions().setVmName(getEntity().getName());
        vncImpl.invokeClient();
    }));
}
Also used : DynamicMessages(org.ovirt.engine.ui.uicommonweb.DynamicMessages) QueryType(org.ovirt.engine.core.common.queries.QueryType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConsoleUtils(org.ovirt.engine.ui.uicommonweb.ConsoleUtils) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) ConfigureConsoleOptionsParams(org.ovirt.engine.core.common.queries.ConfigureConsoleOptionsParams) FrontendUrlUtils(org.ovirt.engine.ui.frontend.utils.FrontendUrlUtils) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo) ConsoleOptions(org.ovirt.engine.core.common.console.ConsoleOptions) Frontend(org.ovirt.engine.ui.frontend.Frontend) VM(org.ovirt.engine.core.common.businessentities.VM) ShowErrorAsyncQuery(org.ovirt.engine.ui.uicommonweb.ShowErrorAsyncQuery) BaseCommandTarget(org.ovirt.engine.ui.uicommonweb.BaseCommandTarget) TypeResolver(org.ovirt.engine.ui.uicommonweb.TypeResolver) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Model(org.ovirt.engine.ui.uicommonweb.models.Model) ConfigureConsoleOptionsParams(org.ovirt.engine.core.common.queries.ConfigureConsoleOptionsParams) ShowErrorAsyncQuery(org.ovirt.engine.ui.uicommonweb.ShowErrorAsyncQuery) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo) ConsoleOptions(org.ovirt.engine.core.common.console.ConsoleOptions)

Example 2 with GraphicsInfo

use of org.ovirt.engine.core.common.businessentities.GraphicsInfo in project ovirt-engine by oVirt.

the class MainVirtualMachineView method initTable.

void initTable() {
    getTable().enableColumnResizing();
    VmStatusColumn<VM> statusIconColumn = new VmStatusColumn<>();
    statusIconColumn.setContextMenuTitle(constants.statusIconVm());
    statusIconColumn.makeSortable(VmConditionFieldAutoCompleter.STATUS);
    // $NON-NLS-1$
    getTable().addColumn(statusIconColumn, constants.empty(), "35px");
    VmTypeColumn typeColumn = new VmTypeColumn();
    typeColumn.setContextMenuTitle(constants.typeVm());
    typeColumn.makeSortable(VmConditionFieldAutoCompleter.TYPE);
    // $NON-NLS-1$
    getTable().addColumn(typeColumn, constants.empty(), "60px");
    AbstractTextColumn<VM> nameColumn = new AbstractLinkColumn<VM>(new FieldUpdater<VM, String>() {

        @Override
        public void update(int index, VM vm, String value) {
            Map<String, String> parameters = new HashMap<>();
            parameters.put(FragmentParams.NAME.getName(), vm.getName());
            // The link was clicked, now fire an event to switch to details.
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.virtualMachineGeneralSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(VM object) {
            return object.getName();
        }
    };
    nameColumn.makeSortable(VmConditionFieldAutoCompleter.NAME);
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameVm(), "120px");
    CommentColumn<VM> commentColumn = new CommentColumn<>();
    getTable().addColumnWithHtmlHeader(commentColumn, SafeHtmlUtils.fromSafeConstant(constants.commentLabel()), // $NON-NLS-1$
    "75px");
    AbstractTextColumn<VM> hostColumn = new AbstractLinkColumn<VM>(new FieldUpdater<VM, String>() {

        @Override
        public void update(int index, VM vm, String value) {
            Map<String, String> parameters = new HashMap<>();
            parameters.put(FragmentParams.NAME.getName(), vm.getRunOnVdsName());
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.hostGeneralSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(VM object) {
            return object.getRunOnVdsName();
        }
    };
    hostColumn.makeSortable(VmConditionFieldAutoCompleter.HOST);
    // $NON-NLS-1$
    getTable().addColumn(hostColumn, constants.hostVm(), "120px");
    AbstractTextColumn<VM> ipColumn = new AbstractTextColumn<VM>() {

        @Override
        public String getValue(VM object) {
            return object.getIp();
        }
    };
    ipColumn.makeSortable(VmConditionFieldAutoCompleter.IP);
    // $NON-NLS-1$
    getTable().addColumn(ipColumn, constants.ipVm(), "120px");
    AbstractTextColumn<VM> fqdnColumn = new AbstractTextColumn<VM>() {

        @Override
        public String getValue(VM object) {
            return object.getFqdn();
        }
    };
    fqdnColumn.makeSortable(VmConditionFieldAutoCompleter.FQDN);
    // $NON-NLS-1$
    getTable().addColumn(fqdnColumn, constants.fqdn(), "120px");
    AbstractTextColumn<VM> clusterColumn = new AbstractLinkColumn<VM>(new FieldUpdater<VM, String>() {

        @Override
        public void update(int index, VM vm, String value) {
            Map<String, String> parameters = new HashMap<>();
            parameters.put(FragmentParams.NAME.getName(), vm.getClusterName());
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.clusterGeneralSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(VM object) {
            return object.getClusterName();
        }
    };
    clusterColumn.makeSortable(VmConditionFieldAutoCompleter.CLUSTER);
    // $NON-NLS-1$
    getTable().addColumn(clusterColumn, constants.clusterVm(), "120px");
    AbstractTextColumn<VM> dcColumn = new AbstractLinkColumn<VM>(new FieldUpdater<VM, String>() {

        @Override
        public void update(int index, VM vm, String value) {
            Map<String, String> parameters = new HashMap<>();
            parameters.put(FragmentParams.NAME.getName(), vm.getStoragePoolName());
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.dataCenterStorageSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(VM object) {
            return object.getStoragePoolName();
        }
    };
    dcColumn.makeSortable(VmConditionFieldAutoCompleter.DATACENTER);
    // $NON-NLS-1$
    getTable().addColumn(dcColumn, constants.dcVm(), "120px");
    getTable().addColumn(new ColumnResizeTableLineChartProgressBar<VM>(getTable(), VmConditionFieldAutoCompleter.MEM_USAGE) {

        @Override
        protected List<Integer> getProgressValues(VM object) {
            return object.getMemoryUsageHistory();
        }
    }, constants.memoryVm(), // $NON-NLS-1$
    "80px");
    getTable().addColumn(new ColumnResizeTableLineChartProgressBar<VM>(getTable(), VmConditionFieldAutoCompleter.CPU_USAGE) {

        @Override
        protected List<Integer> getProgressValues(VM object) {
            return object.getCpuUsageHistory();
        }
    }, constants.cpuVm(), // $NON-NLS-1$
    "80px");
    getTable().addColumn(new ColumnResizeTableLineChartProgressBar<VM>(getTable(), VmConditionFieldAutoCompleter.NETWORK_USAGE) {

        @Override
        protected List<Integer> getProgressValues(VM object) {
            return object.getNetworkUsageHistory();
        }
    }, constants.networkVm(), // $NON-NLS-1$
    "80px");
    AbstractTextColumn<VM> graphicsColumn = new AbstractEnumColumn<VM, UnitVmModel.GraphicsTypes>() {

        @Override
        protected UnitVmModel.GraphicsTypes getRawValue(VM vm) {
            if ((vm.getStatus() == VMStatus.Down) || (vm.getStatus() == VMStatus.ImageLocked)) {
                return UnitVmModel.GraphicsTypes.NONE;
            }
            Map<GraphicsType, GraphicsInfo> graphicsInfos = vm.getGraphicsInfos();
            return UnitVmModel.GraphicsTypes.fromGraphicsTypes(graphicsInfos.keySet());
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(graphicsColumn, constants.graphicsVm(), "70px");
    AbstractTextColumn<VM> statusColumn = new AbstractEnumColumn<VM, VMStatus>() {

        @Override
        public VMStatus getRawValue(VM object) {
            return object.getStatus();
        }

        @Override
        public String getValue(VM vm) {
            if (vm.getStatus() == VMStatus.MigratingFrom) {
                // will be rendered by progress column
                return null;
            }
            if (vm.getBackgroundOperationDescription() != null) {
                // will be rendered by progress column
                return null;
            }
            return super.getValue(vm);
        }
    };
    MigrationProgressColumn migrationProgressColumn = new MigrationProgressColumn();
    ImportProgressColumn importProgressColumn = new ImportProgressColumn();
    ReasonColumn<VM> reasonColumn = new ReasonColumn<VM>() {

        @Override
        protected String getReason(VM value) {
            return value.getStopReason();
        }
    };
    List<HasCell<VM, ?>> list = new ArrayList<>();
    list.add(statusColumn);
    list.add(reasonColumn);
    list.add(migrationProgressColumn);
    list.add(importProgressColumn);
    Cell<VM> compositeCell = new StatusCompositeCell<>(list);
    AbstractColumn<VM, VM> statusTextColumn = new AbstractColumn<VM, VM>(compositeCell) {

        @Override
        public VM getValue(VM object) {
            return object;
        }

        @Override
        public SafeHtml getTooltip(VM value) {
            String stopReason = value.getStopReason();
            if (stopReason != null && !stopReason.trim().isEmpty()) {
                return SafeHtmlUtils.fromString(stopReason);
            }
            return null;
        }
    };
    statusTextColumn.makeSortable(VmConditionFieldAutoCompleter.STATUS);
    // $NON-NLS-1$
    getTable().addColumn(statusTextColumn, constants.statusVm(), "120px");
    AbstractTextColumn<VM> uptimeColumn = new AbstractUptimeColumn<VM>() {

        @Override
        public Double getRawValue(VM object) {
            return object.getElapsedTime();
        }
    };
    uptimeColumn.makeSortable(VmConditionFieldAutoCompleter.UPTIME);
    // $NON-NLS-1$
    getTable().addColumn(uptimeColumn, constants.uptimeVm(), "100px");
    AbstractTextColumn<VM> descriptionColumn = new AbstractTextColumn<VM>() {

        @Override
        public String getValue(VM object) {
            return object.getDescription();
        }
    };
    descriptionColumn.makeSortable(VmConditionFieldAutoCompleter.DESCRIPTION);
    // $NON-NLS-1$
    getTable().addColumn(descriptionColumn, constants.description(), "150px");
}
Also used : HasCell(com.google.gwt.cell.client.HasCell) ArrayList(java.util.ArrayList) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo) VmStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VmStatusColumn) AbstractUptimeColumn(org.ovirt.engine.ui.webadmin.widget.table.column.AbstractUptimeColumn) UnitVmModel(org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ArrayList(java.util.ArrayList) List(java.util.List) VmTypeColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VmTypeColumn) CommentColumn(org.ovirt.engine.ui.webadmin.widget.table.column.CommentColumn) ImportProgressColumn(org.ovirt.engine.ui.webadmin.widget.table.column.ImportProgressColumn) MigrationProgressColumn(org.ovirt.engine.ui.webadmin.widget.table.column.MigrationProgressColumn) AbstractColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractColumn) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) VM(org.ovirt.engine.core.common.businessentities.VM) StatusCompositeCell(org.ovirt.engine.ui.common.widget.table.cell.StatusCompositeCell) ReasonColumn(org.ovirt.engine.ui.webadmin.widget.table.column.ReasonColumn) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with GraphicsInfo

use of org.ovirt.engine.core.common.businessentities.GraphicsInfo in project ovirt-engine by oVirt.

the class ConfigureConsoleOptionsQueryTest method mockVm.

private VM mockVm(GraphicsType graphicsType) {
    VM vm = new VM();
    vm.setId(Guid.Empty);
    vm.getGraphicsInfos().put(graphicsType, new GraphicsInfo().setIp("host").setPort(5901));
    vm.setStatus(VMStatus.Up);
    return vm;
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo)

Example 4 with GraphicsInfo

use of org.ovirt.engine.core.common.businessentities.GraphicsInfo in project ovirt-engine by oVirt.

the class VdsBrokerObjectsBuilder method updateGraphicsInfoFromConf.

/**
 * Updates graphics runtime information according to vm.conf vdsm structure. It's used with legacy VDSMs that have
 * no notion about graphics device.
 * @param vm - VmDynamic to update
 * @param struct - data from VDSM
 */
private static void updateGraphicsInfoFromConf(VmDynamic vm, Map<String, Object> struct) {
    GraphicsType vmGraphicsType = parseGraphicsType(struct);
    if (vmGraphicsType == null) {
        log.debug("graphics data missing in XML.");
        return;
    }
    GraphicsInfo graphicsInfo = new GraphicsInfo();
    if (struct.containsKey(VdsProperties.display_port)) {
        try {
            graphicsInfo.setPort(Integer.parseInt(struct.get(VdsProperties.display_port).toString()));
        } catch (NumberFormatException e) {
            log.error("vm display_port value illegal : {0}", struct.get(VdsProperties.display_port));
        }
    } else if (struct.containsKey(VdsProperties.display)) {
        try {
            graphicsInfo.setPort(VNC_START_PORT + Integer.parseInt(struct.get(VdsProperties.display).toString()));
        } catch (NumberFormatException e) {
            log.error("vm display value illegal : {0}", struct.get(VdsProperties.display));
        }
    }
    if (struct.containsKey(VdsProperties.display_secure_port)) {
        try {
            graphicsInfo.setTlsPort(Integer.parseInt(struct.get(VdsProperties.display_secure_port).toString()));
        } catch (NumberFormatException e) {
            log.error("vm display_secure_port value illegal : {0}", struct.get(VdsProperties.display_secure_port));
        }
    }
    if (struct.containsKey(VdsProperties.displayIp)) {
        graphicsInfo.setIp((String) struct.get(VdsProperties.displayIp));
    }
    vm.getGraphicsInfos().put(vmGraphicsType, graphicsInfo);
}
Also used : GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo)

Example 5 with GraphicsInfo

use of org.ovirt.engine.core.common.businessentities.GraphicsInfo in project ovirt-engine by oVirt.

the class SpiceConsoleModel method invokeClient.

public void invokeClient() {
    final GraphicsInfo spiceInfo = getEntity().getGraphicsInfos().get(GraphicsType.SPICE);
    if (spiceInfo == null) {
        // $NON-NLS-1$
        throw new IllegalStateException("Trying to invoke SPICE console but VM GraphicsInfo is null.");
    }
    final ConsoleOptions options = getSpiceImpl().getOptions();
    options.setVmId(getEntity().getId());
    // configure options
    ConfigureConsoleOptionsParams parameters = new ConfigureConsoleOptionsParams(options, true);
    parameters.setEngineBaseUrl(FrontendUrlUtils.getRootURL());
    parameters.setConsoleClientResourcesUrl(dynamicMessages.consoleClientResourcesUrl());
    Frontend.getInstance().runQuery(QueryType.ConfigureConsoleOptions, parameters, new ShowErrorAsyncQuery(returnValue -> {
        final ConsoleOptions configuredOptions = returnValue.getReturnValue();
        // overriding global server settings by frontend settings
        configuredOptions.setRemapCtrlAltDelete(options.isRemapCtrlAltDelete());
        configuredOptions.setTitle(getClientTitle());
        configuredOptions.setVmName(getEntity().getName());
        configuredOptions.setFullScreen(options.isFullScreen());
        configuredOptions.setSmartcardEnabledOverridden(options.isSmartcardEnabledOverridden());
        if (!configuredOptions.isSpiceProxyEnabled()) {
            // override spice proxy from backend
            configuredOptions.setSpiceProxy(null);
        }
        try {
            getSpiceImpl().setOptions(configuredOptions);
            getSpiceImpl().invokeClient();
        } catch (RuntimeException ex) {
            // $NON-NLS-1$
            getLogger().error("Exception on Spice connect", ex);
        }
    }));
}
Also used : DynamicMessages(org.ovirt.engine.ui.uicommonweb.DynamicMessages) QueryType(org.ovirt.engine.core.common.queries.QueryType) ILogger(org.ovirt.engine.ui.uicommonweb.ILogger) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) ConsoleUtils(org.ovirt.engine.ui.uicommonweb.ConsoleUtils) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo) ConsoleOptions(org.ovirt.engine.core.common.console.ConsoleOptions) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) SsoMethod(org.ovirt.engine.core.common.businessentities.SsoMethod) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) Model(org.ovirt.engine.ui.uicommonweb.models.Model) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfigureConsoleOptionsParams(org.ovirt.engine.core.common.queries.ConfigureConsoleOptionsParams) FrontendUrlUtils(org.ovirt.engine.ui.frontend.utils.FrontendUrlUtils) EngineError(org.ovirt.engine.core.common.errors.EngineError) VM(org.ovirt.engine.core.common.businessentities.VM) ShowErrorAsyncQuery(org.ovirt.engine.ui.uicommonweb.ShowErrorAsyncQuery) VmOperationParameterBase(org.ovirt.engine.core.common.action.VmOperationParameterBase) BaseCommandTarget(org.ovirt.engine.ui.uicommonweb.BaseCommandTarget) TypeResolver(org.ovirt.engine.ui.uicommonweb.TypeResolver) EventDefinition(org.ovirt.engine.ui.uicompat.EventDefinition) GraphicsType(org.ovirt.engine.core.common.businessentities.GraphicsType) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) ConfigureConsoleOptionsParams(org.ovirt.engine.core.common.queries.ConfigureConsoleOptionsParams) ShowErrorAsyncQuery(org.ovirt.engine.ui.uicommonweb.ShowErrorAsyncQuery) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo) ConsoleOptions(org.ovirt.engine.core.common.console.ConsoleOptions)

Aggregations

GraphicsInfo (org.ovirt.engine.core.common.businessentities.GraphicsInfo)20 GraphicsType (org.ovirt.engine.core.common.businessentities.GraphicsType)8 VM (org.ovirt.engine.core.common.businessentities.VM)7 Map (java.util.Map)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)2 Entry (java.util.Map.Entry)2 Vm (org.ovirt.engine.api.model.Vm)2 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)2 VmDeviceId (org.ovirt.engine.core.common.businessentities.VmDeviceId)2 ConsoleOptions (org.ovirt.engine.core.common.console.ConsoleOptions)2 ConfigureConsoleOptionsParams (org.ovirt.engine.core.common.queries.ConfigureConsoleOptionsParams)2 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)2 QueryType (org.ovirt.engine.core.common.queries.QueryType)2 Frontend (org.ovirt.engine.ui.frontend.Frontend)2 FrontendUrlUtils (org.ovirt.engine.ui.frontend.utils.FrontendUrlUtils)2 BaseCommandTarget (org.ovirt.engine.ui.uicommonweb.BaseCommandTarget)2 ConsoleUtils (org.ovirt.engine.ui.uicommonweb.ConsoleUtils)2 DynamicMessages (org.ovirt.engine.ui.uicommonweb.DynamicMessages)2