Skip to content

Commit b5aeb6f

Browse files
author
Abhinandan Prateek
committed
bug 9909: upload manager support multiple secondary storage
1 parent 024bd03 commit b5aeb6f

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

‎api/src/com/cloud/agent/api/storage/CreateEntityDownloadURLCommand.java‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,16 @@
2222

2323
public class CreateEntityDownloadURLCommand extends AbstractDownloadCommand {
2424

25+
public CreateEntityDownloadURLCommand(String parent, String installPath, String uuid) { // this constructor is for creating template download url
26+
super();
27+
this.parent = parent; // parent is required as not the template can be child of one of many parents
28+
this.installPath = installPath;
29+
this.extractLinkUUID = uuid;
30+
}
31+
2532
public CreateEntityDownloadURLCommand(String installPath, String uuid) {
2633
super();
34+
this.parent = parent;
2735
this.installPath = installPath;
2836
this.extractLinkUUID = uuid;
2937
}
@@ -32,6 +40,7 @@ public CreateEntityDownloadURLCommand() {
3240
}
3341

3442
private String installPath;
43+
private String parent;
3544
private String extractLinkUUID;
3645

3746
@Override
@@ -46,6 +55,14 @@ public String getInstallPath() {
4655
public void setInstallPath(String installPath) {
4756
this.installPath = installPath;
4857
}
58+
59+
public String getParent() {
60+
return parent;
61+
}
62+
63+
public void setParent(String parent) {
64+
this.parent = parent;
65+
}
4966

5067
public String getExtractLinkUUID() {
5168
return extractLinkUUID;

‎core/src/com/cloud/storage/template/UploadManagerImpl.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,10 @@ public CreateEntityDownloadURLAnswer handleCreateEntityURLCommand(CreateEntityDo
373373
}
374374

375375

376-
// Create a symbolic link from the actual directory to the template location. The entity would be directly visible under /var/www/html/userdata
377-
cmd.getInstallPath();
376+
// Create a symbolic link from the actual directory to the template location. The entity would be directly visible under /var/www/html/userdata/cmd.getInstallPath();
378377
command = new Script("/bin/bash", s_logger);
379378
command.add("-c");
380-
command.add("ln -sf " + extractMountPoint + File.separator + cmd.getInstallPath() + " " + extractDir + uuid);
379+
command.add("ln -sf /mnt/SecStorage/" + cmd.getParent() + File.separator + cmd.getInstallPath() + " " + extractDir + uuid);
381380
result = command.execute();
382381
if (result != null) {
383382
String errorString = "Error in linking err=" + result;

‎server/src/com/cloud/storage/upload/UploadMonitorImpl.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public UploadVO createEntityDownloadURL(VMTemplateVO template, VMTemplateHostVO
194194
String errorString = "";
195195
boolean success = false;
196196
List<HostVO> storageServers = _serverDao.listByTypeDataCenter(Host.Type.SecondaryStorage, dataCenterId);
197-
if(storageServers == null ) {
197+
if(storageServers == null || storageServers.size() == 0) {
198198
throw new CloudRuntimeException("No Storage Server found at the datacenter - " +dataCenterId);
199199
}
200200

@@ -229,7 +229,7 @@ public UploadVO createEntityDownloadURL(VMTemplateVO template, VMTemplateHostVO
229229
try{
230230
// Create Symlink at ssvm
231231
String uuid = UUID.randomUUID().toString() + ".vhd";
232-
CreateEntityDownloadURLCommand cmd = new CreateEntityDownloadURLCommand(vmTemplateHost.getInstallPath(), uuid);
232+
CreateEntityDownloadURLCommand cmd = new CreateEntityDownloadURLCommand(storageServers.get(0).getParent(), vmTemplateHost.getInstallPath(), uuid);
233233
long result = send(use_ssvm.getId(), cmd, null);
234234
if (result == -1){
235235
errorString = "Unable to create a link for " +type+ " id:"+template.getId();

0 commit comments

Comments
 (0)