DaanHoogland commented on a change in pull request #5831:
URL: https://github.com/apache/cloudstack/pull/5831#discussion_r797752158



##########
File path: utils/src/main/java/com/cloud/utils/FileUtil.java
##########
@@ -21,12 +21,39 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
 
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.ssh.SshHelper;
 import org.apache.commons.io.FileUtils;
+import org.apache.log4j.Logger;
 
 public class FileUtil {
+    private static final Logger s_logger = Logger.getLogger(FileUtil.class);
 
     public static void copyfile(File source, File destination) throws 
IOException {
         FileUtils.copyFile(source, destination);
     }
+
+    public static void scpPatchFiles(String controlIp, String destPath, int 
sshPort, File pemFile, String[] files, String basePath) {
+        String errMsg = "Failed to scp files to system VM";
+        List<String> srcFiles = Arrays.asList(files);
+        srcFiles = srcFiles.stream()
+                .map(file -> basePath + file) // Using Lambda notation to 
update the entries
+                .collect(Collectors.toList());
+        String[] newSrcFiles = srcFiles.toArray(new String[0]);
+        for (int retries = 3; retries > 0; retries--) {
+            try {
+                SshHelper.scpTo(controlIp, sshPort, "root", pemFile, null,
+                        destPath, newSrcFiles, "0755");
+                return;
+            } catch (Exception e) {

Review comment:
       cat we be more specific about what we catch here?




-- 
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