Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow VMWare import via another host #9787

Merged
merged 16 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public class ApiConstants {
public static final String ICMP_TYPE = "icmptype";
public static final String ID = "id";
public static final String IDS = "ids";
public static final String IMPORT_INSTANCE_HOST_ID = "importinstancehostid";
public static final String INDEX = "index";
public static final String INSTANCES_DISKS_STATS_RETENTION_ENABLED = "instancesdisksstatsretentionenabled";
public static final String INSTANCES_DISKS_STATS_RETENTION_TIME = "instancesdisksstatsretentiontime";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,19 @@
private String clusterName;

@Parameter(name = ApiConstants.CONVERT_INSTANCE_HOST_ID, type = CommandType.UUID, entityType = HostResponse.class,
description = "(only for importing VMs from VMware to KVM) optional - the host to perform the virt-v2v migration from VMware to KVM.")
description = "(only for importing VMs from VMware to KVM) optional - the host to perform the virt-v2v conversion from VMware to KVM.")
private Long convertInstanceHostId;

@Parameter(name = ApiConstants.IMPORT_INSTANCE_HOST_ID, type = CommandType.UUID, entityType = HostResponse.class, since = "4.19.2",
description = "(only for importing VMs from VMware to KVM) optional - the host to import the converted instance from VMware to KVM.")
private Long importInstanceHostId;

@Parameter(name = ApiConstants.CONVERT_INSTANCE_STORAGE_POOL_ID, type = CommandType.UUID, entityType = StoragePoolResponse.class,
description = "(only for importing VMs from VMware to KVM) optional - the temporary storage pool to perform the virt-v2v migration from VMware to KVM.")
private Long convertStoragePoolId;

@Parameter(name = ApiConstants.FORCE_MS_TO_IMPORT_VM_FILES, type = CommandType.BOOLEAN,
description = "(only for importing VMs from VMware to KVM) optional - if true, forces MS to import VM file(s) to temporary storage, else uses KVM Host if ovftool is available, falls back to MS if not.")
description = "(only for importing VMs from VMware to KVM) optional - if true, forces MS to export OVF from VMware to temporary storage, else uses KVM Host if ovftool is available, falls back to MS if not.")
private Boolean forceMsToImportVmFiles;

/////////////////////////////////////////////////////
Expand Down Expand Up @@ -201,6 +205,10 @@
return convertInstanceHostId;
}

public Long getImportInstanceHostId() {
return importInstanceHostId;
}

Check warning on line 210 in api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ImportVmCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ImportVmCmd.java#L208-L210

Added lines #L208 - L210 were not covered by tests

public Long getConvertStoragePoolId() {
return convertStoragePoolId;
}
Expand Down
17 changes: 6 additions & 11 deletions core/src/main/java/com/cloud/agent/api/ConvertInstanceAnswer.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,20 @@
// under the License.
package com.cloud.agent.api;

import org.apache.cloudstack.vm.UnmanagedInstanceTO;

public class ConvertInstanceAnswer extends Answer {

private String temporaryConvertUuid;

public ConvertInstanceAnswer() {
super();
}
private UnmanagedInstanceTO convertedInstance;

public ConvertInstanceAnswer(Command command, boolean success, String details) {
super(command, success, details);
}

public ConvertInstanceAnswer(Command command, UnmanagedInstanceTO convertedInstance) {
public ConvertInstanceAnswer(Command command, String temporaryConvertUuid) {
super(command, true, "");
this.convertedInstance = convertedInstance;
this.temporaryConvertUuid = temporaryConvertUuid;

Check warning on line 29 in core/src/main/java/com/cloud/agent/api/ConvertInstanceAnswer.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/com/cloud/agent/api/ConvertInstanceAnswer.java#L29

Added line #L29 was not covered by tests
}

public UnmanagedInstanceTO getConvertedInstance() {
return convertedInstance;
public String getTemporaryConvertUuid() {
return temporaryConvertUuid;

Check warning on line 33 in core/src/main/java/com/cloud/agent/api/ConvertInstanceAnswer.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/com/cloud/agent/api/ConvertInstanceAnswer.java#L32-L33

Added lines #L32 - L33 were not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@
import com.cloud.agent.api.to.RemoteInstanceTO;
import com.cloud.hypervisor.Hypervisor;

import java.util.List;

public class ConvertInstanceCommand extends Command {

private RemoteInstanceTO sourceInstance;
private Hypervisor.HypervisorType destinationHypervisorType;
private List<String> destinationStoragePools;
private DataStoreTO conversionTemporaryLocation;
private String templateDirOnConversionLocation;
private boolean checkConversionSupport;
Expand All @@ -36,12 +33,10 @@ public class ConvertInstanceCommand extends Command {
public ConvertInstanceCommand() {
}

public ConvertInstanceCommand(RemoteInstanceTO sourceInstance, Hypervisor.HypervisorType destinationHypervisorType,
List<String> destinationStoragePools, DataStoreTO conversionTemporaryLocation,
public ConvertInstanceCommand(RemoteInstanceTO sourceInstance, Hypervisor.HypervisorType destinationHypervisorType, DataStoreTO conversionTemporaryLocation,
String templateDirOnConversionLocation, boolean checkConversionSupport, boolean exportOvfToConversionLocation) {
this.sourceInstance = sourceInstance;
this.destinationHypervisorType = destinationHypervisorType;
this.destinationStoragePools = destinationStoragePools;
this.conversionTemporaryLocation = conversionTemporaryLocation;
this.templateDirOnConversionLocation = templateDirOnConversionLocation;
this.checkConversionSupport = checkConversionSupport;
Expand All @@ -56,10 +51,6 @@ public Hypervisor.HypervisorType getDestinationHypervisorType() {
return destinationHypervisorType;
}

public List<String> getDestinationStoragePools() {
return destinationStoragePools;
}

public DataStoreTO getConversionTemporaryLocation() {
return conversionTemporaryLocation;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.agent.api;

import org.apache.cloudstack.vm.UnmanagedInstanceTO;

public class ImportConvertedInstanceAnswer extends Answer {

public ImportConvertedInstanceAnswer() {
super();
}

Check warning on line 25 in core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceAnswer.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceAnswer.java#L24-L25

Added lines #L24 - L25 were not covered by tests
private UnmanagedInstanceTO convertedInstance;

public ImportConvertedInstanceAnswer(Command command, boolean success, String details) {
super(command, success, details);
}

public ImportConvertedInstanceAnswer(Command command, UnmanagedInstanceTO convertedInstance) {
super(command, true, "");
this.convertedInstance = convertedInstance;
}

Check warning on line 35 in core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceAnswer.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceAnswer.java#L33-L35

Added lines #L33 - L35 were not covered by tests

public UnmanagedInstanceTO getConvertedInstance() {
return convertedInstance;
}

Check warning on line 39 in core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceAnswer.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceAnswer.java#L37-L39

Added lines #L37 - L39 were not covered by tests
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.agent.api;

import com.cloud.agent.api.to.DataStoreTO;
import com.cloud.agent.api.to.RemoteInstanceTO;

import java.util.List;

public class ImportConvertedInstanceCommand extends Command {

private RemoteInstanceTO sourceInstance;
private List<String> destinationStoragePools;
private DataStoreTO conversionTemporaryLocation;
private String temporaryConvertUuid;

public ImportConvertedInstanceCommand() {
}

Check warning on line 32 in core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java#L31-L32

Added lines #L31 - L32 were not covered by tests

public ImportConvertedInstanceCommand(RemoteInstanceTO sourceInstance,
List<String> destinationStoragePools,
DataStoreTO conversionTemporaryLocation, String temporaryConvertUuid) {
this.sourceInstance = sourceInstance;
this.destinationStoragePools = destinationStoragePools;
this.conversionTemporaryLocation = conversionTemporaryLocation;
this.temporaryConvertUuid = temporaryConvertUuid;
}

public RemoteInstanceTO getSourceInstance() {
return sourceInstance;
}

Check warning on line 45 in core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java#L43-L45

Added lines #L43 - L45 were not covered by tests

public List<String> getDestinationStoragePools() {
return destinationStoragePools;
}

Check warning on line 49 in core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java#L47-L49

Added lines #L47 - L49 were not covered by tests

public DataStoreTO getConversionTemporaryLocation() {
return conversionTemporaryLocation;
}

Check warning on line 53 in core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java#L51-L53

Added lines #L51 - L53 were not covered by tests

public String getTemporaryConvertUuid() {
return temporaryConvertUuid;
}

Check warning on line 57 in core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java#L55-L57

Added lines #L55 - L57 were not covered by tests

@Override
public boolean executeInSequence() {
return false;
}

Check warning on line 62 in core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/com/cloud/agent/api/ImportConvertedInstanceCommand.java#L60-L62

Added lines #L60 - L62 were not covered by tests
}
Loading
Loading