From f6312574a4da150d07c38b5d1473a82bec35a8f1 Mon Sep 17 00:00:00 2001 From: anthony Date: Sun, 29 Aug 2010 19:24:05 -0700 Subject: [PATCH] support multiple patch files Conflicts: core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java --- .../xen/resource/CitrixResourceBase.java | 96 +++++++++++-------- 1 file changed, 55 insertions(+), 41 deletions(-) diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index e8a350b197c..8037d06f07c 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -3825,49 +3825,56 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR } SCPClient scp = new SCPClient(sshConnection); - File file = new File(_patchPath); - - Properties props = new Properties(); - props.load(new FileInputStream(file)); String path = _patchPath.substring(0, _patchPath.lastIndexOf(File.separator) + 1); - for (Map.Entry entry : props.entrySet()) { - String k = (String) entry.getKey(); - String v = (String) entry.getValue(); - - assert (k != null && k.length() > 0 && v != null && v.length() > 0) : "Problems with " + k + "=" + v; - - String[] tokens = v.split(","); - String f = null; - if (tokens.length == 3 && tokens[0].length() > 0) { - if (tokens[0].startsWith("/")) { - f = tokens[0]; - } else if (tokens[0].startsWith("~")) { - String homedir = System.getenv("HOME"); - f = homedir + tokens[0].substring(1) + k; - } else { - f = path + tokens[0] + '/' + k; - } - } else { - f = path + k; - } - String d = tokens[tokens.length - 1]; - f = f.replace('/', File.separatorChar); - - String p = "0755"; - if (tokens.length == 3) { - p = tokens[1]; - } else if (tokens.length == 2) { - p = tokens[0]; - } - - if (!new File(f).exists()) { - s_logger.warn("We cannot locate " + f); - continue; - } - s_logger.info("Copying " + f + " to " + d + " on " + hr.address + " with permission " + p); - scp.put(f, d, p); - s_logger.info("Copied " + f + " to " + d + " on " + hr.address + " with permission " + p); + List files = getPatchFiles(); + if( files == null || files.isEmpty() ) { + throw new CloudRuntimeException("Can not find patch file"); + } + for( File file :files) { + Properties props = new Properties(); + props.load(new FileInputStream(file)); + + for (Map.Entry entry : props.entrySet()) { + String k = (String) entry.getKey(); + String v = (String) entry.getValue(); + + assert (k != null && k.length() > 0 && v != null && v.length() > 0) : "Problems with " + k + "=" + v; + + String[] tokens = v.split(","); + String f = null; + if (tokens.length == 3 && tokens[0].length() > 0) { + if (tokens[0].startsWith("/")) { + f = tokens[0]; + } else if (tokens[0].startsWith("~")) { + String homedir = System.getenv("HOME"); + f = homedir + tokens[0].substring(1) + k; + } else { + f = path + tokens[0] + '/' + k; + } + } else { + f = path + k; + } + String d = tokens[tokens.length - 1]; + f = f.replace('/', File.separatorChar); + + String p = "0755"; + if (tokens.length == 3) { + p = tokens[1]; + } else if (tokens.length == 2) { + p = tokens[0]; + } + + if (!new File(f).exists()) { + s_logger.warn("We cannot locate " + f); + continue; + } + if (s_logger.isDebugEnabled()) { + s_logger.debug("Copying " + f + " to " + d + " on " + hr.address + " with permission " + p); + } + scp.put(f, d, p); + + } } } catch (IOException e) { throw new CloudRuntimeException("Unable to setup the server correctly", e); @@ -3897,6 +3904,13 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR } } + protected List getPatchFiles() { + List files = new ArrayList(); + File file = new File(_patchPath); + files.add(file); + return files; + } + protected SR getSRByNameLabelandHost(String name) throws BadServerResponse, XenAPIException, XmlRpcException { Connection conn = getConnection(); Set srs = SR.getByNameLabel(conn, name);