|
81 | 81 | import com.cloud.agent.api.routing.IpAssocVpcCommand; |
82 | 82 | import com.cloud.agent.api.routing.NetworkElementCommand; |
83 | 83 | import com.cloud.agent.api.routing.SetSourceNatCommand; |
84 | | -import com.cloud.agent.api.storage.CopyVolumeAnswer; |
85 | | -import com.cloud.agent.api.storage.CopyVolumeCommand; |
86 | 84 | import com.cloud.agent.api.storage.ResizeVolumeAnswer; |
87 | 85 | import com.cloud.agent.api.storage.ResizeVolumeCommand; |
88 | 86 | import com.cloud.agent.api.to.DataStoreTO; |
|
119 | 117 | import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.TermPolicy; |
120 | 118 | import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VideoDef; |
121 | 119 | import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VirtioSerialDef; |
122 | | -import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtUtilitiesHelper; |
123 | 120 | import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper; |
| 121 | +import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtUtilitiesHelper; |
124 | 122 | import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; |
125 | 123 | import com.cloud.hypervisor.kvm.storage.KVMStoragePool; |
126 | 124 | import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; |
@@ -335,7 +333,7 @@ public ExecutionResult cleanupCommand(final NetworkElementCommand cmd) { |
335 | 333 | return new ExecutionResult(true, null); |
336 | 334 | } |
337 | 335 |
|
338 | | - public LibvirtUtilitiesHelper getLibvirtConnectionWrapper() { |
| 336 | + public LibvirtUtilitiesHelper getLibvirtUtilitiesHelper() { |
339 | 337 | return libvirtUtilitiesHelper; |
340 | 338 | } |
341 | 339 |
|
@@ -1250,8 +1248,6 @@ public Answer executeRequest(final Command cmd) { |
1250 | 1248 | return execute((StartCommand)cmd); |
1251 | 1249 | } else if (cmd instanceof NetworkElementCommand) { |
1252 | 1250 | return _virtRouterResource.executeRequest((NetworkElementCommand)cmd); |
1253 | | - } else if (cmd instanceof CopyVolumeCommand) { |
1254 | | - return execute((CopyVolumeCommand)cmd); |
1255 | 1251 | } else if (cmd instanceof ResizeVolumeCommand) { |
1256 | 1252 | return execute((ResizeVolumeCommand)cmd); |
1257 | 1253 | } else if (cmd instanceof StorageSubSystemCommand) { |
@@ -1343,61 +1339,6 @@ public synchronized boolean configureTunnelNetwork(final long networkId, |
1343 | 1339 | return true; |
1344 | 1340 | } |
1345 | 1341 |
|
1346 | | - private CopyVolumeAnswer execute(final CopyVolumeCommand cmd) { |
1347 | | - /** |
1348 | | - This method is only used for copying files from Primary Storage TO Secondary Storage |
1349 | | -
|
1350 | | - It COULD also do it the other way around, but the code in the ManagementServerImpl shows |
1351 | | - that it always sets copyToSecondary to true |
1352 | | -
|
1353 | | - */ |
1354 | | - final boolean copyToSecondary = cmd.toSecondaryStorage(); |
1355 | | - String volumePath = cmd.getVolumePath(); |
1356 | | - final StorageFilerTO pool = cmd.getPool(); |
1357 | | - final String secondaryStorageUrl = cmd.getSecondaryStorageURL(); |
1358 | | - KVMStoragePool secondaryStoragePool = null; |
1359 | | - KVMStoragePool primaryPool = null; |
1360 | | - try { |
1361 | | - try { |
1362 | | - primaryPool = _storagePoolMgr.getStoragePool(pool.getType(), pool.getUuid()); |
1363 | | - } catch (final CloudRuntimeException e) { |
1364 | | - if (e.getMessage().contains("not found")) { |
1365 | | - primaryPool = |
1366 | | - _storagePoolMgr.createStoragePool(cmd.getPool().getUuid(), cmd.getPool().getHost(), cmd.getPool().getPort(), cmd.getPool().getPath(), |
1367 | | - cmd.getPool().getUserInfo(), cmd.getPool().getType()); |
1368 | | - } else { |
1369 | | - return new CopyVolumeAnswer(cmd, false, e.getMessage(), null, null); |
1370 | | - } |
1371 | | - } |
1372 | | - |
1373 | | - final String volumeName = UUID.randomUUID().toString(); |
1374 | | - |
1375 | | - if (copyToSecondary) { |
1376 | | - final String destVolumeName = volumeName + ".qcow2"; |
1377 | | - final KVMPhysicalDisk volume = primaryPool.getPhysicalDisk(cmd.getVolumePath()); |
1378 | | - final String volumeDestPath = "/volumes/" + cmd.getVolumeId() + File.separator; |
1379 | | - secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl); |
1380 | | - secondaryStoragePool.createFolder(volumeDestPath); |
1381 | | - _storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(), secondaryStoragePool.getUuid()); |
1382 | | - secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl + volumeDestPath); |
1383 | | - _storagePoolMgr.copyPhysicalDisk(volume, destVolumeName, secondaryStoragePool, 0); |
1384 | | - return new CopyVolumeAnswer(cmd, true, null, null, volumeName); |
1385 | | - } else { |
1386 | | - volumePath = "/volumes/" + cmd.getVolumeId() + File.separator; |
1387 | | - secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl + volumePath); |
1388 | | - final KVMPhysicalDisk volume = secondaryStoragePool.getPhysicalDisk(cmd.getVolumePath() + ".qcow2"); |
1389 | | - _storagePoolMgr.copyPhysicalDisk(volume, volumeName, primaryPool, 0); |
1390 | | - return new CopyVolumeAnswer(cmd, true, null, null, volumeName); |
1391 | | - } |
1392 | | - } catch (final CloudRuntimeException e) { |
1393 | | - return new CopyVolumeAnswer(cmd, false, e.toString(), null, null); |
1394 | | - } finally { |
1395 | | - if (secondaryStoragePool != null) { |
1396 | | - _storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(), secondaryStoragePool.getUuid()); |
1397 | | - } |
1398 | | - } |
1399 | | - } |
1400 | | - |
1401 | 1342 | protected Storage.StorageResourceType getStorageResourceType() { |
1402 | 1343 | return Storage.StorageResourceType.STORAGE_POOL; |
1403 | 1344 | } |
|
0 commit comments