sureshanaparti commented on code in PR #12778:
URL: https://github.com/apache/cloudstack/pull/12778#discussion_r2909989467


##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapper.java:
##########
@@ -191,23 +191,35 @@ private String mountBackupDirectory(String 
backupRepoAddress, String backupRepoT
             throw new CloudRuntimeException("Failed to create the tmp mount 
directory for restore on the KVM host");
         }
 
-        String mount = String.format(MOUNT_COMMAND, backupRepoType, 
backupRepoAddress, mountDirectory);
-        if ("cifs".equals(backupRepoType)) {
+        if ("cifs".equalsIgnoreCase(backupRepoType)) {
             if (Objects.isNull(mountOptions) || mountOptions.trim().isEmpty()) 
{
                 mountOptions = "nobrl";
             } else {
                 mountOptions += ",nobrl";
             }
         }
+
+        List<String[]> commands = new ArrayList<>();
+        List<String> cmd = new ArrayList<>();
+        cmd.add("sudo");
+        cmd.add("mount");
+        cmd.add("-t");
+        cmd.add(backupRepoType);
+        cmd.add(backupRepoAddress);
+        cmd.add(mountDirectory);
         if (Objects.nonNull(mountOptions) && !mountOptions.trim().isEmpty()) {
-            mount += " -o " + mountOptions;
+            cmd.add("-o");
+            cmd.add(mountOptions);
         }
+        commands.add(cmd.toArray(new String[0]));
 
-        int exitValue = Script.runSimpleBashScriptForExitValue(mount, 
mountTimeout, false);
-        if (exitValue != 0) {
-            logger.error("Failed to mount repository {} of type {} to the 
directory {}", backupRepoAddress, backupRepoType, mountDirectory);
+        Pair<Integer, String> result = Script.executePipedCommands(commands, 
mountTimeout);

Review Comment:
   can move this mount cmd to a method?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to