Repository: cloudstack
Updated Branches:
  refs/heads/volume-upload 3da3d7418 -> b6c86bdb7


volume upload: sending the preshared key to ssvm

sending the key to ssvm in the secondary storage setup command
saving it in a file on ssvm


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d2ef7295
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d2ef7295
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d2ef7295

Branch: refs/heads/volume-upload
Commit: d2ef7295f90ea52788da0d99306bbcf84555cc5b
Parents: 3da3d74
Author: Rajani Karuturi <rajanikarut...@gmail.com>
Authored: Fri Nov 28 16:40:20 2014 +0530
Committer: Rajani Karuturi <rajanikarut...@gmail.com>
Committed: Fri Nov 28 16:40:20 2014 +0530

----------------------------------------------------------------------
 .../cloud/agent/api/SecStorageSetupCommand.java  |  8 ++++++++
 .../SecondaryStorageManagerImpl.java             |  4 ++++
 .../resource/NfsSecondaryStorageResource.java    | 19 ++++++++++++++++---
 3 files changed, 28 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d2ef7295/core/src/com/cloud/agent/api/SecStorageSetupCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/SecStorageSetupCommand.java 
b/core/src/com/cloud/agent/api/SecStorageSetupCommand.java
index 2c29cde..28e55c2 100644
--- a/core/src/com/cloud/agent/api/SecStorageSetupCommand.java
+++ b/core/src/com/cloud/agent/api/SecStorageSetupCommand.java
@@ -27,6 +27,7 @@ public class SecStorageSetupCommand extends Command {
     private DataStoreTO store;
     private String secUrl;
     private KeystoreManager.Certificates certs;
+    private String postUploadKey;
 
 
     public SecStorageSetupCommand() {
@@ -66,4 +67,11 @@ public class SecStorageSetupCommand extends Command {
         this.store = store;
     }
 
+    public String getPostUploadKey() {
+        return postUploadKey;
+    }
+
+    public void setPostUploadKey(String postUploadKey) {
+        this.postUploadKey = postUploadKey;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d2ef7295/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
 
b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
index 3ba4242..79a1486 100755
--- 
a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
+++ 
b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
@@ -310,6 +310,10 @@ public class SecondaryStorageManagerImpl extends 
ManagerBase implements Secondar
                     setupCmd = new SecStorageSetupCommand(ssStore.getTO(), 
secUrl, certs);
                 }
 
+                //template/volume file upload key
+                String postUploadKey = 
_configDao.getValue(Config.SSVMPSK.key());
+                setupCmd.setPostUploadKey(postUploadKey);
+
                 Answer answer = _agentMgr.easySend(ssHostId, setupCmd);
                 if (answer != null && answer.getResult()) {
                     SecStorageSetupAnswer an = (SecStorageSetupAnswer)answer;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d2ef7295/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git 
a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
 
b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
index 55f80e1..54c3630 100755
--- 
a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
+++ 
b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
@@ -47,6 +47,7 @@ import java.util.UUID;
 import javax.naming.ConfigurationException;
 
 import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
@@ -1264,6 +1265,7 @@ public class NfsSecondaryStorageResource extends 
ServerResourceBase implements S
         if (!_inSystemVM) {
             return new Answer(cmd, true, null);
         }
+        Answer answer = null;
         DataStoreTO dStore = cmd.getDataStore();
         if (dStore instanceof NfsTO) {
             String secUrl = cmd.getSecUrl();
@@ -1277,17 +1279,28 @@ public class NfsSecondaryStorageResource extends 
ServerResourceBase implements S
                 configCerts(cmd.getCerts());
 
                 nfsIps.add(nfsHostIp);
-                return new SecStorageSetupAnswer(dir);
+                answer = new SecStorageSetupAnswer(dir);
             } catch (Exception e) {
                 String msg = "GetRootDir for " + secUrl + " failed due to " + 
e.toString();
                 s_logger.error(msg);
-                return new Answer(cmd, false, msg);
+                answer = new Answer(cmd, false, msg);
 
             }
         } else {
             // TODO: what do we need to setup for S3/Swift, maybe need to mount
             // to some cache storage
-            return new Answer(cmd, true, null);
+            answer = new Answer(cmd, true, null);
+        }
+
+        savePostUploadPSK(cmd.getPostUploadKey());
+        return answer;
+    }
+
+    private void savePostUploadPSK(String psk) {
+        try {
+            FileUtils.writeStringToFile(new 
File("/etc/cloudstack/agent/ms-psk"),psk, "utf-8");
+        } catch (IOException ex) {
+            s_logger.debug("Failed to copy PSK to the file.", ex);
         }
     }
 

Reply via email to