cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [08/39] git commit: updated refs/heads/master to 3e28747
Date Thu, 02 Apr 2015 18:22:49 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30e72e4a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java
index 10a97a2..0cf40f5 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServerStorageProcessor.java
@@ -92,7 +92,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
     protected CitrixResourceBase hypervisorResource;
     protected String BaseMountPointOnHost = "/var/run/cloud_mount";
 
-    public XenServerStorageProcessor(CitrixResourceBase resource) {
+    public XenServerStorageProcessor(final CitrixResourceBase resource) {
         hypervisorResource = resource;
     }
 
@@ -104,39 +104,39 @@ public class XenServerStorageProcessor implements StorageProcessor {
     // detach the new SR
     // if we needed to perform an attach to the source SR, detach from it
     @Override
-    public SnapshotAndCopyAnswer snapshotAndCopy(SnapshotAndCopyCommand cmd) {
-        Connection conn = hypervisorResource.getConnection();
+    public SnapshotAndCopyAnswer snapshotAndCopy(final SnapshotAndCopyCommand cmd) {
+        final Connection conn = hypervisorResource.getConnection();
 
         try {
             SR sourceSr = null;
 
-            Map<String, String> sourceDetails = cmd.getSourceDetails();
+            final Map<String, String> sourceDetails = cmd.getSourceDetails();
 
             if (sourceDetails != null && sourceDetails.keySet().size() > 0) {
-                String iScsiName = sourceDetails.get(DiskTO.IQN);
-                String storageHost = sourceDetails.get(DiskTO.STORAGE_HOST);
-                String chapInitiatorUsername = sourceDetails.get(DiskTO.CHAP_INITIATOR_USERNAME);
-                String chapInitiatorSecret = sourceDetails.get(DiskTO.CHAP_INITIATOR_SECRET);
+                final String iScsiName = sourceDetails.get(DiskTO.IQN);
+                final String storageHost = sourceDetails.get(DiskTO.STORAGE_HOST);
+                final String chapInitiatorUsername = sourceDetails.get(DiskTO.CHAP_INITIATOR_USERNAME);
+                final String chapInitiatorSecret = sourceDetails.get(DiskTO.CHAP_INITIATOR_SECRET);
 
                 sourceSr = hypervisorResource.getIscsiSR(conn, iScsiName, storageHost, iScsiName, chapInitiatorUsername, chapInitiatorSecret, false);
             }
 
-            VDI vdiToSnapshot = VDI.getByUuid(conn, cmd.getUuidOfSourceVdi());
+            final VDI vdiToSnapshot = VDI.getByUuid(conn, cmd.getUuidOfSourceVdi());
 
-            VDI vdiSnapshot = vdiToSnapshot.snapshot(conn, new HashMap<String, String>());
+            final VDI vdiSnapshot = vdiToSnapshot.snapshot(conn, new HashMap<String, String>());
 
-            Map<String, String> destDetails = cmd.getDestDetails();
+            final Map<String, String> destDetails = cmd.getDestDetails();
 
-            String iScsiName = destDetails.get(DiskTO.IQN);
-            String storageHost = destDetails.get(DiskTO.STORAGE_HOST);
-            String chapInitiatorUsername = destDetails.get(DiskTO.CHAP_INITIATOR_USERNAME);
-            String chapInitiatorSecret = destDetails.get(DiskTO.CHAP_INITIATOR_SECRET);
+            final String iScsiName = destDetails.get(DiskTO.IQN);
+            final String storageHost = destDetails.get(DiskTO.STORAGE_HOST);
+            final String chapInitiatorUsername = destDetails.get(DiskTO.CHAP_INITIATOR_USERNAME);
+            final String chapInitiatorSecret = destDetails.get(DiskTO.CHAP_INITIATOR_SECRET);
 
-            SR newSr = hypervisorResource.getIscsiSR(conn, iScsiName, storageHost, iScsiName, chapInitiatorUsername, chapInitiatorSecret, false);
+            final SR newSr = hypervisorResource.getIscsiSR(conn, iScsiName, storageHost, iScsiName, chapInitiatorUsername, chapInitiatorSecret, false);
 
-            VDI vdiCopy = vdiSnapshot.copy(conn, newSr);
+            final VDI vdiCopy = vdiSnapshot.copy(conn, newSr);
 
-            String vdiUuid = vdiCopy.getUuid(conn);
+            final String vdiUuid = vdiCopy.getUuid(conn);
 
             vdiSnapshot.destroy(conn);
 
@@ -146,13 +146,13 @@ public class XenServerStorageProcessor implements StorageProcessor {
 
             hypervisorResource.removeSR(conn, newSr);
 
-            SnapshotAndCopyAnswer snapshotAndCopyAnswer = new SnapshotAndCopyAnswer();
+            final SnapshotAndCopyAnswer snapshotAndCopyAnswer = new SnapshotAndCopyAnswer();
 
             snapshotAndCopyAnswer.setPath(vdiUuid);
 
             return snapshotAndCopyAnswer;
         }
-        catch (Exception ex) {
+        catch (final Exception ex) {
             s_logger.warn("Failed to take and copy snapshot: " + ex.toString(), ex);
 
             return new SnapshotAndCopyAnswer(ex.getMessage());
@@ -160,40 +160,40 @@ public class XenServerStorageProcessor implements StorageProcessor {
     }
 
     @Override
-    public AttachAnswer attachIso(AttachCommand cmd) {
-        DiskTO disk = cmd.getDisk();
-        DataTO data = disk.getData();
-        DataStoreTO store = data.getDataStore();
+    public AttachAnswer attachIso(final AttachCommand cmd) {
+        final DiskTO disk = cmd.getDisk();
+        final DataTO data = disk.getData();
+        final DataStoreTO store = data.getDataStore();
 
         String isoURL = null;
         if (store == null) {
-            TemplateObjectTO iso = (TemplateObjectTO) disk.getData();
+            final TemplateObjectTO iso = (TemplateObjectTO) disk.getData();
             isoURL = iso.getName();
         } else {
             if (!(store instanceof NfsTO)) {
                 s_logger.debug("Can't attach a iso which is not created on nfs: ");
                 return new AttachAnswer("Can't attach a iso which is not created on nfs: ");
             }
-            NfsTO nfsStore = (NfsTO) store;
+            final NfsTO nfsStore = (NfsTO) store;
             isoURL = nfsStore.getUrl() + nfsStore.getPathSeparator() + data.getPath();
         }
 
-        String vmName = cmd.getVmName();
+        final String vmName = cmd.getVmName();
         try {
-            Connection conn = hypervisorResource.getConnection();
+            final Connection conn = hypervisorResource.getConnection();
 
             VBD isoVBD = null;
 
             // Find the VM
-            VM vm = hypervisorResource.getVM(conn, vmName);
+            final VM vm = hypervisorResource.getVM(conn, vmName);
             // Find the ISO VDI
-            VDI isoVDI = hypervisorResource.getIsoVDIByURL(conn, vmName, isoURL);
+            final VDI isoVDI = hypervisorResource.getIsoVDIByURL(conn, vmName, isoURL);
 
             // Find the VM's CD-ROM VBD
-            Set<VBD> vbds = vm.getVBDs(conn);
-            for (VBD vbd : vbds) {
-                String userDevice = vbd.getUserdevice(conn);
-                Types.VbdType type = vbd.getType(conn);
+            final Set<VBD> vbds = vm.getVBDs(conn);
+            for (final VBD vbd : vbds) {
+                final String userDevice = vbd.getUserdevice(conn);
+                final Types.VbdType type = vbd.getType(conn);
 
                 if (userDevice.equals("3") && type == Types.VbdType.CD) {
                     isoVBD = vbd;
@@ -215,39 +215,39 @@ public class XenServerStorageProcessor implements StorageProcessor {
 
             return new AttachAnswer(disk);
 
-        } catch (XenAPIException e) {
+        } catch (final XenAPIException e) {
             s_logger.warn("Failed to attach iso" + ": " + e.toString(), e);
             return new AttachAnswer(e.toString());
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.warn("Failed to attach iso" + ": " + e.toString(), e);
             return new AttachAnswer(e.toString());
         }
     }
 
     @Override
-    public AttachAnswer attachVolume(AttachCommand cmd) {
-        DiskTO disk = cmd.getDisk();
-        DataTO data = disk.getData();
+    public AttachAnswer attachVolume(final AttachCommand cmd) {
+        final DiskTO disk = cmd.getDisk();
+        final DataTO data = disk.getData();
         try {
-            String vmName = cmd.getVmName();
-            String vdiNameLabel = vmName + "-DATA";
+            final String vmName = cmd.getVmName();
+            final String vdiNameLabel = vmName + "-DATA";
 
-            Connection conn = this.hypervisorResource.getConnection();
+            final Connection conn = hypervisorResource.getConnection();
             VM vm = null;
 
             boolean vmNotRunning = true;
 
             try {
-                vm = this.hypervisorResource.getVM(conn, vmName);
+                vm = hypervisorResource.getVM(conn, vmName);
 
-                VM.Record vmr = vm.getRecord(conn);
+                final VM.Record vmr = vm.getRecord(conn);
 
                 vmNotRunning = vmr.powerState != VmPowerState.RUNNING;
-            } catch (CloudRuntimeException ex) {
+            } catch (final CloudRuntimeException ex) {
             }
 
-            Map<String, String> details = disk.getDetails();
-            boolean isManaged = Boolean.parseBoolean(details.get(DiskTO.MANAGED));
+            final Map<String, String> details = disk.getDetails();
+            final boolean isManaged = Boolean.parseBoolean(details.get(DiskTO.MANAGED));
 
             // if the VM is not running and we're not dealing with managed storage, just return success (nothing to do here)
             // this should probably never actually happen
@@ -261,7 +261,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
                 vdi = hypervisorResource.prepareManagedStorage(conn, details, data.getPath(), vdiNameLabel);
 
                 if (vmNotRunning) {
-                    DiskTO newDisk = new DiskTO(disk.getData(), disk.getDiskSeq(), vdi.getUuid(conn), disk.getType());
+                    final DiskTO newDisk = new DiskTO(disk.getData(), disk.getDiskSeq(), vdi.getUuid(conn), disk.getType());
 
                     return new AttachAnswer(newDisk);
                 }
@@ -271,17 +271,17 @@ public class XenServerStorageProcessor implements StorageProcessor {
 
             // Figure out the disk number to attach the VM to
             String diskNumber = null;
-            Long deviceId = disk.getDiskSeq();
+            final Long deviceId = disk.getDiskSeq();
 
             if (deviceId != null) {
                 if (deviceId.longValue() == 3) {
-                    String msg = "Device 3 is reserved for CD-ROM, choose other device";
+                    final String msg = "Device 3 is reserved for CD-ROM, choose other device";
 
                     return new AttachAnswer(msg);
                 }
 
                 if (hypervisorResource.isDeviceUsed(conn, vm, deviceId)) {
-                    String msg = "Device " + deviceId + " is used in VM " + vmName;
+                    final String msg = "Device " + deviceId + " is used in VM " + vmName;
 
                     return new AttachAnswer(msg);
                 }
@@ -291,7 +291,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
                 diskNumber = hypervisorResource.getUnusedDeviceNum(conn, vm);
             }
 
-            VBD.Record vbdr = new VBD.Record();
+            final VBD.Record vbdr = new VBD.Record();
 
             vbdr.VM = vm;
             vbdr.VDI = vdi;
@@ -301,66 +301,66 @@ public class XenServerStorageProcessor implements StorageProcessor {
             vbdr.type = Types.VbdType.DISK;
             vbdr.unpluggable = true;
 
-            VBD vbd = VBD.create(conn, vbdr);
+            final VBD vbd = VBD.create(conn, vbdr);
 
             // Attach the VBD to the VM
             try {
                 vbd.plug(conn);
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 vbd.destroy(conn);
                 throw e;
             }
             // Update the VDI's label to include the VM name
             vdi.setNameLabel(conn, vdiNameLabel);
 
-            DiskTO newDisk = new DiskTO(disk.getData(), Long.parseLong(diskNumber), vdi.getUuid(conn), disk.getType());
+            final DiskTO newDisk = new DiskTO(disk.getData(), Long.parseLong(diskNumber), vdi.getUuid(conn), disk.getType());
 
             return new AttachAnswer(newDisk);
-        } catch (Exception e) {
-            String msg = "Failed to attach volume" + " for uuid: " + data.getPath() + "  due to "  + e.toString();
+        } catch (final Exception e) {
+            final String msg = "Failed to attach volume" + " for uuid: " + data.getPath() + "  due to "  + e.toString();
             s_logger.warn(msg, e);
             return new AttachAnswer(msg);
         }
     }
 
     @Override
-    public Answer dettachIso(DettachCommand cmd) {
-        DiskTO disk = cmd.getDisk();
-        DataTO data = disk.getData();
-        DataStoreTO store = data.getDataStore();
+    public Answer dettachIso(final DettachCommand cmd) {
+        final DiskTO disk = cmd.getDisk();
+        final DataTO data = disk.getData();
+        final DataStoreTO store = data.getDataStore();
 
         String isoURL = null;
         if (store == null) {
-            TemplateObjectTO iso = (TemplateObjectTO) disk.getData();
+            final TemplateObjectTO iso = (TemplateObjectTO) disk.getData();
             isoURL = iso.getName();
         } else {
             if (!(store instanceof NfsTO)) {
                 s_logger.debug("Can't attach a iso which is not created on nfs: ");
                 return new AttachAnswer("Can't attach a iso which is not created on nfs: ");
             }
-            NfsTO nfsStore = (NfsTO) store;
+            final NfsTO nfsStore = (NfsTO) store;
             isoURL = nfsStore.getUrl() + nfsStore.getPathSeparator() + data.getPath();
         }
 
         try {
-            Connection conn = hypervisorResource.getConnection();
+            final Connection conn = hypervisorResource.getConnection();
             // Find the VM
-            VM vm = hypervisorResource.getVM(conn, cmd.getVmName());
-            String vmUUID = vm.getUuid(conn);
+            final VM vm = hypervisorResource.getVM(conn, cmd.getVmName());
+            final String vmUUID = vm.getUuid(conn);
 
             // Find the ISO VDI
-            VDI isoVDI = hypervisorResource.getIsoVDIByURL(conn, cmd.getVmName(), isoURL);
+            final VDI isoVDI = hypervisorResource.getIsoVDIByURL(conn, cmd.getVmName(), isoURL);
 
-            SR sr = isoVDI.getSR(conn);
+            final SR sr = isoVDI.getSR(conn);
 
             // Look up all VBDs for this VDI
-            Set<VBD> vbds = isoVDI.getVBDs(conn);
+            final Set<VBD> vbds = isoVDI.getVBDs(conn);
 
             // Iterate through VBDs, and if the VBD belongs the VM, eject
             // the ISO from it
-            for (VBD vbd : vbds) {
-                VM vbdVM = vbd.getVM(conn);
-                String vbdVmUUID = vbdVM.getUuid(conn);
+            for (final VBD vbd : vbds) {
+                final VM vbdVM = vbd.getVM(conn);
+                final String vbdVmUUID = vbdVM.getUuid(conn);
 
                 if (vbdVmUUID.equals(vmUUID)) {
                     // If an ISO is already inserted, eject it
@@ -376,37 +376,37 @@ public class XenServerStorageProcessor implements StorageProcessor {
             }
 
             return new DettachAnswer(disk);
-        } catch (XenAPIException e) {
-            String msg = "Failed to dettach volume" + " for uuid: " + data.getPath() + "  due to " + e.toString();
+        } catch (final XenAPIException e) {
+            final String msg = "Failed to dettach volume" + " for uuid: " + data.getPath() + "  due to " + e.toString();
             s_logger.warn(msg, e);
             return new DettachAnswer(msg);
-        } catch (Exception e) {
-            String msg = "Failed to dettach volume" + " for uuid: " + data.getPath() + "  due to " + e.getMessage();
+        } catch (final Exception e) {
+            final String msg = "Failed to dettach volume" + " for uuid: " + data.getPath() + "  due to " + e.getMessage();
             s_logger.warn(msg, e);
             return new DettachAnswer(msg);
         }
     }
 
     @Override
-    public Answer dettachVolume(DettachCommand cmd) {
-        DiskTO disk = cmd.getDisk();
-        DataTO data = disk.getData();
+    public Answer dettachVolume(final DettachCommand cmd) {
+        final DiskTO disk = cmd.getDisk();
+        final DataTO data = disk.getData();
 
         try {
-            Connection conn = this.hypervisorResource.getConnection();
+            final Connection conn = hypervisorResource.getConnection();
 
-            String vmName = cmd.getVmName();
+            final String vmName = cmd.getVmName();
             VM vm = null;
 
             boolean vmNotRunning = true;
 
             try {
-                vm = this.hypervisorResource.getVM(conn, vmName);
+                vm = hypervisorResource.getVM(conn, vmName);
 
-                VM.Record vmr = vm.getRecord(conn);
+                final VM.Record vmr = vm.getRecord(conn);
 
                 vmNotRunning = vmr.powerState != VmPowerState.RUNNING;
-            } catch (CloudRuntimeException ex) {
+            } catch (final CloudRuntimeException ex) {
             }
 
             // if the VM is not running and we're not dealing with managed storage, just return success (nothing to do here)
@@ -416,14 +416,14 @@ public class XenServerStorageProcessor implements StorageProcessor {
             }
 
             if (!vmNotRunning) {
-                VDI vdi = this.hypervisorResource.mount(conn, null, null, data.getPath());
+                final VDI vdi = hypervisorResource.mount(conn, null, null, data.getPath());
 
                 // Look up all VBDs for this VDI
-                Set<VBD> vbds = vdi.getVBDs(conn);
+                final Set<VBD> vbds = vdi.getVBDs(conn);
 
                 // Detach each VBD from its VM, and then destroy it
-                for (VBD vbd : vbds) {
-                    VBD.Record vbdr = vbd.getRecord(conn);
+                for (final VBD vbd : vbds) {
+                    final VBD.Record vbdr = vbd.getRecord(conn);
 
                     if (vbdr.currentlyAttached) {
                         vbd.unplug(conn);
@@ -435,7 +435,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
                 // Update the VDI's label to be "detached"
                 vdi.setNameLabel(conn, "detached");
 
-                this.hypervisorResource.umount(conn, vdi);
+                hypervisorResource.umount(conn, vdi);
             }
 
             if (cmd.isManaged()) {
@@ -443,83 +443,83 @@ public class XenServerStorageProcessor implements StorageProcessor {
             }
 
             return new DettachAnswer(disk);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.warn("Failed dettach volume: " + data.getPath());
             return new DettachAnswer("Failed dettach volume: " + data.getPath() + ", due to " + e.toString());
         }
     }
 
-    protected SR getSRByNameLabel(Connection conn, String nameLabel) throws BadServerResponse, XenAPIException, XmlRpcException {
-        Set<SR> srs = SR.getByNameLabel(conn, nameLabel);
+    protected SR getSRByNameLabel(final Connection conn, final String nameLabel) throws BadServerResponse, XenAPIException, XmlRpcException {
+        final Set<SR> srs = SR.getByNameLabel(conn, nameLabel);
         if (srs.size() != 1) {
             throw new CloudRuntimeException("storage uuid: " + nameLabel + " is not unique");
         }
-        SR poolsr = srs.iterator().next();
+        final SR poolsr = srs.iterator().next();
         return poolsr;
     }
 
-    protected VDI createVdi(Connection conn, String vdiName, SR sr, long size) throws BadServerResponse, XenAPIException, XmlRpcException {
-        VDI.Record vdir = new VDI.Record();
+    protected VDI createVdi(final Connection conn, final String vdiName, final SR sr, final long size) throws BadServerResponse, XenAPIException, XmlRpcException {
+        final VDI.Record vdir = new VDI.Record();
         vdir.nameLabel = vdiName;
         vdir.SR = sr;
         vdir.type = Types.VdiType.USER;
 
         vdir.virtualSize = size;
-        VDI vdi = VDI.create(conn, vdir);
+        final VDI vdi = VDI.create(conn, vdir);
         return vdi;
     }
 
-    protected void deleteVDI(Connection conn, VDI vdi) throws BadServerResponse, XenAPIException, XmlRpcException {
+    protected void deleteVDI(final Connection conn, final VDI vdi) throws BadServerResponse, XenAPIException, XmlRpcException {
         vdi.destroy(conn);
     }
 
     @Override
-    public Answer createSnapshot(CreateObjectCommand cmd) {
-        Connection conn = hypervisorResource.getConnection();
-        SnapshotObjectTO snapshotTO = (SnapshotObjectTO) cmd.getData();
-        long snapshotId = snapshotTO.getId();
-        String snapshotName = snapshotTO.getName();
+    public Answer createSnapshot(final CreateObjectCommand cmd) {
+        final Connection conn = hypervisorResource.getConnection();
+        final SnapshotObjectTO snapshotTO = (SnapshotObjectTO) cmd.getData();
+        final long snapshotId = snapshotTO.getId();
+        final String snapshotName = snapshotTO.getName();
         String details = "create snapshot operation Failed for snapshotId: " + snapshotId;
         String snapshotUUID = null;
 
         try {
-            String volumeUUID = snapshotTO.getVolume().getPath();
-            VDI volume = VDI.getByUuid(conn, volumeUUID);
+            final String volumeUUID = snapshotTO.getVolume().getPath();
+            final VDI volume = VDI.getByUuid(conn, volumeUUID);
 
-            VDI snapshot = volume.snapshot(conn, new HashMap<String, String>());
+            final VDI snapshot = volume.snapshot(conn, new HashMap<String, String>());
 
             if (snapshotName != null) {
                 snapshot.setNameLabel(conn, snapshotName);
             }
 
             snapshotUUID = snapshot.getUuid(conn);
-            String preSnapshotUUID = snapshotTO.getParentSnapshotPath();
+            final String preSnapshotUUID = snapshotTO.getParentSnapshotPath();
             //check if it is a empty snapshot
             if (preSnapshotUUID != null) {
-                SR sr = volume.getSR(conn);
-                String srUUID = sr.getUuid(conn);
-                String type = sr.getType(conn);
-                Boolean isISCSI = IsISCSI(type);
-                String snapshotParentUUID = getVhdParent(conn, srUUID, snapshotUUID, isISCSI);
+                final SR sr = volume.getSR(conn);
+                final String srUUID = sr.getUuid(conn);
+                final String type = sr.getType(conn);
+                final Boolean isISCSI = IsISCSI(type);
+                final String snapshotParentUUID = getVhdParent(conn, srUUID, snapshotUUID, isISCSI);
 
                 try {
-                    String preSnapshotParentUUID = getVhdParent(conn, srUUID, preSnapshotUUID, isISCSI);
+                    final String preSnapshotParentUUID = getVhdParent(conn, srUUID, preSnapshotUUID, isISCSI);
                     if (snapshotParentUUID != null && snapshotParentUUID.equals(preSnapshotParentUUID)) {
                         // this is empty snapshot, remove it
                         snapshot.destroy(conn);
                         snapshotUUID = preSnapshotUUID;
                     }
-                } catch (Exception e) {
+                } catch (final Exception e) {
                     s_logger.debug("Failed to get parent snapshot", e);
                 }
             }
-            SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
+            final SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
             newSnapshot.setPath(snapshotUUID);
             return new CreateObjectAnswer(newSnapshot);
-        } catch (XenAPIException e) {
+        } catch (final XenAPIException e) {
             details += ", reason: " + e.toString();
             s_logger.warn(details, e);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             details += ", reason: " + e.toString();
             s_logger.warn(details, e);
         }
@@ -528,47 +528,47 @@ public class XenServerStorageProcessor implements StorageProcessor {
     }
 
     @Override
-    public Answer deleteVolume(DeleteCommand cmd) {
-        DataTO volume = cmd.getData();
-        Connection conn = hypervisorResource.getConnection();
+    public Answer deleteVolume(final DeleteCommand cmd) {
+        final DataTO volume = cmd.getData();
+        final Connection conn = hypervisorResource.getConnection();
         String errorMsg = null;
         try {
-            VDI vdi = VDI.getByUuid(conn, volume.getPath());
+            final VDI vdi = VDI.getByUuid(conn, volume.getPath());
             deleteVDI(conn, vdi);
             return new Answer(null);
-        } catch (BadServerResponse e) {
+        } catch (final BadServerResponse e) {
             s_logger.debug("Failed to delete volume", e);
             errorMsg = e.toString();
-        } catch (XenAPIException e) {
+        } catch (final XenAPIException e) {
             s_logger.debug("Failed to delete volume", e);
             errorMsg = e.toString();
-        } catch (XmlRpcException e) {
+        } catch (final XmlRpcException e) {
             s_logger.debug("Failed to delete volume", e);
             errorMsg = e.toString();
         }
         return new Answer(null, false, errorMsg);
     }
 
-    protected SR getNfsSR(Connection conn, StorageFilerTO pool) {
-        Map<String, String> deviceConfig = new HashMap<String, String>();
+    protected SR getNfsSR(final Connection conn, final StorageFilerTO pool) {
+        final Map<String, String> deviceConfig = new HashMap<String, String>();
         try {
-            String server = pool.getHost();
+            final String server = pool.getHost();
             String serverpath = pool.getPath();
             serverpath = serverpath.replace("//", "/");
-            Set<SR> srs = SR.getAll(conn);
-            for (SR sr : srs) {
+            final Set<SR> srs = SR.getAll(conn);
+            for (final SR sr : srs) {
                 if (!SRType.NFS.equals(sr.getType(conn))) {
                     continue;
                 }
 
-                Set<PBD> pbds = sr.getPBDs(conn);
+                final Set<PBD> pbds = sr.getPBDs(conn);
                 if (pbds.isEmpty()) {
                     continue;
                 }
 
-                PBD pbd = pbds.iterator().next();
+                final PBD pbd = pbds.iterator().next();
 
-                Map<String, String> dc = pbd.getDeviceConfig(conn);
+                final Map<String, String> dc = pbd.getDeviceConfig(conn);
 
                 if (dc == null) {
                     continue;
@@ -584,27 +584,27 @@ public class XenServerStorageProcessor implements StorageProcessor {
 
                 if (server.equals(dc.get("server")) && serverpath.equals(dc.get("serverpath"))) {
                     throw new CloudRuntimeException("There is a SR using the same configuration server:" + dc.get("server") + ", serverpath:" + dc.get("serverpath") +
-                            " for pool " + pool.getUuid() + "on host:" + hypervisorResource.getHost().uuid);
+                            " for pool " + pool.getUuid() + "on host:" + hypervisorResource.getHost().getUuid());
                 }
 
             }
             deviceConfig.put("server", server);
             deviceConfig.put("serverpath", serverpath);
-            Host host = Host.getByUuid(conn, hypervisorResource.getHost().uuid);
-            Map<String, String> smConfig = new HashMap<String, String>();
+            final Host host = Host.getByUuid(conn, hypervisorResource.getHost().getUuid());
+            final Map<String, String> smConfig = new HashMap<String, String>();
             smConfig.put("nosubdir", "true");
-            SR sr = SR.create(conn, host, deviceConfig, new Long(0), pool.getUuid(), Long.toString(pool.getId()), SRType.NFS.toString(), "user", true, smConfig);
+            final SR sr = SR.create(conn, host, deviceConfig, new Long(0), pool.getUuid(), Long.toString(pool.getId()), SRType.NFS.toString(), "user", true, smConfig);
             sr.scan(conn);
             return sr;
-        } catch (XenAPIException e) {
+        } catch (final XenAPIException e) {
             throw new CloudRuntimeException("Unable to create NFS SR " + pool.toString(), e);
-        } catch (XmlRpcException e) {
+        } catch (final XmlRpcException e) {
             throw new CloudRuntimeException("Unable to create NFS SR " + pool.toString(), e);
         }
     }
 
-    protected Answer directDownloadHttpTemplate(CopyCommand cmd, DecodedDataObject srcObj, DecodedDataObject destObj) {
-        Connection conn = hypervisorResource.getConnection();
+    protected Answer directDownloadHttpTemplate(final CopyCommand cmd, final DecodedDataObject srcObj, final DecodedDataObject destObj) {
+        final Connection conn = hypervisorResource.getConnection();
         SR poolsr = null;
         VDI vdi = null;
         boolean result = false;
@@ -617,53 +617,53 @@ public class XenServerStorageProcessor implements StorageProcessor {
             if (vdi == null) {
                 throw new CloudRuntimeException("can't find volume: " + destObj.getPath());
             }
-            String destStoreUuid = destObj.getStore().getUuid();
-            Set<SR> srs = SR.getByNameLabel(conn, destStoreUuid);
+            final String destStoreUuid = destObj.getStore().getUuid();
+            final Set<SR> srs = SR.getByNameLabel(conn, destStoreUuid);
             if (srs.size() != 1) {
                 throw new CloudRuntimeException("storage uuid: " + destStoreUuid + " is not unique");
             }
             poolsr = srs.iterator().next();
-            VDI.Record vdir = vdi.getRecord(conn);
-            String vdiLocation = vdir.location;
+            final VDI.Record vdir = vdi.getRecord(conn);
+            final String vdiLocation = vdir.location;
             String pbdLocation = null;
             if (destObj.getStore().getScheme().equalsIgnoreCase(DataStoreProtocol.NFS.toString())) {
                 pbdLocation = "/run/sr-mount/" + poolsr.getUuid(conn);
             } else {
-                Set<PBD> pbds = poolsr.getPBDs(conn);
+                final Set<PBD> pbds = poolsr.getPBDs(conn);
                 if (pbds.size() != 1) {
                     throw new CloudRuntimeException("Don't how to handle multiple pbds:" + pbds.size() + " for sr: " + poolsr.getUuid(conn));
                 }
-                PBD pbd = pbds.iterator().next();
-                Map<String, String> deviceCfg = pbd.getDeviceConfig(conn);
+                final PBD pbd = pbds.iterator().next();
+                final Map<String, String> deviceCfg = pbd.getDeviceConfig(conn);
                 pbdLocation = deviceCfg.get("location");
             }
             if (pbdLocation == null) {
                 throw new CloudRuntimeException("Can't get pbd location");
             }
 
-            String vdiPath = pbdLocation + "/" + vdiLocation + ".vhd";
+            final String vdiPath = pbdLocation + "/" + vdiLocation + ".vhd";
             //download a url into vdipath
             //downloadHttpToLocalFile(vdiPath, template.getPath());
             hypervisorResource.callHostPlugin(conn, "storagePlugin", "downloadTemplateFromUrl", "destPath", vdiPath, "srcUrl", srcObj.getPath());
             result = true;
             //return new CopyCmdAnswer(cmd, vdi.getUuid(conn));
-        } catch (BadServerResponse e) {
+        } catch (final BadServerResponse e) {
             s_logger.debug("Failed to download template", e);
-        } catch (XenAPIException e) {
+        } catch (final XenAPIException e) {
             s_logger.debug("Failed to download template", e);
-        } catch (XmlRpcException e) {
+        } catch (final XmlRpcException e) {
             s_logger.debug("Failed to download template", e);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.debug("Failed to download template", e);
         } finally {
             if (!result && vdi != null) {
                 try {
                     vdi.destroy(conn);
-                } catch (BadServerResponse e) {
+                } catch (final BadServerResponse e) {
                     s_logger.debug("Failed to cleanup newly created vdi");
-                } catch (XenAPIException e) {
+                } catch (final XenAPIException e) {
                     s_logger.debug("Failed to cleanup newly created vdi");
-                } catch (XmlRpcException e) {
+                } catch (final XmlRpcException e) {
                     s_logger.debug("Failed to cleanup newly created vdi");
                 }
             }
@@ -671,61 +671,61 @@ public class XenServerStorageProcessor implements StorageProcessor {
         return new Answer(cmd, false, "Failed to download template");
     }
 
-    protected Answer execute(AttachPrimaryDataStoreCmd cmd) {
-        String dataStoreUri = cmd.getDataStore();
-        Connection conn = hypervisorResource.getConnection();
+    protected Answer execute(final AttachPrimaryDataStoreCmd cmd) {
+        final String dataStoreUri = cmd.getDataStore();
+        final Connection conn = hypervisorResource.getConnection();
         try {
-            DecodedDataObject obj = Decoder.decode(dataStoreUri);
+            final DecodedDataObject obj = Decoder.decode(dataStoreUri);
 
-            DecodedDataStore store = obj.getStore();
+            final DecodedDataStore store = obj.getStore();
 
-            SR sr = hypervisorResource.getStorageRepository(conn, store.getUuid());
+            final SR sr = hypervisorResource.getStorageRepository(conn, store.getUuid());
             hypervisorResource.setupHeartbeatSr(conn, sr, false);
-            long capacity = sr.getPhysicalSize(conn);
-            long available = capacity - sr.getPhysicalUtilisation(conn);
+            final long capacity = sr.getPhysicalSize(conn);
+            final long available = capacity - sr.getPhysicalUtilisation(conn);
             if (capacity == -1) {
-                String msg = "Pool capacity is -1! pool: ";
+                final String msg = "Pool capacity is -1! pool: ";
                 s_logger.warn(msg);
                 return new Answer(cmd, false, msg);
             }
-            AttachPrimaryDataStoreAnswer answer = new AttachPrimaryDataStoreAnswer(cmd);
+            final AttachPrimaryDataStoreAnswer answer = new AttachPrimaryDataStoreAnswer(cmd);
             answer.setCapacity(capacity);
             answer.setUuid(sr.getUuid(conn));
             answer.setAvailable(available);
             return answer;
-        } catch (XenAPIException e) {
-            String msg = "AttachPrimaryDataStoreCmd add XenAPIException:" + e.toString();
+        } catch (final XenAPIException e) {
+            final String msg = "AttachPrimaryDataStoreCmd add XenAPIException:" + e.toString();
             s_logger.warn(msg, e);
             return new Answer(cmd, false, msg);
-        } catch (Exception e) {
-            String msg = "AttachPrimaryDataStoreCmd failed:" + e.getMessage();
+        } catch (final Exception e) {
+            final String msg = "AttachPrimaryDataStoreCmd failed:" + e.getMessage();
             s_logger.warn(msg, e);
             return new Answer(cmd, false, msg);
         }
     }
 
-    protected boolean IsISCSI(String type) {
+    protected boolean IsISCSI(final String type) {
         return SRType.LVMOHBA.equals(type) || SRType.LVMOISCSI.equals(type) || SRType.LVM.equals(type);
     }
 
-    private String copy_vhd_from_secondarystorage(Connection conn, String mountpoint, String sruuid, int wait) {
-        String nameLabel = "cloud-" + UUID.randomUUID().toString();
-        String results =
+    private String copy_vhd_from_secondarystorage(final Connection conn, final String mountpoint, final String sruuid, final int wait) {
+        final String nameLabel = "cloud-" + UUID.randomUUID().toString();
+        final String results =
                 hypervisorResource.callHostPluginAsync(conn, "vmopspremium", "copy_vhd_from_secondarystorage", wait, "mountpoint", mountpoint, "sruuid", sruuid, "namelabel",
                         nameLabel);
         String errMsg = null;
         if (results == null || results.isEmpty()) {
             errMsg = "copy_vhd_from_secondarystorage return null";
         } else {
-            String[] tmp = results.split("#");
-            String status = tmp[0];
+            final String[] tmp = results.split("#");
+            final String status = tmp[0];
             if (status.equals("0")) {
                 return tmp[1];
             } else {
                 errMsg = tmp[1];
             }
         }
-        String source = mountpoint.substring(mountpoint.lastIndexOf('/') + 1);
+        final String source = mountpoint.substring(mountpoint.lastIndexOf('/') + 1);
         if (hypervisorResource.killCopyProcess(conn, source)) {
             destroyVDIbyNameLabel(conn, nameLabel);
         }
@@ -733,35 +733,35 @@ public class XenServerStorageProcessor implements StorageProcessor {
         throw new CloudRuntimeException(errMsg);
     }
 
-    private void destroyVDIbyNameLabel(Connection conn, String nameLabel) {
+    private void destroyVDIbyNameLabel(final Connection conn, final String nameLabel) {
         try {
-            Set<VDI> vdis = VDI.getByNameLabel(conn, nameLabel);
+            final Set<VDI> vdis = VDI.getByNameLabel(conn, nameLabel);
             if (vdis.size() != 1) {
                 s_logger.warn("destoryVDIbyNameLabel failed due to there are " + vdis.size() + " VDIs with name " + nameLabel);
                 return;
             }
-            for (VDI vdi : vdis) {
+            for (final VDI vdi : vdis) {
                 try {
                     vdi.destroy(conn);
-                } catch (Exception e) {
+                } catch (final Exception e) {
                 }
             }
-        } catch (Exception e) {
+        } catch (final Exception e) {
         }
     }
 
-    protected VDI getVDIbyUuid(Connection conn, String uuid) {
+    protected VDI getVDIbyUuid(final Connection conn, final String uuid) {
         try {
             return VDI.getByUuid(conn, uuid);
-        } catch (Exception e) {
-            String msg = "Catch Exception " + e.getClass().getName() + " :VDI getByUuid for uuid: " + uuid + " failed due to " + e.toString();
+        } catch (final Exception e) {
+            final String msg = "Catch Exception " + e.getClass().getName() + " :VDI getByUuid for uuid: " + uuid + " failed due to " + e.toString();
             s_logger.debug(msg);
             throw new CloudRuntimeException(msg, e);
         }
     }
 
-    protected String getVhdParent(Connection conn, String primaryStorageSRUuid, String snapshotUuid, Boolean isISCSI) {
-        String parentUuid =
+    protected String getVhdParent(final Connection conn, final String primaryStorageSRUuid, final String snapshotUuid, final Boolean isISCSI) {
+        final String parentUuid =
                 hypervisorResource.callHostPlugin(conn, "vmopsSnapshot", "getVhdParent", "primaryStorageSRUuid", primaryStorageSRUuid, "snapshotUuid", snapshotUuid,
                         "isISCSI", isISCSI.toString());
 
@@ -774,20 +774,20 @@ public class XenServerStorageProcessor implements StorageProcessor {
     }
 
     @Override
-    public Answer copyTemplateToPrimaryStorage(CopyCommand cmd) {
-        DataTO srcDataTo = cmd.getSrcTO();
-        DataTO destDataTo = cmd.getDestTO();
-        int wait = cmd.getWait();
-        DataStoreTO srcDataStoreTo = srcDataTo.getDataStore();
+    public Answer copyTemplateToPrimaryStorage(final CopyCommand cmd) {
+        final DataTO srcDataTo = cmd.getSrcTO();
+        final DataTO destDataTo = cmd.getDestTO();
+        final int wait = cmd.getWait();
+        final DataStoreTO srcDataStoreTo = srcDataTo.getDataStore();
 
         try {
-            if ((srcDataStoreTo instanceof NfsTO) && (srcDataTo.getObjectType() == DataObjectType.TEMPLATE)) {
-                NfsTO srcImageStore = (NfsTO) srcDataStoreTo;
-                TemplateObjectTO srcTemplateObjectTo = (TemplateObjectTO) srcDataTo;
-                String storeUrl = srcImageStore.getUrl();
-                URI uri = new URI(storeUrl);
-                String tmplPath = uri.getHost() + ":" + uri.getPath() + "/" + srcDataTo.getPath();
-                DataStoreTO destDataStoreTo = destDataTo.getDataStore();
+            if (srcDataStoreTo instanceof NfsTO && srcDataTo.getObjectType() == DataObjectType.TEMPLATE) {
+                final NfsTO srcImageStore = (NfsTO) srcDataStoreTo;
+                final TemplateObjectTO srcTemplateObjectTo = (TemplateObjectTO) srcDataTo;
+                final String storeUrl = srcImageStore.getUrl();
+                final URI uri = new URI(storeUrl);
+                final String tmplPath = uri.getHost() + ":" + uri.getPath() + "/" + srcDataTo.getPath();
+                final DataStoreTO destDataStoreTo = destDataTo.getDataStore();
 
                 boolean managed = false;
                 String storageHost = null;
@@ -798,9 +798,9 @@ public class XenServerStorageProcessor implements StorageProcessor {
                 String chapInitiatorSecret = null;
 
                 if (destDataStoreTo instanceof PrimaryDataStoreTO) {
-                    PrimaryDataStoreTO destPrimaryDataStoreTo = (PrimaryDataStoreTO)destDataStoreTo;
+                    final PrimaryDataStoreTO destPrimaryDataStoreTo = (PrimaryDataStoreTO)destDataStoreTo;
 
-                    Map<String, String> details = destPrimaryDataStoreTo.getDetails();
+                    final Map<String, String> details = destPrimaryDataStoreTo.getDetails();
 
                     if (details != null) {
                         managed = Boolean.parseBoolean(details.get(PrimaryDataStoreTO.MANAGED));
@@ -816,12 +816,12 @@ public class XenServerStorageProcessor implements StorageProcessor {
                     }
                 }
 
-                Connection conn = hypervisorResource.getConnection();
+                final Connection conn = hypervisorResource.getConnection();
 
                 final SR sr;
 
                 if (managed) {
-                    Map<String, String> details = new HashMap<String, String>();
+                    final Map<String, String> details = new HashMap<String, String>();
 
                     details.put(DiskTO.STORAGE_HOST, storageHost);
                     details.put(DiskTO.IQN, managedStoragePoolName);
@@ -831,11 +831,11 @@ public class XenServerStorageProcessor implements StorageProcessor {
 
                     sr = hypervisorResource.prepareManagedSr(conn, details);
                 } else {
-                    String srName = destDataStoreTo.getUuid();
-                    Set<SR> srs = SR.getByNameLabel(conn, srName);
+                    final String srName = destDataStoreTo.getUuid();
+                    final Set<SR> srs = SR.getByNameLabel(conn, srName);
 
                     if (srs.size() != 1) {
-                        String msg = "There are " + srs.size() + " SRs with same name: " + srName;
+                        final String msg = "There are " + srs.size() + " SRs with same name: " + srName;
 
                         s_logger.warn(msg);
 
@@ -845,19 +845,19 @@ public class XenServerStorageProcessor implements StorageProcessor {
                     }
                 }
 
-                String srUuid = sr.getUuid(conn);
-                String tmplUuid = copy_vhd_from_secondarystorage(conn, tmplPath, srUuid, wait);
-                VDI tmplVdi = getVDIbyUuid(conn, tmplUuid);
+                final String srUuid = sr.getUuid(conn);
+                final String tmplUuid = copy_vhd_from_secondarystorage(conn, tmplPath, srUuid, wait);
+                final VDI tmplVdi = getVDIbyUuid(conn, tmplUuid);
 
                 final String uuidToReturn;
-                Long physicalSize = tmplVdi.getPhysicalUtilisation(conn);
+                final Long physicalSize = tmplVdi.getPhysicalUtilisation(conn);
 
                 if (managed) {
                     uuidToReturn = tmplUuid;
 
                     tmplVdi.setNameLabel(conn, managedStoragePoolRootVolumeName);
                 } else {
-                    VDI snapshotVdi = tmplVdi.snapshot(conn, new HashMap<String, String>());
+                    final VDI snapshotVdi = tmplVdi.snapshot(conn, new HashMap<String, String>());
 
                     uuidToReturn = snapshotVdi.getUuid(conn);
 
@@ -870,10 +870,10 @@ public class XenServerStorageProcessor implements StorageProcessor {
 
                 try {
                     Thread.sleep(5000);
-                } catch (InterruptedException e) {
+                } catch (final InterruptedException e) {
                 }
 
-                TemplateObjectTO newVol = new TemplateObjectTO();
+                final TemplateObjectTO newVol = new TemplateObjectTO();
 
                 newVol.setUuid(uuidToReturn);
                 newVol.setPath(uuidToReturn);
@@ -884,8 +884,8 @@ public class XenServerStorageProcessor implements StorageProcessor {
 
                 return new CopyCmdAnswer(newVol);
             }
-        } catch (Exception e) {
-            String msg = "Catch Exception " + e.getClass().getName() + " for template + " + " due to " + e.toString();
+        } catch (final Exception e) {
+            final String msg = "Catch Exception " + e.getClass().getName() + " for template + " + " due to " + e.toString();
 
             s_logger.warn(msg, e);
 
@@ -896,13 +896,13 @@ public class XenServerStorageProcessor implements StorageProcessor {
     }
 
     @Override
-    public Answer createVolume(CreateObjectCommand cmd) {
-        DataTO data = cmd.getData();
-        VolumeObjectTO volume = (VolumeObjectTO) data;
+    public Answer createVolume(final CreateObjectCommand cmd) {
+        final DataTO data = cmd.getData();
+        final VolumeObjectTO volume = (VolumeObjectTO) data;
 
         try {
-            Connection conn = hypervisorResource.getConnection();
-            SR poolSr = hypervisorResource.getStorageRepository(conn, data.getDataStore().getUuid());
+            final Connection conn = hypervisorResource.getConnection();
+            final SR poolSr = hypervisorResource.getStorageRepository(conn, data.getDataStore().getUuid());
             VDI.Record vdir = new VDI.Record();
             vdir.nameLabel = volume.getName();
             vdir.SR = poolSr;
@@ -913,24 +913,24 @@ public class XenServerStorageProcessor implements StorageProcessor {
 
             vdi = VDI.create(conn, vdir);
             vdir = vdi.getRecord(conn);
-            VolumeObjectTO newVol = new VolumeObjectTO();
+            final VolumeObjectTO newVol = new VolumeObjectTO();
             newVol.setName(vdir.nameLabel);
             newVol.setSize(vdir.virtualSize);
             newVol.setPath(vdir.uuid);
 
             return new CreateObjectAnswer(newVol);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.debug("create volume failed: " + e.toString());
             return new CreateObjectAnswer(e.toString());
         }
     }
 
     @Override
-    public Answer cloneVolumeFromBaseTemplate(CopyCommand cmd) {
-        Connection conn = hypervisorResource.getConnection();
-        DataTO srcData = cmd.getSrcTO();
-        DataTO destData = cmd.getDestTO();
-        VolumeObjectTO volume = (VolumeObjectTO) destData;
+    public Answer cloneVolumeFromBaseTemplate(final CopyCommand cmd) {
+        final Connection conn = hypervisorResource.getConnection();
+        final DataTO srcData = cmd.getSrcTO();
+        final DataTO destData = cmd.getDestTO();
+        final VolumeObjectTO volume = (VolumeObjectTO) destData;
         VDI vdi = null;
         try {
             VDI tmpltvdi = null;
@@ -943,43 +943,43 @@ public class XenServerStorageProcessor implements StorageProcessor {
             vdir = vdi.getRecord(conn);
             s_logger.debug("Succesfully created VDI: Uuid = " + vdir.uuid);
 
-            VolumeObjectTO newVol = new VolumeObjectTO();
+            final VolumeObjectTO newVol = new VolumeObjectTO();
             newVol.setName(vdir.nameLabel);
             newVol.setSize(vdir.virtualSize);
             newVol.setPath(vdir.uuid);
 
             return new CopyCmdAnswer(newVol);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.warn("Unable to create volume; Pool=" + destData + "; Disk: ", e);
             return new CopyCmdAnswer(e.toString());
         }
     }
 
     @Override
-    public Answer copyVolumeFromImageCacheToPrimary(CopyCommand cmd) {
-        Connection conn = hypervisorResource.getConnection();
-        DataTO srcData = cmd.getSrcTO();
-        DataTO destData = cmd.getDestTO();
-        int wait = cmd.getWait();
-        VolumeObjectTO srcVolume = (VolumeObjectTO) srcData;
-        VolumeObjectTO destVolume = (VolumeObjectTO) destData;
-        DataStoreTO srcStore = srcVolume.getDataStore();
+    public Answer copyVolumeFromImageCacheToPrimary(final CopyCommand cmd) {
+        final Connection conn = hypervisorResource.getConnection();
+        final DataTO srcData = cmd.getSrcTO();
+        final DataTO destData = cmd.getDestTO();
+        final int wait = cmd.getWait();
+        final VolumeObjectTO srcVolume = (VolumeObjectTO) srcData;
+        final VolumeObjectTO destVolume = (VolumeObjectTO) destData;
+        final DataStoreTO srcStore = srcVolume.getDataStore();
 
         if (srcStore instanceof NfsTO) {
-            NfsTO nfsStore = (NfsTO) srcStore;
+            final NfsTO nfsStore = (NfsTO) srcStore;
             try {
-                SR primaryStoragePool = hypervisorResource.getStorageRepository(conn, destVolume.getDataStore().getUuid());
-                String srUuid = primaryStoragePool.getUuid(conn);
-                URI uri = new URI(nfsStore.getUrl());
-                String volumePath = uri.getHost() + ":" + uri.getPath() + nfsStore.getPathSeparator() + srcVolume.getPath();
-                String uuid = copy_vhd_from_secondarystorage(conn, volumePath, srUuid, wait);
-                VolumeObjectTO newVol = new VolumeObjectTO();
+                final SR primaryStoragePool = hypervisorResource.getStorageRepository(conn, destVolume.getDataStore().getUuid());
+                final String srUuid = primaryStoragePool.getUuid(conn);
+                final URI uri = new URI(nfsStore.getUrl());
+                final String volumePath = uri.getHost() + ":" + uri.getPath() + nfsStore.getPathSeparator() + srcVolume.getPath();
+                final String uuid = copy_vhd_from_secondarystorage(conn, volumePath, srUuid, wait);
+                final VolumeObjectTO newVol = new VolumeObjectTO();
                 newVol.setPath(uuid);
                 newVol.setSize(srcVolume.getSize());
 
                 return new CopyCmdAnswer(newVol);
-            } catch (Exception e) {
-                String msg = "Catch Exception " + e.getClass().getName() + " due to " + e.toString();
+            } catch (final Exception e) {
+                final String msg = "Catch Exception " + e.getClass().getName() + " due to " + e.toString();
                 s_logger.warn(msg, e);
                 return new CopyCmdAnswer(e.toString());
             }
@@ -990,18 +990,18 @@ public class XenServerStorageProcessor implements StorageProcessor {
     }
 
     @Override
-    public Answer copyVolumeFromPrimaryToSecondary(CopyCommand cmd) {
-        Connection conn = hypervisorResource.getConnection();
-        VolumeObjectTO srcVolume = (VolumeObjectTO) cmd.getSrcTO();
-        VolumeObjectTO destVolume = (VolumeObjectTO) cmd.getDestTO();
-        int wait = cmd.getWait();
-        DataStoreTO destStore = destVolume.getDataStore();
+    public Answer copyVolumeFromPrimaryToSecondary(final CopyCommand cmd) {
+        final Connection conn = hypervisorResource.getConnection();
+        final VolumeObjectTO srcVolume = (VolumeObjectTO) cmd.getSrcTO();
+        final VolumeObjectTO destVolume = (VolumeObjectTO) cmd.getDestTO();
+        final int wait = cmd.getWait();
+        final DataStoreTO destStore = destVolume.getDataStore();
 
         if (destStore instanceof NfsTO) {
             SR secondaryStorage = null;
             try {
-                NfsTO nfsStore = (NfsTO) destStore;
-                URI uri = new URI(nfsStore.getUrl());
+                final NfsTO nfsStore = (NfsTO) destStore;
+                final URI uri = new URI(nfsStore.getUrl());
                 // Create the volume folder
                 if (!hypervisorResource.createSecondaryStorageFolder(conn, uri.getHost() + ":" + uri.getPath(), destVolume.getPath())) {
                     throw new InternalErrorException("Failed to create the volume folder.");
@@ -1010,16 +1010,16 @@ public class XenServerStorageProcessor implements StorageProcessor {
                 // Create a SR for the volume UUID folder
                 secondaryStorage = hypervisorResource.createNfsSRbyURI(conn, new URI(nfsStore.getUrl() + nfsStore.getPathSeparator() + destVolume.getPath()), false);
                 // Look up the volume on the source primary storage pool
-                VDI srcVdi = getVDIbyUuid(conn, srcVolume.getPath());
+                final VDI srcVdi = getVDIbyUuid(conn, srcVolume.getPath());
                 // Copy the volume to secondary storage
-                VDI destVdi = hypervisorResource.cloudVDIcopy(conn, srcVdi, secondaryStorage, wait);
-                String destVolumeUUID = destVdi.getUuid(conn);
+                final VDI destVdi = hypervisorResource.cloudVDIcopy(conn, srcVdi, secondaryStorage, wait);
+                final String destVolumeUUID = destVdi.getUuid(conn);
 
-                VolumeObjectTO newVol = new VolumeObjectTO();
+                final VolumeObjectTO newVol = new VolumeObjectTO();
                 newVol.setPath(destVolume.getPath() + nfsStore.getPathSeparator() + destVolumeUUID + ".vhd");
                 newVol.setSize(srcVolume.getSize());
                 return new CopyCmdAnswer(newVol);
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 s_logger.debug("Failed to copy volume to secondary: " + e.toString());
                 return new CopyCmdAnswer("Failed to copy volume to secondary: " + e.toString());
             } finally {
@@ -1029,7 +1029,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
         return new CopyCmdAnswer("unsupported protocol");
     }
 
-    boolean swiftUpload(Connection conn, SwiftTO swift, String container, String ldir, String lfilename, Boolean isISCSI, int wait) {
+    boolean swiftUpload(final Connection conn, final SwiftTO swift, final String container, final String ldir, final String lfilename, final Boolean isISCSI, final int wait) {
         String result = null;
         try {
             result =
@@ -1038,23 +1038,23 @@ public class XenServerStorageProcessor implements StorageProcessor {
             if (result != null && result.equals("true")) {
                 return true;
             }
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.warn("swift upload failed due to " + e.toString(), e);
         }
         return false;
     }
 
-    protected String deleteSnapshotBackup(Connection conn, String localMountPoint, String path, String secondaryStorageMountPath, String backupUUID) {
+    protected String deleteSnapshotBackup(final Connection conn, final String localMountPoint, final String path, final String secondaryStorageMountPath, final String backupUUID) {
 
         // If anybody modifies the formatting below again, I'll skin them
-        String result =
+        final String result =
                 hypervisorResource.callHostPlugin(conn, "vmopsSnapshot", "deleteSnapshotBackup", "backupUUID", backupUUID, "path", path, "secondaryStorageMountPath",
                         secondaryStorageMountPath, "localMountPoint", localMountPoint);
 
         return result;
     }
 
-    public String swiftBackupSnapshot(Connection conn, SwiftTO swift, String srUuid, String snapshotUuid, String container, Boolean isISCSI, int wait) {
+    public String swiftBackupSnapshot(final Connection conn, final SwiftTO swift, final String srUuid, final String snapshotUuid, final String container, final Boolean isISCSI, final int wait) {
         String lfilename;
         String ldir;
         if (isISCSI) {
@@ -1069,7 +1069,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
     }
 
     protected String backupSnapshotToS3(final Connection connection, final S3TO s3, final String srUuid, final String folder, final String snapshotUuid,
-                                        final Boolean iSCSIFlag, final int wait) {
+            final Boolean iSCSIFlag, final int wait) {
 
         final String filename = iSCSIFlag ? "VHD-" + snapshotUuid : snapshotUuid + ".vhd";
         final String dir = (iSCSIFlag ? "/dev/VG_XenStorage-" : "/var/run/sr-mount/") + srUuid;
@@ -1090,7 +1090,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
             }
             return null;
 
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.error(String.format("S3 upload failed of snapshot %1$s due to %2$s.", snapshotUuid, e.toString()), e);
         }
 
@@ -1098,8 +1098,8 @@ public class XenServerStorageProcessor implements StorageProcessor {
 
     }
 
-    protected Long getSnapshotSize(Connection conn, String primaryStorageSRUuid, String snapshotUuid, Boolean isISCSI, int wait) {
-        String physicalSize = hypervisorResource.callHostPluginAsync(conn, "vmopsSnapshot", "getSnapshotSize", wait,
+    protected Long getSnapshotSize(final Connection conn, final String primaryStorageSRUuid, final String snapshotUuid, final Boolean isISCSI, final int wait) {
+        final String physicalSize = hypervisorResource.callHostPluginAsync(conn, "vmopsSnapshot", "getSnapshotSize", wait,
                 "primaryStorageSRUuid", primaryStorageSRUuid, "snapshotUuid", snapshotUuid, "isISCSI", isISCSI.toString());
         if (physicalSize == null || physicalSize.isEmpty()) {
             return (long) 0;
@@ -1108,8 +1108,8 @@ public class XenServerStorageProcessor implements StorageProcessor {
         }
     }
 
-    protected String backupSnapshot(Connection conn, String primaryStorageSRUuid, String localMountPoint, String path, String secondaryStorageMountPath,
-                                    String snapshotUuid, String prevBackupUuid, Boolean isISCSI, int wait) {
+    protected String backupSnapshot(final Connection conn, final String primaryStorageSRUuid, final String localMountPoint, final String path, final String secondaryStorageMountPath,
+            final String snapshotUuid, String prevBackupUuid, final Boolean isISCSI, final int wait) {
         String backupSnapshotUuid = null;
 
         if (prevBackupUuid == null) {
@@ -1118,8 +1118,8 @@ public class XenServerStorageProcessor implements StorageProcessor {
 
         // Each argument is put in a separate line for readability.
         // Using more lines does not harm the environment.
-        String backupUuid = UUID.randomUUID().toString();
-        String results =
+        final String backupUuid = UUID.randomUUID().toString();
+        final String results =
                 hypervisorResource.callHostPluginAsync(conn, "vmopsSnapshot", "backupSnapshot", wait, "primaryStorageSRUuid", primaryStorageSRUuid, "path", path,
                         "secondaryStorageMountPath", secondaryStorageMountPath, "snapshotUuid", snapshotUuid, "prevBackupUuid", prevBackupUuid, "backupUuid", backupUuid,
                         "isISCSI", isISCSI.toString(), "localMountPoint", localMountPoint);
@@ -1130,8 +1130,8 @@ public class XenServerStorageProcessor implements StorageProcessor {
                             secondaryStorageMountPath + " due to null";
         } else {
 
-            String[] tmp = results.split("#");
-            String status = tmp[0];
+            final String[] tmp = results.split("#");
+            final String status = tmp[0];
             backupSnapshotUuid = tmp[1];
             // status == "1" if and only if backupSnapshotUuid != null
             // So we don't rely on status value but return backupSnapshotUuid as an
@@ -1145,45 +1145,45 @@ public class XenServerStorageProcessor implements StorageProcessor {
                                 secondaryStorageMountPath + " due to " + tmp[1];
             }
         }
-        String source = backupUuid + ".vhd";
+        final String source = backupUuid + ".vhd";
         hypervisorResource.killCopyProcess(conn, source);
         s_logger.warn(errMsg);
         throw new CloudRuntimeException(errMsg);
     }
 
-    protected boolean destroySnapshotOnPrimaryStorageExceptThis(Connection conn, String volumeUuid, String avoidSnapshotUuid) {
+    protected boolean destroySnapshotOnPrimaryStorageExceptThis(final Connection conn, final String volumeUuid, final String avoidSnapshotUuid) {
         try {
-            VDI volume = getVDIbyUuid(conn, volumeUuid);
+            final VDI volume = getVDIbyUuid(conn, volumeUuid);
             if (volume == null) {
                 throw new InternalErrorException("Could not destroy snapshot on volume " + volumeUuid + " due to can not find it");
             }
-            Set<VDI> snapshots = volume.getSnapshots(conn);
-            for (VDI snapshot : snapshots) {
+            final Set<VDI> snapshots = volume.getSnapshots(conn);
+            for (final VDI snapshot : snapshots) {
                 try {
                     if (!snapshot.getUuid(conn).equals(avoidSnapshotUuid)) {
                         snapshot.destroy(conn);
                     }
-                } catch (Exception e) {
-                    String msg = "Destroying snapshot: " + snapshot + " on primary storage failed due to " + e.toString();
+                } catch (final Exception e) {
+                    final String msg = "Destroying snapshot: " + snapshot + " on primary storage failed due to " + e.toString();
                     s_logger.warn(msg, e);
                 }
             }
             s_logger.debug("Successfully destroyed snapshot on volume: " + volumeUuid + " execept this current snapshot " + avoidSnapshotUuid);
             return true;
-        } catch (XenAPIException e) {
-            String msg = "Destroying snapshot on volume: " + volumeUuid + " execept this current snapshot " + avoidSnapshotUuid + " failed due to " + e.toString();
+        } catch (final XenAPIException e) {
+            final String msg = "Destroying snapshot on volume: " + volumeUuid + " execept this current snapshot " + avoidSnapshotUuid + " failed due to " + e.toString();
             s_logger.error(msg, e);
-        } catch (Exception e) {
-            String msg = "Destroying snapshot on volume: " + volumeUuid + " execept this current snapshot " + avoidSnapshotUuid + " failed due to " + e.toString();
+        } catch (final Exception e) {
+            final String msg = "Destroying snapshot on volume: " + volumeUuid + " execept this current snapshot " + avoidSnapshotUuid + " failed due to " + e.toString();
             s_logger.warn(msg, e);
         }
 
         return false;
     }
 
-    private boolean destroySnapshotOnPrimaryStorage(Connection conn, String lastSnapshotUuid) {
+    private boolean destroySnapshotOnPrimaryStorage(final Connection conn, final String lastSnapshotUuid) {
         try {
-            VDI snapshot = getVDIbyUuid(conn, lastSnapshotUuid);
+            final VDI snapshot = getVDIbyUuid(conn, lastSnapshotUuid);
             if (snapshot == null) {
                 // since this is just used to cleanup leftover bad snapshots, no need to throw exception
                 s_logger.warn("Could not destroy snapshot " + lastSnapshotUuid + " due to can not find it");
@@ -1191,24 +1191,24 @@ public class XenServerStorageProcessor implements StorageProcessor {
             }
             snapshot.destroy(conn);
             return true;
-        } catch (XenAPIException e) {
-            String msg = "Destroying snapshot: " + lastSnapshotUuid + " failed due to " + e.toString();
+        } catch (final XenAPIException e) {
+            final String msg = "Destroying snapshot: " + lastSnapshotUuid + " failed due to " + e.toString();
             s_logger.error(msg, e);
-        } catch (Exception e) {
-            String msg = "Destroying snapshot: " + lastSnapshotUuid + " failed due to " + e.toString();
+        } catch (final Exception e) {
+            final String msg = "Destroying snapshot: " + lastSnapshotUuid + " failed due to " + e.toString();
             s_logger.warn(msg, e);
         }
         return false;
     }
 
     @Override
-    public Answer backupSnapshot(CopyCommand cmd) {
-        Connection conn = hypervisorResource.getConnection();
-        DataTO srcData = cmd.getSrcTO();
-        DataTO cacheData = cmd.getCacheTO();
-        DataTO destData = cmd.getDestTO();
-        int wait = cmd.getWait();
-        String primaryStorageNameLabel = srcData.getDataStore().getUuid();
+    public Answer backupSnapshot(final CopyCommand cmd) {
+        final Connection conn = hypervisorResource.getConnection();
+        final DataTO srcData = cmd.getSrcTO();
+        final DataTO cacheData = cmd.getCacheTO();
+        final DataTO destData = cmd.getDestTO();
+        final int wait = cmd.getWait();
+        final String primaryStorageNameLabel = srcData.getDataStore().getUuid();
         String secondaryStorageUrl = null;
         NfsTO cacheStore = null;
         String destPath = null;
@@ -1222,58 +1222,58 @@ public class XenServerStorageProcessor implements StorageProcessor {
             destPath = destData.getPath();
         }
 
-        SnapshotObjectTO snapshotTO = (SnapshotObjectTO) srcData;
-        SnapshotObjectTO snapshotOnImage = (SnapshotObjectTO) destData;
-        String snapshotUuid = snapshotTO.getPath();
-        String volumeUuid = snapshotTO.getVolume().getPath();
+        final SnapshotObjectTO snapshotTO = (SnapshotObjectTO) srcData;
+        final SnapshotObjectTO snapshotOnImage = (SnapshotObjectTO) destData;
+        final String snapshotUuid = snapshotTO.getPath();
+        final String volumeUuid = snapshotTO.getVolume().getPath();
 
-        String prevBackupUuid = snapshotOnImage.getParentSnapshotPath();
-        String prevSnapshotUuid = snapshotTO.getParentSnapshotPath();
+        final String prevBackupUuid = snapshotOnImage.getParentSnapshotPath();
+        final String prevSnapshotUuid = snapshotTO.getParentSnapshotPath();
 
         // By default assume failure
         String details = null;
         String snapshotBackupUuid = null;
         Long physicalSize = null;
-        Map<String, String> options = cmd.getOptions();
+        final Map<String, String> options = cmd.getOptions();
         boolean fullbackup = Boolean.parseBoolean(options.get("fullSnapshot"));
         boolean result = false;
         try {
-            SR primaryStorageSR = hypervisorResource.getSRByNameLabelandHost(conn, primaryStorageNameLabel);
+            final SR primaryStorageSR = hypervisorResource.getSRByNameLabelandHost(conn, primaryStorageNameLabel);
             if (primaryStorageSR == null) {
                 throw new InternalErrorException("Could not backup snapshot because the primary Storage SR could not be created from the name label: " +
                         primaryStorageNameLabel);
             }
-            String psUuid = primaryStorageSR.getUuid(conn);
-            Boolean isISCSI = IsISCSI(primaryStorageSR.getType(conn));
+            final String psUuid = primaryStorageSR.getUuid(conn);
+            final Boolean isISCSI = IsISCSI(primaryStorageSR.getType(conn));
 
-            VDI snapshotVdi = getVDIbyUuid(conn, snapshotUuid);
+            final VDI snapshotVdi = getVDIbyUuid(conn, snapshotUuid);
             String snapshotPaUuid = null;
 
             if (prevSnapshotUuid != null && !fullbackup) {
                 try {
                     snapshotPaUuid = getVhdParent(conn, psUuid, snapshotUuid, isISCSI);
                     if (snapshotPaUuid != null) {
-                        String snashotPaPaPaUuid = getVhdParent(conn, psUuid, snapshotPaUuid, isISCSI);
-                        String prevSnashotPaUuid = getVhdParent(conn, psUuid, prevSnapshotUuid, isISCSI);
+                        final String snashotPaPaPaUuid = getVhdParent(conn, psUuid, snapshotPaUuid, isISCSI);
+                        final String prevSnashotPaUuid = getVhdParent(conn, psUuid, prevSnapshotUuid, isISCSI);
                         if (snashotPaPaPaUuid != null && prevSnashotPaUuid != null && prevSnashotPaUuid.equals(snashotPaPaPaUuid)) {
                             fullbackup = false;
                         } else {
                             fullbackup = true;
                         }
                     }
-                } catch (Exception e) {
+                } catch (final Exception e) {
                     s_logger.debug("Failed to get parent snapshots, take full snapshot", e);
                     fullbackup = true;
                 }
             }
 
-            URI uri = new URI(secondaryStorageUrl);
-            String secondaryStorageMountPath = uri.getHost() + ":" + uri.getPath();
-            DataStoreTO destStore = destData.getDataStore();
-            String folder = destPath;
+            final URI uri = new URI(secondaryStorageUrl);
+            final String secondaryStorageMountPath = uri.getHost() + ":" + uri.getPath();
+            final DataStoreTO destStore = destData.getDataStore();
+            final String folder = destPath;
             String finalPath = null;
 
-            String localMountPoint = BaseMountPointOnHost + File.separator + UUID.nameUUIDFromBytes(secondaryStorageUrl.getBytes()).toString();
+            final String localMountPoint = BaseMountPointOnHost + File.separator + UUID.nameUUIDFromBytes(secondaryStorageUrl.getBytes()).toString();
             if (fullbackup) {
                 // the first snapshot is always a full snapshot
 
@@ -1282,25 +1282,25 @@ public class XenServerStorageProcessor implements StorageProcessor {
                     s_logger.warn(details);
                     return new CopyCmdAnswer(details);
                 }
-                String snapshotMountpoint = secondaryStorageUrl + "/" + folder;
+                final String snapshotMountpoint = secondaryStorageUrl + "/" + folder;
                 SR snapshotSr = null;
                 try {
                     snapshotSr = hypervisorResource.createNfsSRbyURI(conn, new URI(snapshotMountpoint), false);
-                    VDI backedVdi = hypervisorResource.cloudVDIcopy(conn, snapshotVdi, snapshotSr, wait);
+                    final VDI backedVdi = hypervisorResource.cloudVDIcopy(conn, snapshotVdi, snapshotSr, wait);
                     snapshotBackupUuid = backedVdi.getUuid(conn);
-                    String primarySRuuid = snapshotSr.getUuid(conn);
+                    final String primarySRuuid = snapshotSr.getUuid(conn);
                     physicalSize = getSnapshotSize(conn, primarySRuuid, snapshotBackupUuid, isISCSI, wait);
 
                     if (destStore instanceof SwiftTO) {
                         try {
-                            String container = "S-" + snapshotTO.getVolume().getVolumeId().toString();
-                            String destSnapshotName = swiftBackupSnapshot(conn, (SwiftTO) destStore, snapshotSr.getUuid(conn), snapshotBackupUuid, container, false, wait);
-                            String swiftPath = container + File.separator + destSnapshotName;
+                            final String container = "S-" + snapshotTO.getVolume().getVolumeId().toString();
+                            final String destSnapshotName = swiftBackupSnapshot(conn, (SwiftTO) destStore, snapshotSr.getUuid(conn), snapshotBackupUuid, container, false, wait);
+                            final String swiftPath = container + File.separator + destSnapshotName;
                             finalPath = swiftPath;
                         } finally {
                             try {
                                 deleteSnapshotBackup(conn, localMountPoint, folder, secondaryStorageMountPath, snapshotBackupUuid);
-                            } catch (Exception e) {
+                            } catch (final Exception e) {
                                 s_logger.debug("Failed to delete snapshot on cache storages", e);
                             }
                         }
@@ -1314,7 +1314,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
                         } finally {
                             try {
                                 deleteSnapshotBackup(conn, localMountPoint, folder, secondaryStorageMountPath, snapshotBackupUuid);
-                            } catch (Exception e) {
+                            } catch (final Exception e) {
                                 s_logger.debug("Failed to delete snapshot on cache storages", e);
                             }
                         }
@@ -1329,9 +1329,9 @@ public class XenServerStorageProcessor implements StorageProcessor {
                     }
                 }
             } else {
-                String primaryStorageSRUuid = primaryStorageSR.getUuid(conn);
+                final String primaryStorageSRUuid = primaryStorageSR.getUuid(conn);
                 if (destStore instanceof SwiftTO) {
-                    String container = "S-" + snapshotTO.getVolume().getVolumeId().toString();
+                    final String container = "S-" + snapshotTO.getVolume().getVolumeId().toString();
                     snapshotBackupUuid =
                             swiftBackupSnapshot(conn, (SwiftTO) destStore, primaryStorageSRUuid, snapshotPaUuid, "S-" + snapshotTO.getVolume().getVolumeId().toString(),
                                     isISCSI, wait);
@@ -1342,10 +1342,10 @@ public class XenServerStorageProcessor implements StorageProcessor {
                         throw new CloudRuntimeException("S3 upload of snapshots " + snapshotPaUuid + " failed");
                     }
                 } else {
-                    String results =
+                    final String results =
                             backupSnapshot(conn, primaryStorageSRUuid, localMountPoint, folder, secondaryStorageMountPath, snapshotUuid, prevBackupUuid, isISCSI, wait);
 
-                    String[] tmp = results.split("#");
+                    final String[] tmp = results.split("#");
                     snapshotBackupUuid = tmp[1];
                     physicalSize = Long.parseLong(tmp[2]);
                     finalPath = folder + cacheStore.getPathSeparator() + snapshotBackupUuid;
@@ -1354,7 +1354,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
             // delete primary snapshots with only the last one left
             destroySnapshotOnPrimaryStorageExceptThis(conn, volumeUuid, snapshotUuid);
 
-            SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
+            final SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
             newSnapshot.setPath(finalPath);
             newSnapshot.setPhysicalSize(physicalSize);
             if (fullbackup) {
@@ -1364,10 +1364,10 @@ public class XenServerStorageProcessor implements StorageProcessor {
             }
             result = true;
             return new CopyCmdAnswer(newSnapshot);
-        } catch (XenAPIException e) {
+        } catch (final XenAPIException e) {
             details = "BackupSnapshot Failed due to " + e.toString();
             s_logger.warn(details, e);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             details = "BackupSnapshot Failed due to " + e.getMessage();
             s_logger.warn(details, e);
         } finally {
@@ -1375,7 +1375,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
                 // remove last bad primary snapshot when exception happens
                 try {
                     destroySnapshotOnPrimaryStorage(conn, snapshotUuid);
-                } catch (Exception e) {
+                } catch (final Exception e) {
                     s_logger.debug("clean up snapshot failed", e);
                 }
             }
@@ -1385,17 +1385,17 @@ public class XenServerStorageProcessor implements StorageProcessor {
     }
 
     @Override
-    public Answer createTemplateFromVolume(CopyCommand cmd) {
-        Connection conn = hypervisorResource.getConnection();
-        VolumeObjectTO volume = (VolumeObjectTO) cmd.getSrcTO();
-        TemplateObjectTO template = (TemplateObjectTO) cmd.getDestTO();
-        NfsTO destStore = (NfsTO) cmd.getDestTO().getDataStore();
-        int wait = cmd.getWait();
+    public Answer createTemplateFromVolume(final CopyCommand cmd) {
+        final Connection conn = hypervisorResource.getConnection();
+        final VolumeObjectTO volume = (VolumeObjectTO) cmd.getSrcTO();
+        final TemplateObjectTO template = (TemplateObjectTO) cmd.getDestTO();
+        final NfsTO destStore = (NfsTO) cmd.getDestTO().getDataStore();
+        final int wait = cmd.getWait();
 
-        String secondaryStoragePoolURL = destStore.getUrl();
-        String volumeUUID = volume.getPath();
+        final String secondaryStoragePoolURL = destStore.getUrl();
+        final String volumeUUID = volume.getPath();
 
-        String userSpecifiedName = template.getName();
+        final String userSpecifiedName = template.getName();
 
         String details = null;
         SR tmpltSR = null;
@@ -1403,7 +1403,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
         String secondaryStorageMountPath = null;
         String installPath = null;
         try {
-            URI uri = new URI(secondaryStoragePoolURL);
+            final URI uri = new URI(secondaryStoragePoolURL);
             secondaryStorageMountPath = uri.getHost() + ":" + uri.getPath();
             installPath = template.getPath();
             if (!hypervisorResource.createSecondaryStorageFolder(conn, secondaryStorageMountPath, installPath)) {
@@ -1412,25 +1412,25 @@ public class XenServerStorageProcessor implements StorageProcessor {
                 return new CopyCmdAnswer(details);
             }
 
-            VDI vol = getVDIbyUuid(conn, volumeUUID);
+            final VDI vol = getVDIbyUuid(conn, volumeUUID);
             // create template SR
-            URI tmpltURI = new URI(secondaryStoragePoolURL + "/" + installPath);
+            final URI tmpltURI = new URI(secondaryStoragePoolURL + "/" + installPath);
             tmpltSR = hypervisorResource.createNfsSRbyURI(conn, tmpltURI, false);
 
             // copy volume to template SR
-            VDI tmpltVDI = hypervisorResource.cloudVDIcopy(conn, vol, tmpltSR, wait);
+            final VDI tmpltVDI = hypervisorResource.cloudVDIcopy(conn, vol, tmpltSR, wait);
             // scan makes XenServer pick up VDI physicalSize
             tmpltSR.scan(conn);
             if (userSpecifiedName != null) {
                 tmpltVDI.setNameLabel(conn, userSpecifiedName);
             }
 
-            String tmpltUUID = tmpltVDI.getUuid(conn);
-            String tmpltFilename = tmpltUUID + ".vhd";
-            long virtualSize = tmpltVDI.getVirtualSize(conn);
-            long physicalSize = tmpltVDI.getPhysicalUtilisation(conn);
+            final String tmpltUUID = tmpltVDI.getUuid(conn);
+            final String tmpltFilename = tmpltUUID + ".vhd";
+            final long virtualSize = tmpltVDI.getVirtualSize(conn);
+            final long physicalSize = tmpltVDI.getPhysicalUtilisation(conn);
             // create the template.properties file
-            String templatePath = secondaryStorageMountPath + "/" + installPath;
+            final String templatePath = secondaryStorageMountPath + "/" + installPath;
             result =
                     hypervisorResource.postCreatePrivateTemplate(conn, templatePath, tmpltFilename, tmpltUUID, userSpecifiedName, null, physicalSize, virtualSize,
                             template.getId());
@@ -1440,15 +1440,15 @@ public class XenServerStorageProcessor implements StorageProcessor {
             installPath = installPath + "/" + tmpltFilename;
             hypervisorResource.removeSR(conn, tmpltSR);
             tmpltSR = null;
-            TemplateObjectTO newTemplate = new TemplateObjectTO();
+            final TemplateObjectTO newTemplate = new TemplateObjectTO();
             newTemplate.setPath(installPath);
             newTemplate.setFormat(ImageFormat.VHD);
             newTemplate.setSize(virtualSize);
             newTemplate.setPhysicalSize(physicalSize);
             newTemplate.setName(tmpltUUID);
-            CopyCmdAnswer answer = new CopyCmdAnswer(newTemplate);
+            final CopyCmdAnswer answer = new CopyCmdAnswer(newTemplate);
             return answer;
-        } catch (Exception e) {
+        } catch (final Exception e) {
             if (tmpltSR != null) {
                 hypervisorResource.removeSR(conn, tmpltSR);
             }
@@ -1462,17 +1462,17 @@ public class XenServerStorageProcessor implements StorageProcessor {
     }
 
     @Override
-    public Answer createTemplateFromSnapshot(CopyCommand cmd) {
-        Connection conn = hypervisorResource.getConnection();
+    public Answer createTemplateFromSnapshot(final CopyCommand cmd) {
+        final Connection conn = hypervisorResource.getConnection();
 
-        SnapshotObjectTO snapshotObjTO = (SnapshotObjectTO)cmd.getSrcTO();
-        TemplateObjectTO templateObjTO = (TemplateObjectTO)cmd.getDestTO();
+        final SnapshotObjectTO snapshotObjTO = (SnapshotObjectTO)cmd.getSrcTO();
+        final TemplateObjectTO templateObjTO = (TemplateObjectTO)cmd.getDestTO();
 
         if (!(snapshotObjTO.getDataStore() instanceof PrimaryDataStoreTO) || !(templateObjTO.getDataStore() instanceof NfsTO)) {
             return null;
         }
 
-        String userSpecifiedTemplateName = templateObjTO.getName();
+        final String userSpecifiedTemplateName = templateObjTO.getName();
 
         NfsTO destStore = null;
         URI destUri = null;
@@ -1481,7 +1481,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
             destStore = (NfsTO)templateObjTO.getDataStore();
 
             destUri = new URI(destStore.getUrl());
-        } catch (Exception ex) {
+        } catch (final Exception ex) {
             s_logger.debug("Invalid URI", ex);
 
             return new CopyCmdAnswer("Invalid URI: " + ex.toString());
@@ -1490,37 +1490,37 @@ public class XenServerStorageProcessor implements StorageProcessor {
         SR srcSr = null;
         SR destSr = null;
 
-        String destDir = templateObjTO.getPath();
+        final String destDir = templateObjTO.getPath();
         VDI destVdi = null;
 
         boolean result = false;
 
         try {
-            Map<String, String> srcDetails = cmd.getOptions();
+            final Map<String, String> srcDetails = cmd.getOptions();
 
-            String iScsiName = srcDetails.get(DiskTO.IQN);
-            String storageHost = srcDetails.get(DiskTO.STORAGE_HOST);
-            String chapInitiatorUsername = srcDetails.get(DiskTO.CHAP_INITIATOR_USERNAME);
-            String chapInitiatorSecret = srcDetails.get(DiskTO.CHAP_INITIATOR_SECRET);
+            final String iScsiName = srcDetails.get(DiskTO.IQN);
+            final String storageHost = srcDetails.get(DiskTO.STORAGE_HOST);
+            final String chapInitiatorUsername = srcDetails.get(DiskTO.CHAP_INITIATOR_USERNAME);
+            final String chapInitiatorSecret = srcDetails.get(DiskTO.CHAP_INITIATOR_SECRET);
 
             srcSr = hypervisorResource.getIscsiSR(conn, iScsiName, storageHost, iScsiName, chapInitiatorUsername, chapInitiatorSecret, true);
 
-            String destNfsPath = destUri.getHost() + ":" + destUri.getPath();
+            final String destNfsPath = destUri.getHost() + ":" + destUri.getPath();
 
             if (!hypervisorResource.createSecondaryStorageFolder(conn, destNfsPath, destDir)) {
-                String details = " Failed to create folder " + destDir + " in secondary storage";
+                final String details = " Failed to create folder " + destDir + " in secondary storage";
 
                 s_logger.warn(details);
 
                 return new CopyCmdAnswer(details);
             }
 
-            URI templateUri = new URI(destStore.getUrl() + "/" + destDir);
+            final URI templateUri = new URI(destStore.getUrl() + "/" + destDir);
 
             destSr = hypervisorResource.createNfsSRbyURI(conn, templateUri, false);
 
             // there should only be one VDI in this SR
-            VDI srcVdi = srcSr.getVDIs(conn).iterator().next();
+            final VDI srcVdi = srcSr.getVDIs(conn).iterator().next();
 
             destVdi = srcVdi.copy(conn, destSr);
 
@@ -1531,10 +1531,10 @@ public class XenServerStorageProcessor implements StorageProcessor {
                 destVdi.setNameLabel(conn, userSpecifiedTemplateName);
             }
 
-            String templateUuid = destVdi.getUuid(conn);
-            String templateFilename = templateUuid + ".vhd";
-            long virtualSize = destVdi.getVirtualSize(conn);
-            long physicalSize = destVdi.getPhysicalUtilisation(conn);
+            final String templateUuid = destVdi.getUuid(conn);
+            final String templateFilename = templateUuid + ".vhd";
+            final long virtualSize = destVdi.getVirtualSize(conn);
+            final long physicalSize = destVdi.getPhysicalUtilisation(conn);
 
             // create the template.properties file
             String templatePath = destNfsPath + "/" + destDir;
@@ -1548,7 +1548,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
                 throw new CloudRuntimeException("Could not create the template.properties file on secondary storage dir: " + templateUri);
             }
 
-            TemplateObjectTO newTemplate = new TemplateObjectTO();
+            final TemplateObjectTO newTemplate = new TemplateObjectTO();
 
             newTemplate.setPath(destDir + "/" + templateFilename);
             newTemplate.setFormat(Storage.ImageFormat.VHD);
@@ -1560,7 +1560,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
             result = true;
 
             return new CopyCmdAnswer(newTemplate);
-        } catch (Exception ex) {
+        } catch (final Exception ex) {
             s_logger.error("Failed to create a template from a snapshot", ex);
 
             return new CopyCmdAnswer("Failed to create a template from a snapshot: " + ex.toString());
@@ -1569,7 +1569,7 @@ public class XenServerStorageProcessor implements StorageProcessor {
                 if (destVdi != null) {
                     try {
                         destVdi.destroy(conn);
-                    } catch (Exception e) {
+                    } catch (final Exception e) {
                         s_logger.debug("Cleaned up leftover VDI on destination storage due to failure: ", e);
                     }
                 }
@@ -1586,12 +1586,12 @@ public class XenServerStorageProcessor implements StorageProcessor {
     }
 
     @Override
-    public Answer createVolumeFromSnapshot(CopyCommand cmd) {
-        Connection conn = hypervisorResource.getConnection();
-        DataTO srcData = cmd.getSrcTO();
-        SnapshotObjectTO snapshot = (SnapshotObjectTO) srcData;
-        DataTO destData = cmd.getDestTO();
-        DataStoreTO imageStore = srcData.getDataStore();
+    public Answer createVolumeFromSnapshot(final CopyCommand cmd) {
+        final Connection conn = hypervisorResource.getConnection();
+        final DataTO srcData = cmd.getSrcTO();
+        final SnapshotObjectTO snapshot = (SnapshotObjectTO) srcData;
+        final DataTO destData = cmd.getDestTO();
+        final DataStoreTO imageStore = srcData.getDataStore();
 
         if (srcData.getDataStore() instanceof PrimaryDataStoreTO && destData.getDataStore() instanceof PrimaryDataStoreTO) {
             return createVolumeFromSnapshot2(cmd);
@@ -1601,10 +1601,10 @@ public class XenServerStorageProcessor implements StorageProcessor {
             return new CopyCmdAnswer("unsupported protocol");
         }
 
-        NfsTO nfsImageStore = (NfsTO) imageStore;


<TRUNCATED>

Mime
View raw message