Skip to content

Commit 0268658

Browse files
committed
First draft of register template using image store.
1 parent 3897590 commit 0268658

36 files changed

Lines changed: 735 additions & 558 deletions

File tree

‎api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,7 @@ public class RegisterTemplateCmd extends BaseCmd {
110110
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType = ProjectResponse.class,
111111
description="Register template for the project")
112112
private Long projectId;
113-
114-
@Parameter(name=ApiConstants.IMAGE_STORE_UUID, type=CommandType.STRING,
115-
description="Image store uuid")
116-
private String imageStoreUuid;
117-
113+
118114
@Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, description="Template details in key/value pairs.")
119115
protected Map details;
120116

@@ -193,10 +189,7 @@ public String getChecksum() {
193189
public String getTemplateTag() {
194190
return templateTag;
195191
}
196-
197-
public String getImageStoreUuid() {
198-
return this.imageStoreUuid;
199-
}
192+
200193

201194
public Map getDetails() {
202195
if (details == null || details.isEmpty()) {

‎engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStore.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public interface DataStore {
2323
String getUuid();
2424
String getUri();
2525
Scope getScope();
26+
String getName();
2627
DataObject create(DataObject obj);
2728
boolean delete(DataObject obj);
2829
}

‎engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreManager.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public interface DataStoreManager {
2626
public DataStore getDataStore(long storeId, DataStoreRole role);
2727
public DataStore getPrimaryDataStore(long storeId);
2828
public DataStore getDataStore(String uuid, DataStoreRole role);
29-
public List<DataStore> getImageStoresByScope(Scope scope);
29+
public List<DataStore> getImageStoresByScope(ZoneScope scope);
3030
public List<DataStore> getImageStoresByProvider(String provider);
3131
public DataStore registerDataStore(Map<String, String> params, String providerUuid);
3232
}

‎engine/api/src/org/apache/cloudstack/storage/datastore/db/ImageStoreDao.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
import java.util.List;
2222

2323

24-
import com.cloud.storage.ScopeType;
24+
import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
25+
26+
2527
import com.cloud.utils.db.GenericDao;
2628

2729
public interface ImageStoreDao extends GenericDao<ImageStoreVO, Long> {
2830
public ImageStoreVO findByName(String name);
2931
public List<ImageStoreVO> findByProvider(String provider);
30-
public List<ImageStoreVO> findByScope(ScopeType scope);
32+
public List<ImageStoreVO> findByScope(ZoneScope scope);
3133

3234
}

‎engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreDao.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@
1919

2020
import java.util.List;
2121

22+
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
2223
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
2324

2425

2526
import com.cloud.utils.db.GenericDao;
2627
import com.cloud.utils.fsm.StateDao;
2728

28-
public interface SnapshotDataStoreDao extends GenericDao<SnapshotDataStoreVO, Long>, StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, SnapshotDataStoreVO> {
29+
public interface SnapshotDataStoreDao extends GenericDao<SnapshotDataStoreVO, Long>, StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
2930

3031
public List<SnapshotDataStoreVO> listByStoreId(long id);
3132

‎engine/api/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ public long getDataStoreId() {
9999
return dataStoreId;
100100
}
101101

102-
public void setHostId(long hostId) {
103-
this.dataStoreId = hostId;
102+
public void setDataStoreId(long storeId) {
103+
this.dataStoreId = storeId;
104104
}
105105

106106

@@ -151,7 +151,7 @@ public SnapshotDataStoreVO(long hostId, long snapshotId) {
151151

152152

153153

154-
protected SnapshotDataStoreVO() {
154+
public SnapshotDataStoreVO() {
155155

156156
}
157157

‎engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,23 @@
1818

1919
import java.util.List;
2020

21+
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
22+
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
2123
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
2224

25+
2326
import com.cloud.utils.db.GenericDao;
2427
import com.cloud.utils.fsm.StateDao;
2528

26-
public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO, Long>, StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, TemplateDataStoreVO> {
29+
public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO, Long>, StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
2730

2831
public List<TemplateDataStoreVO> listByStoreId(long id);
2932

3033
public List<TemplateDataStoreVO> listLiveByStoreId(long id);
3134

3235
public void deletePrimaryRecordsForStore(long id);
36+
37+
List<TemplateDataStoreVO> listByTemplateStoreStatus(long templateId, long storeId, State... states);
38+
39+
TemplateDataStoreVO findByStoreTemplate(long storeId, long templateId);
3340
}

‎engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
3333
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
3434

35-
import com.cloud.storage.VMTemplateStorageResourceAssoc;
3635
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
3736

3837
import com.cloud.utils.db.GenericDaoBase;
@@ -118,8 +117,8 @@ public long getDataStoreId() {
118117
return dataStoreId;
119118
}
120119

121-
public void setHostId(long hostId) {
122-
this.dataStoreId = hostId;
120+
public void setDataStoreId(long storeId) {
121+
this.dataStoreId = storeId;
123122
}
124123

125124
public long getTemplateId() {
@@ -158,6 +157,7 @@ public void setLastUpdated(Date date) {
158157
lastUpdated = date;
159158
}
160159

160+
@Override
161161
public void setInstallPath(String installPath) {
162162
this.installPath = installPath;
163163
}
@@ -190,7 +190,7 @@ public TemplateDataStoreVO(long hostId, long templateId, Date lastUpdated,
190190
this.setDownloadUrl(downloadUrl);
191191
}
192192

193-
protected TemplateDataStoreVO() {
193+
public TemplateDataStoreVO() {
194194

195195
}
196196

‎engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919

2020
import java.util.List;
2121

22+
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
2223
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
2324

2425
import com.cloud.utils.db.GenericDao;
2526
import com.cloud.utils.fsm.StateDao;
2627

27-
public interface VolumeDataStoreDao extends GenericDao<VolumeDataStoreVO, Long>, StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, VolumeDataStoreVO> {
28+
public interface VolumeDataStoreDao extends GenericDao<VolumeDataStoreVO, Long>, StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
2829

2930
public List<VolumeDataStoreVO> listByStoreId(long id);
3031

‎engine/api/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ public long getDataStoreId() {
121121
return dataStoreId;
122122
}
123123

124-
public void setHostId(long hostId) {
125-
this.dataStoreId = hostId;
124+
public void setDataStoreId(long storeId) {
125+
this.dataStoreId = storeId;
126126
}
127127

128128

@@ -223,7 +223,7 @@ public VolumeDataStoreVO(long hostId, long volumeId, long zoneId, Date lastUpdat
223223
this.format = format;
224224
}
225225

226-
protected VolumeDataStoreVO() {
226+
public VolumeDataStoreVO() {
227227

228228
}
229229

0 commit comments

Comments
 (0)