4444import com .cloud .storage .Storage .ImageFormat ;
4545import com .cloud .storage .Storage .TemplateType ;
4646import com .cloud .storage .VMTemplateStoragePoolVO ;
47- import com .cloud .storage .VMTemplateVO ;
4847import com .cloud .storage .VMTemplateStorageResourceAssoc .Status ;
48+ import com .cloud .storage .VMTemplateVO ;
4949import com .cloud .storage .dao .VMTemplateDao ;
5050import com .cloud .storage .dao .VMTemplatePoolDao ;
5151import com .cloud .utils .component .ComponentContext ;
@@ -122,12 +122,12 @@ public Long getSize() {
122122 }
123123
124124 /*
125- *
125+ *
126126 * // If the template that was passed into this allocator is not
127127 * installed in the storage pool, // add 3 * (template size on secondary
128128 * storage) to the running total VMTemplateHostVO templateHostVO =
129129 * _storageMgr.findVmTemplateHost(templateForVmCreation.getId(), null);
130- *
130+ *
131131 * if (templateHostVO == null) { VMTemplateSwiftVO templateSwiftVO =
132132 * _swiftMgr.findByTmpltId(templateForVmCreation.getId()); if
133133 * (templateSwiftVO != null) { long templateSize =
@@ -152,12 +152,14 @@ public ImageFormat getFormat() {
152152 return this .imageVO .getFormat ();
153153 }
154154
155- // public boolean stateTransit(TemplateEvent e) throws NoTransitionException {
156- // this.imageVO = imageDao.findById(this.imageVO.getId());
157- // boolean result = imageMgr.getStateMachine().transitTo(this.imageVO, e, null, imageDao);
158- // this.imageVO = imageDao.findById(this.imageVO.getId());
159- // return result;
160- // }
155+ // public boolean stateTransit(TemplateEvent e) throws NoTransitionException
156+ // {
157+ // this.imageVO = imageDao.findById(this.imageVO.getId());
158+ // boolean result = imageMgr.getStateMachine().transitTo(this.imageVO, e,
159+ // null, imageDao);
160+ // this.imageVO = imageDao.findById(this.imageVO.getId());
161+ // return result;
162+ // }
161163
162164 @ Override
163165 public void processEvent (Event event ) {
@@ -175,9 +177,10 @@ public void processEvent(Event event) {
175177 templEvent = TemplateEvent .OperationFailed ;
176178 }
177179
178- // if (templEvent != null && this.getDataStore().getRole() == DataStoreRole.Image) {
179- // this.stateTransit(templEvent);
180- // }
180+ // if (templEvent != null && this.getDataStore().getRole() ==
181+ // DataStoreRole.Image) {
182+ // this.stateTransit(templEvent);
183+ // }
181184 }
182185
183186 objectInStoreMgr .update (this , event );
@@ -238,9 +241,10 @@ public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answe
238241 templEvent = TemplateEvent .OperationFailed ;
239242 }
240243
241- // if (templEvent != null && this.getDataStore().getRole() == DataStoreRole.Image) {
242- // this.stateTransit(templEvent);
243- // }
244+ // if (templEvent != null && this.getDataStore().getRole() ==
245+ // DataStoreRole.Image) {
246+ // this.stateTransit(templEvent);
247+ // }
244248 }
245249 objectInStoreMgr .update (this , event );
246250 } catch (NoTransitionException e ) {
@@ -264,9 +268,8 @@ public void incRefCount() {
264268 return ;
265269 }
266270
267- if (this .dataStore .getRole () == DataStoreRole .Image ||
268- this .dataStore .getRole () == DataStoreRole .ImageCache ) {
269- TemplateDataStoreVO store = templateStoreDao .findById (this .dataStore .getId ());
271+ if (this .dataStore .getRole () == DataStoreRole .Image || this .dataStore .getRole () == DataStoreRole .ImageCache ) {
272+ TemplateDataStoreVO store = templateStoreDao .findByStoreTemplate (dataStore .getId (), this .getId ());
270273 store .incrRefCnt ();
271274 store .setLastUpdated (new Date ());
272275 templateStoreDao .update (store .getId (), store );
@@ -278,9 +281,8 @@ public void decRefCount() {
278281 if (this .dataStore == null ) {
279282 return ;
280283 }
281- if (this .dataStore .getRole () == DataStoreRole .Image ||
282- this .dataStore .getRole () == DataStoreRole .ImageCache ) {
283- TemplateDataStoreVO store = templateStoreDao .findById (this .dataStore .getId ());
284+ if (this .dataStore .getRole () == DataStoreRole .Image || this .dataStore .getRole () == DataStoreRole .ImageCache ) {
285+ TemplateDataStoreVO store = templateStoreDao .findByStoreTemplate (dataStore .getId (), this .getId ());
284286 store .decrRefCnt ();
285287 store .setLastUpdated (new Date ());
286288 templateStoreDao .update (store .getId (), store );
@@ -292,9 +294,8 @@ public Long getRefCount() {
292294 if (this .dataStore == null ) {
293295 return null ;
294296 }
295- if (this .dataStore .getRole () == DataStoreRole .Image ||
296- this .dataStore .getRole () == DataStoreRole .ImageCache ) {
297- TemplateDataStoreVO store = templateStoreDao .findById (this .dataStore .getId ());
297+ if (this .dataStore .getRole () == DataStoreRole .Image || this .dataStore .getRole () == DataStoreRole .ImageCache ) {
298+ TemplateDataStoreVO store = templateStoreDao .findByStoreTemplate (dataStore .getId (), this .getId ());
298299 return store .getRefCnt ();
299300 }
300301 return null ;
@@ -442,5 +443,4 @@ public boolean delete() {
442443 return true ;
443444 }
444445
445-
446446}
0 commit comments