@@ -73,7 +73,6 @@ public Answer execute(ConvertInstanceCommand cmd, LibvirtComputingResource serve
7373 Hypervisor .HypervisorType sourceHypervisorType = sourceInstance .getHypervisorType ();
7474 String sourceInstanceName = sourceInstance .getInstanceName ();
7575 Hypervisor .HypervisorType destinationHypervisorType = cmd .getDestinationHypervisorType ();
76- List <String > destinationStoragePools = cmd .getDestinationStoragePools ();
7776 DataStoreTO conversionTemporaryLocation = cmd .getConversionTemporaryLocation ();
7877 long timeout = (long ) cmd .getWait () * 1000 ;
7978
@@ -139,21 +138,7 @@ public Answer execute(ConvertInstanceCommand cmd, LibvirtComputingResource serve
139138 s_logger .error (err );
140139 return new ConvertInstanceAnswer (cmd , false , err );
141140 }
142- String convertedBasePath = String .format ("%s/%s" , temporaryConvertPath , temporaryConvertUuid );
143- LibvirtDomainXMLParser xmlParser = parseMigratedVMXmlDomain (convertedBasePath );
144-
145- List <KVMPhysicalDisk > temporaryDisks = xmlParser == null ?
146- getTemporaryDisksWithPrefixFromTemporaryPool (temporaryStoragePool , temporaryConvertPath , temporaryConvertUuid ) :
147- getTemporaryDisksFromParsedXml (temporaryStoragePool , xmlParser , convertedBasePath );
148-
149- List <KVMPhysicalDisk > destinationDisks = moveTemporaryDisksToDestination (temporaryDisks ,
150- destinationStoragePools , storagePoolMgr );
151-
152- cleanupDisksAndDomainFromTemporaryLocation (temporaryDisks , temporaryStoragePool , temporaryConvertUuid );
153-
154- UnmanagedInstanceTO convertedInstanceTO = getConvertedUnmanagedInstance (temporaryConvertUuid ,
155- destinationDisks , xmlParser );
156- return new ConvertInstanceAnswer (cmd , convertedInstanceTO );
141+ return new ConvertInstanceAnswer (cmd , false , null );
157142 } catch (Exception e ) {
158143 String error = String .format ("Error converting instance %s from %s, due to: %s" ,
159144 sourceInstanceName , sourceHypervisorType , e .getMessage ());
@@ -165,10 +150,6 @@ public Answer execute(ConvertInstanceCommand cmd, LibvirtComputingResource serve
165150 s_logger .debug ("Cleaning up exported OVA at dir " + sourceOVFDir );
166151 FileUtil .deletePath (sourceOVFDir );
167152 }
168- if (conversionTemporaryLocation instanceof NfsTO ) {
169- s_logger .debug ("Cleaning up secondary storage temporary location" );
170- storagePoolMgr .deleteStoragePool (temporaryStoragePool .getType (), temporaryStoragePool .getUuid ());
171- }
172153 }
173154 }
174155
@@ -247,17 +228,6 @@ protected List<KVMPhysicalDisk> getTemporaryDisksWithPrefixFromTemporaryPool(KVM
247228 return disksWithPrefix ;
248229 }
249230
250- private void cleanupDisksAndDomainFromTemporaryLocation (List <KVMPhysicalDisk > disks ,
251- KVMStoragePool temporaryStoragePool ,
252- String temporaryConvertUuid ) {
253- for (KVMPhysicalDisk disk : disks ) {
254- s_logger .info (String .format ("Cleaning up temporary disk %s after conversion from temporary location" , disk .getName ()));
255- temporaryStoragePool .deletePhysicalDisk (disk .getName (), Storage .ImageFormat .QCOW2 );
256- }
257- s_logger .info (String .format ("Cleaning up temporary domain %s after conversion from temporary location" , temporaryConvertUuid ));
258- FileUtil .deleteFiles (temporaryStoragePool .getLocalPath (), temporaryConvertUuid , ".xml" );
259- }
260-
261231 protected void sanitizeDisksPath (List <LibvirtVMDef .DiskDef > disks ) {
262232 for (LibvirtVMDef .DiskDef disk : disks ) {
263233 String [] diskPathParts = disk .getDiskPath ().split ("/" );
@@ -303,31 +273,6 @@ protected List<KVMPhysicalDisk> moveTemporaryDisksToDestination(List<KVMPhysical
303273 return targetDisks ;
304274 }
305275
306- private UnmanagedInstanceTO getConvertedUnmanagedInstance (String baseName ,
307- List <KVMPhysicalDisk > vmDisks ,
308- LibvirtDomainXMLParser xmlParser ) {
309- UnmanagedInstanceTO instanceTO = new UnmanagedInstanceTO ();
310- instanceTO .setName (baseName );
311- instanceTO .setDisks (getUnmanagedInstanceDisks (vmDisks , xmlParser ));
312- instanceTO .setNics (getUnmanagedInstanceNics (xmlParser ));
313- return instanceTO ;
314- }
315-
316- private List <UnmanagedInstanceTO .Nic > getUnmanagedInstanceNics (LibvirtDomainXMLParser xmlParser ) {
317- List <UnmanagedInstanceTO .Nic > nics = new ArrayList <>();
318- if (xmlParser != null ) {
319- List <LibvirtVMDef .InterfaceDef > interfaces = xmlParser .getInterfaces ();
320- for (LibvirtVMDef .InterfaceDef interfaceDef : interfaces ) {
321- UnmanagedInstanceTO .Nic nic = new UnmanagedInstanceTO .Nic ();
322- nic .setMacAddress (interfaceDef .getMacAddress ());
323- nic .setNicId (interfaceDef .getBrName ());
324- nic .setAdapterType (interfaceDef .getModel ().toString ());
325- nics .add (nic );
326- }
327- }
328- return nics ;
329- }
330-
331276 protected List <UnmanagedInstanceTO .Disk > getUnmanagedInstanceDisks (List <KVMPhysicalDisk > vmDisks , LibvirtDomainXMLParser xmlParser ) {
332277 List <UnmanagedInstanceTO .Disk > instanceDisks = new ArrayList <>();
333278 List <LibvirtVMDef .DiskDef > diskDefs = xmlParser != null ? xmlParser .getDisks () : null ;
@@ -416,27 +361,6 @@ protected boolean performInstanceConversion(String sourceOVFDirPath,
416361 return exitValue == 0 ;
417362 }
418363
419- protected LibvirtDomainXMLParser parseMigratedVMXmlDomain (String installPath ) throws IOException {
420- String xmlPath = String .format ("%s.xml" , installPath );
421- if (!new File (xmlPath ).exists ()) {
422- String err = String .format ("Conversion failed. Unable to find the converted XML domain, expected %s" , xmlPath );
423- s_logger .error (err );
424- throw new CloudRuntimeException (err );
425- }
426- InputStream is = new BufferedInputStream (new FileInputStream (xmlPath ));
427- String xml = IOUtils .toString (is , Charset .defaultCharset ());
428- final LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser ();
429- try {
430- parser .parseDomainXML (xml );
431- return parser ;
432- } catch (RuntimeException e ) {
433- String err = String .format ("Error parsing the converted instance XML domain at %s: %s" , xmlPath , e .getMessage ());
434- s_logger .error (err , e );
435- s_logger .debug (xml );
436- return null ;
437- }
438- }
439-
440364 protected String encodeUsername (String username ) {
441365 return URLEncoder .encode (username , Charset .defaultCharset ());
442366 }
0 commit comments