test_class.file: cosmic-agent/src/test/java/com/cloud/agent/resource/kvm/storage/KvmStorageProcessorTest.java
test_class.identifier: KvmStorageProcessorTest
test_case.body: @Test
      public void testCopyVolumeFromImageCacheToPrimary() throws Exception {
  
      }
test_case.class_method_signature: KvmStorageProcessorTest.testCopyVolumeFromImageCacheToPrimary()
test_case.full_signature: @Test public void testCopyVolumeFromImageCacheToPrimary()
test_case.identifier: testCopyVolumeFromImageCacheToPrimary
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testCopyVolumeFromImageCacheToPrimary()
focal_class.declarator: SnapshotXML = new MessageFormat("   <domainsnapshot>" + "       <name>{0}</name>" + "          <domain>"
              + "            <uuid>{1}</uuid>" + "        </domain>" + "    </domainsnapshot>")
focal_class.modifier: private static final
focal_class.original_string: private static final MessageFormat SnapshotXML = new MessageFormat("   <domainsnapshot>" + "       <name>{0}</name>" + "          <domain>"
              + "            <uuid>{1}</uuid>" + "        </domain>" + "    </domainsnapshot>");
focal_class.type: MessageFormat
focal_class.var_name: SnapshotXML
focal_class.declarator: logger = LoggerFactory.getLogger(KvmStorageProcessor.class)
focal_class.modifier: private final
focal_class.original_string: private final Logger logger = LoggerFactory.getLogger(KvmStorageProcessor.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: storagePoolMgr
focal_class.modifier: private final
focal_class.original_string: private final KvmStoragePoolManager storagePoolMgr;
focal_class.type: KvmStoragePoolManager
focal_class.var_name: storagePoolMgr
focal_class.declarator: resource
focal_class.modifier: private final
focal_class.original_string: private final LibvirtComputingResource resource;
focal_class.type: LibvirtComputingResource
focal_class.var_name: resource
focal_class.declarator: storageLayer
focal_class.modifier: private
focal_class.original_string: private StorageLayer storageLayer;
focal_class.type: StorageLayer
focal_class.var_name: storageLayer
focal_class.declarator: createTmplPath
focal_class.modifier: private
focal_class.original_string: private String createTmplPath;
focal_class.type: String
focal_class.var_name: createTmplPath
focal_class.declarator: manageSnapshotPath
focal_class.modifier: private
focal_class.original_string: private String manageSnapshotPath;
focal_class.type: String
focal_class.var_name: manageSnapshotPath
focal_class.declarator: cmdsTimeout
focal_class.modifier: private
focal_class.original_string: private int cmdsTimeout;
focal_class.type: int
focal_class.var_name: cmdsTimeout
focal_class.file: cosmic-agent/src/main/java/com/cloud/agent/resource/kvm/storage/KvmStorageProcessor.java
focal_class.identifier: KvmStorageProcessor
focal_class.interfaces: implements StorageProcessor
focal_class.class_method_signature: KvmStorageProcessor.KvmStorageProcessor(final KvmStoragePoolManager storagePoolMgr, final LibvirtComputingResource resource)
focal_class.full_signature: public  KvmStorageProcessor(final KvmStoragePoolManager storagePoolMgr, final LibvirtComputingResource resource)
focal_class.identifier: KvmStorageProcessor
focal_class.modifiers: public
focal_class.parameters: (final KvmStoragePoolManager storagePoolMgr, final LibvirtComputingResource resource)
focal_class.signature:  KvmStorageProcessor(final KvmStoragePoolManager storagePoolMgr, final LibvirtComputingResource resource)
focal_class.class_method_signature: KvmStorageProcessor.configure(final String name, final Map<String, Object> params)
focal_class.full_signature: public boolean configure(final String name, final Map<String, Object> params)
focal_class.identifier: configure
focal_class.modifiers: public
focal_class.parameters: (final String name, final Map<String, Object> params)
focal_class.return: boolean
focal_class.signature: boolean configure(final String name, final Map<String, Object> params)
focal_class.class_method_signature: KvmStorageProcessor.getDefaultStorageScriptsDir()
focal_class.full_signature: private String getDefaultStorageScriptsDir()
focal_class.identifier: getDefaultStorageScriptsDir
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getDefaultStorageScriptsDir()
focal_class.class_method_signature: KvmStorageProcessor.copyTemplateToPrimaryStorage(final CopyCommand cmd)
focal_class.full_signature: @Override public Answer copyTemplateToPrimaryStorage(final CopyCommand cmd)
focal_class.identifier: copyTemplateToPrimaryStorage
focal_class.modifiers: @Override public
focal_class.parameters: (final CopyCommand cmd)
focal_class.return: Answer
focal_class.signature: Answer copyTemplateToPrimaryStorage(final CopyCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.cloneVolumeFromBaseTemplate(final CopyCommand cmd)
focal_class.full_signature: @Override public Answer cloneVolumeFromBaseTemplate(final CopyCommand cmd)
focal_class.identifier: cloneVolumeFromBaseTemplate
focal_class.modifiers: @Override public
focal_class.parameters: (final CopyCommand cmd)
focal_class.return: Answer
focal_class.signature: Answer cloneVolumeFromBaseTemplate(final CopyCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.templateToPrimaryDownload(final String templateUrl, final KvmStoragePool primaryPool,
                                                        final String volUuid, final Long size, final int timeout)
focal_class.full_signature: private KvmPhysicalDisk templateToPrimaryDownload(final String templateUrl, final KvmStoragePool primaryPool,
                                                        final String volUuid, final Long size, final int timeout)
focal_class.identifier: templateToPrimaryDownload
focal_class.modifiers: private
focal_class.parameters: (final String templateUrl, final KvmStoragePool primaryPool,
                                                        final String volUuid, final Long size, final int timeout)
focal_class.return: KvmPhysicalDisk
focal_class.signature: KvmPhysicalDisk templateToPrimaryDownload(final String templateUrl, final KvmStoragePool primaryPool,
                                                        final String volUuid, final Long size, final int timeout)
focal_class.class_method_signature: KvmStorageProcessor.copyVolumeFromImageCacheToPrimary(final CopyCommand cmd)
focal_class.full_signature: @Override public Answer copyVolumeFromImageCacheToPrimary(final CopyCommand cmd)
focal_class.identifier: copyVolumeFromImageCacheToPrimary
focal_class.modifiers: @Override public
focal_class.parameters: (final CopyCommand cmd)
focal_class.return: Answer
focal_class.signature: Answer copyVolumeFromImageCacheToPrimary(final CopyCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.copyVolumeFromPrimaryToSecondary(final CopyCommand cmd)
focal_class.full_signature: @Override public Answer copyVolumeFromPrimaryToSecondary(final CopyCommand cmd)
focal_class.identifier: copyVolumeFromPrimaryToSecondary
focal_class.modifiers: @Override public
focal_class.parameters: (final CopyCommand cmd)
focal_class.return: Answer
focal_class.signature: Answer copyVolumeFromPrimaryToSecondary(final CopyCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.createTemplateFromVolume(final CopyCommand cmd)
focal_class.full_signature: @Override public Answer createTemplateFromVolume(final CopyCommand cmd)
focal_class.identifier: createTemplateFromVolume
focal_class.modifiers: @Override public
focal_class.parameters: (final CopyCommand cmd)
focal_class.return: Answer
focal_class.signature: Answer createTemplateFromVolume(final CopyCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.createTemplateFromSnapshot(final CopyCommand cmd)
focal_class.full_signature: @Override public Answer createTemplateFromSnapshot(final CopyCommand cmd)
focal_class.identifier: createTemplateFromSnapshot
focal_class.modifiers: @Override public
focal_class.parameters: (final CopyCommand cmd)
focal_class.return: Answer
focal_class.signature: Answer createTemplateFromSnapshot(final CopyCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.backupSnapshot(final CopyCommand cmd)
focal_class.full_signature: @Override public Answer backupSnapshot(final CopyCommand cmd)
focal_class.identifier: backupSnapshot
focal_class.modifiers: @Override public
focal_class.parameters: (final CopyCommand cmd)
focal_class.return: Answer
focal_class.signature: Answer backupSnapshot(final CopyCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.attachIso(final AttachCommand cmd)
focal_class.full_signature: @Override public Answer attachIso(final AttachCommand cmd)
focal_class.identifier: attachIso
focal_class.modifiers: @Override public
focal_class.parameters: (final AttachCommand cmd)
focal_class.return: Answer
focal_class.signature: Answer attachIso(final AttachCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.attachOrDetachIso(final Connect conn, final String vmName, String isoPath, final boolean isAttach)
focal_class.full_signature: private synchronized String attachOrDetachIso(final Connect conn, final String vmName, String isoPath, final boolean isAttach)
focal_class.identifier: attachOrDetachIso
focal_class.modifiers: private synchronized
focal_class.parameters: (final Connect conn, final String vmName, String isoPath, final boolean isAttach)
focal_class.return: String
focal_class.signature: String attachOrDetachIso(final Connect conn, final String vmName, String isoPath, final boolean isAttach)
focal_class.class_method_signature: KvmStorageProcessor.attachOrDetachDevice(final Connect conn, final boolean attach, final String vmName, final String xml)
focal_class.full_signature: private synchronized String attachOrDetachDevice(final Connect conn, final boolean attach, final String vmName, final String xml)
focal_class.identifier: attachOrDetachDevice
focal_class.modifiers: private synchronized
focal_class.parameters: (final Connect conn, final boolean attach, final String vmName, final String xml)
focal_class.return: String
focal_class.signature: String attachOrDetachDevice(final Connect conn, final boolean attach, final String vmName, final String xml)
focal_class.class_method_signature: KvmStorageProcessor.attachVolume(final AttachCommand cmd)
focal_class.full_signature: @Override public Answer attachVolume(final AttachCommand cmd)
focal_class.identifier: attachVolume
focal_class.modifiers: @Override public
focal_class.parameters: (final AttachCommand cmd)
focal_class.return: Answer
focal_class.signature: Answer attachVolume(final AttachCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.dettachIso(final DettachCommand cmd)
focal_class.full_signature: @Override public Answer dettachIso(final DettachCommand cmd)
focal_class.identifier: dettachIso
focal_class.modifiers: @Override public
focal_class.parameters: (final DettachCommand cmd)
focal_class.return: Answer
focal_class.signature: Answer dettachIso(final DettachCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.dettachVolume(final DettachCommand cmd)
focal_class.full_signature: @Override public Answer dettachVolume(final DettachCommand cmd)
focal_class.identifier: dettachVolume
focal_class.modifiers: @Override public
focal_class.parameters: (final DettachCommand cmd)
focal_class.return: Answer
focal_class.signature: Answer dettachVolume(final DettachCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.createVolume(final CreateObjectCommand cmd)
focal_class.full_signature: @Override public Answer createVolume(final CreateObjectCommand cmd)
focal_class.identifier: createVolume
focal_class.modifiers: @Override public
focal_class.parameters: (final CreateObjectCommand cmd)
focal_class.return: Answer
focal_class.signature: Answer createVolume(final CreateObjectCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.createSnapshot(final CreateObjectCommand cmd)
focal_class.full_signature: @Override public Answer createSnapshot(final CreateObjectCommand cmd)
focal_class.identifier: createSnapshot
focal_class.modifiers: @Override public
focal_class.parameters: (final CreateObjectCommand cmd)
focal_class.return: Answer
focal_class.signature: Answer createSnapshot(final CreateObjectCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.deleteVolume(final DeleteCommand cmd)
focal_class.full_signature: @Override public Answer deleteVolume(final DeleteCommand cmd)
focal_class.identifier: deleteVolume
focal_class.modifiers: @Override public
focal_class.parameters: (final DeleteCommand cmd)
focal_class.return: Answer
focal_class.signature: Answer deleteVolume(final DeleteCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.createVolumeFromSnapshot(final CopyCommand cmd)
focal_class.full_signature: @Override public Answer createVolumeFromSnapshot(final CopyCommand cmd)
focal_class.identifier: createVolumeFromSnapshot
focal_class.modifiers: @Override public
focal_class.parameters: (final CopyCommand cmd)
focal_class.return: Answer
focal_class.signature: Answer createVolumeFromSnapshot(final CopyCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.deleteSnapshot(final DeleteCommand cmd)
focal_class.full_signature: @Override public Answer deleteSnapshot(final DeleteCommand cmd)
focal_class.identifier: deleteSnapshot
focal_class.modifiers: @Override public
focal_class.parameters: (final DeleteCommand cmd)
focal_class.return: Answer
focal_class.signature: Answer deleteSnapshot(final DeleteCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.introduceObject(final IntroduceObjectCommand cmd)
focal_class.full_signature: @Override public Answer introduceObject(final IntroduceObjectCommand cmd)
focal_class.identifier: introduceObject
focal_class.modifiers: @Override public
focal_class.parameters: (final IntroduceObjectCommand cmd)
focal_class.return: Answer
focal_class.signature: Answer introduceObject(final IntroduceObjectCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.forgetObject(final ForgetObjectCommand cmd)
focal_class.full_signature: @Override public Answer forgetObject(final ForgetObjectCommand cmd)
focal_class.identifier: forgetObject
focal_class.modifiers: @Override public
focal_class.parameters: (final ForgetObjectCommand cmd)
focal_class.return: Answer
focal_class.signature: Answer forgetObject(final ForgetObjectCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.snapshotAndCopy(final SnapshotAndCopyCommand cmd)
focal_class.full_signature: @Override public SnapshotAndCopyAnswer snapshotAndCopy(final SnapshotAndCopyCommand cmd)
focal_class.identifier: snapshotAndCopy
focal_class.modifiers: @Override public
focal_class.parameters: (final SnapshotAndCopyCommand cmd)
focal_class.return: SnapshotAndCopyAnswer
focal_class.signature: SnapshotAndCopyAnswer snapshotAndCopy(final SnapshotAndCopyCommand cmd)
focal_class.class_method_signature: KvmStorageProcessor.attachOrDetachDisk(final Connect conn, final boolean attach, final String vmName, final KvmPhysicalDisk attachingDisk, final int devId,
                                                     final DiskControllerType
                                                             diskControllerType, final ImageFormat diskFormat, final String serial, final VolumeObjectTO volumeObjectTO)
focal_class.full_signature: private synchronized String attachOrDetachDisk(final Connect conn, final boolean attach, final String vmName, final KvmPhysicalDisk attachingDisk, final int devId,
                                                     final DiskControllerType
                                                             diskControllerType, final ImageFormat diskFormat, final String serial, final VolumeObjectTO volumeObjectTO)
focal_class.identifier: attachOrDetachDisk
focal_class.modifiers: private synchronized
focal_class.parameters: (final Connect conn, final boolean attach, final String vmName, final KvmPhysicalDisk attachingDisk, final int devId,
                                                     final DiskControllerType
                                                             diskControllerType, final ImageFormat diskFormat, final String serial, final VolumeObjectTO volumeObjectTO)
focal_class.return: String
focal_class.signature: String attachOrDetachDisk(final Connect conn, final boolean attach, final String vmName, final KvmPhysicalDisk attachingDisk, final int devId,
                                                     final DiskControllerType
                                                             diskControllerType, final ImageFormat diskFormat, final String serial, final VolumeObjectTO volumeObjectTO)
focal_method.body: @Override
      public Answer copyVolumeFromImageCacheToPrimary(final CopyCommand cmd) {
          final DataTO srcData = cmd.getSrcTO();
          final DataTO destData = cmd.getDestTO();
          final DataStoreTO srcStore = srcData.getDataStore();
          final DataStoreTO destStore = destData.getDataStore();
          final VolumeObjectTO srcVol = (VolumeObjectTO) srcData;
          final ImageFormat srcFormat = srcVol.getFormat();
          final PrimaryDataStoreTO primaryStore = (PrimaryDataStoreTO) destStore;
          if (!(srcStore instanceof NfsTO)) {
              return new CopyCmdAnswer("can only handle nfs storage");
          }
          final NfsTO nfsStore = (NfsTO) srcStore;
          final String srcVolumePath = srcData.getPath();
          final String secondaryStorageUrl = nfsStore.getUrl();
          KvmStoragePool secondaryStoragePool = null;
          KvmStoragePool primaryPool;
          try {
              try {
                  primaryPool = this.storagePoolMgr.getStoragePool(primaryStore.getPoolType(), primaryStore.getUuid());
              } catch (final CloudRuntimeException e) {
                  if (e.getMessage().contains("not found")) {
                      primaryPool = this.storagePoolMgr.createStoragePool(primaryStore.getUuid(), primaryStore.getHost(),
                              primaryStore.getPort(), primaryStore.getPath(), null,
                              primaryStore.getPoolType());
                  } else {
                      return new CopyCmdAnswer(e.getMessage());
                  }
              }
  
              final String volumeName = UUID.randomUUID().toString();
  
              final int index = srcVolumePath.lastIndexOf(File.separator);
              final String volumeDir = srcVolumePath.substring(0, index);
              String srcVolumeName = srcVolumePath.substring(index + 1);
              secondaryStoragePool = this.storagePoolMgr.getStoragePoolByUri(secondaryStorageUrl + File.separator + volumeDir);
              if (!srcVolumeName.endsWith(".qcow2") && srcFormat == ImageFormat.QCOW2) {
                  srcVolumeName = srcVolumeName + ".qcow2";
              }
              final KvmPhysicalDisk volume = secondaryStoragePool.getPhysicalDisk(srcVolumeName);
              volume.setFormat(PhysicalDiskFormat.valueOf(srcFormat.toString()));
              final KvmPhysicalDisk newDisk = this.storagePoolMgr.copyPhysicalDisk(volume, volumeName, primaryPool,
                      cmd.getWaitInMillSeconds());
              final VolumeObjectTO newVol = new VolumeObjectTO();
              newVol.setFormat(ImageFormat.valueOf(newDisk.getFormat().toString().toUpperCase()));
              newVol.setPath(volumeName);
              return new CopyCmdAnswer(newVol);
          } catch (final CloudRuntimeException e) {
              this.logger.debug("Failed to ccopyVolumeFromImageCacheToPrimary: ", e);
              return new CopyCmdAnswer(e.toString());
          } finally {
              if (secondaryStoragePool != null) {
                  this.storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(), secondaryStoragePool.getUuid());
              }
          }
      }
focal_method.class_method_signature: KvmStorageProcessor.copyVolumeFromImageCacheToPrimary(final CopyCommand cmd)
focal_method.full_signature: @Override public Answer copyVolumeFromImageCacheToPrimary(final CopyCommand cmd)
focal_method.identifier: copyVolumeFromImageCacheToPrimary
focal_method.invocations: getSrcTO getDestTO getDataStore getDataStore getFormat getPath getUrl getStoragePool getPoolType getUuid contains getMessage createStoragePool getUuid getHost getPort getPath getPoolType getMessage toString randomUUID lastIndexOf substring substring getStoragePoolByUri endsWith getPhysicalDisk setFormat valueOf toString copyPhysicalDisk getWaitInMillSeconds setFormat valueOf toUpperCase toString getFormat setPath debug toString deleteStoragePool getType getUuid
focal_method.modifiers: @Override public
focal_method.parameters: (final CopyCommand cmd)
focal_method.return: Answer
focal_method.signature: Answer copyVolumeFromImageCacheToPrimary(final CopyCommand cmd)