mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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
This commit is contained in:
parent
3da3d7418e
commit
d2ef7295f9
@ -27,6 +27,7 @@ public class SecStorageSetupCommand extends Command {
|
|||||||
private DataStoreTO store;
|
private DataStoreTO store;
|
||||||
private String secUrl;
|
private String secUrl;
|
||||||
private KeystoreManager.Certificates certs;
|
private KeystoreManager.Certificates certs;
|
||||||
|
private String postUploadKey;
|
||||||
|
|
||||||
|
|
||||||
public SecStorageSetupCommand() {
|
public SecStorageSetupCommand() {
|
||||||
@ -66,4 +67,11 @@ public class SecStorageSetupCommand extends Command {
|
|||||||
this.store = store;
|
this.store = store;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPostUploadKey() {
|
||||||
|
return postUploadKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPostUploadKey(String postUploadKey) {
|
||||||
|
this.postUploadKey = postUploadKey;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -310,6 +310,10 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
|||||||
setupCmd = new SecStorageSetupCommand(ssStore.getTO(), secUrl, certs);
|
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);
|
Answer answer = _agentMgr.easySend(ssHostId, setupCmd);
|
||||||
if (answer != null && answer.getResult()) {
|
if (answer != null && answer.getResult()) {
|
||||||
SecStorageSetupAnswer an = (SecStorageSetupAnswer)answer;
|
SecStorageSetupAnswer an = (SecStorageSetupAnswer)answer;
|
||||||
|
|||||||
@ -47,6 +47,7 @@ import java.util.UUID;
|
|||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.http.HttpEntity;
|
import org.apache.http.HttpEntity;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
@ -1264,6 +1265,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
if (!_inSystemVM) {
|
if (!_inSystemVM) {
|
||||||
return new Answer(cmd, true, null);
|
return new Answer(cmd, true, null);
|
||||||
}
|
}
|
||||||
|
Answer answer = null;
|
||||||
DataStoreTO dStore = cmd.getDataStore();
|
DataStoreTO dStore = cmd.getDataStore();
|
||||||
if (dStore instanceof NfsTO) {
|
if (dStore instanceof NfsTO) {
|
||||||
String secUrl = cmd.getSecUrl();
|
String secUrl = cmd.getSecUrl();
|
||||||
@ -1277,17 +1279,28 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||||||
configCerts(cmd.getCerts());
|
configCerts(cmd.getCerts());
|
||||||
|
|
||||||
nfsIps.add(nfsHostIp);
|
nfsIps.add(nfsHostIp);
|
||||||
return new SecStorageSetupAnswer(dir);
|
answer = new SecStorageSetupAnswer(dir);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String msg = "GetRootDir for " + secUrl + " failed due to " + e.toString();
|
String msg = "GetRootDir for " + secUrl + " failed due to " + e.toString();
|
||||||
s_logger.error(msg);
|
s_logger.error(msg);
|
||||||
return new Answer(cmd, false, msg);
|
answer = new Answer(cmd, false, msg);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO: what do we need to setup for S3/Swift, maybe need to mount
|
// TODO: what do we need to setup for S3/Swift, maybe need to mount
|
||||||
// to some cache storage
|
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user