Skip to content

Commit 1247cb3

Browse files
committed
StorPool storage plugin
Adds volume storage plugin for StorPool SDS
1 parent 9eefc76 commit 1247cb3

55 files changed

Lines changed: 6682 additions & 30 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.

client/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@
9797
<artifactId>cloud-plugin-storage-volume-linstor</artifactId>
9898
<version>${project.version}</version>
9999
</dependency>
100+
<dependency>
101+
<groupId>org.apache.cloudstack</groupId>
102+
<artifactId>cloud-plugin-storage-volume-storpool</artifactId>
103+
<version>${project.version}</version>
104+
</dependency>
100105
<dependency>
101106
<groupId>org.apache.cloudstack</groupId>
102107
<artifactId>cloud-server</artifactId>
@@ -755,6 +760,12 @@
755760
<artifactId>bcpkix-jdk15on</artifactId>
756761
<overWrite>false</overWrite>
757762
<outputDirectory>${project.build.directory}/lib</outputDirectory>
763+
</artifactItem>
764+
<artifactItem>
765+
<groupId>org.apache.cloudstack</groupId>
766+
<artifactId>cloud-plugin-storage-volume-storpool</artifactId>
767+
<overWrite>false</overWrite>
768+
<outputDirectory>${project.build.directory}/lib</outputDirectory>
758769
</artifactItem>
759770
<artifactItem>
760771
<groupId>org.bouncycastle</groupId>
@@ -799,6 +810,7 @@
799810
<exclude>org.bouncycastle:bcpkix-jdk15on</exclude>
800811
<exclude>org.bouncycastle:bctls-jdk15on</exclude>
801812
<exclude>mysql:mysql-connector-java</exclude>
813+
<exclude>org.apache.cloudstack:cloud-plugin-storage-volume-storpool</exclude>
802814
</excludes>
803815
</artifactSet>
804816
<transformers>

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,28 @@ enum QualityOfServiceState { MIGRATION, NO_MIGRATION }
103103
* returns true if the host can access the storage pool
104104
*/
105105
boolean canHostAccessStoragePool(Host host, StoragePool pool);
106+
107+
/**
108+
* intended for storage pools
109+
* returns true if additional VM info is needed
110+
*/
111+
boolean vmInfoNeeded();
112+
113+
/**
114+
* intended for storage pools
115+
* provide additional info for a VM
116+
*/
117+
void provideVMInfo(long vmId, long volumeId);
118+
119+
/**
120+
* intended for storage pools
121+
* returns true if the storage have to know about the VM's tags
122+
*/
123+
boolean vmTagsNeeded(String tagKey);
124+
125+
/**
126+
* intended for storage pools
127+
* provide added tags of a VM
128+
*/
129+
void provideVMTags(long vmId, long volumeId, String tagValue);
106130
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,12 @@ public interface StorageStrategyFactory {
3636

3737
VMSnapshotStrategy getVmSnapshotStrategy(VMSnapshot vmSnapshot);
3838

39+
/**
40+
* Used only for KVM hypervisors when allocating a VM snapshot
41+
* @param vmId the ID of the virtual machine
42+
* @param ROOT volume pool ID
43+
* @param snapshotMemory for VM snapshots with memory
44+
* @return VMSnapshotStrategy
45+
*/
46+
VMSnapshotStrategy getVmSnapshotStrategy(Long vmId, Long rootPoolId, boolean snapshotMemory);
3947
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ public interface VMSnapshotStrategy {
2929

3030
StrategyPriority canHandle(VMSnapshot vmSnapshot);
3131

32+
/**
33+
* Used only for KVM hypervisors when allocating a VM snapshot
34+
* @param vmId the ID of the virtual machine
35+
* @param snapshotMemory for VM snapshots with memory
36+
* @return StrategyPriority
37+
*/
38+
StrategyPriority canHandle(Long vmId, Long poolId, boolean snapshotMemory);
39+
3240
/**
3341
* Delete vm snapshot only from database. Introduced as a Vmware optimization in which vm snapshots are deleted when
3442
* the vm gets deleted on hypervisor (no need to delete each vm snapshot before deleting vm, just mark them as deleted on DB)

engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import com.cloud.storage.DiskOfferingVO;
5353
import com.cloud.storage.GuestOSHypervisorVO;
5454
import com.cloud.storage.GuestOSVO;
55+
import com.cloud.storage.Storage.ImageFormat;
5556
import com.cloud.storage.VolumeVO;
5657
import com.cloud.storage.dao.DiskOfferingDao;
5758
import com.cloud.storage.dao.GuestOSDao;
@@ -67,6 +68,7 @@
6768
import com.cloud.utils.exception.CloudRuntimeException;
6869
import com.cloud.utils.fsm.NoTransitionException;
6970
import com.cloud.vm.UserVmVO;
71+
import com.cloud.vm.VirtualMachine.State;
7072
import com.cloud.vm.dao.UserVmDao;
7173
import com.cloud.vm.snapshot.VMSnapshot;
7274
import com.cloud.vm.snapshot.VMSnapshotVO;
@@ -449,4 +451,20 @@ public boolean deleteVMSnapshotFromDB(VMSnapshot vmSnapshot, boolean unmanage) {
449451
}
450452
return vmSnapshotDao.remove(vmSnapshot.getId());
451453
}
454+
455+
@Override
456+
public StrategyPriority canHandle(Long vmId, Long rootPoolId, boolean snapshotMemory) {
457+
UserVmVO vm = userVmDao.findById(vmId);
458+
if (vm.getState() == State.Running && !snapshotMemory) {
459+
return StrategyPriority.CANT_HANDLE;
460+
}
461+
462+
List<VolumeVO> volumes = volumeDao.findByInstance(vmId);
463+
for (VolumeVO volume : volumes) {
464+
if (volume.getFormat() != ImageFormat.QCOW2) {
465+
return StrategyPriority.CANT_HANDLE;
466+
}
467+
}
468+
return StrategyPriority.DEFAULT;
469+
}
452470
}

engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/ScaleIOVMSnapshotStrategy.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import com.cloud.server.ManagementServerImpl;
4848
import com.cloud.storage.DiskOfferingVO;
4949
import com.cloud.storage.Storage;
50+
import com.cloud.storage.Storage.ImageFormat;
5051
import com.cloud.storage.VolumeVO;
5152
import com.cloud.storage.dao.DiskOfferingDao;
5253
import com.cloud.storage.dao.VolumeDao;
@@ -484,4 +485,26 @@ private void publishUsageEvent(String type, VMSnapshot vmSnapshot, UserVm userVm
484485
private ScaleIOGatewayClient getScaleIOClient(final Long storagePoolId) throws Exception {
485486
return ScaleIOGatewayClientConnectionPool.getInstance().getClient(storagePoolId, storagePoolDetailsDao);
486487
}
488+
489+
@Override
490+
public StrategyPriority canHandle(Long vmId, Long rootPoolId, boolean snapshotMemory) {
491+
if (snapshotMemory) {
492+
return StrategyPriority.CANT_HANDLE;
493+
}
494+
List<VolumeObjectTO> volumeTOs = vmSnapshotHelper.getVolumeTOList(vmId);
495+
if (volumeTOs == null || volumeTOs.isEmpty()) {
496+
return StrategyPriority.CANT_HANDLE;
497+
}
498+
499+
for (VolumeObjectTO volumeTO : volumeTOs) {
500+
Long poolId = volumeTO.getPoolId();
501+
Storage.StoragePoolType poolType = vmSnapshotHelper.getStoragePoolType(poolId);
502+
if (poolType != Storage.StoragePoolType.PowerFlex || volumeTO.getFormat() != ImageFormat.RAW
503+
|| poolId != rootPoolId) {
504+
return StrategyPriority.CANT_HANDLE;
505+
}
506+
}
507+
508+
return StrategyPriority.HIGHEST;
509+
}
487510
}

engine/storage/src/main/java/org/apache/cloudstack/storage/helper/StorageStrategyFactoryImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ public StrategyPriority canHandle(VMSnapshotStrategy strategy) {
8484
});
8585
}
8686

87+
@Override
88+
public VMSnapshotStrategy getVmSnapshotStrategy(final Long vmId, Long rootPoolId, boolean snapshotMemory) {
89+
return bestMatch(vmSnapshotStrategies, new CanHandle<VMSnapshotStrategy>() {
90+
@Override
91+
public StrategyPriority canHandle(VMSnapshotStrategy strategy) {
92+
return strategy.canHandle(vmId, rootPoolId, snapshotMemory);
93+
}
94+
});
95+
}
96+
8797
private static <T> T bestMatch(Collection<T> collection, final CanHandle<T> canHandle) {
8898
if (collection.size() == 0)
8999
return null;

packaging/centos7/cloud.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ install -D agent/target/transformed/cloudstack-agent-profile.sh ${RPM_BUILD_ROOT
346346
install -D agent/target/transformed/cloudstack-agent.logrotate ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/%{name}-agent
347347
install -D plugins/hypervisors/kvm/target/cloud-plugin-hypervisor-kvm-%{_maventag}.jar ${RPM_BUILD_ROOT}%{_datadir}/%name-agent/lib/cloud-plugin-hypervisor-kvm-%{_maventag}.jar
348348
cp plugins/hypervisors/kvm/target/dependencies/* ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib
349+
cp plugins/storage/volume/storpool/target/*.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib
349350

350351
# Usage server
351352
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/usage

packaging/centos8/cloud.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ install -D agent/target/transformed/cloudstack-agent-profile.sh ${RPM_BUILD_ROOT
339339
install -D agent/target/transformed/cloudstack-agent.logrotate ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/%{name}-agent
340340
install -D plugins/hypervisors/kvm/target/cloud-plugin-hypervisor-kvm-%{_maventag}.jar ${RPM_BUILD_ROOT}%{_datadir}/%name-agent/lib/cloud-plugin-hypervisor-kvm-%{_maventag}.jar
341341
cp plugins/hypervisors/kvm/target/dependencies/* ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib
342+
cp plugins/storage/volume/storpool/target/*.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib
342343

343344
# Usage server
344345
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/usage

packaging/suse15/cloud.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ install -D agent/target/transformed/cloudstack-agent-profile.sh ${RPM_BUILD_ROOT
341341
install -D agent/target/transformed/cloudstack-agent.logrotate ${RPM_BUILD_ROOT}%{_sysconfdir}/logrotate.d/%{name}-agent
342342
install -D plugins/hypervisors/kvm/target/cloud-plugin-hypervisor-kvm-%{_maventag}.jar ${RPM_BUILD_ROOT}%{_datadir}/%name-agent/lib/cloud-plugin-hypervisor-kvm-%{_maventag}.jar
343343
cp plugins/hypervisors/kvm/target/dependencies/* ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib
344+
cp plugins/storage/volume/storpool/target/*.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib
344345

345346
# Usage server
346347
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/usage

0 commit comments

Comments
 (0)