You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ah...@apache.org on 2013/12/12 22:01:09 UTC

[09/48] All Checkstyle problems corrected

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/server/src/com/cloud/server/ConfigurationServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java
index f907831..6cddc71 100755
--- a/server/src/com/cloud/server/ConfigurationServerImpl.java
+++ b/server/src/com/cloud/server/ConfigurationServerImpl.java
@@ -283,7 +283,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
                             long startIPLong = NetUtils.ip2Long(startIp);
                             long endIPLong = NetUtils.ip2Long(endIp);
                             config.savePublicIPRange(TransactionLegacy.currentTxn(), startIPLong, endIPLong, vlan.getDataCenterId(), vlan.getId(), vlan.getNetworkId(),
-                                    vlan.getPhysicalNetworkId());
+                                vlan.getPhysicalNetworkId());
                         }
                     });
 
@@ -370,16 +370,16 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
                     if (resouce == null)
                         continue;
                     if (resouce.equalsIgnoreCase("com.cloud.hypervisor.xen.resource.XenServer56Resource") ||
-                            resouce.equalsIgnoreCase("com.cloud.hypervisor.xen.resource.XenServer56FP1Resource") ||
-                            resouce.equalsIgnoreCase("com.cloud.hypervisor.xen.resource.XenServer56SP2Resource") ||
-                            resouce.equalsIgnoreCase("com.cloud.hypervisor.xen.resource.XenServer600Resource") ||
-                            resouce.equalsIgnoreCase("com.cloud.hypervisor.xen.resource.XenServer602Resource")) {
+                        resouce.equalsIgnoreCase("com.cloud.hypervisor.xen.resource.XenServer56FP1Resource") ||
+                        resouce.equalsIgnoreCase("com.cloud.hypervisor.xen.resource.XenServer56SP2Resource") ||
+                        resouce.equalsIgnoreCase("com.cloud.hypervisor.xen.resource.XenServer600Resource") ||
+                        resouce.equalsIgnoreCase("com.cloud.hypervisor.xen.resource.XenServer602Resource")) {
                         pvdriverversion = "xenserver56";
                         break;
                     }
                 }
                 _configDao.getValueAndInitIfNotExist(Config.XenPVdriverVersion.key(), Config.XenPVdriverVersion.getCategory(), pvdriverversion,
-                        Config.XenPVdriverVersion.getDescription());
+                    Config.XenPVdriverVersion.getDescription());
                 sql = "select id from vm_template where hypervisor_type='XenServer'  and format!='ISO' and removed is null";
                 pstmt = txn.prepareAutoCloseStatement(sql);
                 rs2 = pstmt.executeQuery();
@@ -455,8 +455,8 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
         }
         // insert system user
         insertSql =
-                "INSERT INTO `cloud`.`user` (id, uuid, username, password, account_id, firstname, lastname, created, user.default)"
-                        + " VALUES (1, UUID(), 'system', RAND(), 1, 'system', 'cloud', now(), 1)";
+            "INSERT INTO `cloud`.`user` (id, uuid, username, password, account_id, firstname, lastname, created, user.default)"
+                + " VALUES (1, UUID(), 'system', RAND(), 1, 'system', 'cloud', now(), 1)";
         txn = TransactionLegacy.currentTxn();
         try {
             PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql);
@@ -473,7 +473,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
 
         // create an account for the admin user first
         insertSql =
-                "INSERT INTO `cloud`.`account` (id, uuid, account_name, type, domain_id, account.default) VALUES (" + id + ", UUID(), '" + username + "', '1', '1', 1)";
+            "INSERT INTO `cloud`.`account` (id, uuid, account_name, type, domain_id, account.default) VALUES (" + id + ", UUID(), '" + username + "', '1', '1', 1)";
         txn = TransactionLegacy.currentTxn();
         try {
             PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql);
@@ -483,7 +483,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
 
         // now insert the user
         insertSql =
-                "INSERT INTO `cloud`.`user` (id, uuid, username, password, account_id, firstname, lastname, created, state, user.default) " + "VALUES (" + id +
+            "INSERT INTO `cloud`.`user` (id, uuid, username, password, account_id, firstname, lastname, created, state, user.default) " + "VALUES (" + id +
                 ", UUID(), '" + username + "', RAND(), 2, '" + firstname + "','" + lastname + "',now(), 'disabled', 1)";
 
         txn = TransactionLegacy.currentTxn();
@@ -511,11 +511,11 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
                 // save default security group
                 if (tableName.equals("security_group")) {
                     insertSql =
-                            "INSERT INTO " + tableName + " (uuid, name, description, account_id, domain_id) " + "VALUES (UUID(), 'default', 'Default Security Group', 2, 1)";
+                        "INSERT INTO " + tableName + " (uuid, name, description, account_id, domain_id) " + "VALUES (UUID(), 'default', 'Default Security Group', 2, 1)";
                 } else {
                     insertSql =
-                            "INSERT INTO " + tableName + " (name, description, account_id, domain_id, account_name) " +
-                                    "VALUES ('default', 'Default Security Group', 2, 1, 'admin')";
+                        "INSERT INTO " + tableName + " (name, description, account_id, domain_id, account_name) " +
+                            "VALUES ('default', 'Default Security Group', 2, 1, 'admin')";
                 }
 
                 txn = TransactionLegacy.currentTxn();
@@ -618,8 +618,8 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
                 }
                 String base64Keystore = getBase64Keystore(keystorePath);
                 ConfigurationVO configVO =
-                        new ConfigurationVO("Hidden", "DEFAULT", "management-server", "ssl.keystore", DBEncryptionUtil.encrypt(base64Keystore),
-                                "SSL Keystore for the management servers");
+                    new ConfigurationVO("Hidden", "DEFAULT", "management-server", "ssl.keystore", DBEncryptionUtil.encrypt(base64Keystore),
+                        "SSL Keystore for the management servers");
                 _configDao.persist(configVO);
                 s_logger.info("Stored SSL keystore to database.");
             } else if (null != keystoreFile && keystoreFile.exists()) { // and dbExisted
@@ -675,9 +675,9 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
             try {
                 String rpassword = PasswordGenerator.generatePresharedKey(8);
                 String wSql =
-                        "INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) " +
-                                "VALUES ('Secure','DEFAULT', 'management-server','system.vm.password', '" + DBEncryptionUtil.encrypt(rpassword) +
-                                "','randmon password generated each management server starts for system vm')";
+                    "INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) " +
+                        "VALUES ('Secure','DEFAULT', 'management-server','system.vm.password', '" + DBEncryptionUtil.encrypt(rpassword) +
+                        "','randmon password generated each management server starts for system vm')";
                 PreparedStatement stmt = txn.prepareAutoCloseStatement(wSql);
                 stmt.executeUpdate(wSql);
                 s_logger.info("Updated systemvm password in database");
@@ -752,13 +752,13 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
             String publicKey = new String(arr2).trim();
 
             String insertSql1 =
-                    "INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) " +
-                            "VALUES ('Hidden','DEFAULT', 'management-server','ssh.privatekey', '" + DBEncryptionUtil.encrypt(privateKey) +
-                            "','Private key for the entire CloudStack')";
+                "INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) " +
+                    "VALUES ('Hidden','DEFAULT', 'management-server','ssh.privatekey', '" + DBEncryptionUtil.encrypt(privateKey) +
+                    "','Private key for the entire CloudStack')";
             String insertSql2 =
-                    "INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) " +
-                            "VALUES ('Hidden','DEFAULT', 'management-server','ssh.publickey', '" + DBEncryptionUtil.encrypt(publicKey) +
-                            "','Public key for the entire CloudStack')";
+                "INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) " +
+                    "VALUES ('Hidden','DEFAULT', 'management-server','ssh.publickey', '" + DBEncryptionUtil.encrypt(publicKey) +
+                    "','Public key for the entire CloudStack')";
 
             TransactionLegacy txn = TransactionLegacy.currentTxn();
             try {
@@ -891,9 +891,9 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
             String password = PasswordGenerator.generateRandomPassword(12);
 
             String insertSql1 =
-                    "INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) " +
-                            "VALUES ('Hidden','DEFAULT', 'management-server','secstorage.copy.password', '" + DBEncryptionUtil.encrypt(password) +
-                            "','Password used to authenticate zone-to-zone template copy requests')";
+                "INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) " +
+                    "VALUES ('Hidden','DEFAULT', 'management-server','secstorage.copy.password', '" + DBEncryptionUtil.encrypt(password) +
+                    "','Password used to authenticate zone-to-zone template copy requests')";
 
             TransactionLegacy txn = TransactionLegacy.currentTxn();
             try {
@@ -924,7 +924,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
 
     @DB
     protected HostPodVO createPod(long userId, String podName, final long zoneId, String gateway, String cidr, final String startIp, String endIp)
-            throws InternalErrorException {
+        throws InternalErrorException {
         String[] cidrPair = cidr.split("\\/");
         String cidrAddress = cidrPair[0];
         int cidrSize = Integer.parseInt(cidrPair[1]);
@@ -983,7 +983,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
     }
 
     private DiskOfferingVO createdefaultDiskOffering(Long domainId, String name, String description, int numGibibytes, String tags, boolean isCustomized,
-            boolean isSystemUse) {
+        boolean isSystemUse) {
         long diskSize = numGibibytes;
         diskSize = diskSize * 1024 * 1024 * 1024;
         tags = cleanupTags(tags);
@@ -996,10 +996,10 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
     }
 
     private ServiceOfferingVO createServiceOffering(long userId, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired,
-            boolean offerHA, String tags) {
+        boolean offerHA, String tags) {
         tags = cleanupTags(tags);
         ServiceOfferingVO offering =
-                new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, offerHA, displayText, localStorageRequired, false, tags, false, null, false);
+            new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, offerHA, displayText, localStorageRequired, false, tags, false, null, false);
         offering.setUniqueName("Cloud.Com-" + name);
         offering = _serviceOfferingDao.persistSystemServiceOffering(offering);
         return offering;
@@ -1074,87 +1074,87 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
             public void doInTransactionWithoutResult(TransactionStatus status) {
                 // Offering #1
                 NetworkOfferingVO defaultSharedSGNetworkOffering =
-                        new NetworkOfferingVO(NetworkOffering.DefaultSharedNetworkOfferingWithSGService, "Offering for Shared Security group enabled networks",
-                                TrafficType.Guest, false, true, null, null, true, Availability.Optional, null, Network.GuestType.Shared, true, true, false, false, false);
+                    new NetworkOfferingVO(NetworkOffering.DefaultSharedNetworkOfferingWithSGService, "Offering for Shared Security group enabled networks",
+                        TrafficType.Guest, false, true, null, null, true, Availability.Optional, null, Network.GuestType.Shared, true, true, false, false, false);
 
                 defaultSharedSGNetworkOffering.setState(NetworkOffering.State.Enabled);
                 defaultSharedSGNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultSharedSGNetworkOffering);
 
                 for (Service service : defaultSharedSGNetworkOfferingProviders.keySet()) {
                     NetworkOfferingServiceMapVO offService =
-                            new NetworkOfferingServiceMapVO(defaultSharedSGNetworkOffering.getId(), service, defaultSharedSGNetworkOfferingProviders.get(service));
+                        new NetworkOfferingServiceMapVO(defaultSharedSGNetworkOffering.getId(), service, defaultSharedSGNetworkOfferingProviders.get(service));
                     _ntwkOfferingServiceMapDao.persist(offService);
                     s_logger.trace("Added service for the network offering: " + offService);
                 }
 
                 // Offering #2
                 NetworkOfferingVO defaultSharedNetworkOffering =
-                        new NetworkOfferingVO(NetworkOffering.DefaultSharedNetworkOffering, "Offering for Shared networks", TrafficType.Guest, false, true, null, null, true,
-                                Availability.Optional, null, Network.GuestType.Shared, true, true, false, false, false);
+                    new NetworkOfferingVO(NetworkOffering.DefaultSharedNetworkOffering, "Offering for Shared networks", TrafficType.Guest, false, true, null, null, true,
+                        Availability.Optional, null, Network.GuestType.Shared, true, true, false, false, false);
 
                 defaultSharedNetworkOffering.setState(NetworkOffering.State.Enabled);
                 defaultSharedNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultSharedNetworkOffering);
 
                 for (Service service : defaultSharedNetworkOfferingProviders.keySet()) {
                     NetworkOfferingServiceMapVO offService =
-                            new NetworkOfferingServiceMapVO(defaultSharedNetworkOffering.getId(), service, defaultSharedNetworkOfferingProviders.get(service));
+                        new NetworkOfferingServiceMapVO(defaultSharedNetworkOffering.getId(), service, defaultSharedNetworkOfferingProviders.get(service));
                     _ntwkOfferingServiceMapDao.persist(offService);
                     s_logger.trace("Added service for the network offering: " + offService);
                 }
 
                 // Offering #3
                 NetworkOfferingVO defaultIsolatedSourceNatEnabledNetworkOffering =
-                        new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService,
-                                "Offering for Isolated networks with Source Nat service enabled", TrafficType.Guest, false, false, null, null, true, Availability.Required, null,
-                                Network.GuestType.Isolated, true, false, false, false, true);
+                    new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOfferingWithSourceNatService,
+                        "Offering for Isolated networks with Source Nat service enabled", TrafficType.Guest, false, false, null, null, true, Availability.Required, null,
+                        Network.GuestType.Isolated, true, false, false, false, true);
 
                 defaultIsolatedSourceNatEnabledNetworkOffering.setState(NetworkOffering.State.Enabled);
                 defaultIsolatedSourceNatEnabledNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultIsolatedSourceNatEnabledNetworkOffering);
 
                 for (Service service : defaultIsolatedSourceNatEnabledNetworkOfferingProviders.keySet()) {
                     NetworkOfferingServiceMapVO offService =
-                            new NetworkOfferingServiceMapVO(defaultIsolatedSourceNatEnabledNetworkOffering.getId(), service,
-                                    defaultIsolatedSourceNatEnabledNetworkOfferingProviders.get(service));
+                        new NetworkOfferingServiceMapVO(defaultIsolatedSourceNatEnabledNetworkOffering.getId(), service,
+                            defaultIsolatedSourceNatEnabledNetworkOfferingProviders.get(service));
                     _ntwkOfferingServiceMapDao.persist(offService);
                     s_logger.trace("Added service for the network offering: " + offService);
                 }
 
                 // Offering #4
                 NetworkOfferingVO defaultIsolatedEnabledNetworkOffering =
-                        new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOffering, "Offering for Isolated networks with no Source Nat service", TrafficType.Guest,
-                                false, true, null, null, true, Availability.Optional, null, Network.GuestType.Isolated, true, true, false, false, false);
+                    new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOffering, "Offering for Isolated networks with no Source Nat service", TrafficType.Guest,
+                        false, true, null, null, true, Availability.Optional, null, Network.GuestType.Isolated, true, true, false, false, false);
 
                 defaultIsolatedEnabledNetworkOffering.setState(NetworkOffering.State.Enabled);
                 defaultIsolatedEnabledNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultIsolatedEnabledNetworkOffering);
 
                 for (Service service : defaultIsolatedNetworkOfferingProviders.keySet()) {
                     NetworkOfferingServiceMapVO offService =
-                            new NetworkOfferingServiceMapVO(defaultIsolatedEnabledNetworkOffering.getId(), service, defaultIsolatedNetworkOfferingProviders.get(service));
+                        new NetworkOfferingServiceMapVO(defaultIsolatedEnabledNetworkOffering.getId(), service, defaultIsolatedNetworkOfferingProviders.get(service));
                     _ntwkOfferingServiceMapDao.persist(offService);
                     s_logger.trace("Added service for the network offering: " + offService);
                 }
 
                 // Offering #5
                 NetworkOfferingVO defaultNetscalerNetworkOffering =
-                        new NetworkOfferingVO(NetworkOffering.DefaultSharedEIPandELBNetworkOffering,
-                                "Offering for Shared networks with Elastic IP and Elastic LB capabilities", TrafficType.Guest, false, true, null, null, true,
-                                Availability.Optional, null, Network.GuestType.Shared, true, false, false, false, true, true, true, false, false, true, true, false, false);
+                    new NetworkOfferingVO(NetworkOffering.DefaultSharedEIPandELBNetworkOffering,
+                        "Offering for Shared networks with Elastic IP and Elastic LB capabilities", TrafficType.Guest, false, true, null, null, true,
+                        Availability.Optional, null, Network.GuestType.Shared, true, false, false, false, true, true, true, false, false, true, true, false, false);
 
                 defaultNetscalerNetworkOffering.setState(NetworkOffering.State.Enabled);
                 defaultNetscalerNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetscalerNetworkOffering);
 
                 for (Service service : netscalerServiceProviders.keySet()) {
                     NetworkOfferingServiceMapVO offService =
-                            new NetworkOfferingServiceMapVO(defaultNetscalerNetworkOffering.getId(), service, netscalerServiceProviders.get(service));
+                        new NetworkOfferingServiceMapVO(defaultNetscalerNetworkOffering.getId(), service, netscalerServiceProviders.get(service));
                     _ntwkOfferingServiceMapDao.persist(offService);
                     s_logger.trace("Added service for the network offering: " + offService);
                 }
 
                 // Offering #6
                 NetworkOfferingVO defaultNetworkOfferingForVpcNetworks =
-                        new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks,
-                                "Offering for Isolated Vpc networks with Source Nat service enabled", TrafficType.Guest, false, false, null, null, true, Availability.Optional,
-                                null, Network.GuestType.Isolated, false, false, false, false, true);
+                    new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks,
+                        "Offering for Isolated Vpc networks with Source Nat service enabled", TrafficType.Guest, false, false, null, null, true, Availability.Optional,
+                        null, Network.GuestType.Isolated, false, false, false, false, true);
 
                 defaultNetworkOfferingForVpcNetworks.setState(NetworkOffering.State.Enabled);
                 defaultNetworkOfferingForVpcNetworks = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetworkOfferingForVpcNetworks);
@@ -1173,16 +1173,16 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
 
                 for (Service service : defaultVpcNetworkOfferingProviders.keySet()) {
                     NetworkOfferingServiceMapVO offService =
-                            new NetworkOfferingServiceMapVO(defaultNetworkOfferingForVpcNetworks.getId(), service, defaultVpcNetworkOfferingProviders.get(service));
+                        new NetworkOfferingServiceMapVO(defaultNetworkOfferingForVpcNetworks.getId(), service, defaultVpcNetworkOfferingProviders.get(service));
                     _ntwkOfferingServiceMapDao.persist(offService);
                     s_logger.trace("Added service for the network offering: " + offService);
                 }
 
                 // Offering #7
                 NetworkOfferingVO defaultNetworkOfferingForVpcNetworksNoLB =
-                        new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksNoLB,
-                                "Offering for Isolated Vpc networks with Source Nat service enabled and LB service Disabled", TrafficType.Guest, false, false, null, null, true,
-                                Availability.Optional, null, Network.GuestType.Isolated, false, false, false, false, false);
+                    new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksNoLB,
+                        "Offering for Isolated Vpc networks with Source Nat service enabled and LB service Disabled", TrafficType.Guest, false, false, null, null, true,
+                        Availability.Optional, null, Network.GuestType.Isolated, false, false, false, false, false);
 
                 defaultNetworkOfferingForVpcNetworksNoLB.setState(NetworkOffering.State.Enabled);
                 defaultNetworkOfferingForVpcNetworksNoLB = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetworkOfferingForVpcNetworksNoLB);
@@ -1200,16 +1200,16 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
 
                 for (Service service : defaultVpcNetworkOfferingProvidersNoLB.keySet()) {
                     NetworkOfferingServiceMapVO offService =
-                            new NetworkOfferingServiceMapVO(defaultNetworkOfferingForVpcNetworksNoLB.getId(), service, defaultVpcNetworkOfferingProvidersNoLB.get(service));
+                        new NetworkOfferingServiceMapVO(defaultNetworkOfferingForVpcNetworksNoLB.getId(), service, defaultVpcNetworkOfferingProvidersNoLB.get(service));
                     _ntwkOfferingServiceMapDao.persist(offService);
                     s_logger.trace("Added service for the network offering: " + offService);
                 }
 
                 //offering #8 - network offering with internal lb service
                 NetworkOfferingVO internalLbOff =
-                        new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB,
-                                "Offering for Isolated Vpc networks with Internal LB support", TrafficType.Guest, false, false, null, null, true, Availability.Optional, null,
-                                Network.GuestType.Isolated, false, false, false, true, false);
+                    new NetworkOfferingVO(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB,
+                        "Offering for Isolated Vpc networks with Internal LB support", TrafficType.Guest, false, false, null, null, true, Availability.Optional, null,
+                        Network.GuestType.Isolated, false, false, false, true, false);
 
                 internalLbOff.setState(NetworkOffering.State.Enabled);
                 internalLbOff = _networkOfferingDao.persistDefaultNetworkOffering(internalLbOff);
@@ -1284,8 +1284,8 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
 
                     if (broadcastDomainType != null) {
                         NetworkVO network =
-                                new NetworkVO(id, trafficType, mode, broadcastDomainType, networkOfferingId, domainId, accountId, related, null, null, networkDomain,
-                                        Network.GuestType.Shared, zoneId, null, null, specifyIpRanges, null);
+                            new NetworkVO(id, trafficType, mode, broadcastDomainType, networkOfferingId, domainId, accountId, related, null, null, networkDomain,
+                                Network.GuestType.Shared, zoneId, null, null, specifyIpRanges, null);
                         network.setGuruName(guruNames.get(network.getTrafficType()));
                         network.setDns1(zone.getDns1());
                         network.setDns2(zone.getDns2());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 2b0f0b8..8bc095d 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -690,7 +690,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
     private LoadBalancerDao _loadbalancerDao;
     @Inject
     private HypervisorCapabilitiesDao _hypervisorCapabilitiesDao;
-    private List<HostAllocator> _hostAllocators;
+    private List<HostAllocator> hostAllocators;
     private List<StoragePoolAllocator> _storagePoolAllocators;
     @Inject
     private ResourceTagDao _resourceTagDao;
@@ -748,8 +748,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         return _planners;
     }
 
-    public void setPlanners(List<DeploymentPlanner> _planners) {
-        this._planners = _planners;
+    public void setPlanners(List<DeploymentPlanner> planners) {
+        this._planners = planners;
     }
 
     @Inject
@@ -792,11 +792,11 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
     }
 
     public List<HostAllocator> getHostAllocators() {
-        return _hostAllocators;
+        return hostAllocators;
     }
 
-    public void setHostAllocators(List<HostAllocator> _hostAllocators) {
-        this._hostAllocators = _hostAllocators;
+    public void setHostAllocators(List<HostAllocator> hostAllocators) {
+        this.hostAllocators = hostAllocators;
     }
 
     @Override
@@ -1071,13 +1071,13 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         }
 
         if (!vm.getHypervisorType().equals(HypervisorType.XenServer) && !vm.getHypervisorType().equals(HypervisorType.VMware)
-                && !vm.getHypervisorType().equals(HypervisorType.KVM) && !vm.getHypervisorType().equals(HypervisorType.Ovm)
-                && !vm.getHypervisorType().equals(HypervisorType.Hyperv)) {
+            && !vm.getHypervisorType().equals(HypervisorType.KVM) && !vm.getHypervisorType().equals(HypervisorType.Ovm)
+            && !vm.getHypervisorType().equals(HypervisorType.Hyperv)) {
             if (s_logger.isDebugEnabled()) {
                 s_logger.debug(vm + " is not XenServer/VMware/KVM/OVM/Hyperv, cannot migrate this VM.");
             }
             throw new InvalidParameterValueException("Unsupported Hypervisor Type for VM migration, we support " +
-                    "XenServer/VMware/KVM/Ovm/Hyperv only");
+                "XenServer/VMware/KVM/Ovm/Hyperv only");
         }
 
         long srcHostId = vm.getHostId();
@@ -1176,7 +1176,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
             }
         }
 
-        for (HostAllocator allocator : _hostAllocators) {
+        for (HostAllocator allocator : hostAllocators) {
             if (canMigrateWithStorage) {
                 suitableHosts = allocator.allocateTo(vmProfile, plan, Host.Type.Routing, excludes, allHosts, HostAllocator.RETURN_UPTO_ALL, false);
             } else {
@@ -2277,7 +2277,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         if (type != null) {
             sc.addAnd("type", SearchCriteria.Op.EQ, type);
         }
-        
+
         if (name != null) {
             sc.addAnd("name", SearchCriteria.Op.EQ, name);
         }
@@ -2866,8 +2866,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         cmdList.add(AssignCertToLoadBalancerCmd.class);
         cmdList.add(RemoveCertFromLoadBalancerCmd.class);
         cmdList.add(GenerateAlertCmd.class);
-	cmdList.add(ListOvsElementsCmd.class);
-	cmdList.add(ConfigureOvsElementCmd.class);
+        cmdList.add(ListOvsElementsCmd.class);
+        cmdList.add(ConfigureOvsElementCmd.class);
         return cmdList;
     }
 
@@ -3790,7 +3790,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
             throw new InvalidParameterValueException("Dynamic Scaling operation is not permitted for this hypervisor on system vm");
         }
         boolean result = _userVmMgr.upgradeVirtualMachine(cmd.getId(), cmd.getServiceOfferingId(), cmd.getCustomParameters());
-        if(result){
+        if (result) {
             VirtualMachine vm = _vmInstanceDao.findById(cmd.getId());
             return vm;
         } else {
@@ -3806,7 +3806,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
 
     }
 
-    private VirtualMachine upgradeStoppedSystemVm(Long systemVmId, Long serviceOfferingId, Map<String, String> customparameters){
+    private VirtualMachine upgradeStoppedSystemVm(Long systemVmId, Long serviceOfferingId, Map<String, String> customparameters) {
         Account caller = CallContext.current().getCallingAccount();
 
         VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(systemVmId, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm);
@@ -3818,8 +3818,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
 
         // Check that the specified service offering ID is valid
         ServiceOfferingVO newServiceOffering = _offeringDao.findById(serviceOfferingId);
-        ServiceOfferingVO currentServiceOffering = _offeringDao.findById(systemVmId,systemVm.getServiceOfferingId());
-        if (newServiceOffering.isDynamic()){
+        ServiceOfferingVO currentServiceOffering = _offeringDao.findById(systemVmId, systemVm.getServiceOfferingId());
+        if (newServiceOffering.isDynamic()) {
             newServiceOffering.setDynamicFlag(true);
             _userVmMgr.validateCustomParameters(newServiceOffering, customparameters);
             newServiceOffering = _offeringDao.getcomputeOffering(newServiceOffering, customparameters);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/server/src/com/cloud/server/StatsCollector.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/StatsCollector.java b/server/src/com/cloud/server/StatsCollector.java
index 82f774f..95ae047 100755
--- a/server/src/com/cloud/server/StatsCollector.java
+++ b/server/src/com/cloud/server/StatsCollector.java
@@ -118,52 +118,78 @@ import com.cloud.vm.dao.VMInstanceDao;
 @Component
 public class StatsCollector extends ManagerBase implements ComponentMethodInterceptable {
 
-	public static final Logger s_logger = Logger.getLogger(StatsCollector.class.getName());
-
-	private static StatsCollector s_instance = null;
-
-	private ScheduledExecutorService _executor = null;
-	@Inject private AgentManager _agentMgr;
-	@Inject private UserVmManager _userVmMgr;
-	@Inject private HostDao _hostDao;
-	@Inject private UserVmDao _userVmDao;
-	@Inject private VolumeDao _volsDao;
-	@Inject private PrimaryDataStoreDao _storagePoolDao;
-	@Inject private ImageStoreDao _imageStoreDao;
-	@Inject private StorageManager _storageManager;
-	@Inject private StoragePoolHostDao _storagePoolHostDao;
-	@Inject private DataStoreManager _dataStoreMgr;
-	@Inject private ResourceManager _resourceMgr;
-    @Inject private ConfigurationDao _configDao;
-    @Inject private EndPointSelector _epSelector;
-    @Inject private VmDiskStatisticsDao _vmDiskStatsDao;
-    @Inject private ManagementServerHostDao _msHostDao;
-	@Inject	private AutoScaleVmGroupDao _asGroupDao;
-	@Inject private AutoScaleVmGroupVmMapDao _asGroupVmDao;
-	@Inject private AutoScaleManager _asManager;
-	@Inject private VMInstanceDao _vmInstance;
-	@Inject private AutoScaleVmGroupPolicyMapDao _asGroupPolicyDao;
-	@Inject private AutoScalePolicyDao _asPolicyDao;
-	@Inject private AutoScalePolicyConditionMapDao _asConditionMapDao; 
-	@Inject private ConditionDao _asConditionDao;
-	@Inject private CounterDao _asCounterDao;
-	@Inject private AutoScaleVmProfileDao _asProfileDao;
-	@Inject private ServiceOfferingDao _serviceOfferingDao;
-
-	private ConcurrentHashMap<Long, HostStats> _hostStats = new ConcurrentHashMap<Long, HostStats>();
-	private final ConcurrentHashMap<Long, VmStats> _VmStats = new ConcurrentHashMap<Long, VmStats>();
-	private ConcurrentHashMap<Long, VolumeStats> _volumeStats = new ConcurrentHashMap<Long, VolumeStats>();
-	private ConcurrentHashMap<Long, StorageStats> _storageStats = new ConcurrentHashMap<Long, StorageStats>();
-	private ConcurrentHashMap<Long, StorageStats> _storagePoolStats = new ConcurrentHashMap<Long, StorageStats>();
-
-	long hostStatsInterval = -1L;
-	long hostAndVmStatsInterval = -1L;
-	long storageStatsInterval = -1L;
-	long volumeStatsInterval = -1L;
-	long autoScaleStatsInterval = -1L;
-	int vmDiskStatsInterval = 0;
-
-	private ScheduledExecutorService _diskStatsUpdateExecutor;
+    public static final Logger s_logger = Logger.getLogger(StatsCollector.class.getName());
+
+    private static StatsCollector s_instance = null;
+
+    private ScheduledExecutorService _executor = null;
+    @Inject
+    private AgentManager _agentMgr;
+    @Inject
+    private UserVmManager _userVmMgr;
+    @Inject
+    private HostDao _hostDao;
+    @Inject
+    private UserVmDao _userVmDao;
+    @Inject
+    private VolumeDao _volsDao;
+    @Inject
+    private PrimaryDataStoreDao _storagePoolDao;
+    @Inject
+    private ImageStoreDao _imageStoreDao;
+    @Inject
+    private StorageManager _storageManager;
+    @Inject
+    private StoragePoolHostDao _storagePoolHostDao;
+    @Inject
+    private DataStoreManager _dataStoreMgr;
+    @Inject
+    private ResourceManager _resourceMgr;
+    @Inject
+    private ConfigurationDao _configDao;
+    @Inject
+    private EndPointSelector _epSelector;
+    @Inject
+    private VmDiskStatisticsDao _vmDiskStatsDao;
+    @Inject
+    private ManagementServerHostDao _msHostDao;
+    @Inject
+    private AutoScaleVmGroupDao _asGroupDao;
+    @Inject
+    private AutoScaleVmGroupVmMapDao _asGroupVmDao;
+    @Inject
+    private AutoScaleManager _asManager;
+    @Inject
+    private VMInstanceDao _vmInstance;
+    @Inject
+    private AutoScaleVmGroupPolicyMapDao _asGroupPolicyDao;
+    @Inject
+    private AutoScalePolicyDao _asPolicyDao;
+    @Inject
+    private AutoScalePolicyConditionMapDao _asConditionMapDao;
+    @Inject
+    private ConditionDao _asConditionDao;
+    @Inject
+    private CounterDao _asCounterDao;
+    @Inject
+    private AutoScaleVmProfileDao _asProfileDao;
+    @Inject
+    private ServiceOfferingDao _serviceOfferingDao;
+
+    private ConcurrentHashMap<Long, HostStats> _hostStats = new ConcurrentHashMap<Long, HostStats>();
+    private final ConcurrentHashMap<Long, VmStats> _VmStats = new ConcurrentHashMap<Long, VmStats>();
+    private final ConcurrentHashMap<Long, VolumeStats> _volumeStats = new ConcurrentHashMap<Long, VolumeStats>();
+    private ConcurrentHashMap<Long, StorageStats> _storageStats = new ConcurrentHashMap<Long, StorageStats>();
+    private ConcurrentHashMap<Long, StorageStats> _storagePoolStats = new ConcurrentHashMap<Long, StorageStats>();
+
+    long hostStatsInterval = -1L;
+    long hostAndVmStatsInterval = -1L;
+    long storageStatsInterval = -1L;
+    long volumeStatsInterval = -1L;
+    long autoScaleStatsInterval = -1L;
+    int vmDiskStatsInterval = 0;
+
+    private ScheduledExecutorService _diskStatsUpdateExecutor;
     private int _usageAggregationRange = 1440;
     private String _usageTimeZone = "GMT";
     private final long mgmtSrvrId = MacAddress.getMacAddress().toLong();
@@ -192,15 +218,15 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
         return true;
     }
 
-	private void init(Map<String, String> configs) {
-		_executor = Executors.newScheduledThreadPool(4, new NamedThreadFactory("StatsCollector"));
+    private void init(Map<String, String> configs) {
+        _executor = Executors.newScheduledThreadPool(4, new NamedThreadFactory("StatsCollector"));
 
-		 hostStatsInterval = NumbersUtil.parseLong(configs.get("host.stats.interval"), 60000L);
-		 hostAndVmStatsInterval = NumbersUtil.parseLong(configs.get("vm.stats.interval"), 60000L);
-		 storageStatsInterval = NumbersUtil.parseLong(configs.get("storage.stats.interval"), 60000L);
-		 volumeStatsInterval = NumbersUtil.parseLong(configs.get("volume.stats.interval"), -1L);
-		 autoScaleStatsInterval = NumbersUtil.parseLong(configs.get("autoscale.stats.interval"), 60000L);
-		 vmDiskStatsInterval = NumbersUtil.parseInt(configs.get("vm.disk.stats.interval"), 0);
+        hostStatsInterval = NumbersUtil.parseLong(configs.get("host.stats.interval"), 60000L);
+        hostAndVmStatsInterval = NumbersUtil.parseLong(configs.get("vm.stats.interval"), 60000L);
+        storageStatsInterval = NumbersUtil.parseLong(configs.get("storage.stats.interval"), 60000L);
+        volumeStatsInterval = NumbersUtil.parseLong(configs.get("volume.stats.interval"), -1L);
+        autoScaleStatsInterval = NumbersUtil.parseLong(configs.get("autoscale.stats.interval"), 60000L);
+        vmDiskStatsInterval = NumbersUtil.parseInt(configs.get("vm.disk.stats.interval"), 0);
 
         if (hostStatsInterval > 0) {
             _executor.scheduleWithFixedDelay(new HostCollector(), 15000L, hostStatsInterval, TimeUnit.MILLISECONDS);
@@ -210,13 +236,13 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
             _executor.scheduleWithFixedDelay(new VmStatsCollector(), 15000L, hostAndVmStatsInterval, TimeUnit.MILLISECONDS);
         }
 
-		if (storageStatsInterval > 0) {
-		    _executor.scheduleWithFixedDelay(new StorageCollector(), 15000L, storageStatsInterval, TimeUnit.MILLISECONDS);
-		}
-		 
-		if (autoScaleStatsInterval > 0) {
+        if (storageStatsInterval > 0) {
+            _executor.scheduleWithFixedDelay(new StorageCollector(), 15000L, storageStatsInterval, TimeUnit.MILLISECONDS);
+        }
+
+        if (autoScaleStatsInterval > 0) {
             _executor.scheduleWithFixedDelay(new AutoScaleMonitor(), 15000L, autoScaleStatsInterval, TimeUnit.MILLISECONDS);
-		}
+        }
 
         if (vmDiskStatsInterval > 0) {
             if (vmDiskStatsInterval < 300)
@@ -606,300 +632,301 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
                     }
                 }
                 _storagePoolStats = storagePoolStats;
-			} catch (Throwable t) {
-				s_logger.error("Error trying to retrieve storage stats", t);
-			}
-		}
-	}
-
-	class AutoScaleMonitor extends ManagedContextRunnable {
-		@Override
-		protected void runInContext() {
-			try {
-				if (s_logger.isDebugEnabled()) {
-					s_logger.debug("AutoScaling Monitor is running...");
-				}
-				// list all AS VMGroups
-				List<AutoScaleVmGroupVO> asGroups = _asGroupDao.listAll();
-				for (AutoScaleVmGroupVO asGroup : asGroups) {
-					// check group state
-					if ((asGroup.getState().equals("enabled")) && (is_native(asGroup.getId()))) {
-						// check minimum vm of group
-						Integer currentVM = _asGroupVmDao.countByGroup(asGroup.getId());
-						if (currentVM < asGroup.getMinMembers()) {
-							_asManager.doScaleUp(asGroup.getId(), asGroup.getMinMembers() - currentVM);
-							continue;
-						}
-						
-						//check interval
-						long now = (new Date()).getTime();
-						if (asGroup.getLastInterval() != null)
-							if ((now - asGroup.getLastInterval().getTime()) < (long) asGroup
-									.getInterval()) {
-								continue;
-							}
-
-						// update last_interval
-						asGroup.setLastInterval(new Date());
-						_asGroupDao.persist(asGroup);
-
-						// collect RRDs data for this group
-						if (s_logger.isDebugEnabled()) {
-							s_logger.debug("[AutoScale] Collecting RRDs data...");
-						}
-						Map<String, String> params = new HashMap<String, String>();
-						List <AutoScaleVmGroupVmMapVO> asGroupVmVOs = _asGroupVmDao.listByGroup(asGroup.getId());
-						params.put("total_vm", String.valueOf(asGroupVmVOs.size()));
-						for (int i = 0; i < asGroupVmVOs.size(); i++) {
-							long vmId = asGroupVmVOs.get(i).getInstanceId();
-							VMInstanceVO vmVO = _vmInstance.findById(vmId);
-							//xe vm-list | grep vmname -B 1 | head -n 1 | awk -F':' '{print $2}'
-							params.put("vmname" + String.valueOf(i + 1), vmVO.getInstanceName());
-							params.put("vmid" + String.valueOf(i + 1), String.valueOf(vmVO.getId()));
-
-						}
-						// get random hostid because all vms are in a cluster
-						long vmId = asGroupVmVOs.get(0).getInstanceId();
-						VMInstanceVO vmVO = _vmInstance.findById(vmId);
-						Long receiveHost = vmVO.getHostId();
-
-						// setup parameters phase: duration and counter
-						// list pair [counter, duration]
-						List<Pair<String, Integer>> lstPair = getPairofCounternameAndDuration(asGroup.getId());
-						int total_counter = 0;
-						String[] lstCounter = new String[lstPair.size()];
-						for (int i = 0; i < lstPair.size(); i++) {
-							Pair<String, Integer> pair = lstPair.get(i);
-							String strCounterNames = pair.first();
-							Integer duration = pair.second();
-							
-							lstCounter[i] = strCounterNames.split(",")[0];
-							total_counter++;
-							params.put("duration" + String.valueOf(total_counter), duration.toString());
-							params.put("counter" + String.valueOf(total_counter), lstCounter[i]);
-							params.put("con" + String.valueOf(total_counter), strCounterNames.split(",")[1]);
-						}
-						params.put("total_counter", String.valueOf(total_counter));
-
-						PerformanceMonitorCommand perfMon = new PerformanceMonitorCommand(params, 20);
-
-						try {
-							Answer answer = _agentMgr.send(receiveHost, perfMon);
-							if (answer == null || !answer.getResult()) {
-								s_logger.debug("Failed to send data to node !");
-							} else {
-								String result = answer.getDetails();
-								s_logger.debug("[AutoScale] RRDs collection answer: " + result);
-								HashMap<Long, Double> avgCounter = new HashMap<Long, Double>();
-								
-								// extract data
-								String[] counterElements = result.split(",");
-								if ((counterElements != null) && (counterElements.length > 0)) {
-									for (String string : counterElements) {
-										try {
-											String[] counterVals = string.split(":");
-											String[] counter_vm = counterVals[0].split("\\.");
-											
-											Long counterId = Long.parseLong(counter_vm[1]);
-											Long conditionId = Long.parseLong(params.get("con" + counter_vm[1]));
-											Double coVal = Double.parseDouble(counterVals[1]);
-
-											// Summary of all counter by counterId key
-											if (avgCounter.get(counterId) == null){													
-												/* initialize if data is not set */
-												avgCounter.put(counterId, new Double(0));
-											}
-											
-											String counterName = getCounternamebyCondition(conditionId.longValue());
-											if (counterName == Counter.Source.memory.toString()) {
-												// calculate memory in percent
-												Long profileId = asGroup.getProfileId();
-												AutoScaleVmProfileVO profileVo = _asProfileDao.findById(profileId);
-												ServiceOfferingVO serviceOff = _serviceOfferingDao.findById(profileVo.getServiceOfferingId());
-												int maxRAM = serviceOff.getRamSize();
-
-												// get current RAM percent
-												coVal = coVal / maxRAM;
-											} else {
-												// cpu
-												coVal = coVal * 100;
-											}
-											
-											// update data entry
-											avgCounter.put(counterId, avgCounter.get(counterId)+ coVal);
-											
-										} catch (Exception e) {
-											e.printStackTrace();
-										}
-									}
-
-									String scaleAction = getAutoscaleAction(avgCounter, asGroup.getId(), currentVM, params);
-									if (scaleAction != null) {
-										s_logger.debug("[AutoScale] Doing scale action: " + scaleAction + " for group " + asGroup.getId());
-										if (scaleAction.equals("scaleup")) {
-											_asManager.doScaleUp(asGroup.getId(), 1);
-										} else {
-											_asManager.doScaleDown(asGroup.getId());
-										}
-									}
-								}
-							}
-
-						} catch (Exception e) {
-							e.printStackTrace();
-						}
-
-					}
-				}
-
-			} catch (Throwable t) {
-				s_logger.error("Error trying to monitor autoscaling", t);
-			}
-
-		}
-		
-		private boolean is_native(long groupId) {
-			List <AutoScaleVmGroupPolicyMapVO> vos = _asGroupPolicyDao.listByVmGroupId(groupId);
-			for (AutoScaleVmGroupPolicyMapVO vo : vos) {
-				List<AutoScalePolicyConditionMapVO> ConditionPolicies = _asConditionMapDao.findByPolicyId(vo.getPolicyId());
-				for (AutoScalePolicyConditionMapVO ConditionPolicy : ConditionPolicies) {
-					ConditionVO condition = _asConditionDao.findById(ConditionPolicy.getConditionId());
-					CounterVO counter = _asCounterDao.findById(condition.getCounterid());
-					if (counter.getSource() == Counter.Source.cpu || counter.getSource() == Counter.Source.memory)
-						return true;
-				}
-			}
-			return false;
-		}
-		
-		private String getAutoscaleAction(HashMap<Long, Double> avgCounter, long groupId, long currentVM, Map<String, String> params) {
-			
-			List<AutoScaleVmGroupPolicyMapVO> listMap = _asGroupPolicyDao.listByVmGroupId(groupId);
-			if ( (listMap == null) || (listMap.size() == 0) )
-				return null;
-			for (AutoScaleVmGroupPolicyMapVO asVmgPmap : listMap) {
-				AutoScalePolicyVO policyVO = _asPolicyDao.findById(asVmgPmap.getPolicyId());
-				if (policyVO != null) {
-					Integer quitetime = policyVO.getQuietTime();
-					Date quitetimeDate = policyVO.getLastQuiteTime();
-					long last_quitetime = 0L;
-					if (quitetimeDate != null) {
-						last_quitetime = policyVO.getLastQuiteTime().getTime();
-					}
-					long current_time = (new Date()).getTime();
-
-					// check quite time for this policy
-					if ((current_time - last_quitetime) >= (long) quitetime) {
-
-						// list all condition of this policy
-						boolean bValid = true;
-						List<ConditionVO> lstConditions = getConditionsbyPolicyId(policyVO.getId());
-						if ((lstConditions != null) && (lstConditions.size() > 0)) {
-							// check whole conditions of this policy
-							for (ConditionVO conditionVO : lstConditions) {
-								long thresholdValue = conditionVO.getThreshold();
-								Double thresholdPercent = (double)thresholdValue / 100;
-								CounterVO counterVO = _asCounterDao.findById(conditionVO.getCounterid());
-//								Double sum = avgCounter.get(conditionVO.getCounterid());
-								long counter_count=1;
-								do {
-									String counter_param = params.get("counter" + String.valueOf(counter_count));
-									Counter.Source counter_source = counterVO.getSource(); 
-									if (counter_param.equals(counter_source.toString()))
-										break;
-									counter_count++;
-								} while (1==1);
-								
-								Double sum = avgCounter.get(counter_count);
-								Double avg = sum / currentVM;
-								Operator op = conditionVO.getRelationalOperator();
-								boolean bConditionCheck = ((op == com.cloud.network.as.Condition.Operator.EQ) && (thresholdPercent == avg))
-										|| ((op == com.cloud.network.as.Condition.Operator.GE) && (avg >= thresholdPercent))
-										|| ((op == com.cloud.network.as.Condition.Operator.GT) && (avg > thresholdPercent))
-										|| ((op == com.cloud.network.as.Condition.Operator.LE) && (avg <= thresholdPercent))
-										|| ((op == com.cloud.network.as.Condition.Operator.LT) && (avg < thresholdPercent));
-
-								if (!bConditionCheck) {
-									bValid = false;
-									break;
-								}
-							}
-							if (bValid) {
-								return policyVO.getAction();
-							}
-						}
-					}
-				}
-			}
-			return null;
-		}
-		
-		private List<ConditionVO> getConditionsbyPolicyId(long policyId){
-			List<AutoScalePolicyConditionMapVO> conditionMap = _asConditionMapDao.findByPolicyId(policyId);
-			if ( (conditionMap == null) || (conditionMap.size() == 0))
-				return null;
-			
-			List<ConditionVO> lstResult = new ArrayList<ConditionVO>();
-			for (AutoScalePolicyConditionMapVO asPCmap : conditionMap) {
-				lstResult.add(_asConditionDao.findById(asPCmap.getConditionId()));
-			}
-			
-			return lstResult;
-		}
-
-		public List<Pair<String, Integer>> getPairofCounternameAndDuration(
-				long groupId) {
-			AutoScaleVmGroupVO groupVo = _asGroupDao.findById(groupId);
-			if (groupVo == null)
-				return null;
-			List<Pair<String, Integer>> result = new ArrayList<Pair<String, Integer>>();
-			//list policy map
-			List<AutoScaleVmGroupPolicyMapVO> groupPolicymap = _asGroupPolicyDao.listByVmGroupId(groupVo.getId());
-			if (groupPolicymap == null)
-				return null;
-			for (AutoScaleVmGroupPolicyMapVO gpMap : groupPolicymap) {
-				//get duration
-				AutoScalePolicyVO policyVo = _asPolicyDao.findById(gpMap.getPolicyId());				
-				Integer duration = policyVo.getDuration();
-				//get collection of counter name
-				String counterNames = "";
-				List<AutoScalePolicyConditionMapVO> lstPCmap = _asConditionMapDao.findByPolicyId(policyVo.getId());
-				for (AutoScalePolicyConditionMapVO pcMap : lstPCmap) {
-					String counterName = getCounternamebyCondition(pcMap.getConditionId());
-					
-					counterNames += counterName + "," + pcMap.getConditionId();
-				}
-				// add to result
-				Pair<String, Integer> pair = new Pair<String, Integer>(counterNames, duration);
-				result.add(pair);
-			}
-
-			return result;
-		}
-		
-		public String getCounternamebyCondition(long conditionId){
-			
-			ConditionVO condition = _asConditionDao.findById(conditionId);
-			if (condition == null)
-				return "";
-			
-			long counterId = condition.getCounterid();
-			CounterVO counter = _asCounterDao.findById(counterId);
-			if (counter == null)
-				return "";
-			
-			return counter.getSource().toString();
-		}
-	}
-	public StorageStats getStorageStats(long id) {
-		return _storageStats.get(id);
-	}
-
-	public HostStats getHostStats(long hostId){
-		return _hostStats.get(hostId);
-	}
-
-	public StorageStats getStoragePoolStats(long id) {
-		return _storagePoolStats.get(id);
-	}
+            } catch (Throwable t) {
+                s_logger.error("Error trying to retrieve storage stats", t);
+            }
+        }
+    }
+
+    class AutoScaleMonitor extends ManagedContextRunnable {
+        @Override
+        protected void runInContext() {
+            try {
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("AutoScaling Monitor is running...");
+                }
+                // list all AS VMGroups
+                List<AutoScaleVmGroupVO> asGroups = _asGroupDao.listAll();
+                for (AutoScaleVmGroupVO asGroup : asGroups) {
+                    // check group state
+                    if ((asGroup.getState().equals("enabled")) && (is_native(asGroup.getId()))) {
+                        // check minimum vm of group
+                        Integer currentVM = _asGroupVmDao.countByGroup(asGroup.getId());
+                        if (currentVM < asGroup.getMinMembers()) {
+                            _asManager.doScaleUp(asGroup.getId(), asGroup.getMinMembers() - currentVM);
+                            continue;
+                        }
+
+                        //check interval
+                        long now = (new Date()).getTime();
+                        if (asGroup.getLastInterval() != null)
+                            if ((now - asGroup.getLastInterval().getTime()) < asGroup
+                                .getInterval()) {
+                                continue;
+                            }
+
+                        // update last_interval
+                        asGroup.setLastInterval(new Date());
+                        _asGroupDao.persist(asGroup);
+
+                        // collect RRDs data for this group
+                        if (s_logger.isDebugEnabled()) {
+                            s_logger.debug("[AutoScale] Collecting RRDs data...");
+                        }
+                        Map<String, String> params = new HashMap<String, String>();
+                        List<AutoScaleVmGroupVmMapVO> asGroupVmVOs = _asGroupVmDao.listByGroup(asGroup.getId());
+                        params.put("total_vm", String.valueOf(asGroupVmVOs.size()));
+                        for (int i = 0; i < asGroupVmVOs.size(); i++) {
+                            long vmId = asGroupVmVOs.get(i).getInstanceId();
+                            VMInstanceVO vmVO = _vmInstance.findById(vmId);
+                            //xe vm-list | grep vmname -B 1 | head -n 1 | awk -F':' '{print $2}'
+                            params.put("vmname" + String.valueOf(i + 1), vmVO.getInstanceName());
+                            params.put("vmid" + String.valueOf(i + 1), String.valueOf(vmVO.getId()));
+
+                        }
+                        // get random hostid because all vms are in a cluster
+                        long vmId = asGroupVmVOs.get(0).getInstanceId();
+                        VMInstanceVO vmVO = _vmInstance.findById(vmId);
+                        Long receiveHost = vmVO.getHostId();
+
+                        // setup parameters phase: duration and counter
+                        // list pair [counter, duration]
+                        List<Pair<String, Integer>> lstPair = getPairofCounternameAndDuration(asGroup.getId());
+                        int total_counter = 0;
+                        String[] lstCounter = new String[lstPair.size()];
+                        for (int i = 0; i < lstPair.size(); i++) {
+                            Pair<String, Integer> pair = lstPair.get(i);
+                            String strCounterNames = pair.first();
+                            Integer duration = pair.second();
+
+                            lstCounter[i] = strCounterNames.split(",")[0];
+                            total_counter++;
+                            params.put("duration" + String.valueOf(total_counter), duration.toString());
+                            params.put("counter" + String.valueOf(total_counter), lstCounter[i]);
+                            params.put("con" + String.valueOf(total_counter), strCounterNames.split(",")[1]);
+                        }
+                        params.put("total_counter", String.valueOf(total_counter));
+
+                        PerformanceMonitorCommand perfMon = new PerformanceMonitorCommand(params, 20);
+
+                        try {
+                            Answer answer = _agentMgr.send(receiveHost, perfMon);
+                            if (answer == null || !answer.getResult()) {
+                                s_logger.debug("Failed to send data to node !");
+                            } else {
+                                String result = answer.getDetails();
+                                s_logger.debug("[AutoScale] RRDs collection answer: " + result);
+                                HashMap<Long, Double> avgCounter = new HashMap<Long, Double>();
+
+                                // extract data
+                                String[] counterElements = result.split(",");
+                                if ((counterElements != null) && (counterElements.length > 0)) {
+                                    for (String string : counterElements) {
+                                        try {
+                                            String[] counterVals = string.split(":");
+                                            String[] counter_vm = counterVals[0].split("\\.");
+
+                                            Long counterId = Long.parseLong(counter_vm[1]);
+                                            Long conditionId = Long.parseLong(params.get("con" + counter_vm[1]));
+                                            Double coVal = Double.parseDouble(counterVals[1]);
+
+                                            // Summary of all counter by counterId key
+                                            if (avgCounter.get(counterId) == null) {
+                                                /* initialize if data is not set */
+                                                avgCounter.put(counterId, new Double(0));
+                                            }
+
+                                            String counterName = getCounternamebyCondition(conditionId.longValue());
+                                            if (counterName == Counter.Source.memory.toString()) {
+                                                // calculate memory in percent
+                                                Long profileId = asGroup.getProfileId();
+                                                AutoScaleVmProfileVO profileVo = _asProfileDao.findById(profileId);
+                                                ServiceOfferingVO serviceOff = _serviceOfferingDao.findById(profileVo.getServiceOfferingId());
+                                                int maxRAM = serviceOff.getRamSize();
+
+                                                // get current RAM percent
+                                                coVal = coVal / maxRAM;
+                                            } else {
+                                                // cpu
+                                                coVal = coVal * 100;
+                                            }
+
+                                            // update data entry
+                                            avgCounter.put(counterId, avgCounter.get(counterId) + coVal);
+
+                                        } catch (Exception e) {
+                                            e.printStackTrace();
+                                        }
+                                    }
+
+                                    String scaleAction = getAutoscaleAction(avgCounter, asGroup.getId(), currentVM, params);
+                                    if (scaleAction != null) {
+                                        s_logger.debug("[AutoScale] Doing scale action: " + scaleAction + " for group " + asGroup.getId());
+                                        if (scaleAction.equals("scaleup")) {
+                                            _asManager.doScaleUp(asGroup.getId(), 1);
+                                        } else {
+                                            _asManager.doScaleDown(asGroup.getId());
+                                        }
+                                    }
+                                }
+                            }
+
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+
+                    }
+                }
+
+            } catch (Throwable t) {
+                s_logger.error("Error trying to monitor autoscaling", t);
+            }
+
+        }
+
+        private boolean is_native(long groupId) {
+            List<AutoScaleVmGroupPolicyMapVO> vos = _asGroupPolicyDao.listByVmGroupId(groupId);
+            for (AutoScaleVmGroupPolicyMapVO vo : vos) {
+                List<AutoScalePolicyConditionMapVO> ConditionPolicies = _asConditionMapDao.findByPolicyId(vo.getPolicyId());
+                for (AutoScalePolicyConditionMapVO ConditionPolicy : ConditionPolicies) {
+                    ConditionVO condition = _asConditionDao.findById(ConditionPolicy.getConditionId());
+                    CounterVO counter = _asCounterDao.findById(condition.getCounterid());
+                    if (counter.getSource() == Counter.Source.cpu || counter.getSource() == Counter.Source.memory)
+                        return true;
+                }
+            }
+            return false;
+        }
+
+        private String getAutoscaleAction(HashMap<Long, Double> avgCounter, long groupId, long currentVM, Map<String, String> params) {
+
+            List<AutoScaleVmGroupPolicyMapVO> listMap = _asGroupPolicyDao.listByVmGroupId(groupId);
+            if ((listMap == null) || (listMap.size() == 0))
+                return null;
+            for (AutoScaleVmGroupPolicyMapVO asVmgPmap : listMap) {
+                AutoScalePolicyVO policyVO = _asPolicyDao.findById(asVmgPmap.getPolicyId());
+                if (policyVO != null) {
+                    Integer quitetime = policyVO.getQuietTime();
+                    Date quitetimeDate = policyVO.getLastQuiteTime();
+                    long last_quitetime = 0L;
+                    if (quitetimeDate != null) {
+                        last_quitetime = policyVO.getLastQuiteTime().getTime();
+                    }
+                    long current_time = (new Date()).getTime();
+
+                    // check quite time for this policy
+                    if ((current_time - last_quitetime) >= (long)quitetime) {
+
+                        // list all condition of this policy
+                        boolean bValid = true;
+                        List<ConditionVO> lstConditions = getConditionsbyPolicyId(policyVO.getId());
+                        if ((lstConditions != null) && (lstConditions.size() > 0)) {
+                            // check whole conditions of this policy
+                            for (ConditionVO conditionVO : lstConditions) {
+                                long thresholdValue = conditionVO.getThreshold();
+                                Double thresholdPercent = (double)thresholdValue / 100;
+                                CounterVO counterVO = _asCounterDao.findById(conditionVO.getCounterid());
+//Double sum = avgCounter.get(conditionVO.getCounterid());
+                                long counter_count = 1;
+                                do {
+                                    String counter_param = params.get("counter" + String.valueOf(counter_count));
+                                    Counter.Source counter_source = counterVO.getSource();
+                                    if (counter_param.equals(counter_source.toString()))
+                                        break;
+                                    counter_count++;
+                                } while (1 == 1);
+
+                                Double sum = avgCounter.get(counter_count);
+                                Double avg = sum / currentVM;
+                                Operator op = conditionVO.getRelationalOperator();
+                                boolean bConditionCheck = ((op == com.cloud.network.as.Condition.Operator.EQ) && (thresholdPercent == avg))
+                                    || ((op == com.cloud.network.as.Condition.Operator.GE) && (avg >= thresholdPercent))
+                                    || ((op == com.cloud.network.as.Condition.Operator.GT) && (avg > thresholdPercent))
+                                    || ((op == com.cloud.network.as.Condition.Operator.LE) && (avg <= thresholdPercent))
+                                    || ((op == com.cloud.network.as.Condition.Operator.LT) && (avg < thresholdPercent));
+
+                                if (!bConditionCheck) {
+                                    bValid = false;
+                                    break;
+                                }
+                            }
+                            if (bValid) {
+                                return policyVO.getAction();
+                            }
+                        }
+                    }
+                }
+            }
+            return null;
+        }
+
+        private List<ConditionVO> getConditionsbyPolicyId(long policyId) {
+            List<AutoScalePolicyConditionMapVO> conditionMap = _asConditionMapDao.findByPolicyId(policyId);
+            if ((conditionMap == null) || (conditionMap.size() == 0))
+                return null;
+
+            List<ConditionVO> lstResult = new ArrayList<ConditionVO>();
+            for (AutoScalePolicyConditionMapVO asPCmap : conditionMap) {
+                lstResult.add(_asConditionDao.findById(asPCmap.getConditionId()));
+            }
+
+            return lstResult;
+        }
+
+        public List<Pair<String, Integer>> getPairofCounternameAndDuration(
+            long groupId) {
+            AutoScaleVmGroupVO groupVo = _asGroupDao.findById(groupId);
+            if (groupVo == null)
+                return null;
+            List<Pair<String, Integer>> result = new ArrayList<Pair<String, Integer>>();
+            //list policy map
+            List<AutoScaleVmGroupPolicyMapVO> groupPolicymap = _asGroupPolicyDao.listByVmGroupId(groupVo.getId());
+            if (groupPolicymap == null)
+                return null;
+            for (AutoScaleVmGroupPolicyMapVO gpMap : groupPolicymap) {
+                //get duration
+                AutoScalePolicyVO policyVo = _asPolicyDao.findById(gpMap.getPolicyId());
+                Integer duration = policyVo.getDuration();
+                //get collection of counter name
+                String counterNames = "";
+                List<AutoScalePolicyConditionMapVO> lstPCmap = _asConditionMapDao.findByPolicyId(policyVo.getId());
+                for (AutoScalePolicyConditionMapVO pcMap : lstPCmap) {
+                    String counterName = getCounternamebyCondition(pcMap.getConditionId());
+
+                    counterNames += counterName + "," + pcMap.getConditionId();
+                }
+                // add to result
+                Pair<String, Integer> pair = new Pair<String, Integer>(counterNames, duration);
+                result.add(pair);
+            }
+
+            return result;
+        }
+
+        public String getCounternamebyCondition(long conditionId) {
+
+            ConditionVO condition = _asConditionDao.findById(conditionId);
+            if (condition == null)
+                return "";
+
+            long counterId = condition.getCounterid();
+            CounterVO counter = _asCounterDao.findById(counterId);
+            if (counter == null)
+                return "";
+
+            return counter.getSource().toString();
+        }
+    }
+
+    public StorageStats getStorageStats(long id) {
+        return _storageStats.get(id);
+    }
+
+    public HostStats getHostStats(long hostId) {
+        return _hostStats.get(hostId);
+    }
+
+    public StorageStats getStoragePoolStats(long id) {
+        return _storagePoolStats.get(id);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index 7a7f6b7..831fac8 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -269,8 +269,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
         return _discoverers;
     }
 
-    public void setDiscoverers(List<StoragePoolDiscoverer> _discoverers) {
-        this._discoverers = _discoverers;
+    public void setDiscoverers(List<StoragePoolDiscoverer> discoverers) {
+        this._discoverers = discoverers;
     }
 
     protected SearchBuilder<VMTemplateHostVO> HostTemplateStatesSearch;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index 18c64dd..d215858 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -382,8 +382,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
             userSpecifiedName = getRandomVolumeName();
         }
         if ((!url.toLowerCase().endsWith("vhd")) && (!url.toLowerCase().endsWith("vhd.zip")) && (!url.toLowerCase().endsWith("vhd.bz2")) &&
-            (!url.toLowerCase().endsWith("vhdx")) && (!url.toLowerCase().endsWith("vhdx.zip")) && 
-            (!url.toLowerCase().endsWith("vhdx.gz")) && (!url.toLowerCase().endsWith("vhdx.bz2")) && 
+            (!url.toLowerCase().endsWith("vhdx")) && (!url.toLowerCase().endsWith("vhdx.zip")) &&
+            (!url.toLowerCase().endsWith("vhdx.gz")) && (!url.toLowerCase().endsWith("vhdx.bz2")) &&
             (!url.toLowerCase().endsWith("vhd.gz")) && (!url.toLowerCase().endsWith("qcow2")) && (!url.toLowerCase().endsWith("qcow2.zip")) &&
             (!url.toLowerCase().endsWith("qcow2.bz2")) && (!url.toLowerCase().endsWith("qcow2.gz")) && (!url.toLowerCase().endsWith("ova")) &&
             (!url.toLowerCase().endsWith("ova.zip")) && (!url.toLowerCase().endsWith("ova.bz2")) && (!url.toLowerCase().endsWith("ova.gz")) &&
@@ -393,8 +393,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
         if ((format.equalsIgnoreCase("vhd") && (!url.toLowerCase().endsWith(".vhd") && !url.toLowerCase().endsWith("vhd.zip") && !url.toLowerCase().endsWith("vhd.bz2") && !url.toLowerCase()
             .endsWith("vhd.gz"))) ||
-            (format.equalsIgnoreCase("vhdx") && (!url.toLowerCase().endsWith(".vhdx") && !url.toLowerCase().endsWith("vhdx.zip") && !url.toLowerCase().endsWith("vhdx.bz2") && !url.toLowerCase()
-            .endsWith("vhdx.gz"))) ||
+            (format.equalsIgnoreCase("vhdx") && (!url.toLowerCase().endsWith(".vhdx") && !url.toLowerCase().endsWith("vhdx.zip") &&
+                !url.toLowerCase().endsWith("vhdx.bz2") && !url.toLowerCase()
+                .endsWith("vhdx.gz"))) ||
             (format.equalsIgnoreCase("qcow2") && (!url.toLowerCase().endsWith(".qcow2") && !url.toLowerCase().endsWith("qcow2.zip") &&
                 !url.toLowerCase().endsWith("qcow2.bz2") && !url.toLowerCase().endsWith("qcow2.gz"))) ||
             (format.equalsIgnoreCase("ova") && (!url.toLowerCase().endsWith(".ova") && !url.toLowerCase().endsWith("ova.zip") && !url.toLowerCase().endsWith("ova.bz2") && !url.toLowerCase()
@@ -632,7 +633,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
         }
 
         VolumeVO volume = commitVolume(cmd, caller, ownerId, displayVolumeEnabled, zoneId, diskOfferingId, size, minIops,
-                maxIops, parentVolume, userSpecifiedName, _uuidMgr.generateUuid(Volume.class, cmd.getCustomId()));
+            maxIops, parentVolume, userSpecifiedName, _uuidMgr.generateUuid(Volume.class, cmd.getCustomId()));
 
         return volume;
     }
@@ -740,7 +741,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
     }
 
     protected VolumeVO createVolumeFromSnapshot(VolumeVO volume, long snapshotId, Long vmId)
-            throws StorageUnavailableException {
+        throws StorageUnavailableException {
         VolumeInfo createdVolume = null;
         SnapshotVO snapshot = _snapshotDao.findById(snapshotId);
 
@@ -873,7 +874,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
         if (!shrinkOk) {
             /* Check resource limit for this account on primary storage resource */
-            _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(volume.getAccountId()), ResourceType.primary_storage, volume.isDisplayVolume(), new Long(newSize - currentSize));
+            _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(volume.getAccountId()), ResourceType.primary_storage, volume.isDisplayVolume(), new Long(newSize -
+                currentSize));
         }
 
         /*
@@ -980,7 +982,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
                     /* If volume is in primary storage, decrement primary storage count else decrement secondary
                      storage count (in case of upload volume). */
                     if (volume.getFolder() != null || volume.getPath() != null || volume.getState() == Volume.State.Allocated) {
-                        _resourceLimitMgr.decrementResourceCount(volume.getAccountId(), ResourceType.primary_storage, volume.isDisplayVolume(), new Long(volume.getSize()));
+                        _resourceLimitMgr.decrementResourceCount(volume.getAccountId(), ResourceType.primary_storage, volume.isDisplayVolume(),
+                            new Long(volume.getSize()));
                     } else {
                         _resourceLimitMgr.recalculateResourceCount(volume.getAccountId(), volume.getDomainId(), ResourceType.secondary_storage.getOrdinal());
                     }
@@ -1037,7 +1040,6 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
         return attachVolumeToVM(vmId, volumeId, deviceId);
     }
 
-
     @ActionEvent(eventType = EventTypes.EVENT_VOLUME_ATTACH, eventDescription = "attaching volume", async = true)
     public Volume attachVolumeToVM(Long vmId, Long volumeId, Long deviceId) {
         Account caller = CallContext.current().getCallingAccount();
@@ -1218,7 +1220,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
             volume.setPoolId(pool.getId());
         }
 
-        if (customId != null){
+        if (customId != null) {
             _uuidMgr.checkUuid(customId, Volume.class);
             volume.setUuid(customId);
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/server/src/com/cloud/storage/download/DownloadListener.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/download/DownloadListener.java b/server/src/com/cloud/storage/download/DownloadListener.java
index 2941b6e..4f9a560 100755
--- a/server/src/com/cloud/storage/download/DownloadListener.java
+++ b/server/src/com/cloud/storage/download/DownloadListener.java
@@ -122,7 +122,7 @@ public class DownloadListener implements Listener {
     private StatusTask _statusTask;
     private TimeoutTask _timeoutTask;
     private Date _lastUpdated = new Date();
-    private String _jobId;
+    private String jobId;
 
     private final Map<String, DownloadState> _stateMap = new HashMap<String, DownloadState>();
     private AsyncCompletionCallback<DownloadAnswer> _callback;
@@ -137,7 +137,7 @@ public class DownloadListener implements Listener {
     private VolumeService _volumeSrv;
 
     // TODO: this constructor should be the one used for template only, remove other template constructor later
-    public DownloadListener(EndPoint ssAgent, DataStore store, DataObject object, Timer _timer, DownloadMonitorImpl downloadMonitor, DownloadCommand cmd,
+    public DownloadListener(EndPoint ssAgent, DataStore store, DataObject object, Timer timer, DownloadMonitorImpl downloadMonitor, DownloadCommand cmd,
             AsyncCompletionCallback<DownloadAnswer> callback) {
         _ssAgent = ssAgent;
         this.object = object;
@@ -145,7 +145,7 @@ public class DownloadListener implements Listener {
         _cmd = cmd;
         initStateMachine();
         _currState = getState(Status.NOT_DOWNLOADED.toString());
-        this._timer = _timer;
+        this._timer = timer;
         _timeoutTask = new TimeoutTask(this);
         this._timer.schedule(_timeoutTask, 3 * STATUS_POLL_INTERVAL);
         _callback = callback;
@@ -306,8 +306,8 @@ public class DownloadListener implements Listener {
         }
     }
 
-    public void setCommand(DownloadCommand _cmd) {
-        this._cmd = _cmd;
+    public void setCommand(DownloadCommand cmd) {
+        this._cmd = cmd;
     }
 
     public DownloadCommand getCommand() {
@@ -318,12 +318,12 @@ public class DownloadListener implements Listener {
         transition(DownloadEvent.ABANDON_DOWNLOAD, null);
     }
 
-    public void setJobId(String _jobId) {
-        this._jobId = _jobId;
+    public void setJobId(String jobId) {
+        this.jobId = jobId;
     }
 
     public String getJobId() {
-        return _jobId;
+        return jobId;
     }
 
     public void scheduleStatusCheck(RequestType request) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/server/src/com/cloud/storage/download/DownloadMonitorImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/download/DownloadMonitorImpl.java b/server/src/com/cloud/storage/download/DownloadMonitorImpl.java
index d900333..33278af 100755
--- a/server/src/com/cloud/storage/download/DownloadMonitorImpl.java
+++ b/server/src/com/cloud/storage/download/DownloadMonitorImpl.java
@@ -56,7 +56,6 @@ import com.cloud.agent.api.storage.Proxy;
 import com.cloud.configuration.Config;
 import com.cloud.storage.RegisterVolumePayload;
 import com.cloud.storage.Storage.ImageFormat;
-import com.cloud.storage.VMTemplateStorageResourceAssoc;
 import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
 import com.cloud.storage.Volume;
 import com.cloud.storage.dao.VMTemplateDao;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/server/src/com/cloud/storage/listener/SnapshotStateListener.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/listener/SnapshotStateListener.java b/server/src/com/cloud/storage/listener/SnapshotStateListener.java
index 649aeff..45f0c5d 100644
--- a/server/src/com/cloud/storage/listener/SnapshotStateListener.java
+++ b/server/src/com/cloud/storage/listener/SnapshotStateListener.java
@@ -29,7 +29,6 @@ import org.apache.cloudstack.framework.events.EventBus;
 import org.apache.cloudstack.framework.events.EventBusException;
 
 import com.cloud.event.EventCategory;
-import com.cloud.server.ManagementServer;
 import com.cloud.server.ManagementService;
 import com.cloud.storage.Snapshot;
 import com.cloud.storage.Snapshot.Event;
@@ -40,7 +39,7 @@ import com.cloud.utils.fsm.StateListener;
 
 public class SnapshotStateListener implements StateListener<State, Event, SnapshotVO> {
 
-    protected static EventBus _eventBus = null;
+    protected static EventBus s_eventBus = null;
 
     private static final Logger s_logger = Logger.getLogger(VolumeStateListener.class);
 
@@ -63,7 +62,7 @@ public class SnapshotStateListener implements StateListener<State, Event, Snapsh
     private void pubishOnEventBus(String event, String status, Snapshot vo, State oldState, State newState) {
 
         try {
-            _eventBus = ComponentContext.getComponent(EventBus.class);
+            s_eventBus = ComponentContext.getComponent(EventBus.class);
         } catch (NoSuchBeanDefinitionException nbe) {
             return; // no provider is configured to provide events bus, so just return
         }
@@ -83,7 +82,7 @@ public class SnapshotStateListener implements StateListener<State, Event, Snapsh
 
         eventMsg.setDescription(eventDescription);
         try {
-            _eventBus.publish(eventMsg);
+            s_eventBus.publish(eventMsg);
         } catch (EventBusException e) {
             s_logger.warn("Failed to publish state change event on the the event bus.");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/server/src/com/cloud/storage/listener/VolumeStateListener.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/listener/VolumeStateListener.java b/server/src/com/cloud/storage/listener/VolumeStateListener.java
index cd78d4e..1ab2755 100644
--- a/server/src/com/cloud/storage/listener/VolumeStateListener.java
+++ b/server/src/com/cloud/storage/listener/VolumeStateListener.java
@@ -29,7 +29,6 @@ import org.apache.cloudstack.framework.events.EventBus;
 import org.apache.cloudstack.framework.events.EventBusException;
 
 import com.cloud.event.EventCategory;
-import com.cloud.server.ManagementServer;
 import com.cloud.server.ManagementService;
 import com.cloud.storage.Volume;
 import com.cloud.storage.Volume.Event;
@@ -39,7 +38,7 @@ import com.cloud.utils.fsm.StateListener;
 
 public class VolumeStateListener implements StateListener<State, Event, Volume> {
 
-    protected static EventBus _eventBus = null;
+    protected static EventBus s_eventBus = null;
 
     private static final Logger s_logger = Logger.getLogger(VolumeStateListener.class);
 
@@ -62,7 +61,7 @@ public class VolumeStateListener implements StateListener<State, Event, Volume>
     private void pubishOnEventBus(String event, String status, Volume vo, State oldState, State newState) {
 
         try {
-            _eventBus = ComponentContext.getComponent(EventBus.class);
+            s_eventBus = ComponentContext.getComponent(EventBus.class);
         } catch (NoSuchBeanDefinitionException nbe) {
             return; // no provider is configured to provide events bus, so just return
         }
@@ -82,7 +81,7 @@ public class VolumeStateListener implements StateListener<State, Event, Volume>
 
         eventMsg.setDescription(eventDescription);
         try {
-            _eventBus.publish(eventMsg);
+            s_eventBus.publish(eventMsg);
         } catch (EventBusException e) {
             s_logger.warn("Failed to state change event on the the event bus.");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/server/src/com/cloud/storage/resource/DummySecondaryStorageResource.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/resource/DummySecondaryStorageResource.java b/server/src/com/cloud/storage/resource/DummySecondaryStorageResource.java
index 583ad9b..ce01a69 100644
--- a/server/src/com/cloud/storage/resource/DummySecondaryStorageResource.java
+++ b/server/src/com/cloud/storage/resource/DummySecondaryStorageResource.java
@@ -159,8 +159,8 @@ public class DummySecondaryStorageResource extends ServerResourceBase implements
         return true;
     }
 
-    public void setUseServiceVm(boolean _useServiceVm) {
-        this._useServiceVm = _useServiceVm;
+    public void setUseServiceVm(boolean useServiceVm) {
+        this._useServiceVm = useServiceVm;
     }
 
     public boolean useServiceVm() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
index 5c7557f..8decfd2 100755
--- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
+++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
@@ -92,7 +92,6 @@ import com.cloud.network.dao.NetworkVO;
 import com.cloud.network.rules.RulesManager;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offering.ServiceOffering;
-import com.cloud.offerings.NetworkOfferingVO;
 import com.cloud.offerings.dao.NetworkOfferingDao;
 import com.cloud.resource.ResourceManager;
 import com.cloud.resource.ResourceStateAdapter;
@@ -168,7 +167,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
 
     private static final int STARTUP_DELAY = 60000; // 60 seconds
 
-    private int _mgmt_port = 8250;
+    private int _mgmtPort = 8250;
 
     private List<SecondaryStorageVmAllocator> _ssVmAllocators;
 
@@ -825,7 +824,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
         Map<String, String> agentMgrConfigs = _configDao.getConfiguration("AgentManager", params);
 
         value = agentMgrConfigs.get("port");
-        _mgmt_port = NumbersUtil.parseInt(value, 8250);
+        _mgmtPort = NumbersUtil.parseInt(value, 8250);
 
         _listener = new SecondaryStorageListener(this, _agentMgr);
         _agentMgr.registerForHostEvents(_listener, true, false, true);
@@ -1017,7 +1016,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
         StringBuilder buf = profile.getBootArgsBuilder();
         buf.append(" template=domP type=secstorage");
         buf.append(" host=").append(ClusterManager.ManagementHostIPAdr.value());
-        buf.append(" port=").append(_mgmt_port);
+        buf.append(" port=").append(_mgmtPort);
         buf.append(" name=").append(profile.getVirtualMachine().getHostName());
 
         buf.append(" zone=").append(dest.getDataCenter().getId());
@@ -1381,6 +1380,6 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
 
     @Inject
     public void setSecondaryStorageVmAllocators(List<SecondaryStorageVmAllocator> ssVmAllocators) {
-        this._ssVmAllocators = ssVmAllocators;
+        _ssVmAllocators = ssVmAllocators;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/be5e5cc6/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index ef89fe2..7efc24b 100755
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -1077,8 +1077,9 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
             if (snapshotType != Type.MANUAL) {
                 String msg = "Snapshot resource limit exceeded for account id : " + owner.getId() + ". Failed to create recurring snapshots";
                 s_logger.warn(msg);
-                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_UPDATE_RESOURCE_COUNT, 0L, 0L, msg, "Snapshot resource limit exceeded for account id : " + owner.getId() +
-                    ". Failed to create recurring snapshots; please use updateResourceLimit to increase the limit");
+                _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_UPDATE_RESOURCE_COUNT, 0L, 0L, msg,
+                    "Snapshot resource limit exceeded for account id : " + owner.getId() +
+                        ". Failed to create recurring snapshots; please use updateResourceLimit to increase the limit");
             }
             throw e;
         }