@@ -342,69 +342,4 @@ public TemplateProfile prepareDelete(DeleteIsoCmd cmd) {
342342
343343 return profile ;
344344 }
345-
346- @ Override
347- public TemplateProfile prepareExtractTemplate (ExtractTemplateCmd extractcmd ) {
348- TemplateProfile profile = super .prepareExtractTemplate (extractcmd );
349- VMTemplateVO template = profile .getTemplate ();
350- Long zoneId = profile .getZoneId ();
351- Long templateId = template .getId ();
352-
353- // Simply return profile if non-ESX hypervisor.
354- if (template .getHypervisorType () == HypervisorType .VMware ) {
355- PrepareOVAPackingCommand cmd = null ;
356- String zoneName ="" ;
357- List <DataStore > imageStores = null ;
358-
359- if (!template .isCrossZones ()) {
360- if (zoneId == null ) {
361- throw new CloudRuntimeException ("ZoneId cannot be null for a template that is not available across zones" );
362- }
363- // Else get the list of image stores in this zone's scope.
364- DataCenterVO zone = _dcDao .findById (zoneId );
365- zoneName = zone .getName ();
366- imageStores = this .storeMgr .getImageStoresByScope (new ZoneScope (profile .getZoneId ()));
367- } else {
368- // template is available across zones. Get a list of all image stores.
369- imageStores = this .storeMgr .listImageStores ();
370- }
371-
372- if (imageStores == null || imageStores .size () == 0 ) {
373- throw new CloudRuntimeException ("Unable to find an image store zone when trying to download template " + profile .getTemplate ());
374- }
375-
376- s_logger .debug ("Attempting to mark template host refs for template: " + template .getName () + " as destroyed in zone: " + zoneName );
377-
378- // Make sure the template is downloaded to all the necessary secondary storage hosts
379-
380- for (DataStore store : imageStores ) {
381- long storeId = store .getId ();
382- List <TemplateDataStoreVO > templateStoreVOs = _tmpltStoreDao .listByTemplateStore (templateId , storeId );
383- for (TemplateDataStoreVO templateStoreVO : templateStoreVOs ) {
384- if (templateStoreVO .getDownloadState () == Status .DOWNLOAD_IN_PROGRESS ) {
385- String errorMsg = "Please specify a template that is not currently being downloaded." ;
386- s_logger .debug ("Template: " + template .getName () + " is currently being downloaded to secondary storage host: " + store .getName () + "." );
387- throw new CloudRuntimeException (errorMsg );
388- }
389- String installPath = templateStoreVO .getInstallPath ();
390- if (installPath != null ) {
391- EndPoint ep = _epSelector .select (store );
392- if (ep == null ) {
393- s_logger .warn ("prepareOVAPacking (hyervisorTemplateAdapter): There is no secondary storage VM for secondary storage host " + store .getName ());
394- throw new CloudRuntimeException ("PrepareExtractTemplate: can't locate ssvm for SecStorage Host." );
395- }
396- cmd = new PrepareOVAPackingCommand (store .getUri (), installPath );
397- cmd .setContextParam ("hypervisor" , HypervisorType .VMware .toString ());
398- Answer answer = ep .sendMessage (cmd );
399-
400- if (answer == null || !answer .getResult ()) {
401- s_logger .debug ("Failed to create OVA for template " + templateStoreVO + " due to " + ((answer == null ) ? "answer is null" : answer .getDetails ()));
402- throw new CloudRuntimeException ("PrepareExtractTemplate: Failed to create OVA for template extraction. " );
403- }
404- }
405- }
406- }
407- }
408- return profile ;
409- }
410345}
0 commit comments