Skip to content

Commit 5439cf3

Browse files
nvazquezyadvr
authored andcommitted
KVM live storage migration intra cluster from NFS source and destination
Missing new line and revert schema changes
1 parent 3101612 commit 5439cf3

File tree

23 files changed

+988
-35
lines changed

23 files changed

+988
-35
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package com.cloud.storage;
20+
21+
import java.io.Serializable;
22+
23+
public class MigrationOptions implements Serializable {
24+
25+
private String srcPoolUuid;
26+
private Storage.StoragePoolType srcPoolType;
27+
private Type type;
28+
private String srcBackingFilePath;
29+
private boolean copySrcTemplate;
30+
private String snapshotName;
31+
private String srcVolumeUuid;
32+
private int timeout;
33+
34+
public enum Type {
35+
LinkedClone, FullClone
36+
}
37+
38+
public MigrationOptions() {
39+
}
40+
41+
public MigrationOptions(String srcPoolUuid, Storage.StoragePoolType srcPoolType, String srcBackingFilePath, boolean copySrcTemplate) {
42+
this.srcPoolUuid = srcPoolUuid;
43+
this.srcPoolType = srcPoolType;
44+
this.type = Type.LinkedClone;
45+
this.srcBackingFilePath = srcBackingFilePath;
46+
this.copySrcTemplate = copySrcTemplate;
47+
}
48+
49+
public MigrationOptions(String srcPoolUuid, Storage.StoragePoolType srcPoolType, String snapshotName, String srcVolumeUuid) {
50+
this.srcPoolUuid = srcPoolUuid;
51+
this.srcPoolType = srcPoolType;
52+
this.type = Type.FullClone;
53+
this.snapshotName = snapshotName;
54+
this.srcVolumeUuid = srcVolumeUuid;
55+
}
56+
57+
public String getSrcPoolUuid() {
58+
return srcPoolUuid;
59+
}
60+
61+
public Storage.StoragePoolType getSrcPoolType() {
62+
return srcPoolType;
63+
}
64+
65+
public String getSrcBackingFilePath() {
66+
return srcBackingFilePath;
67+
}
68+
69+
public boolean isCopySrcTemplate() {
70+
return copySrcTemplate;
71+
}
72+
73+
public String getSnapshotName() {
74+
return snapshotName;
75+
}
76+
77+
public String getSrcVolumeUuid() {
78+
return srcVolumeUuid;
79+
}
80+
81+
public Type getType() {
82+
return type;
83+
}
84+
85+
public int getTimeout() {
86+
return timeout;
87+
}
88+
89+
public void setTimeout(int timeout) {
90+
this.timeout = timeout;
91+
}
92+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public CreateVMSnapshotCommand(String vmName, String vmUuid, VMSnapshotTO snapsh
3232
this.vmUuid = vmUuid;
3333
}
3434

35+
public CreateVMSnapshotCommand(String vmName, VMSnapshotTO snapshot) {
36+
super(vmName, snapshot, null, null);
37+
}
38+
3539
public String getVmUuid() {
3640
return vmUuid;
3741
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ public class DeleteVMSnapshotCommand extends VMSnapshotBaseCommand {
2727
public DeleteVMSnapshotCommand(String vmName, VMSnapshotTO snapshot, List<VolumeObjectTO> volumeTOs, String guestOSType) {
2828
super(vmName, snapshot, volumeTOs, guestOSType);
2929
}
30+
31+
public DeleteVMSnapshotCommand(String vmName, VMSnapshotTO snapshot) {
32+
super(vmName, snapshot, null, null);
33+
}
3034
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class MigrateCommand extends Command {
2828
private String vmName;
2929
private String destIp;
3030
private Map<String, MigrateDiskInfo> migrateStorage;
31+
private boolean migrateStorageManaged;
3132
private boolean autoConvergence;
3233
private String hostGuid;
3334
private boolean isWindows;
@@ -53,6 +54,14 @@ public Map<String, MigrateDiskInfo> getMigrateStorage() {
5354
return migrateStorage != null ? new HashMap<>(migrateStorage) : new HashMap<String, MigrateDiskInfo>();
5455
}
5556

57+
public boolean isMigrateStorageManaged() {
58+
return migrateStorageManaged;
59+
}
60+
61+
public void setMigrateStorageManaged(boolean migrateStorageManaged) {
62+
this.migrateStorageManaged = migrateStorageManaged;
63+
}
64+
5665
public void setAutoConvergence(boolean autoConvergence) {
5766
this.autoConvergence = autoConvergence;
5867
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
20+
package com.cloud.agent.api.storage;
21+
22+
import com.cloud.agent.api.Command;
23+
import com.cloud.storage.Storage;
24+
25+
import java.util.Map;
26+
27+
public class CheckStorageAvailabilityCommand extends Command {
28+
29+
private Map<String, Storage.StoragePoolType> poolsMap;
30+
31+
public CheckStorageAvailabilityCommand(Map<String, Storage.StoragePoolType> poolsMap) {
32+
this.poolsMap = poolsMap;
33+
}
34+
35+
public Map<String, Storage.StoragePoolType> getPoolsMap() {
36+
return poolsMap;
37+
}
38+
39+
@Override
40+
public boolean executeInSequence() {
41+
return false;
42+
}
43+
}

core/src/main/java/org/apache/cloudstack/storage/to/VolumeObjectTO.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.apache.cloudstack.storage.to;
2121

22+
import com.cloud.storage.MigrationOptions;
2223
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
2324

2425
import com.cloud.agent.api.to.DataObjectType;
@@ -51,6 +52,7 @@ public class VolumeObjectTO implements DataTO {
5152
private Long iopsWriteRate;
5253
private DiskCacheMode cacheMode;
5354
private Hypervisor.HypervisorType hypervisorType;
55+
private MigrationOptions migrationOptions;
5456

5557
public VolumeObjectTO() {
5658

@@ -81,6 +83,7 @@ public VolumeObjectTO(VolumeInfo volume) {
8183
cacheMode = volume.getCacheMode();
8284
hypervisorType = volume.getHypervisorType();
8385
setDeviceId(volume.getDeviceId());
86+
this.migrationOptions = volume.getMigrationOptions();
8487
}
8588

8689
public String getUuid() {
@@ -252,4 +255,8 @@ public void setCacheMode(DiskCacheMode cacheMode) {
252255
public DiskCacheMode getCacheMode() {
253256
return cacheMode;
254257
}
258+
259+
public MigrationOptions getMigrationOptions() {
260+
return migrationOptions;
261+
}
255262
}

engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.cloud.agent.api.Answer;
2222
import com.cloud.hypervisor.Hypervisor.HypervisorType;
2323
import com.cloud.offering.DiskOffering.DiskCacheMode;
24+
import com.cloud.storage.MigrationOptions;
2425
import com.cloud.storage.Volume;
2526
import com.cloud.vm.VirtualMachine;
2627

@@ -55,4 +56,11 @@ public interface VolumeInfo extends DataObject, Volume {
5556
Long getIopsWriteRate();
5657

5758
DiskCacheMode getCacheMode();
59+
60+
/**
61+
* Currently available for KVM volumes
62+
*/
63+
MigrationOptions getMigrationOptions();
64+
65+
void setMigrationOptions(MigrationOptions migrationOptions);
5866
}

0 commit comments

Comments
 (0)