Skip to content

Commit f327792

Browse files
committed
New Feature: Migrate VMware VMs to KVM
1 parent 7cdf864 commit f327792

62 files changed

Lines changed: 1977 additions & 92 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/agent/api/to/DatadiskTO.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
public class DatadiskTO {
2222
private String path;
23-
private long virtualSize;
23+
private Long virtualSize;
2424
private long fileSize;
2525
boolean bootable;
2626
private String diskId;
@@ -29,11 +29,19 @@ public class DatadiskTO {
2929
private String diskControllerSubType;
3030
private int diskNumber;
3131
private String configuration;
32+
private Long templateId;
3233

3334
public DatadiskTO() {
3435
}
3536

36-
public DatadiskTO(String path, long virtualSize, long fileSize, String diskId, boolean isIso, boolean bootable,
37+
public DatadiskTO(String path, Long virtualSize, long fileSize, int diskNumber) {
38+
this.path = path;
39+
this.virtualSize = virtualSize;
40+
this.fileSize = fileSize;
41+
this.diskNumber = diskNumber;
42+
}
43+
44+
public DatadiskTO(String path, Long virtualSize, long fileSize, String diskId, boolean isIso, boolean bootable,
3745
String controller, String controllerSubType, int diskNumber, String configuration) {
3846
this.path = path;
3947
this.virtualSize = virtualSize;
@@ -110,4 +118,16 @@ public int getDiskNumber() {
110118
public String getConfiguration() {
111119
return configuration;
112120
}
121+
122+
public Long getTemplateId() {
123+
return templateId;
124+
}
125+
126+
public void setTemplateId(Long templateId) {
127+
this.templateId = templateId;
128+
}
129+
130+
public void setDiskNumber(int diskNumber) {
131+
this.diskNumber = diskNumber;
132+
}
113133
}

api/src/main/java/com/cloud/agent/api/to/OVFInformationTO.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public class OVFInformationTO {
4848
public OVFInformationTO() {
4949
}
5050

51+
public OVFInformationTO(List<DatadiskTO> disks) {
52+
this.disks = disks;
53+
}
54+
5155
public List<OVFPropertyTO> getProperties() {
5256
return properties;
5357
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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.to;
18+
19+
/**
20+
* TO class sent to the hypervisor layer with the information needed to handle
21+
* VM Migrations from Vmware to KVM templates
22+
*/
23+
public class VmwareVmForMigrationTO {
24+
25+
private String vcenter;
26+
private String datacenter;
27+
private String cluster;
28+
private String username;
29+
private String password;
30+
private String url;
31+
private String host;
32+
private String vmName;
33+
private String secondaryStorageUrl;
34+
35+
public VmwareVmForMigrationTO() {
36+
}
37+
38+
public VmwareVmForMigrationTO(String vcenter, String datacenter, String cluster, String username, String password,
39+
String url, String hostname, String vmName, String secondaryStorageUrl) {
40+
this.vcenter = vcenter;
41+
this.datacenter = datacenter;
42+
this.cluster = cluster;
43+
this.username = username;
44+
this.password = password;
45+
this.url = url;
46+
this.host = hostname;
47+
this.vmName = vmName;
48+
this.secondaryStorageUrl = secondaryStorageUrl;
49+
}
50+
51+
public String getVcenter() {
52+
return vcenter;
53+
}
54+
55+
public String getDatacenter() {
56+
return datacenter;
57+
}
58+
59+
public String getUsername() {
60+
return username;
61+
}
62+
63+
public String getPassword() {
64+
return password;
65+
}
66+
67+
public String getUrl() {
68+
return url;
69+
}
70+
71+
public String getHost() {
72+
return host;
73+
}
74+
75+
public String getVmName() {
76+
return vmName;
77+
}
78+
79+
public String getSecondaryStorageUrl() {
80+
return secondaryStorageUrl;
81+
}
82+
83+
public String getCluster() {
84+
return cluster;
85+
}
86+
}

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/VmwareDatacenter.java renamed to api/src/main/java/com/cloud/dc/VmwareDatacenter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
package com.cloud.hypervisor.vmware;
18+
package com.cloud.dc;
1919

2020
import org.apache.cloudstack.api.Identity;
2121
import org.apache.cloudstack.api.InternalIdentity;

api/src/main/java/com/cloud/event/EventTypes.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,8 @@ public class EventTypes {
706706
// SystemVM
707707
public static final String EVENT_LIVE_PATCH_SYSTEMVM = "LIVE.PATCH.SYSTEM.VM";
708708

709+
public static final String EVENT_REGISTER_TEMPLATE_FROM_VMWARE_VM = "REGISTER.TEMPLATE.FROM.VMWARE";
710+
709711
static {
710712

711713
// TODO: need a way to force author adding event types to declare the entity details as well, with out braking

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,11 @@ boolean attachRestoredVolumeToVirtualMachine(long zoneId, String location, Backu
104104
* @return a list of commands to perform for a successful migration
105105
*/
106106
List<Command> finalizeMigrate(VirtualMachine vm, Map<Volume, StoragePool> volumeToPool);
107+
108+
/**
109+
* Will perform a clone of a VM on an external host (if the guru can handle)
110+
*/
111+
HypervisorOutOfBandVMClone cloneHypervisorVMOutOfBand(String hostIp, String vmName, Map<String, String> params);
112+
113+
boolean removeHypervisorVMOutOfBand(String hostIp, String vmName, Map<String, String> params);
107114
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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.hypervisor;
18+
19+
public class HypervisorOutOfBandVMClone {
20+
21+
private String cloneName;
22+
private int disksNumber;
23+
private long capacity;
24+
25+
public HypervisorOutOfBandVMClone(String cloneName, int disksNumber, long capacity) {
26+
this.cloneName = cloneName;
27+
this.disksNumber = disksNumber;
28+
this.capacity = capacity;
29+
}
30+
31+
public String getCloneName() {
32+
return cloneName;
33+
}
34+
35+
public int getDisksNumber() {
36+
return disksNumber;
37+
}
38+
39+
public long getCapacity() {
40+
return capacity;
41+
}
42+
}

api/src/main/java/com/cloud/template/TemplateApiService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.apache.cloudstack.api.command.user.template.ExtractTemplateCmd;
3434
import org.apache.cloudstack.api.command.user.template.GetUploadParamsForTemplateCmd;
3535
import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
36+
import org.apache.cloudstack.api.command.user.template.RegisterTemplateFromVMwareVMCmd;
3637
import org.apache.cloudstack.api.command.user.template.UpdateTemplateCmd;
3738

3839
import com.cloud.exception.InternalErrorException;
@@ -47,6 +48,8 @@ public interface TemplateApiService {
4748

4849
VirtualMachineTemplate registerTemplate(RegisterTemplateCmd cmd) throws URISyntaxException, ResourceAllocationException;
4950

51+
VirtualMachineTemplate registerTemplateFromVMwareVM(RegisterTemplateFromVMwareVMCmd cmd) throws ResourceAllocationException;
52+
5053
GetUploadParamsResponse registerTemplateForPostUpload(GetUploadParamsForTemplateCmd cmd) throws ResourceAllocationException, MalformedURLException;
5154

5255
VirtualMachineTemplate registerIso(RegisterIsoCmd cmd) throws IllegalArgumentException, ResourceAllocationException;

api/src/main/java/com/cloud/template/VirtualMachineTemplate.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ public enum TemplateFilter {
144144

145145
boolean isDeployAsIs();
146146

147+
boolean isMigratedFromVmwareVM();
148+
147149
Long getUserDataId();
148150

149151
UserData.UserDataOverridePolicy getUserDataOverridePolicy();

api/src/main/java/com/cloud/vm/VmDetailConstants.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,15 @@ public interface VmDetailConstants {
8484
String DEPLOY_AS_IS_CONFIGURATION = "configurationId";
8585
String KEY_PAIR_NAMES = "keypairnames";
8686
String CKS_CONTROL_NODE_LOGIN_USER = "controlNodeLoginUser";
87+
88+
// VMware to KVM VM migrations specific
89+
String VMWARE_TO_KVM_PREFIX = "vmw-to-kvm";
90+
String VMWARE_VCENTER = String.format("%s-vcenter", VMWARE_TO_KVM_PREFIX);
91+
String VMWARE_DATACENTER = String.format("%s-datacenter", VMWARE_TO_KVM_PREFIX);
92+
String VMWARE_CLUSTER = String.format("%s-cluster", VMWARE_TO_KVM_PREFIX);
93+
String VMWARE_VCENTER_USERNAME = String.format("%s-username", VMWARE_TO_KVM_PREFIX);
94+
String VMWARE_VCENTER_PASSWORD = String.format("%s-password", VMWARE_TO_KVM_PREFIX);
95+
String VMWARE_VM_NAME = String.format("%s-vmname", VMWARE_TO_KVM_PREFIX);
96+
String VMWARE_HOST = String.format("%s-host", VMWARE_TO_KVM_PREFIX);
97+
String VMWARE_DISK = String.format("%s-disk", VMWARE_TO_KVM_PREFIX);
8798
}

0 commit comments

Comments
 (0)