Ramesh N has uploaded a new change for review.

Change subject: engine: filter out volume snapshots from storage devices list
......................................................................

engine: filter out volume snapshots from storage devices list

  Filter out all the lvmsnapshots which are created as part of
gluster volume snapshot from the storage devices list. All the
LVM snapshots creted by gluster volume snapshots will be
mounted at the location /var/run/gluster/snaps/.

Change-Id: Ib8e8fa3049e271db8a4919afc72716fb459d22e5
Bug-Url: https://bugzilla.redhat.com/1227885
Signed-off-by: Ramesh Nachimuthu <rnach...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterStorageDevicesQuery.java
M packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
2 files changed, 16 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/25/42225/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterStorageDevicesQuery.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterStorageDevicesQuery.java
index 4f5a99a..c3edcc6 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterStorageDevicesQuery.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GetGlusterStorageDevicesQuery.java
@@ -3,6 +3,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.regex.Pattern;
 
 import org.ovirt.engine.core.bll.QueriesCommandBase;
 import org.ovirt.engine.core.common.businessentities.gluster.StorageDevice;
@@ -27,12 +28,11 @@
 
     private List<StorageDevice> filterStorageDevices(List<StorageDevice> 
storageDevices) {
         List<StorageDevice> filteredStorageDevices = new ArrayList<>();
-        List<String> mountPointsToFilterOutList = getMountPointsFilter();
+        Pattern mountPointsFilterPattern = 
Pattern.compile(getMountPointsFilterPattern());
         List<String> fsTypesToFilterOutList = getFsTypesFilter();
-
         // Filter out the devices which are not going to be used as storage 
device for gluster.
         for (StorageDevice device : storageDevices) {
-            if ((device.getMountPoint() != null && 
mountPointsToFilterOutList.contains(device.getMountPoint()))
+            if ((device.getMountPoint() != null && 
mountPointsFilterPattern.matcher(device.getMountPoint()).matches())
                     || (device.getFsType() != null && 
fsTypesToFilterOutList.contains(device.getFsType()))) {
                 continue;
             }
@@ -43,9 +43,18 @@
         return filteredStorageDevices;
     }
 
-    private List<String> getMountPointsFilter() {
-        return Arrays.asList(Config.<String> 
getValue(ConfigValues.GlusterStorageDeviceListMountPointsToIgore).split(","));
-
+    private String getMountPointsFilterPattern() {
+        String[] mountPointsToIgnore = Config.<String> 
getValue(ConfigValues.GlusterStorageDeviceListMountPointsToIgore).split(",");
+        // Mounts to be ignored can be exact mount point are a regular 
expression which should with the starting part of
+        // the mount point. So create a regex which can match against any 
given pattern in the list.
+        StringBuilder pattern = new StringBuilder();
+        for(String mointPoint:mountPointsToIgnore){
+            pattern.append("^");
+            pattern.append(mointPoint);
+            pattern.append("$");
+            pattern.append("|");
+        }
+        return pattern.toString();
     }
 
     private List<String> getFsTypesFilter() {
diff --git a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql 
b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
index 7426364..0c2ac7d 100644
--- a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
+++ b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
@@ -180,7 +180,7 @@
 
 -- Gluster Disk Provisioning --
 select 
fn_db_add_config_value_for_versions_up_to('GlusterBrickProvisioningEnabled', 
'false', '3.5');
-select 
fn_db_add_config_value('GlusterStorageDeviceListMountPointsToIgore','/,/home,/boot','general');
+select 
fn_db_add_config_value('GlusterStorageDeviceListMountPointsToIgore','/,/home,/boot,/var/run/gluster/snaps/.*','general');
 select 
fn_db_add_config_value('GlusterStorageDeviceListFileSystemTypesToIgore','swap','general');
 select 
fn_db_add_config_value('GlusterDefaultBrickMountPoint','/gluster-bricks','general');
 


-- 
To view, visit https://gerrit.ovirt.org/42225
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib8e8fa3049e271db8a4919afc72716fb459d22e5
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Ramesh N <rnach...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to