Search in sources :

Example 1 with ImportVmFromExternalUrlParameters

use of org.ovirt.engine.core.common.action.ImportVmFromExternalUrlParameters in project ovirt-engine by oVirt.

the class BackendExternalVmImportsResource method add.

@Override
public Response add(ExternalVmImport externalVmImport) {
    validateParameters(externalVmImport, "provider", "url", "name", "sparse", "cluster.id|name", "storageDomain.id|name");
    ImportVmFromExternalUrlParameters parameters = buildImportParameters(externalVmImport);
    VM createdVm = performAction(ActionType.ImportVmFromExternalUrl, parameters, VM.class);
    // Postprocess output entity to clear sensitive data and resolve links.
    externalVmImport.setPassword(null);
    externalVmImport.setVm(withIdLink(new Vm(), createdVm.getId()));
    externalVmImport.setCluster(withIdLink(new org.ovirt.engine.api.model.Cluster(), parameters.getClusterId()));
    externalVmImport.setStorageDomain(withIdLink(new StorageDomain(), parameters.getStorageDomainId()));
    if (externalVmImport.isSetHost()) {
        externalVmImport.setHost(withIdLink(new Host(), parameters.getProxyHostId()));
    }
    return Response.ok(externalVmImport).status(Response.Status.CREATED).build();
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) ImportVmFromExternalUrlParameters(org.ovirt.engine.core.common.action.ImportVmFromExternalUrlParameters) VM(org.ovirt.engine.core.common.businessentities.VM) Vm(org.ovirt.engine.api.model.Vm) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Host(org.ovirt.engine.api.model.Host)

Example 2 with ImportVmFromExternalUrlParameters

use of org.ovirt.engine.core.common.action.ImportVmFromExternalUrlParameters in project ovirt-engine by oVirt.

the class BackendExternalVmImportsResource method buildImportParameters.

private ImportVmFromExternalUrlParameters buildImportParameters(ExternalVmImport vmImport) {
    ImportVmFromExternalUrlParameters parameters = new ImportVmFromExternalUrlParameters();
    parameters.setUrl(vmImport.getUrl());
    parameters.setOriginType(getOriginType(vmImport));
    parameters.setExternalName(vmImport.getName());
    parameters.setNewVmName(vmImport.getVm() != null ? vmImport.getVm().getName() : null);
    parameters.setVolumeType(getVolumeType(vmImport));
    parameters.setProxyHostId(getProxyHostId(vmImport));
    parameters.setVirtioIsoName(getVirtioIsoName(vmImport));
    parameters.setStorageDomainId(getStorageDomainId(vmImport));
    parameters.setClusterId(getClusterId(vmImport));
    parameters.setQuotaId(getQuotaId(vmImport));
    parameters.setCpuProfileId(getCpuProfileId(vmImport));
    parameters.setUsername(vmImport.getUsername());
    parameters.setPassword(vmImport.getPassword());
    return parameters;
}
Also used : ImportVmFromExternalUrlParameters(org.ovirt.engine.core.common.action.ImportVmFromExternalUrlParameters)

Aggregations

ImportVmFromExternalUrlParameters (org.ovirt.engine.core.common.action.ImportVmFromExternalUrlParameters)2 Host (org.ovirt.engine.api.model.Host)1 StorageDomain (org.ovirt.engine.api.model.StorageDomain)1 Vm (org.ovirt.engine.api.model.Vm)1 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)1 VM (org.ovirt.engine.core.common.businessentities.VM)1