You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ek...@apache.org on 2015/05/13 11:35:44 UTC

[02/41] git commit: updated refs/heads/master to 45c0fa2

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/508f1052/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index 2bd584e..892e906 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -61,6 +61,13 @@ import java.util.regex.Pattern;
 import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeObjectTO;
+import org.apache.cloudstack.utils.qemu.QemuImg;
+import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat;
+import org.apache.cloudstack.utils.qemu.QemuImgException;
+import org.apache.cloudstack.utils.qemu.QemuImgFile;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.log4j.Logger;
@@ -81,15 +88,6 @@ import com.ceph.rados.RadosException;
 import com.ceph.rbd.Rbd;
 import com.ceph.rbd.RbdException;
 import com.ceph.rbd.RbdImage;
-
-import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
-import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
-import org.apache.cloudstack.storage.to.VolumeObjectTO;
-import org.apache.cloudstack.utils.qemu.QemuImg;
-import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat;
-import org.apache.cloudstack.utils.qemu.QemuImgException;
-import org.apache.cloudstack.utils.qemu.QemuImgFile;
-
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.AttachIsoCommand;
 import com.cloud.agent.api.AttachVolumeAnswer;
@@ -232,6 +230,7 @@ import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.SerialDef;
 import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.TermPolicy;
 import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VideoDef;
 import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.VirtioSerialDef;
+import com.cloud.hypervisor.kvm.resource.wrapper.LibvirtRequestWrapper;
 import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk;
 import com.cloud.hypervisor.kvm.storage.KVMStoragePool;
 import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager;
@@ -334,12 +333,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
     protected static final String DEFAULT_BRIDGE_VIF_DRIVER_CLASS_NAME = "com.cloud.hypervisor.kvm.resource.BridgeVifDriver";
 
     @Override
-    public ExecutionResult executeInVR(String routerIp, String script, String args) {
+    public ExecutionResult executeInVR(final String routerIp, final String script, final String args) {
         return executeInVR(routerIp, script, args, _timeout / 1000);
     }
 
     @Override
-    public ExecutionResult executeInVR(String routerIp, String script, String args, int timeout) {
+    public ExecutionResult executeInVR(final String routerIp, final String script, final String args, final int timeout) {
         final Script command = new Script(_routerProxyPath, timeout * 1000, s_logger);
         final AllLinesParser parser = new AllLinesParser();
         command.add(script);
@@ -355,13 +354,13 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
     }
 
     @Override
-    public ExecutionResult createFileInVR(String routerIp, String path, String filename, String content) {
-        File permKey = new File("/root/.ssh/id_rsa.cloud");
+    public ExecutionResult createFileInVR(final String routerIp, final String path, final String filename, final String content) {
+        final File permKey = new File("/root/.ssh/id_rsa.cloud");
         String error = null;
 
         try {
             SshHelper.scpTo(routerIp, 3922, "root", permKey, null, path, content.getBytes(), filename, null);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.warn("Fail to create file " + path + filename + " in VR " + routerIp, e);
             error = e.getMessage();
         }
@@ -369,7 +368,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
     }
 
     @Override
-    public ExecutionResult prepareCommand(NetworkElementCommand cmd) {
+    public ExecutionResult prepareCommand(final NetworkElementCommand cmd) {
         //Update IP used to access router
         cmd.setRouterAccessIp(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP));
         assert cmd.getRouterAccessIp() != null;
@@ -387,7 +386,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
     }
 
     @Override
-    public ExecutionResult cleanupCommand(NetworkElementCommand cmd) {
+    public ExecutionResult cleanupCommand(final NetworkElementCommand cmd) {
         if (cmd instanceof IpAssocCommand && !(cmd instanceof IpAssocVpcCommand)) {
             return cleanupNetworkElementCommand((IpAssocCommand)cmd);
         }
@@ -398,11 +397,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         private final Map<String, String> map = new HashMap<String, String>();
 
         @Override
-        public String interpret(BufferedReader reader) throws IOException {
+        public String interpret(final BufferedReader reader) throws IOException {
             String line = null;
             int numLines = 0;
             while ((line = reader.readLine()) != null) {
-                String[] toks = line.trim().split("=");
+                final String[] toks = line.trim().split("=");
                 if (toks.length < 2) {
                     s_logger.warn("Failed to parse Script output: " + line);
                 } else {
@@ -491,13 +490,13 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 
     protected StorageSubsystemCommandHandler storageHandler;
 
-    private String getEndIpFromStartIp(String startIp, int numIps) {
-        String[] tokens = startIp.split("[.]");
-        assert (tokens.length == 4);
+    private String getEndIpFromStartIp(final String startIp, final int numIps) {
+        final String[] tokens = startIp.split("[.]");
+        assert tokens.length == 4;
         int lastbyte = Integer.parseInt(tokens[3]);
         lastbyte = lastbyte + numIps;
         tokens[3] = Integer.toString(lastbyte);
-        StringBuilder end = new StringBuilder(15);
+        final StringBuilder end = new StringBuilder(15);
         end.append(tokens[0]).append(".").append(tokens[1]).append(".").append(tokens[2]).append(".").append(tokens[3]);
         return end.toString();
     }
@@ -511,14 +510,14 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 
         s_logger.info("developer.properties found at " + file.getAbsolutePath());
         try {
-            Properties properties = PropertiesUtil.loadFromFile(file);
+            final Properties properties = PropertiesUtil.loadFromFile(file);
 
-            String startMac = (String)properties.get("private.macaddr.start");
+            final String startMac = (String)properties.get("private.macaddr.start");
             if (startMac == null) {
                 throw new ConfigurationException("Developers must specify start mac for private ip range");
             }
 
-            String startIp = (String)properties.get("private.ipaddr.start");
+            final String startIp = (String)properties.get("private.ipaddr.start");
             if (startIp == null) {
                 throw new ConfigurationException("Developers must specify start ip for private ip range");
             }
@@ -562,7 +561,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
     }
 
     @Override
-    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+    public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
         boolean success = super.configure(name, params);
         if (!success) {
             return false;
@@ -591,7 +590,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             storageScriptsDir = getDefaultStorageScriptsDir();
         }
 
-        String bridgeType = (String)params.get("network.bridge.type");
+        final String bridgeType = (String)params.get("network.bridge.type");
         if (bridgeType == null) {
             _bridgeType = BridgeType.NATIVE;
         } else {
@@ -690,7 +689,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         }
 
         String value = (String)params.get("developer");
-        boolean isDeveloper = Boolean.parseBoolean(value);
+        final boolean isDeveloper = Boolean.parseBoolean(value);
 
         if (isDeveloper) {
             params.putAll(getDeveloperProperties());
@@ -701,7 +700,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             _pool = "/root";
         }
 
-        String instance = (String)params.get("instance");
+        final String instance = (String)params.get("instance");
 
         _hypervisorType = HypervisorType.getType((String)params.get("hypervisor.type"));
         if (_hypervisorType == HypervisorType.None) {
@@ -780,7 +779,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             _localStoragePath = "/var/lib/libvirt/images/";
         }
 
-        File storagePath = new File(_localStoragePath);
+        final File storagePath = new File(_localStoragePath);
         _localStoragePath = storagePath.getAbsolutePath();
 
         _localStorageUUID = (String)params.get("local.storage.uuid");
@@ -812,7 +811,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         value = (String) params.get("kvmclock.disable");
         if (Boolean.parseBoolean(value)) {
             _noKvmClock = true;
-        } else if(HypervisorType.LXC.equals(_hypervisorType) && (value == null)){
+        } else if(HypervisorType.LXC.equals(_hypervisorType) && value == null){
             //Disable kvmclock by default for LXC
             _noKvmClock = true;
         }
@@ -823,11 +822,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             conn = LibvirtConnection.getConnection();
 
             if (_bridgeType == BridgeType.OPENVSWITCH) {
-                if (conn.getLibVirVersion() < (10 * 1000 + 0)) {
+                if (conn.getLibVirVersion() < 10 * 1000 + 0) {
                     throw new ConfigurationException("LibVirt version 0.10.0 required for openvswitch support, but version " + conn.getLibVirVersion() + " detected");
                 }
             }
-        } catch (LibvirtException e) {
+        } catch (final LibvirtException e) {
             throw new CloudRuntimeException(e.getMessage());
         }
 
@@ -842,10 +841,10 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         _hypervisorPath = getHypervisorPath(conn);
         try {
             _hvVersion = conn.getVersion();
-            _hvVersion = (_hvVersion % 1000000) / 1000;
+            _hvVersion = _hvVersion % 1000000 / 1000;
             _hypervisorLibvirtVersion = conn.getLibVirVersion();
             _hypervisorQemuVersion = conn.getVersion();
-        } catch (LibvirtException e) {
+        } catch (final LibvirtException e) {
             s_logger.trace("Ignoring libvirt error.", e);
         }
 
@@ -853,7 +852,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         if (_guestCpuMode != null) {
             _guestCpuModel = (String)params.get("guest.cpu.model");
 
-            if (_hypervisorLibvirtVersion < (9 * 1000 + 10)) {
+            if (_hypervisorLibvirtVersion < 9 * 1000 + 10) {
                 s_logger.warn("LibVirt version 0.9.10 required for guest cpu mode, but version " + prettyVersion(_hypervisorLibvirtVersion) +
                         " detected, so it will be disabled");
                 _guestCpuMode = "";
@@ -863,28 +862,28 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             params.put("guest.cpu.model", _guestCpuModel);
         }
 
-        String cpuFeatures = (String)params.get("guest.cpu.features");
+        final String cpuFeatures = (String)params.get("guest.cpu.features");
         if (cpuFeatures != null) {
             _cpuFeatures = new ArrayList<String>();
-            for (String feature: cpuFeatures.split(" ")) {
+            for (final String feature: cpuFeatures.split(" ")) {
                 if (!feature.isEmpty()) {
                     _cpuFeatures.add(feature);
                 }
             }
         }
 
-        String[] info = NetUtils.getNetworkParams(_privateNic);
+        final String[] info = NetUtils.getNetworkParams(_privateNic);
 
         _monitor = new KVMHAMonitor(null, info[0], _heartBeatPath);
-        Thread ha = new Thread(_monitor);
+        final Thread ha = new Thread(_monitor);
         ha.start();
 
         _storagePoolMgr = new KVMStoragePoolManager(_storage, _monitor);
 
         _sysvmISOPath = (String)params.get("systemvm.iso.path");
         if (_sysvmISOPath == null) {
-            String[] isoPaths = {"/usr/share/cloudstack-common/vms/systemvm.iso"};
-            for (String isoPath : isoPaths) {
+            final String[] isoPaths = {"/usr/share/cloudstack-common/vms/systemvm.iso"};
+            for (final String isoPath : isoPaths) {
                 if (_storage.exists(isoPath)) {
                     _sysvmISOPath = isoPath;
                     break;
@@ -939,13 +938,13 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         if (_migrateSpeed == -1) {
             //get guest network device speed
             _migrateSpeed = 0;
-            String speed = Script.runSimpleBashScript("ethtool " + _pifs.get("public") + " |grep Speed | cut -d \\  -f 2");
+            final String speed = Script.runSimpleBashScript("ethtool " + _pifs.get("public") + " |grep Speed | cut -d \\  -f 2");
             if (speed != null) {
-                String[] tokens = speed.split("M");
+                final String[] tokens = speed.split("M");
                 if (tokens.length == 2) {
                     try {
                         _migrateSpeed = Integer.parseInt(tokens[0]);
-                    } catch (NumberFormatException e) {
+                    } catch (final NumberFormatException e) {
                         s_logger.trace("Ignoring migrateSpeed extraction error.", e);
                     }
                     s_logger.debug("device " + _pifs.get("public") + " has speed: " + String.valueOf(_migrateSpeed));
@@ -954,7 +953,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             params.put("vm.migrate.speed", String.valueOf(_migrateSpeed));
         }
 
-        Map<String, String> bridges = new HashMap<String, String>();
+        final Map<String, String> bridges = new HashMap<String, String>();
         bridges.put("linklocal", _linkLocalBridgeName);
         bridges.put("public", _publicBridgeName);
         bridges.put("private", _privBridgeName);
@@ -968,12 +967,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 
         configureVifDrivers(params);
 
-        KVMStorageProcessor storageProcessor = new KVMStorageProcessor(_storagePoolMgr, this);
+        final KVMStorageProcessor storageProcessor = new KVMStorageProcessor(_storagePoolMgr, this);
         storageProcessor.configure(name, params);
         storageHandler = new StorageSubsystemCommandHandlerBase(storageProcessor);
 
-        String unameKernelVersion = Script.runSimpleBashScript("uname -r");
-        String[] kernelVersions = unameKernelVersion.split("[\\.\\-]");
+        final String unameKernelVersion = Script.runSimpleBashScript("uname -r");
+        final String[] kernelVersions = unameKernelVersion.split("[\\.\\-]");
         _kernelVersion = Integer.parseInt(kernelVersions[0]) * 1000 * 1000 + (long)Integer.parseInt(kernelVersions[1]) * 1000 + Integer.parseInt(kernelVersions[2]);
 
         /* Disable this, the code using this is pretty bad and non portable
@@ -982,7 +981,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         return true;
     }
 
-    protected void configureVifDrivers(Map<String, Object> params) throws ConfigurationException {
+    protected void configureVifDrivers(final Map<String, Object> params) throws ConfigurationException {
         final String LIBVIRT_VIF_DRIVER = "libvirt.vif.driver";
 
         _trafficTypeVifDrivers = new HashMap<TrafficType, VifDriver>();
@@ -1001,19 +1000,19 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         _defaultVifDriver = getVifDriverClass(defaultVifDriverName, params);
 
         // Load any per-traffic-type vif drivers
-        for (Map.Entry<String, Object> entry : params.entrySet()) {
-            String k = entry.getKey();
-            String vifDriverPrefix = LIBVIRT_VIF_DRIVER + ".";
+        for (final Map.Entry<String, Object> entry : params.entrySet()) {
+            final String k = entry.getKey();
+            final String vifDriverPrefix = LIBVIRT_VIF_DRIVER + ".";
 
             if (k.startsWith(vifDriverPrefix)) {
                 // Get trafficType
-                String trafficTypeSuffix = k.substring(vifDriverPrefix.length());
+                final String trafficTypeSuffix = k.substring(vifDriverPrefix.length());
 
                 // Does this suffix match a real traffic type?
-                TrafficType trafficType = TrafficType.getTrafficType(trafficTypeSuffix);
+                final TrafficType trafficType = TrafficType.getTrafficType(trafficTypeSuffix);
                 if (!trafficType.equals(TrafficType.None)) {
                     // Get vif driver class name
-                    String vifDriverClassName = (String)entry.getValue();
+                    final String vifDriverClassName = (String)entry.getValue();
                     // if value is null, ignore
                     if (vifDriverClassName != null) {
                         // add traffic type to vif driver mapping to Map
@@ -1024,24 +1023,24 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         }
     }
 
-    protected VifDriver getVifDriverClass(String vifDriverClassName, Map<String, Object> params) throws ConfigurationException {
+    protected VifDriver getVifDriverClass(final String vifDriverClassName, final Map<String, Object> params) throws ConfigurationException {
         VifDriver vifDriver;
 
         try {
-            Class<?> clazz = Class.forName(vifDriverClassName);
+            final Class<?> clazz = Class.forName(vifDriverClassName);
             vifDriver = (VifDriver)clazz.newInstance();
             vifDriver.configure(params);
-        } catch (ClassNotFoundException e) {
+        } catch (final ClassNotFoundException e) {
             throw new ConfigurationException("Unable to find class for libvirt.vif.driver " + e);
-        } catch (InstantiationException e) {
+        } catch (final InstantiationException e) {
             throw new ConfigurationException("Unable to instantiate class for libvirt.vif.driver " + e);
-        } catch (IllegalAccessException e) {
+        } catch (final IllegalAccessException e) {
             throw new ConfigurationException("Unable to instantiate class for libvirt.vif.driver " + e);
         }
         return vifDriver;
     }
 
-    protected VifDriver getVifDriver(TrafficType trafficType) {
+    protected VifDriver getVifDriver(final TrafficType trafficType) {
         VifDriver vifDriver = _trafficTypeVifDrivers.get(trafficType);
 
         if (vifDriver == null) {
@@ -1051,24 +1050,24 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         return vifDriver;
     }
 
-    protected List<VifDriver> getAllVifDrivers() {
-        Set<VifDriver> vifDrivers = new HashSet<VifDriver>();
+    public List<VifDriver> getAllVifDrivers() {
+        final Set<VifDriver> vifDrivers = new HashSet<VifDriver>();
 
         vifDrivers.add(_defaultVifDriver);
         vifDrivers.addAll(_trafficTypeVifDrivers.values());
 
-        ArrayList<VifDriver> vifDriverList = new ArrayList<VifDriver>(vifDrivers);
+        final ArrayList<VifDriver> vifDriverList = new ArrayList<VifDriver>(vifDrivers);
 
         return vifDriverList;
     }
 
     private void getPifs() {
-        File dir = new File("/sys/devices/virtual/net");
-        File[] netdevs = dir.listFiles();
-        List<String> bridges = new ArrayList<String>();
+        final File dir = new File("/sys/devices/virtual/net");
+        final File[] netdevs = dir.listFiles();
+        final List<String> bridges = new ArrayList<String>();
         for (int i = 0; i < netdevs.length; i++) {
-            File isbridge = new File(netdevs[i].getAbsolutePath() + "/bridge");
-            String netdevName = netdevs[i].getName();
+            final File isbridge = new File(netdevs[i].getAbsolutePath() + "/bridge");
+            final String netdevName = netdevs[i].getName();
             s_logger.debug("looking in file " + netdevs[i].getAbsolutePath() + "/bridge");
             if (isbridge.exists()) {
                 s_logger.debug("Found bridge " + netdevName);
@@ -1076,9 +1075,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             }
         }
 
-        for (String bridge : bridges) {
+        for (final String bridge : bridges) {
             s_logger.debug("looking for pif for bridge " + bridge);
-            String pif = getPif(bridge);
+            final String pif = getPif(bridge);
             if (_publicBridgeName != null && bridge.equals(_publicBridgeName)) {
                 _pifs.put("public", pif);
             }
@@ -1092,7 +1091,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         // This addresses the unnecessary requirement of someone to create an unused bridge just for traffic label
         if (_pifs.get("private") == null) {
             s_logger.debug("guest(private) traffic label '" + _guestBridgeName + "' not found as bridge, looking for physical interface");
-            File dev = new File("/sys/class/net/" + _guestBridgeName);
+            final File dev = new File("/sys/class/net/" + _guestBridgeName);
             if (dev.exists()) {
                 s_logger.debug("guest(private) traffic label '" + _guestBridgeName + "' found as a physical device");
                 _pifs.put("private", _guestBridgeName);
@@ -1103,7 +1102,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         // This addresses the unnecessary requirement of someone to create an unused bridge just for traffic label
         if (_pifs.get("public") == null) {
             s_logger.debug("public traffic label '" + _publicBridgeName+ "' not found as bridge, looking for physical interface");
-            File dev = new File("/sys/class/net/" + _publicBridgeName);
+            final File dev = new File("/sys/class/net/" + _publicBridgeName);
             if (dev.exists()) {
                 s_logger.debug("public traffic label '" + _publicBridgeName + "' found as a physical device");
                 _pifs.put("public", _publicBridgeName);
@@ -1114,15 +1113,15 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
     }
 
     private void getOvsPifs() {
-        String cmdout = Script.runSimpleBashScript("ovs-vsctl list-br | sed '{:q;N;s/\\n/%/g;t q}'");
+        final String cmdout = Script.runSimpleBashScript("ovs-vsctl list-br | sed '{:q;N;s/\\n/%/g;t q}'");
         s_logger.debug("cmdout was " + cmdout);
-        List<String> bridges = Arrays.asList(cmdout.split("%"));
-        for (String bridge : bridges) {
+        final List<String> bridges = Arrays.asList(cmdout.split("%"));
+        for (final String bridge : bridges) {
             s_logger.debug("looking for pif for bridge " + bridge);
             // String pif = getOvsPif(bridge);
             // Not really interested in the pif name at this point for ovs
             // bridges
-            String pif = bridge;
+            final String pif = bridge;
             if (_publicBridgeName != null && bridge.equals(_publicBridgeName)) {
                 _pifs.put("public", pif);
             }
@@ -1134,9 +1133,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         s_logger.debug("done looking for pifs, no more bridges");
     }
 
-    private String getPif(String bridge) {
+    private String getPif(final String bridge) {
         String pif = matchPifFileInDirectory(bridge);
-        File vlanfile = new File("/proc/net/vlan/" + pif);
+        final File vlanfile = new File("/proc/net/vlan/" + pif);
 
         if (vlanfile.isFile()) {
             pif = Script.runSimpleBashScript("grep ^Device\\: /proc/net/vlan/" + pif + " | awk {'print $2'}");
@@ -1145,11 +1144,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         return pif;
     }
 
-    private String matchPifFileInDirectory(String bridgeName) {
-        File brif = new File("/sys/devices/virtual/net/" + bridgeName + "/brif");
+    private String matchPifFileInDirectory(final String bridgeName) {
+        final File brif = new File("/sys/devices/virtual/net/" + bridgeName + "/brif");
 
         if (!brif.isDirectory()) {
-            File pif = new File("/sys/class/net/" + bridgeName);
+            final File pif = new File("/sys/class/net/" + bridgeName);
             if (pif.isDirectory()) {
                 // if bridgeName already refers to a pif, return it as-is
                 return bridgeName;
@@ -1158,10 +1157,10 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             return "";
         }
 
-        File[] interfaces = brif.listFiles();
+        final File[] interfaces = brif.listFiles();
 
         for (int i = 0; i < interfaces.length; i++) {
-            String fname = interfaces[i].getName();
+            final String fname = interfaces[i].getName();
             s_logger.debug("matchPifFileInDirectory: file name '" + fname + "'");
             if (fname.startsWith("eth") || fname.startsWith("bond") || fname.startsWith("vlan") || fname.startsWith("vx") || fname.startsWith("em") ||
                     fname.matches("^p\\d+p\\d+.*")) {
@@ -1173,7 +1172,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         return "";
     }
 
-    private boolean checkNetwork(String networkName) {
+    private boolean checkNetwork(final String networkName) {
         if (networkName == null) {
             return true;
         }
@@ -1185,12 +1184,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         }
     }
 
-    private boolean checkBridgeNetwork(String networkName) {
+    private boolean checkBridgeNetwork(final String networkName) {
         if (networkName == null) {
             return true;
         }
 
-        String name = matchPifFileInDirectory(networkName);
+        final String name = matchPifFileInDirectory(networkName);
 
         if (name == null || name.isEmpty()) {
             return false;
@@ -1199,19 +1198,19 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         }
     }
 
-    private boolean checkOvsNetwork(String networkName) {
+    private boolean checkOvsNetwork(final String networkName) {
         s_logger.debug("Checking if network " + networkName + " exists as openvswitch bridge");
         if (networkName == null) {
             return true;
         }
 
-        Script command = new Script("/bin/sh", _timeout);
+        final Script command = new Script("/bin/sh", _timeout);
         command.add("-c");
         command.add("ovs-vsctl br-exists " + networkName);
         return "0".equals(command.execute(null));
     }
 
-    private boolean passCmdLine(String vmName, String cmdLine) throws InternalErrorException {
+    private boolean passCmdLine(final String vmName, final String cmdLine) throws InternalErrorException {
         final Script command = new Script(_patchViaSocketPath, 5 * 1000, s_logger);
         String result;
         command.add("-n", vmName);
@@ -1224,20 +1223,20 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         return true;
     }
 
-    boolean isDirectAttachedNetwork(String type) {
+    boolean isDirectAttachedNetwork(final String type) {
         if ("untagged".equalsIgnoreCase(type)) {
             return true;
         } else {
             try {
                 Long.valueOf(type);
-            } catch (NumberFormatException e) {
+            } catch (final NumberFormatException e) {
                 return true;
             }
             return false;
         }
     }
 
-    protected String startVM(Connect conn, String vmName, String domainXML) throws LibvirtException, InternalErrorException {
+    protected String startVM(final Connect conn, final String vmName, final String domainXML) throws LibvirtException, InternalErrorException {
         try {
             /*
                 We create a transient domain here. When this method gets
@@ -1257,7 +1256,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                     // this is safe because it doesn't stop running VMs
                     dm.undefine();
                 }
-            } catch (LibvirtException e) {
+            } catch (final LibvirtException e) {
                 // this is what we want, no domain found
             } finally {
                 if (dm != null) {
@@ -1275,9 +1274,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
     @Override
     public boolean stop() {
         try {
-            Connect conn = LibvirtConnection.getConnection();
+            final Connect conn = LibvirtConnection.getConnection();
             conn.close();
-        } catch (LibvirtException e) {
+        } catch (final LibvirtException e) {
             s_logger.trace("Ignoring libvirt error.", e);
         }
 
@@ -1285,12 +1284,18 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
     }
 
     @Override
-    public Answer executeRequest(Command cmd) {
+    public Answer executeRequest(final Command cmd) {
 
+        final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
         try {
-            if (cmd instanceof StopCommand) {
-                return execute((StopCommand)cmd);
-            } else if (cmd instanceof GetVmStatsCommand) {
+            return wrapper.execute(cmd, this);
+        } catch (final Exception e) {
+            //[TODO] ignore for now, we still need to finish the other commands.
+            //return Answer.createUnsupportedCommandAnswer(cmd);
+        }
+
+        try {
+            if (cmd instanceof GetVmStatsCommand) {
                 return execute((GetVmStatsCommand)cmd);
             } else if (cmd instanceof GetVmDiskStatsCommand) {
                 return execute((GetVmDiskStatsCommand)cmd);
@@ -1411,17 +1416,17 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         }
     }
 
-    private OvsFetchInterfaceAnswer execute(OvsFetchInterfaceCommand cmd) {
-        String label = cmd.getLabel();
+    private OvsFetchInterfaceAnswer execute(final OvsFetchInterfaceCommand cmd) {
+        final String label = cmd.getLabel();
         s_logger.debug("Will look for network with name-label:" + label);
         try {
-            String ipadd = Script.runSimpleBashScript("ifconfig " + label + " | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'");
-            String mask = Script.runSimpleBashScript("ifconfig " + label + " | grep 'inet addr:' | cut -d: -f4");
-            String mac = Script.runSimpleBashScript("ifconfig " + label + " | grep HWaddr | awk -F \" \" '{print $5}'");
+            final String ipadd = Script.runSimpleBashScript("ifconfig " + label + " | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'");
+            final String mask = Script.runSimpleBashScript("ifconfig " + label + " | grep 'inet addr:' | cut -d: -f4");
+            final String mac = Script.runSimpleBashScript("ifconfig " + label + " | grep HWaddr | awk -F \" \" '{print $5}'");
             return new OvsFetchInterfaceAnswer(cmd, true, "Interface " + label
                     + " retrieved successfully", ipadd, mask, mac);
 
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.warn("Caught execption when fetching interface", e);
             return new OvsFetchInterfaceAnswer(cmd, false, "EXCEPTION:"
                     + e.getMessage());
@@ -1429,7 +1434,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 
     }
 
-    private Answer execute(OvsSetupBridgeCommand cmd) {
+    private Answer execute(final OvsSetupBridgeCommand cmd) {
         findOrCreateTunnelNetwork(cmd.getBridgeName());
         configureTunnelNetwork(cmd.getNetworkId(), cmd.getHostId(),
                 cmd.getBridgeName());
@@ -1437,60 +1442,60 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         return new Answer(cmd, true, null);
     }
 
-    private Answer execute(OvsDestroyBridgeCommand cmd) {
+    private Answer execute(final OvsDestroyBridgeCommand cmd) {
         destroyTunnelNetwork(cmd.getBridgeName());
         s_logger.debug("OVS Bridge destroyed");
         return new Answer(cmd, true, null);
     }
 
-    public Answer execute(OvsVpcPhysicalTopologyConfigCommand cmd) {
+    public Answer execute(final OvsVpcPhysicalTopologyConfigCommand cmd) {
 
-        String bridge = cmd.getBridgeName();
+        final String bridge = cmd.getBridgeName();
         try {
-            Script command = new Script(_ovsTunnelPath, _timeout, s_logger);
+            final Script command = new Script(_ovsTunnelPath, _timeout, s_logger);
             command.add("configure_ovs_bridge_for_network_topology");
             command.add("--bridge", bridge);
             command.add("--config", cmd.getVpcConfigInJson());
 
-            String result = command.execute();
+            final String result = command.execute();
             if (result.equalsIgnoreCase("SUCCESS")) {
                 return new Answer(cmd, true, result);
             } else {
                 return new Answer(cmd, false, result);
             }
-        } catch  (Exception e) {
+        } catch  (final Exception e) {
             s_logger.warn("caught exception while updating host with latest routing polcies", e);
             return new Answer(cmd, false, e.getMessage());
         }
     }
 
-    public Answer execute(OvsVpcRoutingPolicyConfigCommand cmd) {
+    public Answer execute(final OvsVpcRoutingPolicyConfigCommand cmd) {
 
         try {
-            Script command = new Script(_ovsTunnelPath, _timeout, s_logger);
+            final Script command = new Script(_ovsTunnelPath, _timeout, s_logger);
             command.add("configure_ovs_bridge_for_routing_policies");
             command.add("--bridge", cmd.getBridgeName());
             command.add("--config", cmd.getVpcConfigInJson());
 
-            String result = command.execute();
+            final String result = command.execute();
             if (result.equalsIgnoreCase("SUCCESS")) {
                 return new Answer(cmd, true, result);
             } else {
                 return new Answer(cmd, false, result);
             }
-        } catch  (Exception e) {
+        } catch  (final Exception e) {
             s_logger.warn("caught exception while updating host with latest VPC topology", e);
             return new Answer(cmd, false, e.getMessage());
         }
     }
 
-    private synchronized void destroyTunnelNetwork(String bridge) {
+    private synchronized void destroyTunnelNetwork(final String bridge) {
         try {
             findOrCreateTunnelNetwork(bridge);
-            Script cmd = new Script(_ovsTunnelPath, _timeout, s_logger);
+            final Script cmd = new Script(_ovsTunnelPath, _timeout, s_logger);
             cmd.add("destroy_ovs_bridge");
             cmd.add("--bridge", bridge);
-            String result = cmd.execute();
+            final String result = cmd.execute();
             if (result != null) {
                 // TODO: Should make this error not fatal?
                 // Can Concurrent VM shutdown/migration/reboot events can cause
@@ -1499,41 +1504,41 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                 throw new CloudRuntimeException("Unable to remove OVS bridge " + bridge);
             }
             return;
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.warn("destroyTunnelNetwork failed:", e);
             return;
         }
     }
 
-    private synchronized boolean findOrCreateTunnelNetwork(String nwName) {
+    private synchronized boolean findOrCreateTunnelNetwork(final String nwName) {
         try {
             if (checkNetwork(nwName)) {
                 return true;
             }
             // if not found, create a new one
-            Map<String, String> otherConfig = new HashMap<String, String>();
+            final Map<String, String> otherConfig = new HashMap<String, String>();
             otherConfig.put("ovs-host-setup", "");
             Script.runSimpleBashScript("ovs-vsctl -- --may-exist add-br "
                     + nwName + " -- set bridge " + nwName
                     + " other_config:ovs-host-setup='-1'");
             s_logger.debug("### KVM network for tunnels created:" + nwName);
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.warn("createTunnelNetwork failed", e);
         }
         return true;
     }
 
-    private synchronized boolean configureTunnelNetwork(long networkId,
-            long hostId, String nwName) {
+    private synchronized boolean configureTunnelNetwork(final long networkId,
+            final long hostId, final String nwName) {
         try {
             findOrCreateTunnelNetwork(nwName);
-            String configuredHosts = Script
+            final String configuredHosts = Script
                     .runSimpleBashScript("ovs-vsctl get bridge " + nwName
                             + " other_config:ovs-host-setup");
             boolean configured = false;
             if (configuredHosts != null) {
-                String hostIdsStr[] = configuredHosts.split(",");
-                for (String hostIdStr : hostIdsStr) {
+                final String hostIdsStr[] = configuredHosts.split(",");
+                for (final String hostIdStr : hostIdsStr) {
                     if (hostIdStr.equals(((Long)hostId).toString())) {
                         configured = true;
                         break;
@@ -1541,27 +1546,27 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                 }
             }
             if (!configured) {
-                Script cmd = new Script(_ovsTunnelPath, _timeout, s_logger);
+                final Script cmd = new Script(_ovsTunnelPath, _timeout, s_logger);
                 cmd.add("setup_ovs_bridge");
                 cmd.add("--key", nwName);
                 cmd.add("--cs_host_id", ((Long)hostId).toString());
                 cmd.add("--bridge", nwName);
-                String result = cmd.execute();
+                final String result = cmd.execute();
                 if (result != null) {
                     throw new CloudRuntimeException(
                             "Unable to pre-configure OVS bridge " + nwName
                             + " for network ID:" + networkId);
                 }
             }
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.warn("createandConfigureTunnelNetwork failed", e);
             return false;
         }
         return true;
     }
 
-    private OvsCreateTunnelAnswer execute(OvsCreateTunnelCommand cmd) {
-        String bridge = cmd.getNetworkName();
+    private OvsCreateTunnelAnswer execute(final OvsCreateTunnelCommand cmd) {
+        final String bridge = cmd.getNetworkName();
         try {
             if (!findOrCreateTunnelNetwork(bridge)) {
                 s_logger.debug("Error during bridge setup");
@@ -1571,7 +1576,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 
             configureTunnelNetwork(cmd.getNetworkId(), cmd.getFrom(),
                     cmd.getNetworkName());
-            Script command = new Script(_ovsTunnelPath, _timeout, s_logger);
+            final Script command = new Script(_ovsTunnelPath, _timeout, s_logger);
             command.add("create_tunnel");
             command.add("--bridge", bridge);
             command.add("--remote_ip", cmd.getRemoteIp());
@@ -1579,21 +1584,21 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             command.add("--src_host", cmd.getFrom().toString());
             command.add("--dst_host", cmd.getTo().toString());
 
-            String result = command.execute();
+            final String result = command.execute();
             if (result != null) {
                 return new OvsCreateTunnelAnswer(cmd, true, result, null,
                         bridge);
             } else {
                 return new OvsCreateTunnelAnswer(cmd, false, result, bridge);
             }
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.debug("Error during tunnel setup");
             s_logger.warn("Caught execption when creating ovs tunnel", e);
             return new OvsCreateTunnelAnswer(cmd, false, e.getMessage(), bridge);
         }
     }
 
-    private Answer execute(OvsDestroyTunnelCommand cmd) {
+    private Answer execute(final OvsDestroyTunnelCommand cmd) {
         try {
             if (!findOrCreateTunnelNetwork(cmd.getBridgeName())) {
                 s_logger.warn("Unable to find tunnel network for GRE key:"
@@ -1601,26 +1606,26 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                 return new Answer(cmd, false, "No network found");
             }
 
-            Script command = new Script(_ovsTunnelPath, _timeout, s_logger);
+            final Script command = new Script(_ovsTunnelPath, _timeout, s_logger);
             command.add("destroy_tunnel");
             command.add("--bridge", cmd.getBridgeName());
             command.add("--iface_name", cmd.getInPortName());
-            String result = command.execute();
+            final String result = command.execute();
             if (result == null) {
                 return new Answer(cmd, true, result);
             } else {
                 return new Answer(cmd, false, result);
             }
-        } catch (Exception e) {
+        } catch (final Exception e) {
             s_logger.warn("caught execption when destroy ovs tunnel", e);
             return new Answer(cmd, false, e.getMessage());
         }
     }
 
-    private CheckNetworkAnswer execute(CheckNetworkCommand cmd) {
-        List<PhysicalNetworkSetupInfo> phyNics = cmd.getPhysicalNetworkInfoList();
+    private CheckNetworkAnswer execute(final CheckNetworkCommand cmd) {
+        final List<PhysicalNetworkSetupInfo> phyNics = cmd.getPhysicalNetworkInfoList();
         String errMsg = null;
-        for (PhysicalNetworkSetupInfo nic : phyNics) {
+        for (final PhysicalNetworkSetupInfo nic : phyNics) {
             if (!checkNetwork(nic.getGuestNetworkName())) {
                 errMsg = "Can not find network: " + nic.getGuestNetworkName();
                 break;
@@ -1640,7 +1645,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         }
     }
 
-    private CopyVolumeAnswer execute(CopyVolumeCommand cmd) {
+    private CopyVolumeAnswer execute(final CopyVolumeCommand cmd) {
         /**
              This method is only used for copying files from Primary Storage TO Secondary Storage
 
@@ -1648,16 +1653,16 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
              that it always sets copyToSecondary to true
 
          */
-        boolean copyToSecondary = cmd.toSecondaryStorage();
+        final boolean copyToSecondary = cmd.toSecondaryStorage();
         String volumePath = cmd.getVolumePath();
-        StorageFilerTO pool = cmd.getPool();
-        String secondaryStorageUrl = cmd.getSecondaryStorageURL();
+        final StorageFilerTO pool = cmd.getPool();
+        final String secondaryStorageUrl = cmd.getSecondaryStorageURL();
         KVMStoragePool secondaryStoragePool = null;
         KVMStoragePool primaryPool = null;
         try {
             try {
                 primaryPool = _storagePoolMgr.getStoragePool(pool.getType(), pool.getUuid());
-            } catch (CloudRuntimeException e) {
+            } catch (final CloudRuntimeException e) {
                 if (e.getMessage().contains("not found")) {
                     primaryPool =
                             _storagePoolMgr.createStoragePool(cmd.getPool().getUuid(), cmd.getPool().getHost(), cmd.getPool().getPort(), cmd.getPool().getPath(),
@@ -1667,12 +1672,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                 }
             }
 
-            String volumeName = UUID.randomUUID().toString();
+            final String volumeName = UUID.randomUUID().toString();
 
             if (copyToSecondary) {
-                String destVolumeName = volumeName + ".qcow2";
-                KVMPhysicalDisk volume = primaryPool.getPhysicalDisk(cmd.getVolumePath());
-                String volumeDestPath = "/volumes/" + cmd.getVolumeId() + File.separator;
+                final String destVolumeName = volumeName + ".qcow2";
+                final KVMPhysicalDisk volume = primaryPool.getPhysicalDisk(cmd.getVolumePath());
+                final String volumeDestPath = "/volumes/" + cmd.getVolumeId() + File.separator;
                 secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl);
                 secondaryStoragePool.createFolder(volumeDestPath);
                 _storagePoolMgr.deleteStoragePool(secondaryStoragePool.getType(), secondaryStoragePool.getUuid());
@@ -1682,11 +1687,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             } else {
                 volumePath = "/volumes/" + cmd.getVolumeId() + File.separator;
                 secondaryStoragePool = _storagePoolMgr.getStoragePoolByURI(secondaryStorageUrl + volumePath);
-                KVMPhysicalDisk volume = secondaryStoragePool.getPhysicalDisk(cmd.getVolumePath() + ".qcow2");
+                final KVMPhysicalDisk volume = secondaryStoragePool.getPhysicalDisk(cmd.getVolumePath() + ".qcow2");
                 _storagePoolMgr.copyPhysicalDisk(volume, volumeName, primaryPool, 0);
                 return new CopyVolumeAnswer(cmd, true, null, null, volumeName);
             }
-        } catch (CloudRuntimeException e) {
+        } catch (final CloudRuntimeException e) {
             return new CopyVolumeAnswer(cmd, false, e.toString(), null, null);
         } finally {
             if (secondaryStoragePool != null) {
@@ -1695,52 +1700,52 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         }
     }
 
-    protected Answer execute(DeleteStoragePoolCommand cmd) {
+    protected Answer execute(final DeleteStoragePoolCommand cmd) {
         try {
             _storagePoolMgr.deleteStoragePool(cmd.getPool().getType(), cmd.getPool().getUuid());
             return new Answer(cmd);
-        } catch (CloudRuntimeException e) {
+        } catch (final CloudRuntimeException e) {
             return new Answer(cmd, false, e.toString());
         }
     }
 
-    protected FenceAnswer execute(FenceCommand cmd) {
-        ExecutorService executors = Executors.newSingleThreadExecutor();
-        List<NfsStoragePool> pools = _monitor.getStoragePools();
-        KVMHAChecker ha = new KVMHAChecker(pools, cmd.getHostIp());
-        Future<Boolean> future = executors.submit(ha);
+    protected FenceAnswer execute(final FenceCommand cmd) {
+        final ExecutorService executors = Executors.newSingleThreadExecutor();
+        final List<NfsStoragePool> pools = _monitor.getStoragePools();
+        final KVMHAChecker ha = new KVMHAChecker(pools, cmd.getHostIp());
+        final Future<Boolean> future = executors.submit(ha);
         try {
-            Boolean result = future.get();
+            final Boolean result = future.get();
             if (result) {
                 return new FenceAnswer(cmd, false, "Heart is still beating...");
             } else {
                 return new FenceAnswer(cmd);
             }
-        } catch (InterruptedException e) {
+        } catch (final InterruptedException e) {
             s_logger.warn("Unable to fence", e);
             return new FenceAnswer(cmd, false, e.getMessage());
-        } catch (ExecutionException e) {
+        } catch (final ExecutionException e) {
             s_logger.warn("Unable to fence", e);
             return new FenceAnswer(cmd, false, e.getMessage());
         }
 
     }
 
-    protected Answer execute(CheckOnHostCommand cmd) {
-        ExecutorService executors = Executors.newSingleThreadExecutor();
-        List<NfsStoragePool> pools = _monitor.getStoragePools();
-        KVMHAChecker ha = new KVMHAChecker(pools, cmd.getHost().getPrivateNetwork().getIp());
-        Future<Boolean> future = executors.submit(ha);
+    protected Answer execute(final CheckOnHostCommand cmd) {
+        final ExecutorService executors = Executors.newSingleThreadExecutor();
+        final List<NfsStoragePool> pools = _monitor.getStoragePools();
+        final KVMHAChecker ha = new KVMHAChecker(pools, cmd.getHost().getPrivateNetwork().getIp());
+        final Future<Boolean> future = executors.submit(ha);
         try {
-            Boolean result = future.get();
+            final Boolean result = future.get();
             if (result) {
                 return new Answer(cmd, false, "Heart is still beating...");
             } else {
                 return new Answer(cmd);
             }
-        } catch (InterruptedException e) {
+        } catch (final InterruptedException e) {
             return new Answer(cmd, false, "can't get status of host:");
-        } catch (ExecutionException e) {
+        } catch (final ExecutionException e) {
             return new Answer(cmd, false, "can't get status of host:");
         }
 
@@ -1750,9 +1755,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         return Storage.StorageResourceType.STORAGE_POOL;
     }
 
-    protected Answer execute(CreateCommand cmd) {
-        StorageFilerTO pool = cmd.getPool();
-        DiskProfile dskch = cmd.getDiskCharacteristics();
+    protected Answer execute(final CreateCommand cmd) {
+        final StorageFilerTO pool = cmd.getPool();
+        final DiskProfile dskch = cmd.getDiskCharacteristics();
         KVMPhysicalDisk BaseVol = null;
         KVMStoragePool primaryPool = null;
         KVMPhysicalDisk vol = null;
@@ -1775,7 +1780,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             } else {
                 vol = primaryPool.createPhysicalDisk(dskch.getPath(), dskch.getProvisioningType(), dskch.getSize());
             }
-            VolumeTO volume =
+            final VolumeTO volume =
                     new VolumeTO(cmd.getVolumeId(), dskch.getType(), pool.getType(), pool.getUuid(), pool.getPath(), vol.getName(), vol.getName(), disksize, null);
             volume.setBytesReadRate(dskch.getBytesReadRate());
             volume.setBytesWriteRate(dskch.getBytesWriteRate());
@@ -1783,16 +1788,16 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             volume.setIopsWriteRate(dskch.getIopsWriteRate());
             volume.setCacheMode(dskch.getCacheMode());
             return new CreateAnswer(cmd, volume);
-        } catch (CloudRuntimeException e) {
+        } catch (final CloudRuntimeException e) {
             s_logger.debug("Failed to create volume: " + e.toString());
             return new CreateAnswer(cmd, e);
         }
     }
 
     // this is much like PrimaryStorageDownloadCommand, but keeping it separate
-    protected KVMPhysicalDisk templateToPrimaryDownload(String templateUrl, KVMStoragePool primaryPool, String volUuid) {
-        int index = templateUrl.lastIndexOf("/");
-        String mountpoint = templateUrl.substring(0, index);
+    protected KVMPhysicalDisk templateToPrimaryDownload(final String templateUrl, final KVMStoragePool primaryPool, final String volUuid) {
+        final int index = templateUrl.lastIndexOf("/");
+        final String mountpoint = templateUrl.substring(0, index);
         String templateName = null;
         if (index < templateUrl.length() - 1) {
             templateName = templateUrl.substring(index + 1);
@@ -1805,12 +1810,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             /* Get template vol */
             if (templateName == null) {
                 secondaryPool.refresh();
-                List<KVMPhysicalDisk> disks = secondaryPool.listPhysicalDisks();
+                final List<KVMPhysicalDisk> disks = secondaryPool.listPhysicalDisks();
                 if (disks == null || disks.isEmpty()) {
                     s_logger.error("Failed to get volumes from pool: " + secondaryPool.getUuid());
                     return null;
                 }
-                for (KVMPhysicalDisk disk : disks) {
+                for (final KVMPhysicalDisk disk : disks) {
                     if (disk.getName().endsWith("qcow2")) {
                         templateVol = disk;
                         break;
@@ -1826,9 +1831,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 
             /* Copy volume to primary storage */
 
-            KVMPhysicalDisk primaryVol = _storagePoolMgr.copyPhysicalDisk(templateVol, volUuid, primaryPool, 0);
+            final KVMPhysicalDisk primaryVol = _storagePoolMgr.copyPhysicalDisk(templateVol, volUuid, primaryPool, 0);
             return primaryVol;
-        } catch (CloudRuntimeException e) {
+        } catch (final CloudRuntimeException e) {
             s_logger.error("Failed to download template to primary storage", e);
             return null;
         } finally {
@@ -1838,9 +1843,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         }
     }
 
-    private String getResizeScriptType(KVMStoragePool pool, KVMPhysicalDisk vol) {
-        StoragePoolType poolType = pool.getType();
-        PhysicalDiskFormat volFormat = vol.getFormat();
+    private String getResizeScriptType(final KVMStoragePool pool, final KVMPhysicalDisk vol) {
+        final StoragePoolType poolType = pool.getType();
+        final PhysicalDiskFormat volFormat = vol.getFormat();
 
         if (pool.getType() == StoragePoolType.CLVM && volFormat == PhysicalDiskFormat.RAW) {
             return "CLVM";
@@ -1856,13 +1861,13 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 
     /* uses a local script now, eventually support for virStorageVolResize() will maybe work on
        qcow2 and lvm and we can do this in libvirt calls */
-    public Answer execute(ResizeVolumeCommand cmd) {
-        String volid = cmd.getPath();
-        long newSize = cmd.getNewSize();
-        long currentSize = cmd.getCurrentSize();
-        String vmInstanceName = cmd.getInstanceName();
-        boolean shrinkOk = cmd.getShrinkOk();
-        StorageFilerTO spool = cmd.getPool();
+    public Answer execute(final ResizeVolumeCommand cmd) {
+        final String volid = cmd.getPath();
+        final long newSize = cmd.getNewSize();
+        final long currentSize = cmd.getCurrentSize();
+        final String vmInstanceName = cmd.getInstanceName();
+        final boolean shrinkOk = cmd.getShrinkOk();
+        final StorageFilerTO spool = cmd.getPool();
         final String notifyOnlyType = "NOTIFYONLY";
 
         if ( currentSize == newSize) {
@@ -1873,8 +1878,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 
         try {
             KVMStoragePool pool = _storagePoolMgr.getStoragePool(spool.getType(), spool.getUuid());
-            KVMPhysicalDisk vol = pool.getPhysicalDisk(volid);
-            String path = vol.getPath();
+            final KVMPhysicalDisk vol = pool.getPhysicalDisk(volid);
+            final String path = vol.getPath();
             String type = getResizeScriptType(pool, vol);
 
             if (pool.getType() != StoragePoolType.RBD) {
@@ -1891,8 +1896,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             if (pool.getType() != StoragePoolType.CLVM && vol.getFormat() != PhysicalDiskFormat.QCOW2) {
                 s_logger.debug("Volume " + path +  " can be resized by libvirt. Asking libvirt to resize the volume.");
                 try {
-                    Connect conn = LibvirtConnection.getConnection();
-                    StorageVol v = conn.storageVolLookupByPath(path);
+                    final Connect conn = LibvirtConnection.getConnection();
+                    final StorageVol v = conn.storageVolLookupByPath(path);
                     int flags = 0;
 
                     if (conn.getLibVirVersion() > 1001000 && vol.getFormat() == PhysicalDiskFormat.RAW && pool.getType() != StoragePoolType.RBD) {
@@ -1904,7 +1909,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 
                     v.resize(newSize, flags);
                     type = notifyOnlyType;
-                } catch (LibvirtException e) {
+                } catch (final LibvirtException e) {
                     return new ResizeVolumeAnswer(cmd, false, e.toString());
                 }
             }
@@ -1916,7 +1921,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             resizecmd.add("-t", type);
             resizecmd.add("-r", String.valueOf(shrinkOk));
             resizecmd.add("-v", vmInstanceName);
-            String result = resizecmd.execute();
+            final String result = resizecmd.execute();
 
             if (result != null) {
                 if(type.equals(notifyOnlyType)) {
@@ -1929,33 +1934,33 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             /* fetch new size as seen from libvirt, don't want to assume anything */
             pool = _storagePoolMgr.getStoragePool(spool.getType(), spool.getUuid());
             pool.refresh();
-            long finalSize = pool.getPhysicalDisk(volid).getVirtualSize();
+            final long finalSize = pool.getPhysicalDisk(volid).getVirtualSize();
             s_logger.debug("after resize, size reports as " + finalSize + ", requested " + newSize);
             return new ResizeVolumeAnswer(cmd, true, "success", finalSize);
-        } catch (CloudRuntimeException e) {
-            String error = "Failed to resize volume: " + e.getMessage();
+        } catch (final CloudRuntimeException e) {
+            final String error = "Failed to resize volume: " + e.getMessage();
             s_logger.debug(error);
             return new ResizeVolumeAnswer(cmd, false, error);
         }
 
     }
 
-    public Answer execute(DestroyCommand cmd) {
-        VolumeTO vol = cmd.getVolume();
+    public Answer execute(final DestroyCommand cmd) {
+        final VolumeTO vol = cmd.getVolume();
         try {
-            KVMStoragePool pool = _storagePoolMgr.getStoragePool(vol.getPoolType(), vol.getPoolUuid());
+            final KVMStoragePool pool = _storagePoolMgr.getStoragePool(vol.getPoolType(), vol.getPoolUuid());
             pool.deletePhysicalDisk(vol.getPath(), null);
             return new Answer(cmd, true, "Success");
-        } catch (CloudRuntimeException e) {
+        } catch (final CloudRuntimeException e) {
             s_logger.debug("Failed to delete volume: " + e.toString());
             return new Answer(cmd, false, e.toString());
         }
     }
 
-    private String getBroadcastUriFromBridge(String brName) {
-        String pif = matchPifFileInDirectory(brName);
-        Pattern pattern = Pattern.compile("(\\D+)(\\d+)(\\D*)(\\d*)");
-        Matcher matcher = pattern.matcher(pif);
+    private String getBroadcastUriFromBridge(final String brName) {
+        final String pif = matchPifFileInDirectory(brName);
+        final Pattern pattern = Pattern.compile("(\\D+)(\\d+)(\\D*)(\\d*)");
+        final Matcher matcher = pattern.matcher(pif);
         s_logger.debug("getting broadcast uri for pif " + pif + " and bridge " + brName);
         if(matcher.find()) {
             if (brName.startsWith("brvx")){
@@ -1977,14 +1982,14 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         }
     }
 
-    private Answer execute(PvlanSetupCommand cmd) {
-        String primaryPvlan = cmd.getPrimary();
-        String isolatedPvlan = cmd.getIsolated();
-        String op = cmd.getOp();
-        String dhcpName = cmd.getDhcpName();
-        String dhcpMac = cmd.getDhcpMac();
-        String dhcpIp = cmd.getDhcpIp();
-        String vmMac = cmd.getVmMac();
+    private Answer execute(final PvlanSetupCommand cmd) {
+        final String primaryPvlan = cmd.getPrimary();
+        final String isolatedPvlan = cmd.getIsolated();
+        final String op = cmd.getOp();
+        final String dhcpName = cmd.getDhcpName();
+        final String dhcpMac = cmd.getDhcpMac();
+        final String dhcpIp = cmd.getDhcpIp();
+        final String vmMac = cmd.getVmMac();
         boolean add = true;
 
         String opr = "-A";
@@ -1997,11 +2002,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
         Connect conn;
         try {
             if (cmd.getType() == PvlanSetupCommand.Type.DHCP) {
-                Script script = new Script(_ovsPvlanDhcpHostPath, _timeout, s_logger);
+                final Script script = new Script(_ovsPvlanDhcpHostPath, _timeout, s_logger);
                 if (add) {
                     conn = LibvirtConnection.getConnectionByVmName(dhcpName);
-                    List<InterfaceDef> ifaces = getInterfaces(conn, dhcpName);
-                    InterfaceDef guestNic = ifaces.get(0);
+                    final List<InterfaceDef> ifaces = getInterfaces(conn, dhcpName);
+                    final InterfaceDef guestNic = ifaces.get(0);
                     script.add(opr, "-b", _guestBridgeName, "-p", primaryPvlan, "-i", isolatedPvlan, "-n", dhcpName, "-d", dhcpIp, "-m", dhcpMac, "-I",
                             guestNic.getDevName());
                 } else {
@@ -2015,7 +2020,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                     s_logger.info("Programmed pvlan for dhcp server with mac " + dhcpMac);
                 }
             } else if (cmd.getType() == PvlanSetupCommand.Type.VM) {
-                Script script = new Script(_ovsPvlanVmPath, _timeout, s_logger);
+                final Script script = new Script(_ovsPvlanVmPath, _timeout, s_logger);
                 script.add(opr, "-b", _guestBridgeName, "-p", primaryPvlan, "-i", isolatedPvlan, "-v", vmMac);
                 result = script.execute();
                 if (result != null) {
@@ -2025,57 +2030,57 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                     s_logger.info("Programmed pvlan for vm with mac " + vmMac);
                 }
             }
-        } catch (LibvirtException e) {
+        } catch (final LibvirtException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
         }
         return new Answer(cmd, true, result);
     }
 
-    private void VifHotPlug(Connect conn, String vmName, String broadcastUri, String macAddr) throws InternalErrorException, LibvirtException {
-        NicTO nicTO = new NicTO();
+    private void VifHotPlug(final Connect conn, final String vmName, final String broadcastUri, final String macAddr) throws InternalErrorException, LibvirtException {
+        final NicTO nicTO = new NicTO();
         nicTO.setMac(macAddr);
         nicTO.setType(TrafficType.Public);
         if (broadcastUri == null) {
             nicTO.setBroadcastType(BroadcastDomainType.Native);
         } else {
-            URI uri = BroadcastDomainType.fromString(broadcastUri);
+            final URI uri = BroadcastDomainType.fromString(broadcastUri);
             nicTO.setBroadcastType(BroadcastDomainType.getSchemeValue(uri));
             nicTO.setBroadcastUri(uri);
         }
 
-        Domain vm = getDomain(conn, vmName);
+        final Domain vm = getDomain(conn, vmName);
         vm.attachDevice(getVifDriver(nicTO.getType()).plug(nicTO, "Other PV", "").toString());
     }
 
 
-    private void vifHotUnPlug (Connect conn, String vmName, String macAddr) throws InternalErrorException, LibvirtException {
+    private void vifHotUnPlug (final Connect conn, final String vmName, final String macAddr) throws InternalErrorException, LibvirtException {
 
         Domain vm = null;
         vm = getDomain(conn, vmName);
-        List<InterfaceDef> pluggedNics = getInterfaces(conn, vmName);
-        for (InterfaceDef pluggedNic : pluggedNics) {
+        final List<InterfaceDef> pluggedNics = getInterfaces(conn, vmName);
+        for (final InterfaceDef pluggedNic : pluggedNics) {
             if (pluggedNic.getMacAddress().equalsIgnoreCase(macAddr)) {
                 vm.detachDevice(pluggedNic.toString());
                 // We don't know which "traffic type" is associated with
                 // each interface at this point, so inform all vif drivers
-                for (VifDriver vifDriver : getAllVifDrivers()) {
+                for (final VifDriver vifDriver : getAllVifDrivers()) {
                     vifDriver.unplug(pluggedNic);
                 }
             }
         }
     }
 
-    private PlugNicAnswer execute(PlugNicCommand cmd) {
-        NicTO nic = cmd.getNic();
-        String vmName = cmd.getVmName();
+    private PlugNicAnswer execute(final PlugNicCommand cmd) {
+        final NicTO nic = cmd.getNic();
+        final String vmName = cmd.getVmName();
         Domain vm = null;
         try {
-            Connect conn = LibvirtConnection.getConnectionByVmName(vmName);
+            final Connect conn = LibvirtConnection.getConnectionByVmName(vmName);
             vm = getDomain(conn, vmName);
-            List<InterfaceDef> pluggedNics = getInterfaces(conn, vmName);
+            final List<InterfaceDef> pluggedNics = getInterfaces(conn, vmName);
             Integer nicnum = 0;
-            for (InterfaceDef pluggedNic : pluggedNics) {
+            for (final InterfaceDef pluggedNic : pluggedNics) {
                 if (pluggedNic.getMacAddress().equalsIgnoreCase(nic.getMac())) {
                     s_logger.debug("found existing nic for mac " + pluggedNic.getMacAddress() + " at index " + nicnum);
                     return new PlugNicAnswer(cmd, true, "success");
@@ -2084,72 +2089,72 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             }
             vm.attachDevice(getVifDriver(nic.getType()).plug(nic, "Other PV", "").toString());
             return new PlugNicAnswer(cmd, true, "success");
-        } catch (LibvirtException e) {
-            String msg = " Plug Nic failed due to " + e.toString();
+        } catch (final LibvirtException e) {
+            final String msg = " Plug Nic failed due to " + e.toString();
             s_logger.warn(msg, e);
             return new PlugNicAnswer(cmd, false, msg);
-        } catch (InternalErrorException e) {
-            String msg = " Plug Nic failed due to " + e.toString();
+        } catch (final InternalErrorException e) {
+            final String msg = " Plug Nic failed due to " + e.toString();
             s_logger.warn(msg, e);
             return new PlugNicAnswer(cmd, false, msg);
         } finally {
             if (vm != null) {
                 try {
                     vm.free();
-                } catch (LibvirtException l) {
+                } catch (final LibvirtException l) {
                     s_logger.trace("Ignoring libvirt error.", l);
                 }
             }
         }
     }
 
-    private UnPlugNicAnswer execute(UnPlugNicCommand cmd) {
+    private UnPlugNicAnswer execute(final UnPlugNicCommand cmd) {
         Connect conn;
-        NicTO nic = cmd.getNic();
-        String vmName = cmd.getVmName();
+        final NicTO nic = cmd.getNic();
+        final String vmName = cmd.getVmName();
         Domain vm = null;
         try {
             conn = LibvirtConnection.getConnectionByVmName(vmName);
             vm = getDomain(conn, vmName);
-            List<InterfaceDef> pluggedNics = getInterfaces(conn, vmName);
-            for (InterfaceDef pluggedNic : pluggedNics) {
+            final List<InterfaceDef> pluggedNics = getInterfaces(conn, vmName);
+            for (final InterfaceDef pluggedNic : pluggedNics) {
                 if (pluggedNic.getMacAddress().equalsIgnoreCase(nic.getMac())) {
                     vm.detachDevice(pluggedNic.toString());
                     // We don't know which "traffic type" is associated with
                     // each interface at this point, so inform all vif drivers
-                    for (VifDriver vifDriver : getAllVifDrivers()) {
+                    for (final VifDriver vifDriver : getAllVifDrivers()) {
                         vifDriver.unplug(pluggedNic);
                     }
                     return new UnPlugNicAnswer(cmd, true, "success");
                 }
             }
             return new UnPlugNicAnswer(cmd, true, "success");
-        } catch (LibvirtException e) {
-            String msg = " Unplug Nic failed due to " + e.toString();
+        } catch (final LibvirtException e) {
+            final String msg = " Unplug Nic failed due to " + e.toString();
             s_logger.warn(msg, e);
             return new UnPlugNicAnswer(cmd, false, msg);
         } finally {
             if (vm != null) {
                 try {
                     vm.free();
-                } catch (LibvirtException l) {
+                } catch (final LibvirtException l) {
                     s_logger.trace("Ignoring libvirt error.", l);
                 }
             }
         }
     }
 
-    private ExecutionResult prepareNetworkElementCommand(SetupGuestNetworkCommand cmd) {
+    private ExecutionResult prepareNetworkElementCommand(final SetupGuestNetworkCommand cmd) {
         Connect conn;
-        NicTO nic = cmd.getNic();
-        String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
+        final NicTO nic = cmd.getNic();
+        final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
 
         try {
             conn = LibvirtConnection.getConnectionByVmName(routerName);
-            List<InterfaceDef> pluggedNics = getInterfaces(conn, routerName);
+            final List<InterfaceDef> pluggedNics = getInterfaces(conn, routerName);
             InterfaceDef routerNic = null;
 
-            for (InterfaceDef pluggedNic : pluggedNics) {
+            for (final InterfaceDef pluggedNic : pluggedNics) {
                 if (pluggedNic.getMacAddress().equalsIgnoreCase(nic.getMac())) {
                     routerNic = pluggedNic;
                     break;
@@ -2161,28 +2166,28 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             }
 
             return new ExecutionResult(true, null);
-        } catch (LibvirtException e) {
-            String msg = "Creating guest network failed due to " + e.toString();
+        } catch (final LibvirtException e) {
+            final String msg = "Creating guest network failed due to " + e.toString();
             s_logger.warn(msg, e);
             return new ExecutionResult(false, msg);
         }
     }
 
-    protected ExecutionResult prepareNetworkElementCommand(SetSourceNatCommand cmd) {
+    protected ExecutionResult prepareNetworkElementCommand(final SetSourceNatCommand cmd) {
         Connect conn;
-        String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
+        final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
         cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
-        IpAddressTO pubIP = cmd.getIpAddress();
+        final IpAddressTO pubIP = cmd.getIpAddress();
 
         try {
             conn = LibvirtConnection.getConnectionByVmName(routerName);
             Integer devNum = 0;
-            String pubVlan = pubIP.getBroadcastUri();
-            List<InterfaceDef> pluggedNics = getInterfaces(conn, routerName);
+            final String pubVlan = pubIP.getBroadcastUri();
+            final List<InterfaceDef> pluggedNics = getInterfaces(conn, routerName);
 
-            for (InterfaceDef pluggedNic : pluggedNics) {
-                String pluggedVlanBr = pluggedNic.getBrName();
-                String pluggedVlanId = getBroadcastUriFromBridge(pluggedVlanBr);
+            for (final InterfaceDef pluggedNic : pluggedNics) {
+                final String pluggedVlanBr = pluggedNic.getBrName();
+                final String pluggedVlanId = getBroadcastUriFromBridge(pluggedVlanBr);
                 if (pubVlan.equalsIgnoreCase(Vlan.UNTAGGED) && pluggedVlanBr.equalsIgnoreCase(_publicBridgeName)) {
                     break;
                 } else if (pluggedVlanBr.equalsIgnoreCase(_linkLocalBridgeName)) {
@@ -2200,26 +2205,26 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             pubIP.setNicDevId(devNum);
 
             return new ExecutionResult(true, "success");
-        } catch (LibvirtException e) {
-            String msg = "Ip SNAT failure due to " + e.toString();
+        } catch (final LibvirtException e) {
+            final String msg = "Ip SNAT failure due to " + e.toString();
             s_logger.error(msg, e);
             return new ExecutionResult(false, msg);
         }
     }
 
-    protected ExecutionResult prepareNetworkElementCommand(IpAssocVpcCommand cmd) {
+    protected ExecutionResult prepareNetworkElementCommand(final IpAssocVpcCommand cmd) {
         Connect conn;
-        String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
+        final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
 
         try {
             conn = LibvirtConnection.getConnectionByVmName(routerName);
-            IpAddressTO[] ips = cmd.getIpAddresses();
+            final IpAddressTO[] ips = cmd.getIpAddresses();
             Integer devNum = 0;
-            Map<String, Integer> broadcastUriToNicNum = new HashMap<String, Integer>();
-            List<InterfaceDef> pluggedNics = getInterfaces(conn, routerName);
+            final Map<String, Integer> broadcastUriToNicNum = new HashMap<String, Integer>();
+            final List<InterfaceDef> pluggedNics = getInterfaces(conn, routerName);
 
-            for (InterfaceDef pluggedNic : pluggedNics) {
-                String pluggedVlan = pluggedNic.getBrName();
+            for (final InterfaceDef pluggedNic : pluggedNics) {
+                final String pluggedVlan = pluggedNic.getBrName();
                 if (pluggedVlan.equalsIgnoreCase(_linkLocalBridgeName)) {
                     broadcastUriToNicNum.put("LinkLocal", devNum);
                 } else if (pluggedVlan.equalsIgnoreCase(_publicBridgeName) || pluggedVlan.equalsIgnoreCase(_privBridgeName) ||
@@ -2231,27 +2236,27 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                 devNum++;
             }
 
-            for (IpAddressTO ip : ips) {
+            for (final IpAddressTO ip : ips) {
                 ip.setNicDevId(broadcastUriToNicNum.get(ip.getBroadcastUri()));
             }
 
             return new ExecutionResult(true, null);
-        } catch (LibvirtException e) {
+        } catch (final LibvirtException e) {
             s_logger.error("Ip Assoc failure on applying one ip due to exception:  ", e);
             return new ExecutionResult(false, e.getMessage());
         }
     }
 
-    public ExecutionResult prepareNetworkElementCommand(IpAssocCommand cmd) {
-        String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
-        String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
+    public ExecutionResult prepareNetworkElementCommand(final IpAssocCommand cmd) {
+        final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
+        final String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
         Connect conn;
         try {
             conn = LibvirtConnection.getConnectionByVmName(routerName);
-            List<InterfaceDef> nics = getInterfaces(conn, routerName);
-            Map<String, Integer> broadcastUriAllocatedToVM = new HashMap<String, Integer>();
+            final List<InterfaceDef> nics = getInterfaces(conn, routerName);
+            final Map<String, Integer> broadcastUriAllocatedToVM = new HashMap<String, Integer>();
             Integer nicPos = 0;
-            for (InterfaceDef nic : nics) {
+            for (final InterfaceDef nic : nics) {
                 if (nic.getBrName().equalsIgnoreCase(_linkLocalBridgeName)) {
                     broadcastUriAllocatedToVM.put("LinkLocal", nicPos);
                 } else {
@@ -2259,15 +2264,15 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                             nic.getBrName().equalsIgnoreCase(_guestBridgeName)) {
                         broadcastUriAllocatedToVM.put(BroadcastDomainType.Vlan.toUri(Vlan.UNTAGGED).toString(), nicPos);
                     } else {
-                        String broadcastUri = getBroadcastUriFromBridge(nic.getBrName());
+                        final String broadcastUri = getBroadcastUriFromBridge(nic.getBrName());
                         broadcastUriAllocatedToVM.put(broadcastUri, nicPos);
                     }
                 }
                 nicPos++;
             }
-            IpAddressTO[] ips = cmd.getIpAddresses();
+            final IpAddressTO[] ips = cmd.getIpAddresses();
             int nicNum = 0;
-            for (IpAddressTO ip : ips) {
+            for (final IpAddressTO ip : ips) {
                 boolean newNic = false;
                 if (!broadcastUriAllocatedToVM.containsKey(ip.getBroadcastUri())) {
                     /* plug a vif into router */
@@ -2282,29 +2287,29 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                 ip.setNewNic(newNic);
             }
             return new ExecutionResult(true, null);
-        } catch (LibvirtException e) {
+        } catch (final LibvirtException e) {
             s_logger.error("ipassoccmd failed", e);
             return new ExecutionResult(false, e.getMessage());
-        } catch (InternalErrorException e) {
+        } catch (final InternalErrorException e) {
             s_logger.error("ipassoccmd failed", e);
             return new ExecutionResult(false, e.getMessage());
         }
     }
 
-    protected ExecutionResult cleanupNetworkElementCommand(IpAssocCommand cmd) {
+    protected ExecutionResult cleanupNetworkElementCommand(final IpAssocCommand cmd) {
 
-        String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
-        String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
+        final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
+        final String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
         Connect conn;
 
 
         try{
             conn = LibvirtConnection.getConnectionByVmName(routerName);
-            List<InterfaceDef> nics = getInterfaces(conn, routerName);
-            Map<String, Integer> broadcastUriAllocatedToVM = new HashMap<String, Integer>();
+            final List<InterfaceDef> nics = getInterfaces(conn, routerName);
+            final Map<String, Integer> broadcastUriAllocatedToVM = new HashMap<String, Integer>();
 
             Integer nicPos = 0;
-            for (InterfaceDef nic : nics) {
+            for (final InterfaceDef nic : nics) {
                 if (nic.getBrName().equalsIgnoreCase(_linkLocalBridgeName)) {
                     broadcastUriAllocatedToVM.put("LinkLocal", nicPos);
                 } else {
@@ -2312,17 +2317,17 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                             nic.getBrName().equalsIgnoreCase(_guestBridgeName)) {
                         broadcastUriAllocatedToVM.put(BroadcastDomainType.Vlan.toUri(Vlan.UNTAGGED).toString(), nicPos);
                     } else {
-                        String broadcastUri = getBroadcastUriFromBridge(nic.getBrName());
+                        final String broadcastUri = getBroadcastUriFromBridge(nic.getBrName());
                         broadcastUriAllocatedToVM.put(broadcastUri, nicPos);
                     }
                 }
                 nicPos++;
             }
 
-            IpAddressTO[] ips = cmd.getIpAddresses();
-            int numOfIps = ips.length;
+            final IpAddressTO[] ips = cmd.getIpAddresses();
+            final int numOfIps = ips.length;
             int nicNum = 0;
-            for (IpAddressTO ip : ips) {
+            for (final IpAddressTO ip : ips) {
 
                 if (!broadcastUriAllocatedToVM.containsKey(ip.getBroadcastUri())) {
                     /* plug a vif into router */
@@ -2337,10 +2342,10 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                 }
             }
 
-        } catch (LibvirtException e) {
+        } catch (final LibvirtException e) {
             s_logger.error("ipassoccmd failed", e);
             return new ExecutionResult(false, e.getMessage());
-        } catch (InternalErrorException e) {
+        } catch (final InternalErrorException e) {
             s_logger.error("ipassoccmd failed", e);
             return new ExecutionResult(false, e.getMessage());
         }
@@ -2349,34 +2354,34 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
     }
 
     protected ManageSnapshotAnswer execute(final ManageSnapshotCommand cmd) {
-        String snapshotName = cmd.getSnapshotName();
-        String snapshotPath = cmd.getSnapshotPath();
-        String vmName = cmd.getVmName();
+        final String snapshotName = cmd.getSnapshotName();
+        final String snapshotPath = cmd.getSnapshotPath();
+        final String vmName = cmd.getVmName();
         try {
-            Connect conn = LibvirtConnection.getConnectionByVmName(vmName);
+            final Connect conn = LibvirtConnection.getConnectionByVmName(vmName);
             DomainState state = null;
             Domain vm = null;
             if (vmName != null) {
                 try {
                     vm = getDomain(conn, cmd.getVmName());
                     state = vm.getInfo().state;
-                } catch (LibvirtException e) {
+                } catch (final LibvirtException e) {
                     s_logger.trace("Ignoring libvirt error.", e);
                 }
             }
 
-            KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), cmd.getPool().getUuid());
+            final KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), cmd.getPool().getUuid());
 
-            KVMPhysicalDisk disk = primaryPool.getPhysicalDisk(cmd.getVolumePath());
+            final KVMPhysicalDisk disk = primaryPool.getPhysicalDisk(cmd.getVolumePath());
             if (state == DomainState.VIR_DOMAIN_RUNNING && !primaryPool.isExternalSnapshot()) {
-                String vmUuid = vm.getUUIDString();
-                Object[] args = new Object[] {snapshotName, vmUuid};
-                String snapshot = SnapshotXML.format(args);
+                final String vmUuid = vm.getUUIDString();
+                final Object[] args = new Object[] {snapshotName, vmUuid};
+                final String snapshot = SnapshotXML.format(args);
                 s_logger.debug(snapshot);
                 if (cmd.getCommandSwitch().equalsIgnoreCase(ManageSnapshotCommand.CREATE_SNAPSHOT)) {
                     vm.snapshotCreateXML(snapshot);
                 } else {
-                    DomainSnapshot snap = vm.snapshotLookupByName(snapshotName);
+                    final DomainSnapshot snap = vm.snapshotLookupByName(snapshotName);
                     snap.delete(0);
                 }
 
@@ -2405,16 +2410,16 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                  */
                 if (primaryPool.getType() == StoragePoolType.RBD) {
                     try {
-                        Rados r = new Rados(primaryPool.getAuthUserName());
+                        final Rados r = new Rados(primaryPool.getAuthUserName());
                         r.confSet("mon_host", primaryPool.getSourceHost() + ":" + primaryPool.getSourcePort());
                         r.confSet("key", primaryPool.getAuthSecret());
                         r.confSet("client_mount_timeout", "30");
                         r.connect();
                         s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host"));
 
-                        IoCTX io = r.ioCtxCreate(primaryPool.getSourceDir());
-                        Rbd rbd = new Rbd(io);
-                        RbdImage image = rbd.open(disk.getName());
+                        final IoCTX io = r.ioCtxCreate(primaryPool.getSourceDir());
+                        final Rbd rbd = new Rbd(io);
+                        final RbdImage image = rbd.open(disk.getName());
 
                         if (cmd.getCommandSwitch().equalsIgnoreCase(ManageSnapshotCommand.CREATE_SNAPSHOT)) {
                             s_logger.debug("Attempting to create RBD snapshot " + disk.getName() + "@" + snapshotName);
@@ -2426,7 +2431,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
 
                         rbd.close(image);
                         r.ioCtxDestroy(io);
-                    } catch (Exception e) {
+                    } catch (final Exception e) {
                         s_logger.error("A RBD snapshot operation on " + disk.getName() + " failed. The error was: " + e.getMessage());
                     }
                 } else {
@@ -2439,7 +2444,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                     }
 
                     command.add("-n", snapshotName);
-                    String result = command.execute();
+                    final String result = command.execute();
                     if (result != null) {
                         s_logger.debug("Failed to manage snapshot: " + result);
                         return new ManageSnapshotAnswer(cmd, false, "Failed to manage snapshot: " + result);
@@ -2447,7 +2452,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                 }
             }
             return new ManageSnapshotAnswer(cmd, cmd.getSnapshotId(), disk.getPath() + File.separator + snapshotName, true, null);
-        } catch (LibvirtException e) {
+        } catch (final LibvirtException e) {
             s_logger.debug("Failed to manage snapshot: " + e.toString());
             return new ManageSnapshotAnswer(cmd, false, "Failed to manage snapshot: " + e.toString());
         }
@@ -2455,26 +2460,26 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
     }
 
     protected BackupSnapshotAnswer execute(final BackupSnapshotCommand cmd) {
-        Long dcId = cmd.getDataCenterId();
-        Long accountId = cmd.getAccountId();
-        Long volumeId = cmd.getVolumeId();
-        String secondaryStoragePoolUrl = cmd.getSecondaryStorageUrl();
-        String snapshotName = cmd.getSnap

<TRUNCATED>