Skip to content

Commit 3b45bc9

Browse files
committed
Make S3 register template work.
1 parent f8edb55 commit 3b45bc9

5 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎core/src/com/cloud/storage/VMTemplateVO.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,11 @@ public long getDomainId() {
421421
return -1;
422422
}
423423

424+
425+
public void setAccountId(long accountId) {
426+
this.accountId = accountId;
427+
}
428+
424429
@Override
425430
public String getUuid() {
426431
return this.uuid;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ public void setDownloadStatus(String jobId, Status status) {
286286
td.setStatus(Status.POST_DOWNLOAD_FINISHED);
287287
td.setDownloadError("Install completed successfully at " + new SimpleDateFormat().format(new Date()));
288288
}
289+
} else{
290+
// for s3 and swift, we skip post download step and just set status to trigger callback.
291+
td.setStatus(Status.POST_DOWNLOAD_FINISHED);
289292
}
290293
dj.cleanup();
291294
break;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ private Pair<String, Integer> validateUrl(String url) throws IllegalArgumentExc
170170
throw new IllegalArgumentException("Unsupported scheme for url");
171171
}
172172
int port = uri.getPort();
173-
if (!(port == 80 || port == 443 || port == -1)) {
174-
throw new IllegalArgumentException("Only ports 80 and 443 are allowed");
173+
if (!(port == 80 || port == 8080 || port == 443 || port == -1)) {
174+
throw new IllegalArgumentException("Only ports 80, 8080 and 443 are allowed");
175175
}
176176

177177
if (port == -1 && uri.getScheme().equalsIgnoreCase("https")) {

‎engine/storage/integration-test/test/org/apache/cloudstack/storage/test/S3TemplateTest.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.apache.cloudstack.storage.test;
22

3+
import java.util.Date;
34
import java.util.HashMap;
45
import java.util.Map;
56
import java.util.UUID;
@@ -30,10 +31,12 @@
3031
import com.cloud.dc.DataCenterVO;
3132
import com.cloud.dc.DataCenter.NetworkType;
3233
import com.cloud.dc.dao.DataCenterDao;
34+
import com.cloud.hypervisor.Hypervisor.HypervisorType;
3335
import com.cloud.storage.DataStoreRole;
3436
import com.cloud.storage.ScopeType;
3537
import com.cloud.storage.Storage;
3638
import com.cloud.storage.VMTemplateVO;
39+
import com.cloud.storage.Storage.ImageFormat;
3740
import com.cloud.storage.Storage.TemplateType;
3841
import com.cloud.storage.dao.VMTemplateDao;
3942
import com.cloud.storage.download.DownloadMonitorImpl;
@@ -89,6 +92,7 @@ public void setUp() {
8992
sDetails.put(ApiConstants.S3_END_POINT, this.getS3EndPoint());
9093
this.imageStoreHelper.createImageStore(sParams, sDetails);
9194

95+
9296
VMTemplateVO image = new VMTemplateVO();
9397
image.setTemplateType(TemplateType.SYSTEM);
9498
image.setUrl(this.getTemplateUrl());
@@ -106,6 +110,7 @@ public void setUp() {
106110
image.setPrepopulate(true);
107111
image.setCrossZones(true);
108112
image.setExtractable(true);
113+
image.setAccountId(2);
109114
image = templateDao.persist(image);
110115
templateId = image.getId();
111116

‎engine/storage/integration-test/test/resource/testng.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<parameter name="s3-accesskey" value="OYAZXCAFUC1DAFOXNJWI"/>
3636
<parameter name="s3-secretkey" value="YHpRtzNDwl12DtrQmwRvdpnf2xK2AeVM30rXxQ=="/>
3737
<parameter name="s3-endpoint" value="10.223.89.7:8080" />
38-
<parameter name="s3-template-bucket" value="cstemplates"/>
38+
<parameter name="s3-template-bucket" value="cloudstack"/>
3939
<parameter name="s3-usehttps" value="false" />
4040

4141
<parameter name="image-install-path" value="template/tmpl/1/5/"/>

0 commit comments

Comments
 (0)