Douglas Schilling Landgraf has uploaded a new change for review.

Change subject: backend: upgrade - process symbolic link files
......................................................................

backend: upgrade - process symbolic link files

Currently if users decided to upgrade the ovirt-node via restapi using
the symbolic link name ovirt-node-iso.iso it will fail due the regex
introduced via commit a0293b45c1c. This patch re-introduce the
previous regex and change the java code to process symbolic link files.

Change-Id: If4084095c40848dc5573d434c1c7ca497883b280
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1093303
Signed-off-by: Douglas Schilling Landgraf <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetoVirtISOsQuery.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpgradeOvirtNodeInternalCommand.java
M packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
3 files changed, 33 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/95/27395/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetoVirtISOsQuery.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetoVirtISOsQuery.java
index dc6960c..a759438 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetoVirtISOsQuery.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetoVirtISOsQuery.java
@@ -5,6 +5,9 @@
 import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -59,6 +62,10 @@
             if (matcher.matches() && info.path.isDirectory()) {
                 log.debugFormat("Looking for list of ISOs in [{0}], regex 
[{1}]", info.path, info.isoPattern);
                 for (File file : info.path.listFiles()) {
+                    Path path = Paths.get(file.toString());
+                    if (Files.isSymbolicLink(path)) {
+                        continue;
+                    }
                     matcher = info.isoPattern.matcher(file.getName());
                     if (matcher.matches()) {
                         log.debugFormat("ISO Found [{0}]", file);
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpgradeOvirtNodeInternalCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpgradeOvirtNodeInternalCommand.java
index f4a4cb7..8ec0e43 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpgradeOvirtNodeInternalCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpgradeOvirtNodeInternalCommand.java
@@ -1,5 +1,6 @@
 package org.ovirt.engine.core.bll;
 
+import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.commons.lang.StringUtils;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.action.InstallVdsParameters;
@@ -14,6 +15,11 @@
 import org.ovirt.engine.core.utils.log.LogFactory;
 
 import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
 import java.util.Collections;
 import java.util.Map;
 import java.util.regex.Matcher;
@@ -51,12 +57,28 @@
 
         log.debugFormat("Check if ISO compatible: {0}", iso);
 
+        String FileName = iso.getName();
+        Path path = Paths.get(iso.toString());
+        try {
+            if (Files.isSymbolicLink(path)) {
+                FileName = 
Files.readSymbolicLink(path).getFileName().toString();
+            }
+        } catch(java.nio.file.NotLinkException e) {
+            // If it's not a link, ignore and continue
+        } catch(IOException e) {
+            log.errorFormat(
+                "Cannot find iso [{0}] [{1}]",
+                path,
+                ExceptionUtils.getMessage(e)
+            );
+        }
+
         for (OVirtNodeInfo.Entry info : OVirtNodeInfo.getInstance().get()) {
             if (info.path.equals(iso.getParentFile())) {
-                Matcher matcher = info.isoPattern.matcher(iso.getName());
+                Matcher matcher = info.isoPattern.matcher(FileName);
                 if (matcher.find()) {
                     String rpmLike = matcher.group(1).replaceAll("-", ".");
-                    log.debugFormat("ISO version: {0} {1} {3}", iso, rpmLike, 
ovirtHostOsVersion);
+                    log.debugFormat("ISO version: {0} {1} {2}", iso, rpmLike, 
ovirtHostOsVersion);
                     RpmVersion isoVersion = new RpmVersion(rpmLike, "", true);
                     if 
(VdsHandler.isIsoVersionCompatibleForUpgrade(ovirtHostOsVersion, isoVersion)) {
                         log.debugFormat("ISO compatible: {0}", iso);
diff --git a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql 
b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
index 155f22f..6416e75 100644
--- a/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
+++ b/packaging/dbscripts/upgrade/pre_upgrade/0000_config.sql
@@ -433,7 +433,7 @@
 select fn_db_add_config_value('OvfVirtualSystemType','ENGINE','general');
 --Handling The ovirt-node installation files path
 select 
fn_db_add_config_value('OvirtInitialSupportedIsoVersion','2.5.5:5.8','general');
-select 
fn_db_add_config_value('OvirtIsoPrefix','^ovirt-node-iso-([0-9].*)\.iso$:^rhevh-([0-9].*)\.iso$','general');
+select 
fn_db_add_config_value('OvirtIsoPrefix','^ovirt-node-iso-(.*)\.*\.iso$:^rhevh-(.*)\.*\.iso$','general');
 select fn_db_add_config_value('OvirtNodeOS','^ovirt.*$:^rhev.*$','general');
 select 
fn_db_add_config_value('oVirtISOsRepositoryPath','/usr/share/ovirt-node-iso:/usr/share/rhev-hypervisor','general');
 select 
fn_db_add_config_value('oVirtUpgradeScriptName','/usr/share/vdsm-reg/vdsm-upgrade','general');
@@ -788,7 +788,7 @@
 select fn_db_update_config_value('MigrationSupportForNativeUsb','false','3.1');
 select fn_db_update_config_value('MinimalETLVersion','3.4.0','general');
 select 
fn_db_update_config_value('OvirtInitialSupportedIsoVersion','2.5.5:5.8','general');
-select 
fn_db_update_config_value('OvirtIsoPrefix','^ovirt-node-iso-([0-9].*)\.iso$:^rhevh-([0-9].*)\.iso$','general');
+select 
fn_db_update_config_value('OvirtIsoPrefix','^ovirt-node-iso-(.*)\.*\.iso$:^rhevh-(.*)\.*\.iso$','general');
 select fn_db_update_config_value('OvirtNodeOS','^ovirt.*$:^rhev.*$','general');
 select 
fn_db_update_config_value('oVirtISOsRepositoryPath','/usr/share/ovirt-node-iso:/usr/share/rhev-hypervisor','general');
 select fn_db_update_config_value('PostgresPagingSyntax','OFFSET (%1$s -1) 
LIMIT %2$s','general');


-- 
To view, visit http://gerrit.ovirt.org/27395
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If4084095c40848dc5573d434c1c7ca497883b280
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Douglas Schilling Landgraf <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to