Skip to content

Commit 0e516b0

Browse files
committed
ABLESTACK V2K 기능을 이요한 Mold UI 병합(1차 HCI - RBD 환경 지원)
1 parent 44ce3f5 commit 0e516b0

43 files changed

Lines changed: 2761 additions & 123 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/src/main/java/com/cloud/hypervisor/HypervisorGuru.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ boolean attachRestoredVolumeToVirtualMachine(long zoneId, String location, Backu
117117
*/
118118
Pair<UnmanagedInstanceTO, Boolean> getHypervisorVMOutOfBandAndCloneIfRequired(String hostIp, String vmName, Map<String, String> params);
119119

120+
/**
121+
* Will return the hypervisor VM without cloning it on an external host (if the guru can handle)
122+
* @param hostIp VM's source host IP
123+
* @param vmName name of the source VM
124+
* @param params hypervisor specific additional parameters
125+
* @return a reference to the hypervisor VM
126+
*/
127+
UnmanagedInstanceTO getHypervisorVMOutOfBand(String hostIp, String vmName, Map<String, String> params);
128+
120129
/**
121130
* Removes a VM created as a clone of a VM on an external host
122131
* @param hostIp VM's source host IP

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ public class ApiConstants {
298298
public static final String ID = "id";
299299
public static final String IDS = "ids";
300300
public static final String IMPORT_INSTANCE_HOST_ID = "importinstancehostid";
301+
public static final String IMPORT_VM_TASK_ID = "importvmtaskid";
301302
public static final String INDEX = "index";
302303
public static final String INSTANCES_DISKS_STATS_RETENTION_ENABLED = "instancesdisksstatsretentionenabled";
303304
public static final String INSTANCES_DISKS_STATS_RETENTION_TIME = "instancesdisksstatsretentiontime";
@@ -1601,4 +1602,4 @@ public static ApiKeyAccess fromBoolean(Boolean value) {
16011602
}
16021603
}
16031604
}
1604-
}
1605+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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 org.apache.cloudstack.api.command.admin.vm;
18+
19+
import com.cloud.exception.ConcurrentOperationException;
20+
import com.cloud.exception.InsufficientCapacityException;
21+
import com.cloud.exception.NetworkRuleConflictException;
22+
import com.cloud.exception.ResourceAllocationException;
23+
import com.cloud.exception.ResourceUnavailableException;
24+
import org.apache.cloudstack.acl.RoleType;
25+
import org.apache.cloudstack.api.APICommand;
26+
import org.apache.cloudstack.api.ApiConstants;
27+
import org.apache.cloudstack.api.Parameter;
28+
import org.apache.cloudstack.api.ResponseObject;
29+
import org.apache.cloudstack.api.ServerApiException;
30+
import org.apache.cloudstack.api.response.UserVmResponse;
31+
import org.apache.commons.lang3.StringUtils;
32+
33+
@APICommand(name = "importUnmanagedInstanceForAblestackV2K",
34+
description = "Import virtual machine from VMware into CloudStack using ablestack-v2k workflow",
35+
responseObject = UserVmResponse.class,
36+
responseView = ResponseObject.ResponseView.Full,
37+
requestHasSensitiveInfo = false,
38+
responseHasSensitiveInfo = true,
39+
authorized = {RoleType.Admin},
40+
since = "4.19.0")
41+
public class ImportUnmanagedInstanceForAblestackV2KCmd extends ImportVmCmd {
42+
43+
private static final String DEFAULT_SPLIT_MODE = "phase1";
44+
45+
@Parameter(name = "split",
46+
type = CommandType.STRING,
47+
description = "(only for importing VMs from VMware to KVM with ablestack-v2k) split-run mode: phase1 or phase2")
48+
private String splitMode;
49+
50+
@Parameter(name = ApiConstants.IMPORT_VM_TASK_ID,
51+
type = CommandType.STRING,
52+
description = "(only for phase2 execution) existing import VM task ID to continue on the original conversion host")
53+
private String importVmTaskId;
54+
55+
public String getSplitMode() {
56+
return StringUtils.defaultIfBlank(splitMode, DEFAULT_SPLIT_MODE);
57+
}
58+
59+
public String getImportVmTaskId() {
60+
return importVmTaskId;
61+
}
62+
63+
@Override
64+
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
65+
UserVmResponse response = vmImportService.importVmForAblestackV2K(this);
66+
response.setResponseName(getCommandName());
67+
setResponseObject(response);
68+
}
69+
}

api/src/main/java/org/apache/cloudstack/api/response/ImportVMTaskResponse.java

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ public class ImportVMTaskResponse extends BaseResponse {
4747
@Param(description = "the ID of account")
4848
private String accountId;
4949

50+
@SerializedName(ApiConstants.CLUSTER_ID)
51+
@Param(description = "the cluster ID used by the import task")
52+
private String clusterId;
53+
54+
@SerializedName(ApiConstants.SERVICE_OFFERING_ID)
55+
@Param(description = "the service offering ID used by the import task")
56+
private String serviceOfferingId;
57+
5058
@SerializedName(ApiConstants.VIRTUAL_MACHINE_ID)
5159
@Param(description = "the ID of the imported VM (after task is completed)")
5260
private String virtualMachineId;
@@ -75,6 +83,10 @@ public class ImportVMTaskResponse extends BaseResponse {
7583
@Param(description = "the current step on the importing VM task")
7684
private String step;
7785

86+
@SerializedName("v2kstep")
87+
@Param(description = "the current ablestack-v2k step on the importing VM task")
88+
private String v2kStep;
89+
7890
@SerializedName("stepduration")
7991
@Param(description = "the duration of the current step")
8092
private String stepDuration;
@@ -103,6 +115,26 @@ public class ImportVMTaskResponse extends BaseResponse {
103115
@Param(description = "the last updated date of the importing task")
104116
private Date lastUpdated;
105117

118+
@SerializedName("phase")
119+
@Param(description = "the current PHASE from ablestack-v2k status")
120+
private String phase;
121+
122+
@SerializedName("migrationstate")
123+
@Param(description = "the current STATE from ablestack-v2k status")
124+
private String migrationState;
125+
126+
@SerializedName("migrationstep")
127+
@Param(description = "the current STEP from ablestack-v2k status")
128+
private String migrationStep;
129+
130+
@SerializedName("syncphysical")
131+
@Param(description = "the current SYNC(Physical) from ablestack-v2k status")
132+
private String syncPhysical;
133+
134+
@SerializedName("workdir")
135+
@Param(description = "the current WORKDIR from ablestack-v2k status")
136+
private String workdir;
137+
106138
public String getId() {
107139
return id;
108140
}
@@ -143,6 +175,22 @@ public void setAccountId(String accountId) {
143175
this.accountId = accountId;
144176
}
145177

178+
public String getClusterId() {
179+
return clusterId;
180+
}
181+
182+
public void setClusterId(String clusterId) {
183+
this.clusterId = clusterId;
184+
}
185+
186+
public String getServiceOfferingId() {
187+
return serviceOfferingId;
188+
}
189+
190+
public void setServiceOfferingId(String serviceOfferingId) {
191+
this.serviceOfferingId = serviceOfferingId;
192+
}
193+
146194
public String getVirtualMachineId() {
147195
return virtualMachineId;
148196
}
@@ -191,6 +239,14 @@ public void setStep(String step) {
191239
this.step = step;
192240
}
193241

242+
public String getV2kStep() {
243+
return v2kStep;
244+
}
245+
246+
public void setV2kStep(String v2kStep) {
247+
this.v2kStep = v2kStep;
248+
}
249+
194250
public String getStepDuration() {
195251
return stepDuration;
196252
}
@@ -254,4 +310,44 @@ public String getState() {
254310
public void setState(String state) {
255311
this.state = state;
256312
}
313+
314+
public String getPhase() {
315+
return phase;
316+
}
317+
318+
public void setPhase(String phase) {
319+
this.phase = phase;
320+
}
321+
322+
public String getMigrationState() {
323+
return migrationState;
324+
}
325+
326+
public void setMigrationState(String migrationState) {
327+
this.migrationState = migrationState;
328+
}
329+
330+
public String getMigrationStep() {
331+
return migrationStep;
332+
}
333+
334+
public void setMigrationStep(String migrationStep) {
335+
this.migrationStep = migrationStep;
336+
}
337+
338+
public String getSyncPhysical() {
339+
return syncPhysical;
340+
}
341+
342+
public void setSyncPhysical(String syncPhysical) {
343+
this.syncPhysical = syncPhysical;
344+
}
345+
346+
public String getWorkdir() {
347+
return workdir;
348+
}
349+
350+
public void setWorkdir(String workdir) {
351+
this.workdir = workdir;
352+
}
257353
}

api/src/main/java/org/apache/cloudstack/vm/ImportVmTask.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@
2222
import org.apache.cloudstack.api.InternalIdentity;
2323

2424
public interface ImportVmTask extends Identity, InternalIdentity {
25+
String V2K_STEP_NONE = "None";
26+
2527
enum Step {
2628
Prepare, CloningInstance, ConvertingInstance, Importing, Completed
2729
}
2830

31+
enum V2KStep {
32+
Phase1_In_Progress, Phase1_Completed, Phase2_In_Progress, Phase2_Completed, Completed
33+
}
34+
2935
enum TaskState {
3036
Running, Completed, Failed;
3137

api/src/main/java/org/apache/cloudstack/vm/ImportVmTasksManager.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import org.apache.cloudstack.api.response.ImportVMTaskResponse;
2424
import org.apache.cloudstack.api.response.ListResponse;
2525

26+
import java.util.Map;
27+
2628
public interface ImportVmTasksManager {
2729

2830
ListResponse<ImportVMTaskResponse> listImportVMTasks(ListImportVMTasksCmd cmd);
@@ -34,5 +36,13 @@ ImportVmTask createImportVMTaskRecord(DataCenter zone, Account owner, long userI
3436
void updateImportVMTaskStep(ImportVmTask importVMTaskVO, DataCenter zone, Account owner, Host convertHost,
3537
Host importHost, Long vmId, ImportVmTask.Step step);
3638

39+
void updateImportVMTaskV2KStep(ImportVmTask importVMTaskVO, ImportVmTask.V2KStep step);
40+
41+
void updateImportVMTaskV2KContext(ImportVmTask importVMTaskVO, Long clusterId, Long serviceOfferingId,
42+
Long targetStoragePoolId, String sourceClusterName, String sourceHostName,
43+
Long vcenterId, String vcenterUsername, String vcenterPassword,
44+
Map<String, String> serviceOfferingDetails,
45+
Map<String, Map<String, String>> nicSelectionMap);
46+
3747
void updateImportVMTaskErrorState(ImportVmTask importVMTaskVO, ImportVmTask.TaskState state, String errorMsg);
3848
}

api/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,6 @@ public interface UnmanagedVMsManager extends VmImportService, UnmanageVMService,
7373
static boolean isSupported(Hypervisor.HypervisorType hypervisorType) {
7474
return hypervisorType == VMware || hypervisorType == KVM;
7575
}
76+
77+
void finalizeAblestackV2KTask(String importVmTaskUuid);
7678
}

api/src/main/java/org/apache/cloudstack/vm/VmImportService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.cloudstack.vm;
1919

2020
import org.apache.cloudstack.api.command.admin.vm.ImportUnmanagedInstanceCmd;
21+
import org.apache.cloudstack.api.command.admin.vm.ImportUnmanagedInstanceForAblestackV2KCmd;
2122
import org.apache.cloudstack.api.command.admin.vm.ImportVmCmd;
2223
import org.apache.cloudstack.api.command.admin.vm.ListUnmanagedInstancesCmd;
2324
import org.apache.cloudstack.api.command.admin.vm.ListVmsForImportCmd;
@@ -40,6 +41,7 @@ public String toString() {
4041
UserVmResponse importUnmanagedInstance(ImportUnmanagedInstanceCmd cmd);
4142

4243
UserVmResponse importVm(ImportVmCmd cmd);
44+
UserVmResponse importVmForAblestackV2K(ImportUnmanagedInstanceForAblestackV2KCmd cmd);
4345

4446
ListResponse<UnmanagedInstanceResponse> listVmsForImport(ListVmsForImportCmd cmd);
4547
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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+
21+
public class AblestackV2KConvertInstanceCommand extends Command {
22+
23+
private String vmName;
24+
private String vcenter;
25+
private String username;
26+
private String password;
27+
private DataStoreTO targetStorageLocation;
28+
private String splitMode;
29+
private String targetFormat;
30+
private String targetStorage;
31+
private String targetMapJson;
32+
33+
public AblestackV2KConvertInstanceCommand() {
34+
}
35+
36+
public AblestackV2KConvertInstanceCommand(String vmName, String vcenter, String username, String password,
37+
DataStoreTO targetStorageLocation, String splitMode) {
38+
this.vmName = vmName;
39+
this.vcenter = vcenter;
40+
this.username = username;
41+
this.password = password;
42+
this.targetStorageLocation = targetStorageLocation;
43+
this.splitMode = splitMode;
44+
}
45+
46+
public String getVmName() {
47+
return vmName;
48+
}
49+
50+
public String getVcenter() {
51+
return vcenter;
52+
}
53+
54+
public String getUsername() {
55+
return username;
56+
}
57+
58+
public String getPassword() {
59+
return password;
60+
}
61+
62+
public DataStoreTO getTargetStorageLocation() {
63+
return targetStorageLocation;
64+
}
65+
66+
public String getSplitMode() {
67+
return splitMode;
68+
}
69+
70+
public String getTargetFormat() {
71+
return targetFormat;
72+
}
73+
74+
public void setTargetFormat(String targetFormat) {
75+
this.targetFormat = targetFormat;
76+
}
77+
78+
public String getTargetStorage() {
79+
return targetStorage;
80+
}
81+
82+
public void setTargetStorage(String targetStorage) {
83+
this.targetStorage = targetStorage;
84+
}
85+
86+
public String getTargetMapJson() {
87+
return targetMapJson;
88+
}
89+
90+
public void setTargetMapJson(String targetMapJson) {
91+
this.targetMapJson = targetMapJson;
92+
}
93+
94+
@Override
95+
public boolean executeInSequence() {
96+
return false;
97+
}
98+
}

0 commit comments

Comments
 (0)