Skip to content

Commit 37eec06

Browse files
Allow VMWare import via another host (#9787)
Co-authored-by: Suresh Kumar Anaparti <[email protected]>
1 parent d54b105 commit 37eec06

File tree

15 files changed

+1157
-426
lines changed

15 files changed

+1157
-426
lines changed

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ public class ApiConstants {
225225
public static final String ICMP_TYPE = "icmptype";
226226
public static final String ID = "id";
227227
public static final String IDS = "ids";
228+
public static final String IMPORT_INSTANCE_HOST_ID = "importinstancehostid";
228229
public static final String INDEX = "index";
229230
public static final String INSTANCES_DISKS_STATS_RETENTION_ENABLED = "instancesdisksstatsretentionenabled";
230231
public static final String INSTANCES_DISKS_STATS_RETENTION_TIME = "instancesdisksstatsretentiontime";

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ImportVmCmd.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,19 @@ public class ImportVmCmd extends ImportUnmanagedInstanceCmd {
146146
private String clusterName;
147147

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

152+
@Parameter(name = ApiConstants.IMPORT_INSTANCE_HOST_ID, type = CommandType.UUID, entityType = HostResponse.class, since = "4.19.2",
153+
description = "(only for importing VMs from VMware to KVM) optional - the host to import the converted instance from VMware to KVM.")
154+
private Long importInstanceHostId;
155+
152156
@Parameter(name = ApiConstants.CONVERT_INSTANCE_STORAGE_POOL_ID, type = CommandType.UUID, entityType = StoragePoolResponse.class,
153157
description = "(only for importing VMs from VMware to KVM) optional - the temporary storage pool to perform the virt-v2v migration from VMware to KVM.")
154158
private Long convertStoragePoolId;
155159

156160
@Parameter(name = ApiConstants.FORCE_MS_TO_IMPORT_VM_FILES, type = CommandType.BOOLEAN,
157-
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.")
161+
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.")
158162
private Boolean forceMsToImportVmFiles;
159163

160164
/////////////////////////////////////////////////////
@@ -201,6 +205,10 @@ public Long getConvertInstanceHostId() {
201205
return convertInstanceHostId;
202206
}
203207

208+
public Long getImportInstanceHostId() {
209+
return importInstanceHostId;
210+
}
211+
204212
public Long getConvertStoragePoolId() {
205213
return convertStoragePoolId;
206214
}

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,20 @@
1616
// under the License.
1717
package com.cloud.agent.api;
1818

19-
import org.apache.cloudstack.vm.UnmanagedInstanceTO;
20-
2119
public class ConvertInstanceAnswer extends Answer {
2220

21+
private String temporaryConvertUuid;
22+
2323
public ConvertInstanceAnswer() {
2424
super();
2525
}
26-
private UnmanagedInstanceTO convertedInstance;
27-
28-
public ConvertInstanceAnswer(Command command, boolean success, String details) {
29-
super(command, success, details);
30-
}
3126

32-
public ConvertInstanceAnswer(Command command, UnmanagedInstanceTO convertedInstance) {
27+
public ConvertInstanceAnswer(Command command, String temporaryConvertUuid) {
3328
super(command, true, "");
34-
this.convertedInstance = convertedInstance;
29+
this.temporaryConvertUuid = temporaryConvertUuid;
3530
}
3631

37-
public UnmanagedInstanceTO getConvertedInstance() {
38-
return convertedInstance;
32+
public String getTemporaryConvertUuid() {
33+
return temporaryConvertUuid;
3934
}
4035
}

core/src/main/java/com/cloud/agent/api/ConvertInstanceCommand.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@
2020
import com.cloud.agent.api.to.RemoteInstanceTO;
2121
import com.cloud.hypervisor.Hypervisor;
2222

23-
import java.util.List;
24-
2523
public class ConvertInstanceCommand extends Command {
2624

2725
private RemoteInstanceTO sourceInstance;
2826
private Hypervisor.HypervisorType destinationHypervisorType;
29-
private List<String> destinationStoragePools;
3027
private DataStoreTO conversionTemporaryLocation;
3128
private String templateDirOnConversionLocation;
3229
private boolean checkConversionSupport;
@@ -36,12 +33,10 @@ public class ConvertInstanceCommand extends Command {
3633
public ConvertInstanceCommand() {
3734
}
3835

39-
public ConvertInstanceCommand(RemoteInstanceTO sourceInstance, Hypervisor.HypervisorType destinationHypervisorType,
40-
List<String> destinationStoragePools, DataStoreTO conversionTemporaryLocation,
36+
public ConvertInstanceCommand(RemoteInstanceTO sourceInstance, Hypervisor.HypervisorType destinationHypervisorType, DataStoreTO conversionTemporaryLocation,
4137
String templateDirOnConversionLocation, boolean checkConversionSupport, boolean exportOvfToConversionLocation) {
4238
this.sourceInstance = sourceInstance;
4339
this.destinationHypervisorType = destinationHypervisorType;
44-
this.destinationStoragePools = destinationStoragePools;
4540
this.conversionTemporaryLocation = conversionTemporaryLocation;
4641
this.templateDirOnConversionLocation = templateDirOnConversionLocation;
4742
this.checkConversionSupport = checkConversionSupport;
@@ -56,10 +51,6 @@ public Hypervisor.HypervisorType getDestinationHypervisorType() {
5651
return destinationHypervisorType;
5752
}
5853

59-
public List<String> getDestinationStoragePools() {
60-
return destinationStoragePools;
61-
}
62-
6354
public DataStoreTO getConversionTemporaryLocation() {
6455
return conversionTemporaryLocation;
6556
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.agent.api;
18+
19+
import org.apache.cloudstack.vm.UnmanagedInstanceTO;
20+
21+
public class ImportConvertedInstanceAnswer extends Answer {
22+
23+
public ImportConvertedInstanceAnswer() {
24+
super();
25+
}
26+
private UnmanagedInstanceTO convertedInstance;
27+
28+
public ImportConvertedInstanceAnswer(Command command, boolean success, String details) {
29+
super(command, success, details);
30+
}
31+
32+
public ImportConvertedInstanceAnswer(Command command, UnmanagedInstanceTO convertedInstance) {
33+
super(command, true, "");
34+
this.convertedInstance = convertedInstance;
35+
}
36+
37+
public UnmanagedInstanceTO getConvertedInstance() {
38+
return convertedInstance;
39+
}
40+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.agent.api;
18+
19+
import com.cloud.agent.api.to.DataStoreTO;
20+
import com.cloud.agent.api.to.RemoteInstanceTO;
21+
22+
import java.util.List;
23+
24+
public class ImportConvertedInstanceCommand extends Command {
25+
26+
private RemoteInstanceTO sourceInstance;
27+
private List<String> destinationStoragePools;
28+
private DataStoreTO conversionTemporaryLocation;
29+
private String temporaryConvertUuid;
30+
31+
public ImportConvertedInstanceCommand() {
32+
}
33+
34+
public ImportConvertedInstanceCommand(RemoteInstanceTO sourceInstance,
35+
List<String> destinationStoragePools,
36+
DataStoreTO conversionTemporaryLocation, String temporaryConvertUuid) {
37+
this.sourceInstance = sourceInstance;
38+
this.destinationStoragePools = destinationStoragePools;
39+
this.conversionTemporaryLocation = conversionTemporaryLocation;
40+
this.temporaryConvertUuid = temporaryConvertUuid;
41+
}
42+
43+
public RemoteInstanceTO getSourceInstance() {
44+
return sourceInstance;
45+
}
46+
47+
public List<String> getDestinationStoragePools() {
48+
return destinationStoragePools;
49+
}
50+
51+
public DataStoreTO getConversionTemporaryLocation() {
52+
return conversionTemporaryLocation;
53+
}
54+
55+
public String getTemporaryConvertUuid() {
56+
return temporaryConvertUuid;
57+
}
58+
59+
@Override
60+
public boolean executeInSequence() {
61+
return false;
62+
}
63+
}

0 commit comments

Comments
 (0)