@@ -530,61 +530,6 @@ private void reallyRun() {
530530 }
531531
532532
533-
534- String uploadTemplateToSwiftFromSecondaryStorage (VMTemplateHostVO templateHostRef ) {
535- Long templateId = templateHostRef .getTemplateId ();
536- VMTemplateVO template = _tmpltDao .findById (templateId );
537- if (template == null ) {
538- String errMsg = " Can not find template " + templateId ;
539- s_logger .warn (errMsg );
540- return errMsg ;
541- }
542-
543- if (template .getTemplateType () == TemplateType .PERHOST ) {
544- return null ;
545- }
546-
547- SwiftTO swift = _swiftMgr .getSwiftTO ();
548- if (swift == null ) {
549- String errMsg = " There is no Swift in this setup " ;
550- s_logger .warn (errMsg );
551- return errMsg ;
552- }
553-
554- HostVO secHost = _hostDao .findById (templateHostRef .getHostId ());
555- if (secHost == null ) {
556- String errMsg = "Can not find secondary storage " + templateHostRef .getHostId ();
557- s_logger .warn (errMsg );
558- return errMsg ;
559- }
560-
561- uploadTemplateToSwiftFromSecondaryStorageCommand cmd = new uploadTemplateToSwiftFromSecondaryStorageCommand (swift , secHost .getName (), secHost .getDataCenterId (), template .getAccountId (),
562- templateId , _primaryStorageDownloadWait );
563- Answer answer = null ;
564- try {
565- answer = _agentMgr .sendToSSVM (secHost .getDataCenterId (), cmd );
566- if (answer == null || !answer .getResult ()) {
567- if (template .getTemplateType () != TemplateType .SYSTEM ) {
568- String errMsg = "Failed to upload template " + templateId + " to Swift from secondary storage due to " + ((answer == null ) ? "null" : answer .getDetails ());
569- s_logger .warn (errMsg );
570- throw new CloudRuntimeException (errMsg );
571- }
572- return null ;
573- }
574- String path = templateHostRef .getInstallPath ();
575- int index = path .lastIndexOf ('/' );
576- path = path .substring (index + 1 );
577- VMTemplateSwiftVO tmpltSwift = new VMTemplateSwiftVO (swift .getId (), templateHostRef .getTemplateId (), new Date (), path , templateHostRef .getSize (), templateHostRef .getPhysicalSize ());
578- _tmpltSwiftDao .persist (tmpltSwift );
579- _swiftMgr .propagateTemplateOnAllZones (templateHostRef .getTemplateId ());
580- } catch (Exception e ) {
581- String errMsg = "Failed to upload template " + templateId + " to Swift from secondary storage due to " + e .toString ();
582- s_logger .warn (errMsg );
583- throw new CloudRuntimeException (errMsg );
584- }
585- return null ;
586- }
587-
588533 @ Override @ DB
589534 public VMTemplateStoragePoolVO prepareTemplateForCreate (VMTemplateVO templ , StoragePool pool ) {
590535 VMTemplateVO template = _tmpltDao .findById (templ .getId (), true );
@@ -1182,30 +1127,14 @@ public boolean deleteIso(DeleteIsoCmd cmd) {
11821127 if (template .getFormat () != ImageFormat .ISO ) {
11831128 throw new InvalidParameterValueException ("Please specify a valid iso." );
11841129 }
1185- if (cmd .getZoneId () == null && _swiftMgr .isSwiftEnabled ()) {
1186- _swiftMgr .deleteIso (cmd );
1187- }
1188- if (cmd .getZoneId () == null && _s3Mgr .isS3Enabled ()) {
1189- _s3Mgr .deleteTemplate (caller .getAccountId (), templateId );
1190- }
11911130
1192- if (zoneId != null && (_ssvmMgr . findSecondaryStorageHost (zoneId ) == null )) {
1193- throw new InvalidParameterValueException ("Failed to find a secondary storage host in the specified zone." );
1131+ if (zoneId != null && (this . _dataStoreMgr . getImageStore (zoneId ) == null )) {
1132+ throw new InvalidParameterValueException ("Failed to find a secondary storage store in the specified zone." );
11941133 }
11951134 TemplateAdapter adapter = getAdapter (template .getHypervisorType ());
11961135 TemplateProfile profile = adapter .prepareDelete (cmd );
11971136 boolean result = adapter .delete (profile );
11981137 if (result ) {
1199- if (cmd .getZoneId () == null
1200- && (_swiftMgr .isSwiftEnabled () || _s3Mgr .isS3Enabled ())) {
1201- List <VMTemplateZoneVO > templateZones = _tmpltZoneDao
1202- .listByZoneTemplate (null , templateId );
1203- if (templateZones != null ) {
1204- for (VMTemplateZoneVO templateZone : templateZones ) {
1205- _tmpltZoneDao .remove (templateZone .getId ());
1206- }
1207- }
1208- }
12091138 return true ;
12101139 } else {
12111140 throw new CloudRuntimeException ("Failed to delete ISO" );
0 commit comments