Search in sources :

Example 1 with GraphicsType

use of org.ovirt.engine.api.model.GraphicsType in project ovirt-engine by oVirt.

the class BackendGraphicsConsoleHelper method remove.

public static Response remove(BackendResource resource, Guid guid, String consoleId) {
    List<GraphicsDevice> devices = DisplayHelper.getGraphicsDevicesForEntity(resource, guid, false);
    if (devices == null) {
        throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
    }
    org.ovirt.engine.core.common.businessentities.GraphicsType graphicsType = asGraphicsType(consoleId);
    return devices.stream().filter(device -> device.getGraphicsType().equals(graphicsType)).findFirst().map(device -> resource.performAction(ActionType.RemoveGraphicsAndVideoDevices, new GraphicsParameters(device))).orElseThrow(() -> new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build()));
}
Also used : SetVmTicketParameters(org.ovirt.engine.core.common.action.SetVmTicketParameters) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) EnumMap(java.util.EnumMap) Guid(org.ovirt.engine.core.compat.Guid) GraphicsConsole(org.ovirt.engine.api.model.GraphicsConsole) DisplayHelper(org.ovirt.engine.api.restapi.util.DisplayHelper) Ticketing.generateOTP(org.ovirt.engine.core.utils.Ticketing.generateOTP) Supplier(java.util.function.Supplier) Ticket(org.ovirt.engine.api.model.Ticket) GraphicsParameters(org.ovirt.engine.core.common.action.GraphicsParameters) CreationStatus(org.ovirt.engine.api.model.CreationStatus) GraphicsInfo(org.ovirt.engine.core.common.businessentities.GraphicsInfo) VmMapper(org.ovirt.engine.api.restapi.types.VmMapper) GraphicsType(org.ovirt.engine.api.model.GraphicsType) ActionType(org.ovirt.engine.core.common.action.ActionType) List(java.util.List) GraphicsConsoles(org.ovirt.engine.api.model.GraphicsConsoles) Response(javax.ws.rs.core.Response) Map(java.util.Map) WebApplicationException(javax.ws.rs.WebApplicationException) URI(java.net.URI) HexUtils(org.ovirt.engine.api.restapi.utils.HexUtils) Action(org.ovirt.engine.api.model.Action) GraphicsDevice(org.ovirt.engine.core.common.businessentities.GraphicsDevice) WebApplicationException(javax.ws.rs.WebApplicationException) GraphicsParameters(org.ovirt.engine.core.common.action.GraphicsParameters)

Example 2 with GraphicsType

use of org.ovirt.engine.api.model.GraphicsType in project ovirt-engine by oVirt.

the class BackendVmGraphicsConsoleResource method proxyTicket.

@Override
public Response proxyTicket(Action action) {
    final String plainConsoleId = HexUtils.hex2string(consoleId);
    final GraphicsType graphicsTypeModel = GraphicsType.fromValue(plainConsoleId);
    final org.ovirt.engine.core.common.businessentities.GraphicsType graphicsTypeEntity = VmMapper.map(graphicsTypeModel, null);
    final String ticketValue = getTicket(graphicsTypeEntity);
    if (!action.isSetProxyTicket()) {
        action.setProxyTicket(new ProxyTicket());
    }
    action.getProxyTicket().setValue(ticketValue);
    return Response.ok().entity(action).build();
}
Also used : GraphicsType(org.ovirt.engine.api.model.GraphicsType) BackendGraphicsConsoleHelper.asGraphicsType(org.ovirt.engine.api.restapi.resource.BackendGraphicsConsoleHelper.asGraphicsType) ProxyTicket(org.ovirt.engine.api.model.ProxyTicket)

Example 3 with GraphicsType

use of org.ovirt.engine.api.model.GraphicsType in project ovirt-engine by oVirt.

the class VmMapper method map.

@Mapping(from = Map.Entry.class, to = GraphicsConsole.class)
public static GraphicsConsole map(Map.Entry<org.ovirt.engine.core.common.businessentities.GraphicsType, GraphicsInfo> graphicsInfo, GraphicsConsole template) {
    GraphicsConsole model = template != null ? template : new GraphicsConsole();
    GraphicsType graphicsType = map(graphicsInfo.getKey(), null);
    if (graphicsType != null) {
        model.setId(HexUtils.string2hex(graphicsType.value()));
        model.setProtocol(graphicsType);
    }
    if (graphicsInfo.getValue() != null) {
        model.setPort(graphicsInfo.getValue().getPort());
        model.setTlsPort(graphicsInfo.getValue().getTlsPort());
        model.setAddress(graphicsInfo.getValue().getIp());
    }
    return model;
}
Also used : GraphicsType(org.ovirt.engine.api.model.GraphicsType) GraphicsConsole(org.ovirt.engine.api.model.GraphicsConsole)

Example 4 with GraphicsType

use of org.ovirt.engine.api.model.GraphicsType in project ovirt-engine by oVirt.

the class BackendGraphicsConsoleHelper method asGraphicsType.

public static org.ovirt.engine.core.common.businessentities.GraphicsType asGraphicsType(String consoleId) {
    String consoleString = HexUtils.hex2string(consoleId);
    GraphicsType type = GraphicsType.fromValue(consoleString);
    return VmMapper.map(type, null);
}
Also used : GraphicsType(org.ovirt.engine.api.model.GraphicsType)

Aggregations

GraphicsType (org.ovirt.engine.api.model.GraphicsType)4 GraphicsConsole (org.ovirt.engine.api.model.GraphicsConsole)2 URI (java.net.URI)1 EnumMap (java.util.EnumMap)1 List (java.util.List)1 Map (java.util.Map)1 Supplier (java.util.function.Supplier)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Response (javax.ws.rs.core.Response)1 Action (org.ovirt.engine.api.model.Action)1 CreationStatus (org.ovirt.engine.api.model.CreationStatus)1 GraphicsConsoles (org.ovirt.engine.api.model.GraphicsConsoles)1 ProxyTicket (org.ovirt.engine.api.model.ProxyTicket)1 Ticket (org.ovirt.engine.api.model.Ticket)1 BackendGraphicsConsoleHelper.asGraphicsType (org.ovirt.engine.api.restapi.resource.BackendGraphicsConsoleHelper.asGraphicsType)1 VmMapper (org.ovirt.engine.api.restapi.types.VmMapper)1 DisplayHelper (org.ovirt.engine.api.restapi.util.DisplayHelper)1 HexUtils (org.ovirt.engine.api.restapi.utils.HexUtils)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 GraphicsParameters (org.ovirt.engine.core.common.action.GraphicsParameters)1