From 0b1b2b6d925ec919e5b467ce5da1fc91f60673cb Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Wed, 6 May 2015 07:38:51 +0200 Subject: [PATCH] Refactoring the LibvirtComputingResource - Adding LibvirtCopyVolumeCommandWrapper Refactoring the LibvirtUtilitiesHelper - Changing method name Did not add any test to this commit due to the refactor mentioned abot. Will proceed and add the tests i# Please enter the commit message for your changes. Lines starting --- .../resource/LibvirtComputingResource.java | 63 +----- .../LibvirtAttachIsoCommandWrapper.java | 2 +- .../LibvirtAttachVolumeCommandWrapper.java | 2 +- .../LibvirtBackupSnapshotCommandWrapper.java | 2 +- ...virtCheckVirtualMachineCommandWrapper.java | 2 +- .../LibvirtCopyVolumeCommandWrapper.java | 99 ++++++++++ ...ateTemplateFromSnapshotCommandWrapper.java | 4 +- .../LibvirtGetVmDiskStatsCommandWrapper.java | 2 +- .../LibvirtGetVmStatsCommandWrapper.java | 2 +- .../LibvirtGetVncPortCommandWrapper.java | 2 +- .../LibvirtManageSnapshotCommandWrapper.java | 2 +- .../wrapper/LibvirtMigrateCommandWrapper.java | 2 +- ...irtNetworkRulesSystemVmCommandWrapper.java | 2 +- ...tworkRulesVmSecondaryIpCommandWrapper.java | 2 +- .../wrapper/LibvirtPlugNicCommandWrapper.java | 2 +- ...virtPrepareForMigrationCommandWrapper.java | 2 +- .../wrapper/LibvirtRebootCommandWrapper.java | 2 +- .../wrapper/LibvirtRequestWrapper.java | 2 + ...bvirtSecurityGroupRulesCommandWrapper.java | 2 +- .../wrapper/LibvirtStopCommandWrapper.java | 2 +- .../LibvirtUnPlugNicCommandWrapper.java | 2 +- .../wrapper/LibvirtUtilitiesHelper.java | 2 +- .../LibvirtComputingResourceTest.java | 184 +++++++++--------- 23 files changed, 215 insertions(+), 173 deletions(-) create mode 100644 plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCopyVolumeCommandWrapper.java diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index a9410fb1c32..8b74b1c3b58 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -81,8 +81,6 @@ import com.cloud.agent.api.routing.IpAssocCommand; import com.cloud.agent.api.routing.IpAssocVpcCommand; import com.cloud.agent.api.routing.NetworkElementCommand; import com.cloud.agent.api.routing.SetSourceNatCommand; -import com.cloud.agent.api.storage.CopyVolumeAnswer; -import com.cloud.agent.api.storage.CopyVolumeCommand; import com.cloud.agent.api.storage.ResizeVolumeAnswer; import com.cloud.agent.api.storage.ResizeVolumeCommand; import com.cloud.agent.api.to.DataStoreTO; @@ -119,8 +117,8 @@ import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.SerialDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.TermPolicy; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VideoDef; import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VirtioSerialDef; -import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtUtilitiesHelper; import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper; +import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtUtilitiesHelper; import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk; import com.cloud.hypervisor.kvm.storage.KVMStoragePool; import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager; @@ -335,7 +333,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv return new ExecutionResult(true, null); } - public LibvirtUtilitiesHelper getLibvirtConnectionWrapper() { + public LibvirtUtilitiesHelper getLibvirtUtilitiesHelper() { return libvirtUtilitiesHelper; } @@ -1250,8 +1248,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv return execute((StartCommand)cmd); } else if (cmd instanceof NetworkElementCommand) { return _virtRouterResource.executeRequest((NetworkElementCommand)cmd); - } else if (cmd instanceof CopyVolumeCommand) { - return execute((CopyVolumeCommand)cmd); } else if (cmd instanceof ResizeVolumeCommand) { return execute((ResizeVolumeCommand)cmd); } else if (cmd instanceof StorageSubSystemCommand) { @@ -1343,61 +1339,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv return true; } - private CopyVolumeAnswer execute(final CopyVolumeCommand cmd) { - /** - This method is only used for copying files from Primary Storage TO Secondary Storage - - It COULD also do it the other way around, but the code in the ManagementServerImpl shows - that it always sets copyToSecondary to true - - */ - final boolean copyToSecondary = cmd.toSecondaryStorage(); - String volumePath = cmd.getVolumePath(); - final StorageFilerTO pool = cmd.getPool(); - final String secondaryStorageUrl = cmd.getSecondaryStorageURL(); - KVMStoragePool secondaryStoragePool = null; - KVMStoragePool primaryPool = null; - try { - try { - primaryPool = _storagePoolMgr.getStoragePool(pool.getType(), pool.getUuid()); - } catch (final CloudRuntimeException e) { - if (e.getMessage().contains("not found")) { - primaryPool = - _storagePoolMgr.createStoragePool(cmd.getPool().getUuid(), cmd.getPool().getHost(), cmd.getPool().getPort(), cmd.getPool().getPath(), - cmd.getPool().getUserInfo(), cmd.getPool().getType()); - } else { - return new CopyVolumeAnswer(cmd, false, e.getMessage(), null, null); - } - } - - final String volumeName = UUID.randomUUID().toString(); - - if (copyToSecondary) { - final String destVolumeName = volumeName + ".qcow2"; - final KVMPhysicalDisk volume = primaryPool.getPhysicalDisk(cmd.getVolumePath()); - final String volumeDestPath = "/volumes/" + cmd.getVolumeId() + File.separator; - secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl); - secondaryStoragePool.createFolder(volumeDestPath); - _storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(), secondaryStoragePool.getUuid()); - secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl + volumeDestPath); - _storagePoolMgr.copyPhysicalDisk(volume, destVolumeName, secondaryStoragePool, 0); - return new CopyVolumeAnswer(cmd, true, null, null, volumeName); - } else { - volumePath = "/volumes/" + cmd.getVolumeId() + File.separator; - secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl + volumePath); - final KVMPhysicalDisk volume = secondaryStoragePool.getPhysicalDisk(cmd.getVolumePath() + ".qcow2"); - _storagePoolMgr.copyPhysicalDisk(volume, volumeName, primaryPool, 0); - return new CopyVolumeAnswer(cmd, true, null, null, volumeName); - } - } catch (final CloudRuntimeException e) { - return new CopyVolumeAnswer(cmd, false, e.toString(), null, null); - } finally { - if (secondaryStoragePool != null) { - _storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(), secondaryStoragePool.getUuid()); - } - } - } - protected Storage.StorageResourceType getStorageResourceType() { return Storage.StorageResourceType.STORAGE_POOL; } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java index 9c128456d33..a85ea54ebf7 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtAttachIsoCommandWrapper.java @@ -35,7 +35,7 @@ public final class LibvirtAttachIsoCommandWrapper extends CommandWrapper { + + @Override + public Answer execute(final CopyVolumeCommand command, final LibvirtComputingResource libvirtComputingResource) { + /** + This method is only used for copying files from Primary Storage TO Secondary Storage + + It COULD also do it the other way around, but the code in the ManagementServerImpl shows + that it always sets copyToSecondary to true + + */ + final boolean copyToSecondary = command.toSecondaryStorage(); + String volumePath = command.getVolumePath(); + final StorageFilerTO pool = command.getPool(); + final String secondaryStorageUrl = command.getSecondaryStorageURL(); + KVMStoragePool secondaryStoragePool = null; + KVMStoragePool primaryPool = null; + + final KVMStoragePoolManager storagePoolMgr = libvirtComputingResource.getStoragePoolMgr(); + try { + try { + primaryPool = storagePoolMgr.getStoragePool(pool.getType(), pool.getUuid()); + } catch (final CloudRuntimeException e) { + if (e.getMessage().contains("not found")) { + primaryPool = + storagePoolMgr.createStoragePool(command.getPool().getUuid(), command.getPool().getHost(), command.getPool().getPort(), command.getPool().getPath(), + command.getPool().getUserInfo(), command.getPool().getType()); + } else { + return new CopyVolumeAnswer(command, false, e.getMessage(), null, null); + } + } + + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper(); + final String volumeName = libvirtUtilitiesHelper.generatereUUIDName(); + + if (copyToSecondary) { + final String destVolumeName = volumeName + ".qcow2"; + final KVMPhysicalDisk volume = primaryPool.getPhysicalDisk(command.getVolumePath()); + final String volumeDestPath = "/volumes/" + command.getVolumeId() + File.separator; + + secondaryStoragePool = storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl); + secondaryStoragePool.createFolder(volumeDestPath); + storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(), secondaryStoragePool.getUuid()); + secondaryStoragePool = storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl + volumeDestPath); + storagePoolMgr.copyPhysicalDisk(volume, destVolumeName, secondaryStoragePool, 0); + + return new CopyVolumeAnswer(command, true, null, null, volumeName); + } else { + volumePath = "/volumes/" + command.getVolumeId() + File.separator; + secondaryStoragePool = storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl + volumePath); + + final KVMPhysicalDisk volume = secondaryStoragePool.getPhysicalDisk(command.getVolumePath() + ".qcow2"); + storagePoolMgr.copyPhysicalDisk(volume, volumeName, primaryPool, 0); + + return new CopyVolumeAnswer(command, true, null, null, volumeName); + } + } catch (final CloudRuntimeException e) { + return new CopyVolumeAnswer(command, false, e.toString(), null, null); + } finally { + if (secondaryStoragePool != null) { + storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(), secondaryStoragePool.getUuid()); + } + } + } +} \ No newline at end of file diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper.java index 0778586437f..35c14f86dcd 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper.java @@ -48,11 +48,11 @@ public final class LibvirtCreatePrivateTemplateFromSnapshotCommandWrapper extend @Override public Answer execute(final CreatePrivateTemplateFromSnapshotCommand command, final LibvirtComputingResource libvirtComputingResource) { - final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtConnectionWrapper(); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper(); final String templateFolder = command.getAccountId() + File.separator + command.getNewTemplateId(); final String templateInstallFolder = "template/tmpl/" + templateFolder; - final String tmplName = libvirtUtilitiesHelper.buildTemplateUUIDName(); + final String tmplName = libvirtUtilitiesHelper.generatereUUIDName(); final String tmplFileName = tmplName + ".qcow2"; KVMStoragePool secondaryPool = null; diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmDiskStatsCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmDiskStatsCommandWrapper.java index 7c76833ff31..4a8ee49b88d 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmDiskStatsCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmDiskStatsCommandWrapper.java @@ -40,7 +40,7 @@ public final class LibvirtGetVmDiskStatsCommandWrapper extends CommandWrapper vmNames = command.getVmNames(); - final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtConnectionWrapper(); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper(); try { final HashMap> vmDiskStatsNameMap = new HashMap>(); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java index f1ddca1d14a..2e6f0a78d1f 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmStatsCommandWrapper.java @@ -44,7 +44,7 @@ public final class LibvirtGetVmStatsCommandWrapper extends CommandWrapper vmStatsNameMap = new HashMap(); for (final String vmName : vmNames) { - final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtConnectionWrapper(); + final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper(); final Connect conn = libvirtUtilitiesHelper.getConnectionByVmName(vmName); final VmStatsEntry statEntry = libvirtComputingResource.getVmStat(conn, vmName); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java index d7c182088ca..abd9bf9ad0e 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVncPortCommandWrapper.java @@ -33,7 +33,7 @@ public final class LibvirtGetVncPortCommandWrapper extends CommandWrapper nics = libvirtComputingResource.getInterfaces(conn, command.getVmName()); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java index 0d5f8920f52..59a44fc01ea 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStopCommandWrapper.java @@ -44,7 +44,7 @@ public final class LibvirtStopCommandWrapper extends CommandWrapper drivers = new ArrayList(); drivers.add(vifDriver); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); when(intDef.getDevName()).thenReturn("eth0"); @@ -3198,7 +3198,7 @@ public class LibvirtComputingResourceTest { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertTrue(answer.getResult()); - verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); try { verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); verify(libvirtComputingResource, times(1)).getDomain(conn, instanceName); @@ -3225,7 +3225,7 @@ public class LibvirtComputingResourceTest { final List drivers = new ArrayList(); drivers.add(vifDriver); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); when(libvirtComputingResource.getInterfaces(conn, command.getVmName())).thenReturn(nics); try { @@ -3241,7 +3241,7 @@ public class LibvirtComputingResourceTest { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertTrue(answer.getResult()); - verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); try { verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); verify(libvirtComputingResource, times(1)).getDomain(conn, instanceName); @@ -3260,7 +3260,7 @@ public class LibvirtComputingResourceTest { final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); try { when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); @@ -3274,7 +3274,7 @@ public class LibvirtComputingResourceTest { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertFalse(answer.getResult()); - verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); try { verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); } catch (final LibvirtException e) { @@ -3471,7 +3471,7 @@ public class LibvirtComputingResourceTest { final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); //final Connect conn = Mockito.mock(Connect.class); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); try { when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); @@ -3485,7 +3485,7 @@ public class LibvirtComputingResourceTest { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertFalse(answer.getResult()); - verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); try { verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); } catch (final LibvirtException e) { @@ -3522,7 +3522,7 @@ public class LibvirtComputingResourceTest { final LibvirtUtilitiesHelper libvirtUtilitiesHelper = Mockito.mock(LibvirtUtilitiesHelper.class); //final Connect conn = Mockito.mock(Connect.class); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); try { when(libvirtUtilitiesHelper.getConnectionByVmName(command.getVmName())).thenThrow(LibvirtException.class); @@ -3536,7 +3536,7 @@ public class LibvirtComputingResourceTest { final Answer answer = wrapper.execute(command, libvirtComputingResource); assertFalse(answer.getResult()); - verify(libvirtComputingResource, times(1)).getLibvirtConnectionWrapper(); + verify(libvirtComputingResource, times(1)).getLibvirtUtilitiesHelper(); try { verify(libvirtUtilitiesHelper, times(1)).getConnectionByVmName(command.getVmName()); } catch (final LibvirtException e) { @@ -3593,9 +3593,9 @@ public class LibvirtComputingResourceTest { final String templateInstallFolder = "template/tmpl/" + templateFolder; final String tmplPath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); when(libvirtUtilitiesHelper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); - when(libvirtUtilitiesHelper.buildTemplateUUIDName()).thenReturn(tmplName); + when(libvirtUtilitiesHelper.generatereUUIDName()).thenReturn(tmplName); try { when(libvirtUtilitiesHelper.buildQCOW2Processor(storage)).thenReturn(qcow2Processor); @@ -3667,9 +3667,9 @@ public class LibvirtComputingResourceTest { final String templateInstallFolder = "template/tmpl/" + templateFolder; final String tmplPath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); when(libvirtUtilitiesHelper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); - when(libvirtUtilitiesHelper.buildTemplateUUIDName()).thenReturn(tmplName); + when(libvirtUtilitiesHelper.generatereUUIDName()).thenReturn(tmplName); try { when(libvirtUtilitiesHelper.buildQCOW2Processor(storage)).thenThrow(ConfigurationException.class); @@ -3740,9 +3740,9 @@ public class LibvirtComputingResourceTest { final String templateInstallFolder = "template/tmpl/" + templateFolder; final String tmplPath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); when(libvirtUtilitiesHelper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); - when(libvirtUtilitiesHelper.buildTemplateUUIDName()).thenReturn(tmplName); + when(libvirtUtilitiesHelper.generatereUUIDName()).thenReturn(tmplName); try { when(libvirtUtilitiesHelper.buildQCOW2Processor(storage)).thenReturn(qcow2Processor); @@ -3814,9 +3814,9 @@ public class LibvirtComputingResourceTest { final String templateInstallFolder = "template/tmpl/" + templateFolder; final String tmplPath = secondaryPool.getLocalPath() + File.separator + templateInstallFolder; - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); when(libvirtUtilitiesHelper.buildTemplateLocation(storage, tmplPath)).thenReturn(location); - when(libvirtUtilitiesHelper.buildTemplateUUIDName()).thenReturn(tmplName); + when(libvirtUtilitiesHelper.generatereUUIDName()).thenReturn(tmplName); try { when(libvirtUtilitiesHelper.buildQCOW2Processor(storage)).thenReturn(qcow2Processor); @@ -3873,8 +3873,8 @@ public class LibvirtComputingResourceTest { final int index = snapshotPath.lastIndexOf("/"); snapshotPath = snapshotPath.substring(0, index); - when(libvirtComputingResource.getLibvirtConnectionWrapper()).thenReturn(libvirtUtilitiesHelper); - when(libvirtUtilitiesHelper.buildTemplateUUIDName()).thenReturn(tmplName); + when(libvirtComputingResource.getLibvirtUtilitiesHelper()).thenReturn(libvirtUtilitiesHelper); + when(libvirtUtilitiesHelper.generatereUUIDName()).thenReturn(tmplName); when(storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl() + snapshotPath)).thenReturn(snapshotPool); when(storagePoolMgr.getStoragePoolByURI(command.getSecondaryStorageUrl())).thenReturn(secondaryPool);