You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by re...@apache.org on 2016/01/17 19:14:13 UTC

[1/9] git commit: updated refs/heads/4.7 to ff89587

Repository: cloudstack
Updated Branches:
  refs/heads/4.7 7d4b3d4d8 -> ff89587fd


CLOUDSTACK-9154 - Adds test to cover nics state after GC


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/749ac2e2
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/749ac2e2
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/749ac2e2

Branch: refs/heads/4.7
Commit: 749ac2e2242d8af9f05977951dd1b4855c1f6f08
Parents: 7988f51
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Fri Dec 18 10:37:13 2015 +0100
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Tue Dec 22 14:52:05 2015 +0100

----------------------------------------------------------------------
 test/integration/smoke/test_vpc_redundant.py | 72 ++++++++++++++++-------
 1 file changed, 51 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/749ac2e2/test/integration/smoke/test_vpc_redundant.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_vpc_redundant.py b/test/integration/smoke/test_vpc_redundant.py
index 9bdf6c9..89bfb42 100644
--- a/test/integration/smoke/test_vpc_redundant.py
+++ b/test/integration/smoke/test_vpc_redundant.py
@@ -34,7 +34,8 @@ from marvin.lib.base import (stopRouter,
                              NetworkOffering,
                              Network,
                              VirtualMachine,
-                             LoadBalancerRule)
+                             LoadBalancerRule,
+                             Configurations)
 from marvin.lib.common import (get_domain,
                                get_zone,
                                get_template,
@@ -295,7 +296,7 @@ class TestVPCRedundancy(cloudstackTestCase):
             len(self.routers), count,
             "Check that %s routers were indeed created" % count)
 
-    def check_master_status(self,count=2, showall=False):
+    def check_routers_state(self,count=2, status_to_check="MASTER", expected_count=1, showall=False):
         vals = ["MASTER", "BACKUP", "UNKNOWN"]
         cnts = [0, 0, 0]
 
@@ -348,8 +349,8 @@ class TestVPCRedundancy(cloudstackTestCase):
                 if result.count(vals[0]) == 1:
                     cnts[vals.index(vals[0])] += 1
 
-        if cnts[vals.index('MASTER')] != 1:
-            self.fail("No Master or too many master routers found %s" % cnts[vals.index('MASTER')])
+        if cnts[vals.index(status_to_check)] != expected_count:
+            self.fail("Expected '%s' routers at state '%s', but found '%s'!" % (expected_count, status_to_check, cnts[vals.index('status_to_check')]))
 
     def stop_router(self, router):
         self.logger.debug('Stopping router %s' % router.id)
@@ -364,14 +365,14 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.apiclient.rebootRouter(cmd)
 
     def stop_router_by_type(self, type):
-        self.check_master_status(2)
+        self.check_routers_state()
         self.logger.debug('Stopping %s router' % type)
         for router in self.routers:
             if router.redundantstate == type:
                 self.stop_router(router)
 
     def reboot_router_by_type(self, type):
-        self.check_master_status(2)
+        self.check_routers_state()
         self.logger.debug('Rebooting %s router' % type)
         for router in self.routers:
             if router.redundantstate == type:
@@ -387,7 +388,7 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.routers = []
 
     def start_routers(self):
-        self.check_master_status(2, showall=True)
+        self.check_routers_state(showall=True)
         self.logger.debug('Starting stopped routers')
         for router in self.routers:
             self.logger.debug('Router %s has state %s' % (router.id, router.state))
@@ -397,7 +398,9 @@ class TestVPCRedundancy(cloudstackTestCase):
                 cmd.id = router.id
                 self.apiclient.startRouter(cmd)
 
-    def create_network(self, net_offerring, gateway='10.1.1.1', vpc=None):
+    def create_network(self, net_offerring, gateway='10.1.1.1', vpc=None, nr_vms=2):
+        if not nr_vms or nr_vms <= 0:
+            self.fail("At least 1 VM has to be created. You informed nr_vms < 1")
         try:
             self.logger.debug('Create NetworkOffering')
             net_offerring["name"] = "NET_OFF-" + str(gateway)
@@ -428,13 +431,13 @@ class TestVPCRedundancy(cloudstackTestCase):
             self.fail('Unable to create a Network with offering=%s because of %s ' % (net_offerring, e))
         o = networkO(obj_network)
         
-        vm1 = self.deployvm_in_network(obj_network)
-        vm2 = self.deployvm_in_network(obj_network)
+        for i in range(0, nr_vms):
+            vm1 = self.deployvm_in_network(obj_network)
+            o.add_vm(vm1)
+
         self.cleanup.insert(2, obj_network)
         self.cleanup.insert(3, nw_off)
-        
-        o.add_vm(vm1)
-        o.add_vm(vm2)
+
         return o
 
     def deployvm_in_network(self, network, host_id=None):
@@ -524,22 +527,22 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.query_routers()
         self.networks.append(self.create_network(self.services["network_offering"], "10.1.1.1"))
         self.networks.append(self.create_network(self.services["network_offering_no_lb"], "10.1.2.1"))
-        self.check_master_status(2)
+        self.check_routers_state()
         self.add_nat_rules()
         self.do_vpc_test(False)
         
         self.stop_router_by_type("MASTER")
-        self.check_master_status(1)
+        self.check_routers_state(1)
         self.do_vpc_test(False)
 
         self.delete_nat_rules()
-        self.check_master_status(1)
+        self.check_routers_state(count=1)
         self.do_vpc_test(True)
         self.delete_public_ip()
 
         self.start_routers()
         self.add_nat_rules()
-        self.check_master_status(2)
+        self.check_routers_state()
         self.do_vpc_test(False)
 
     @attr(tags=["advanced", "intervlan"], required_hardware="true")
@@ -549,7 +552,7 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.query_routers()
         self.networks.append(self.create_network(self.services["network_offering"], "10.1.1.1"))
         self.networks.append(self.create_network(self.services["network_offering_no_lb"], "10.1.2.1"))
-        self.check_master_status(2)
+        self.check_routers_state()
         self.add_nat_rules()
         self.do_default_routes_test()
     
@@ -559,18 +562,45 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.logger.debug("Starting test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL")
         self.query_routers()
         self.networks.append(self.create_network(self.services["network_offering"], "10.1.1.1"))
-        self.check_master_status(2)
+        self.check_routers_state()
         self.add_nat_rules()
         self.do_vpc_test(False)
         
         self.reboot_router_by_type("MASTER")
-        self.check_master_status(2)
+        self.check_routers_state()
         self.do_vpc_test(False)
 
         self.reboot_router_by_type("MASTER")
-        self.check_master_status(2)
+        self.check_routers_state()
+        self.do_vpc_test(False)
+
+    @attr(tags=["advanced", "intervlan"], required_hardware="true")
+    def test_04_rvpc_network_garbage_collector_nics(self):
+        """ Create a redundant VPC with 1 Tier, 1 VM, 1 ACL, 1 PF and test Network GC Nics"""
+        self.logger.debug("Starting test_04_rvpc_network_garbage_collector_nics")
+        self.query_routers()
+        self.networks.append(self.create_network(self.services["network_offering"], "10.1.1.1", nr_vms=1))
+        self.check_routers_state()
+        self.add_nat_rules()
         self.do_vpc_test(False)
 
+        self.stop_vm()
+        time.sleep(total_sleep)
+        self.check_routers_state(status_to_check="BACKUP", expected_count=2)
+        self.start_vm()
+        self.check_routers_state(status_to_check="MASTER")
+        self.do_vpc_test(False)
+
+    def stop_vm(self):
+        for o in self.networks:
+            for vm in o.get_vms():
+                vm.stop(self.apiclient)
+
+    def start_vm(self):
+        for o in self.networks:
+            for vm in o.get_vms():
+                vm.start(self.apiclient)
+
     def delete_nat_rules(self):
         for o in self.networks:
             for vm in o.get_vms():


[7/9] git commit: updated refs/heads/4.7 to ff89587

Posted by re...@apache.org.
CLOUDSTACK-9187 - Makes code ready for more something like ethXXXX, if we ever get that far

   - Adds log info to NetworkOrchestrator in order to make the work of the Net-Scavenger more visible.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/f5a6dee8
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f5a6dee8
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f5a6dee8

Branch: refs/heads/4.7
Commit: f5a6dee8dd6b89ef954d39b4ade91f8f898cc026
Parents: 2aab4c1
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Fri Dec 18 20:18:24 2015 +0100
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Tue Dec 22 14:52:07 2015 +0100

----------------------------------------------------------------------
 .../engine/orchestration/NetworkOrchestrator.java      |  6 +++++-
 .../debian/config/opt/cloud/bin/cs/CsAddress.py        | 10 ++++++----
 test/integration/smoke/test_vpc_redundant.py           | 13 +++++--------
 3 files changed, 16 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5a6dee8/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
index ca465ef..5f442b3 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
@@ -586,6 +586,8 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
     @Override
     public boolean start() {
         final int netGcInterval = NumbersUtil.parseInt(_configDao.getValue(NetworkGcInterval.key()), 60);
+        s_logger.info("Network Manager will run the NetworkGarbageCollector every '" + netGcInterval + "' seconds.");
+
         _executor.scheduleWithFixedDelay(new NetworkGarbageCollector(), netGcInterval, netGcInterval, TimeUnit.SECONDS);
         return true;
     }
@@ -2445,7 +2447,9 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                 final HashMap<Long, Long> stillFree = new HashMap<Long, Long>();
 
                 final List<Long> networkIds = _networksDao.findNetworksToGarbageCollect();
-                final int netGcWait = NumbersUtil.parseInt(_configDao.getValue(NetworkGcWait.key()), 1);
+                final int netGcWait = NumbersUtil.parseInt(_configDao.getValue(NetworkGcWait.key()), 60);
+                s_logger.info("NetworkGarbageCollector uses '" + netGcWait + "' seconds for GC interval.");
+
                 for (final Long networkId : networkIds) {
 
                     if (!_networkModel.isNetworkReadyForGc(networkId)) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5a6dee8/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
index 3eb9447..1b39b38 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
@@ -51,13 +51,15 @@ class CsAddress(CsDataBag):
         Return CsInterface object for the lowest in use guest interface
         """
         guest_interface = None
-        lowest_device = 99
+        lowest_device = 1000
         for ip in self.get_ips():
             if ip.is_guest() and ip.is_added():
-                devive_sufix = int(ip.get_device()[-1:])
-                if devive_sufix < lowest_device:
-                    lowest_device = devive_sufix
+                device = ip.get_device()
+                device_suffix = int(''.join([digit for digit in device if digit.isdigit()]))
+                if device_suffix < lowest_device:
+                    lowest_device = device_suffix
                     guest_interface = ip
+                    logging.debug("Guest interface will be set on device '%s' and IP '%s'" % (guest_interface.get_device(), guest_interface.get_ip()))
         return guest_interface
 
     def get_guest_ip(self):

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f5a6dee8/test/integration/smoke/test_vpc_redundant.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_vpc_redundant.py b/test/integration/smoke/test_vpc_redundant.py
index 2ffc938..65797e8 100644
--- a/test/integration/smoke/test_vpc_redundant.py
+++ b/test/integration/smoke/test_vpc_redundant.py
@@ -523,8 +523,7 @@ class TestVPCRedundancy(cloudstackTestCase):
                 self.fail("Failed to SSH into VM - %s" % (public_ip.ipaddress.ipaddress))
 
     @attr(tags=["advanced", "intervlan"], required_hardware="true")
-    def test_04_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL(self):
-        self.skipTest("Skipping for now...")
+    def test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL(self):
         """ Create a redundant VPC with two networks with two VMs in each network """
         self.logger.debug("Starting test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL")
         self.query_routers()
@@ -549,8 +548,7 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.do_vpc_test(False)
 
     @attr(tags=["advanced", "intervlan"], required_hardware="true")
-    def test_05_redundant_VPC_default_routes(self):
-        self.skipTest("Skipping for now...")
+    def test_02_redundant_VPC_default_routes(self):
         """ Create a redundant VPC with two networks with two VMs in each network and check default routes"""
         self.logger.debug("Starting test_02_redundant_VPC_default_routes")
         self.query_routers()
@@ -562,7 +560,6 @@ class TestVPCRedundancy(cloudstackTestCase):
     
     @attr(tags=["advanced", "intervlan"], required_hardware="true")
     def test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers(self):
-        self.skipTest("Skipping for now...")
         """ Create a redundant VPC with two networks with two VMs in each network """
         self.logger.debug("Starting test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL")
         self.query_routers()
@@ -580,7 +577,7 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.do_vpc_test(False)
 
     @attr(tags=["advanced", "intervlan"], required_hardware="true")
-    def test_01_rvpc_network_garbage_collector_nics(self):
+    def test_04_rvpc_network_garbage_collector_nics(self):
         """ Create a redundant VPC with 1 Tier, 1 VM, 1 ACL, 1 PF and test Network GC Nics"""
         self.logger.debug("Starting test_04_rvpc_network_garbage_collector_nics")
         self.query_routers()
@@ -597,7 +594,7 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.logger.debug("network.gc.wait is ==> %s" % gc_wait)
         self.logger.debug("network.gc.interval is ==> %s" % gc_wait)
 
-        total_sleep = 90
+        total_sleep = 120
         if gc_wait and gc_interval:
             total_sleep = int(gc_wait[0].value) + int(gc_interval[0].value)
         else:
@@ -611,7 +608,7 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.do_vpc_test(False)
 
     @attr(tags=["advanced", "intervlan"], required_hardware="true")
-    def test_02_rvpc_multi_tiers(self):
+    def test_05_rvpc_multi_tiers(self):
         """ Create a redundant VPC with 1 Tier, 1 VM, 1 ACL, 1 PF and test Network GC Nics"""
         self.logger.debug("Starting test_04_rvpc_network_garbage_collector_nics")
         self.query_routers()


[4/9] git commit: updated refs/heads/4.7 to ff89587

Posted by re...@apache.org.
CLOUDSTACK-9187 - Adds test to cover multiple nics and nic removal


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b1e42106
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b1e42106
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b1e42106

Branch: refs/heads/4.7
Commit: b1e421068280fe0acc427baf3e9f07dd2d610803
Parents: 749ac2e
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Fri Dec 18 18:32:29 2015 +0100
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Tue Dec 22 14:52:06 2015 +0100

----------------------------------------------------------------------
 test/integration/smoke/test_vpc_redundant.py | 84 ++++++++++++++++++-----
 1 file changed, 67 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b1e42106/test/integration/smoke/test_vpc_redundant.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_vpc_redundant.py b/test/integration/smoke/test_vpc_redundant.py
index 89bfb42..2ffc938 100644
--- a/test/integration/smoke/test_vpc_redundant.py
+++ b/test/integration/smoke/test_vpc_redundant.py
@@ -135,7 +135,7 @@ class Services:
             "vpc": {
                 "name": "TestVPC",
                 "displaytext": "TestVPC",
-                "cidr": '10.0.0.1/24'
+                "cidr": '10.0.0.0/16'
             },
             "network": {
                 "name": "Test Network",
@@ -346,11 +346,11 @@ class TestVPCRedundancy(cloudstackTestCase):
                             "Marvin configuration has no host credentials to\
                                     check router services")
             
-                if result.count(vals[0]) == 1:
-                    cnts[vals.index(vals[0])] += 1
+                if result.count(status_to_check) == 1:
+                    cnts[vals.index(status_to_check)] += 1
 
         if cnts[vals.index(status_to_check)] != expected_count:
-            self.fail("Expected '%s' routers at state '%s', but found '%s'!" % (expected_count, status_to_check, cnts[vals.index('status_to_check')]))
+            self.fail("Expected '%s' routers at state '%s', but found '%s'!" % (expected_count, status_to_check, cnts[vals.index(status_to_check)]))
 
     def stop_router(self, router):
         self.logger.debug('Stopping router %s' % router.id)
@@ -398,7 +398,7 @@ class TestVPCRedundancy(cloudstackTestCase):
                 cmd.id = router.id
                 self.apiclient.startRouter(cmd)
 
-    def create_network(self, net_offerring, gateway='10.1.1.1', vpc=None, nr_vms=2):
+    def create_network(self, net_offerring, gateway='10.1.1.1', vpc=None, nr_vms=2, mark_net_cleanup=True):
         if not nr_vms or nr_vms <= 0:
             self.fail("At least 1 VM has to be created. You informed nr_vms < 1")
         try:
@@ -430,17 +430,18 @@ class TestVPCRedundancy(cloudstackTestCase):
         except Exception, e:
             self.fail('Unable to create a Network with offering=%s because of %s ' % (net_offerring, e))
         o = networkO(obj_network)
-        
+
+        self.cleanup.insert(0, nw_off)
+        if mark_net_cleanup:
+            self.cleanup.insert(0, obj_network)
+
         for i in range(0, nr_vms):
-            vm1 = self.deployvm_in_network(obj_network)
+            vm1 = self.deployvm_in_network(obj_network, mark_vm_cleanup=mark_net_cleanup)
             o.add_vm(vm1)
 
-        self.cleanup.insert(2, obj_network)
-        self.cleanup.insert(3, nw_off)
-
         return o
 
-    def deployvm_in_network(self, network, host_id=None):
+    def deployvm_in_network(self, network, host_id=None, mark_vm_cleanup=True):
         try:
             self.logger.debug('Creating VM in network=%s' % network.name)
             vm = VirtualMachine.create(
@@ -454,7 +455,8 @@ class TestVPCRedundancy(cloudstackTestCase):
             )
 
             self.logger.debug('Created VM=%s in network=%s' % (vm.id, network.name))
-            self.cleanup.insert(0, vm)
+            if mark_vm_cleanup:
+                self.cleanup.insert(0, vm)
             return vm
         except:
             self.fail('Unable to create VM in a Network=%s' % network.name)
@@ -521,7 +523,8 @@ class TestVPCRedundancy(cloudstackTestCase):
                 self.fail("Failed to SSH into VM - %s" % (public_ip.ipaddress.ipaddress))
 
     @attr(tags=["advanced", "intervlan"], required_hardware="true")
-    def test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL(self):
+    def test_04_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL(self):
+        self.skipTest("Skipping for now...")
         """ Create a redundant VPC with two networks with two VMs in each network """
         self.logger.debug("Starting test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL")
         self.query_routers()
@@ -546,7 +549,8 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.do_vpc_test(False)
 
     @attr(tags=["advanced", "intervlan"], required_hardware="true")
-    def test_02_redundant_VPC_default_routes(self):
+    def test_05_redundant_VPC_default_routes(self):
+        self.skipTest("Skipping for now...")
         """ Create a redundant VPC with two networks with two VMs in each network and check default routes"""
         self.logger.debug("Starting test_02_redundant_VPC_default_routes")
         self.query_routers()
@@ -558,6 +562,7 @@ class TestVPCRedundancy(cloudstackTestCase):
     
     @attr(tags=["advanced", "intervlan"], required_hardware="true")
     def test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers(self):
+        self.skipTest("Skipping for now...")
         """ Create a redundant VPC with two networks with two VMs in each network """
         self.logger.debug("Starting test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACL")
         self.query_routers()
@@ -575,7 +580,7 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.do_vpc_test(False)
 
     @attr(tags=["advanced", "intervlan"], required_hardware="true")
-    def test_04_rvpc_network_garbage_collector_nics(self):
+    def test_01_rvpc_network_garbage_collector_nics(self):
         """ Create a redundant VPC with 1 Tier, 1 VM, 1 ACL, 1 PF and test Network GC Nics"""
         self.logger.debug("Starting test_04_rvpc_network_garbage_collector_nics")
         self.query_routers()
@@ -585,21 +590,66 @@ class TestVPCRedundancy(cloudstackTestCase):
         self.do_vpc_test(False)
 
         self.stop_vm()
+
+        gc_wait = Configurations.list(self.apiclient, name="network.gc.wait")
+        gc_interval = Configurations.list(self.apiclient, name="network.gc.interval")
+        
+        self.logger.debug("network.gc.wait is ==> %s" % gc_wait)
+        self.logger.debug("network.gc.interval is ==> %s" % gc_wait)
+
+        total_sleep = 90
+        if gc_wait and gc_interval:
+            total_sleep = int(gc_wait[0].value) + int(gc_interval[0].value)
+        else:
+            self.logger.debug("Could not retrieve the keys 'network.gc.interval' and 'network.gc.wait'. Sleeping for 2 minutes.")
+
         time.sleep(total_sleep)
+
         self.check_routers_state(status_to_check="BACKUP", expected_count=2)
         self.start_vm()
         self.check_routers_state(status_to_check="MASTER")
         self.do_vpc_test(False)
 
+    @attr(tags=["advanced", "intervlan"], required_hardware="true")
+    def test_02_rvpc_multi_tiers(self):
+        """ Create a redundant VPC with 1 Tier, 1 VM, 1 ACL, 1 PF and test Network GC Nics"""
+        self.logger.debug("Starting test_04_rvpc_network_garbage_collector_nics")
+        self.query_routers()
+
+        network = self.create_network(self.services["network_offering"], "10.1.1.1", nr_vms=1, mark_net_cleanup=False)
+        self.networks.append(network)
+        self.networks.append(self.create_network(self.services["network_offering_no_lb"], "10.1.2.1", nr_vms=1))
+        self.networks.append(self.create_network(self.services["network_offering_no_lb"], "10.1.3.1", nr_vms=1))
+        
+        self.check_routers_state()
+        self.add_nat_rules()
+        self.do_vpc_test(False)
+
+        self.destroy_vm(network)
+        network.get_net().delete(self.apiclient)
+        self.networks.remove(network)
+        
+        self.check_routers_state(status_to_check="MASTER")
+        self.do_vpc_test(False)
+
+    def destroy_vm(self, network):
+        vms_to_delete = []
+        for vm in network.get_vms():
+            vm.get_vm().delete(self.apiclient, expunge=True)
+            vms_to_delete.append(vm)
+
+        all_vms = network.get_vms()
+        [all_vms.remove(vm) for vm in vms_to_delete]
+
     def stop_vm(self):
         for o in self.networks:
             for vm in o.get_vms():
-                vm.stop(self.apiclient)
+                vm.get_vm().stop(self.apiclient)
 
     def start_vm(self):
         for o in self.networks:
             for vm in o.get_vms():
-                vm.start(self.apiclient)
+                vm.get_vm().start(self.apiclient)
 
     def delete_nat_rules(self):
         for o in self.networks:


[6/9] git commit: updated refs/heads/4.7 to ff89587

Posted by re...@apache.org.
CLOUDSTACK-9188 -  Reads network GC interval and wait from configDao


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/2aab4c14
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/2aab4c14
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/2aab4c14

Branch: refs/heads/4.7
Commit: 2aab4c142d47b77e7bbc584927a80b8ba180934e
Parents: c99d6f1
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Fri Dec 18 19:56:06 2015 +0100
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Tue Dec 22 14:52:07 2015 +0100

----------------------------------------------------------------------
 .../orchestration/NetworkOrchestrator.java      | 940 ++++++++++---------
 1 file changed, 472 insertions(+), 468 deletions(-)
----------------------------------------------------------------------



[9/9] git commit: updated refs/heads/4.7 to ff89587

Posted by re...@apache.org.
Merge pull request #1277 from ekholabs/fix/4.7-rvpc-net-gc-CLOUDSTACK-9154

[4.7] Critical VPCVR issues fixed: CLOUDSTACK-9154; CLOUDSTACK-9187; and CLOUDSTACK-9188This PR applies the same fixes as in the PR #1259, but against branch 4.7.

Please refer to PR #1259 for the tests results and all the comments already made there.

Issues fixed are:

* CLOUDSTACK-9154: rVPC doesn't recover from cleaning up of network garbage collector
* CLOUDSTACK-9187: rVPC routers in Master/Master due to concurrency problem when writing the keepalivd.conf
* CLOUDSTACK-9188: NetworkGarbageCollector is not using gc.interval and gc.wait from settings

Those changes have been covered by 2 new tests added to ```smoke/test_vpc_redundant.py```:

* test_04_rvpc_network_garbage_collector_nics
* test_05_rvpc_multi_tiers

The test ```test_04_rvpc_network_garbage_collector_nics``` depends on the global settings for the network.gc.interval and gc.wait. If one wants the test to run quicker, please change the settings (default is 600 seconds for each) and restart the Management Server before running the tests. I would suggest to set it to 60 seconds.

In addition, the NetworkGarbageCollector was redefining the settings above mentioned and not reading their values through ConfigDao. Due to that, the settings were not being applied properly and the test was waiting to long to check the VPC routers.

* pr/1277:
  CLOUDSTACK-9154 - Sets the pub interface down when all guest nets are gone
  CLOUDSTACK-9187 - Makes code ready for more something like ethXXXX, if we ever get that far
  CLOUDSTACK-9188 -  Reads network GC interval and wait from configDao
  CLOUDSTACK-9187 - Fixes interface allocation to VRRP instances
  CLOUDSTACK-9187 - Adds test to cover multiple nics and nic removal
  CLOUDSTACK-9154 - Adds test to cover nics state after GC
  CLOUDSTACK-9154 - Returns the guest iterface that is marked as added

Signed-off-by: Remi Bergsma <gi...@remi.nl>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ff89587f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ff89587f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ff89587f

Branch: refs/heads/4.7
Commit: ff89587fd119b1cad543d8e96f0c428e41c35840
Parents: 7d4b3d4 5ef3144
Author: Remi Bergsma <gi...@remi.nl>
Authored: Sun Jan 17 19:12:42 2016 +0100
Committer: Remi Bergsma <gi...@remi.nl>
Committed: Sun Jan 17 19:12:43 2016 +0100

----------------------------------------------------------------------
 .../orchestration/NetworkOrchestrator.java      | 944 ++++++++++---------
 .../debian/config/opt/cloud/bin/cs/CsAddress.py |  21 +-
 .../config/opt/cloud/bin/cs/CsRedundant.py      |  70 +-
 test/integration/smoke/test_vpc_redundant.py    | 134 ++-
 4 files changed, 637 insertions(+), 532 deletions(-)
----------------------------------------------------------------------



[8/9] git commit: updated refs/heads/4.7 to ff89587

Posted by re...@apache.org.
CLOUDSTACK-9154 - Sets the pub interface down when all guest nets are gone

   - Refactors the set_backup, set_master and set_fault methods to have better names for the variable
   - Increase the sleep on the test in order to wait for the routers to be ready. It's now 3 times the GC settings


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5ef3144f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5ef3144f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5ef3144f

Branch: refs/heads/4.7
Commit: 5ef3144fdf65922a3da99357c6f90f3811b231d8
Parents: f5a6dee
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Sat Dec 19 11:21:18 2015 +0100
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Tue Dec 22 14:52:08 2015 +0100

----------------------------------------------------------------------
 .../config/opt/cloud/bin/cs/CsRedundant.py      | 48 ++++++++++++--------
 test/integration/smoke/test_vpc_redundant.py    |  3 +-
 2 files changed, 29 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5ef3144f/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
index 84771ce..77d0a6b 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
@@ -84,6 +84,7 @@ class CsRedundant(object):
 
         # No redundancy if there is no guest network
         if guest is None:
+            self.set_backup()
             self._redundant_off()
             return
 
@@ -226,17 +227,21 @@ class CsRedundant(object):
 
         self.set_lock()
         logging.info("Router switched to fault mode")
-        ads = [o for o in self.address.get_ips() if o.is_public()]
-        for o in ads:
-            CsHelper.execute("ifconfig %s down" % o.get_device())
+
+        ips = [ip for ip in self.address.get_ips() if ip.is_public()]
+        for ip in ips:
+            CsHelper.execute("ifconfig %s down" % ip.get_device())
+
         cmd = "%s -C %s" % (self.CONNTRACKD_BIN, self.CONNTRACKD_CONF)
         CsHelper.execute("%s -s" % cmd)
         CsHelper.service("ipsec", "stop")
         CsHelper.service("xl2tpd", "stop")
         CsHelper.service("dnsmasq", "stop")
-        ads = [o for o in self.address.get_ips() if o.needs_vrrp()]
-        for o in ads:
-            CsPasswdSvc(o.get_gateway()).stop()
+
+        ips = [ip for ip in self.address.get_ips() if ip.needs_vrrp()]
+        for ip in ips:
+            CsPasswdSvc(ip.get_gateway()).stop()
+
         self.cl.set_fault_state()
         self.cl.save()
         self.release_lock()
@@ -250,22 +255,25 @@ class CsRedundant(object):
 
         self.set_lock()
         logging.debug("Setting router to backup")
-        ads = [o for o in self.address.get_ips() if o.is_public()]
+
         dev = ''
-        for o in ads:
-            if dev == o.get_device():
+        ips = [ip for ip in self.address.get_ips() if ip.is_public()]
+        for ip in ips:
+            if dev == ip.get_device():
                 continue
-            logging.info("Bringing public interface %s down" % o.get_device())
-            cmd2 = "ip link set %s down" % o.get_device()
+            logging.info("Bringing public interface %s down" % ip.get_device())
+            cmd2 = "ip link set %s down" % ip.get_device()
             CsHelper.execute(cmd2)
-            dev = o.get_device()
+            dev = ip.get_device()
+
         cmd = "%s -C %s" % (self.CONNTRACKD_BIN, self.CONNTRACKD_CONF)
         CsHelper.execute("%s -d" % cmd)
         CsHelper.service("ipsec", "stop")
         CsHelper.service("xl2tpd", "stop")
-        ads = [o for o in self.address.get_ips() if o.needs_vrrp()]
-        for o in ads:
-            CsPasswdSvc(o.get_gateway()).stop()
+
+        ips = [ip for ip in self.address.get_ips() if ip.needs_vrrp()]
+        for ip in ips:
+            CsPasswdSvc(ip.get_gateway()).stop()
         CsHelper.service("dnsmasq", "stop")
 
         self.cl.set_master_state(False)
@@ -282,13 +290,13 @@ class CsRedundant(object):
         self.set_lock()
         logging.debug("Setting router to master")
 
-        ads = [o for o in self.address.get_ips() if o.is_public()]
         dev = ''
+        ips = [ip for ip in self.address.get_ips() if ip.is_public()]
         route = CsRoute()
-        for o in ads:
-            if dev == o.get_device():
+        for ip in ips:
+            if dev == ip.get_device():
                 continue
-            dev = o.get_device()
+            dev = ip.get_device()
             logging.info("Will proceed configuring device ==> %s" % dev)
             cmd2 = "ip link set %s up" % dev
             if CsDevice(dev, self.config).waitfordevice():
@@ -296,7 +304,7 @@ class CsRedundant(object):
                 logging.info("Bringing public interface %s up" % dev)
 
                 try:
-                    gateway = o.get_gateway()
+                    gateway = ip.get_gateway()
                     logging.info("Adding gateway ==> %s to device ==> %s" % (gateway, dev))
                     route.add_defaultroute(gateway)
                 except:

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5ef3144f/test/integration/smoke/test_vpc_redundant.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_vpc_redundant.py b/test/integration/smoke/test_vpc_redundant.py
index 65797e8..fbaa5b9 100644
--- a/test/integration/smoke/test_vpc_redundant.py
+++ b/test/integration/smoke/test_vpc_redundant.py
@@ -600,12 +600,11 @@ class TestVPCRedundancy(cloudstackTestCase):
         else:
             self.logger.debug("Could not retrieve the keys 'network.gc.interval' and 'network.gc.wait'. Sleeping for 2 minutes.")
 
-        time.sleep(total_sleep)
+        time.sleep(total_sleep * 3)
 
         self.check_routers_state(status_to_check="BACKUP", expected_count=2)
         self.start_vm()
         self.check_routers_state(status_to_check="MASTER")
-        self.do_vpc_test(False)
 
     @attr(tags=["advanced", "intervlan"], required_hardware="true")
     def test_05_rvpc_multi_tiers(self):


[3/9] git commit: updated refs/heads/4.7 to ff89587

Posted by re...@apache.org.
CLOUDSTACK-9187 - Fixes interface allocation to VRRP instances


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c99d6f18
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c99d6f18
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c99d6f18

Branch: refs/heads/4.7
Commit: c99d6f18c9fccdc44698a30af1b20701a2e85df4
Parents: b1e4210
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Fri Dec 18 18:36:02 2015 +0100
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Tue Dec 22 14:52:06 2015 +0100

----------------------------------------------------------------------
 .../debian/config/opt/cloud/bin/cs/CsAddress.py       | 14 ++++++++------
 .../debian/config/opt/cloud/bin/cs/CsRedundant.py     | 11 +++++++----
 2 files changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c99d6f18/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
index d320d0a..3eb9447 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
@@ -48,15 +48,17 @@ class CsAddress(CsDataBag):
 
     def get_guest_if(self):
         """
-        Return CsInterface object for the lowest guest interface
+        Return CsInterface object for the lowest in use guest interface
         """
-        ipr = []
+        guest_interface = None
+        lowest_device = 99
         for ip in self.get_ips():
             if ip.is_guest() and ip.is_added():
-                ipr.append(ip)
-        if len(ipr) > 0:
-            return sorted(ipr)[-1]
-        return None
+                devive_sufix = int(ip.get_device()[-1:])
+                if devive_sufix < lowest_device:
+                    lowest_device = devive_sufix
+                    guest_interface = ip
+        return guest_interface
 
     def get_guest_ip(self):
         """

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c99d6f18/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
index f975871..84771ce 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
@@ -81,6 +81,7 @@ class CsRedundant(object):
 
     def _redundant_on(self):
         guest = self.address.get_guest_if()
+
         # No redundancy if there is no guest network
         if guest is None:
             self._redundant_off()
@@ -344,13 +345,15 @@ class CsRedundant(object):
         that could function as a router and VPC router at the same time
         """
         lines = []
-        for o in self.address.get_ips():
-            if o.needs_vrrp():
+        for ip in self.address.get_ips():
+            if ip.needs_vrrp():
                 cmdline=self.config.get_cmdline_instance()
+                if not ip.is_added():
+                    continue
                 if(cmdline.get_type()=='router'):
-                    str = "        %s brd %s dev %s\n" % (cmdline.get_guest_gw(), o.get_broadcast(), o.get_device())
+                    str = "        %s brd %s dev %s\n" % (cmdline.get_guest_gw(), ip.get_broadcast(), ip.get_device())
                 else:
-                    str = "        %s brd %s dev %s\n" % (o.get_gateway_cidr(), o.get_broadcast(), o.get_device())
+                    str = "        %s brd %s dev %s\n" % (ip.get_gateway_cidr(), ip.get_broadcast(), ip.get_device())
                 lines.append(str)
         return lines
 


[5/9] git commit: updated refs/heads/4.7 to ff89587

Posted by re...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2aab4c14/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
index d99c9ef..ca465ef 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
@@ -167,6 +167,7 @@ import com.cloud.user.Account;
 import com.cloud.user.ResourceLimitService;
 import com.cloud.user.User;
 import com.cloud.user.dao.AccountDao;
+import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.utils.component.AdapterBase;
 import com.cloud.utils.component.ManagerBase;
@@ -269,7 +270,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         return networkGurus;
     }
 
-    public void setNetworkGurus(List<NetworkGuru> networkGurus) {
+    public void setNetworkGurus(final List<NetworkGuru> networkGurus) {
         this.networkGurus = networkGurus;
     }
 
@@ -279,7 +280,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         return networkElements;
     }
 
-    public void setNetworkElements(List<NetworkElement> networkElements) {
+    public void setNetworkElements(final List<NetworkElement> networkElements) {
         this.networkElements = networkElements;
     }
 
@@ -292,7 +293,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         return ipDeployers;
     }
 
-    public void setIpDeployers(List<IpDeployer> ipDeployers) {
+    public void setIpDeployers(final List<IpDeployer> ipDeployers) {
         this.ipDeployers = ipDeployers;
     }
 
@@ -302,7 +303,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         return _dhcpProviders;
     }
 
-    public void setDhcpProviders(List<DhcpServiceProvider> dhcpProviders) {
+    public void setDhcpProviders(final List<DhcpServiceProvider> dhcpProviders) {
         _dhcpProviders = dhcpProviders;
     }
 
@@ -361,7 +362,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
     public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
         // populate providers
         final Map<Network.Service, Set<Network.Provider>> defaultSharedNetworkOfferingProviders = new HashMap<Network.Service, Set<Network.Provider>>();
-        Set<Network.Provider> defaultProviders = new HashSet<Network.Provider>();
+        final Set<Network.Provider> defaultProviders = new HashSet<Network.Provider>();
 
         defaultProviders.add(Network.Provider.VirtualRouter);
         defaultSharedNetworkOfferingProviders.put(Service.Dhcp, defaultProviders);
@@ -383,7 +384,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         defaultSharedSGEnabledNetworkOfferingProviders.put(Service.Dhcp, defaultProviders);
         defaultSharedSGEnabledNetworkOfferingProviders.put(Service.Dns, defaultProviders);
         defaultSharedSGEnabledNetworkOfferingProviders.put(Service.UserData, defaultProviders);
-        Set<Provider> sgProviders = new HashSet<Provider>();
+        final Set<Provider> sgProviders = new HashSet<Provider>();
         sgProviders.add(Provider.SecurityGroupProvider);
         defaultSharedSGEnabledNetworkOfferingProviders.put(Service.SecurityGroup, sgProviders);
 
@@ -417,7 +418,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
 
         Transaction.execute(new TransactionCallbackNoReturn() {
             @Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public void doInTransactionWithoutResult(final TransactionStatus status) {
                 NetworkOfferingVO offering = null;
                 //#1 - quick cloud network offering
                 if (_networkOfferingDao.findByUniqueName(NetworkOffering.QuickCloudNoServices) == null) {
@@ -487,11 +488,11 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                 }
 
                 //#8 - network offering with internal lb service
-                Map<Network.Service, Set<Network.Provider>> internalLbOffProviders = new HashMap<Network.Service, Set<Network.Provider>>();
-                Set<Network.Provider> defaultVpcProvider = new HashSet<Network.Provider>();
+                final Map<Network.Service, Set<Network.Provider>> internalLbOffProviders = new HashMap<Network.Service, Set<Network.Provider>>();
+                final Set<Network.Provider> defaultVpcProvider = new HashSet<Network.Provider>();
                 defaultVpcProvider.add(Network.Provider.VPCVirtualRouter);
 
-                Set<Network.Provider> defaultInternalLbProvider = new HashSet<Network.Provider>();
+                final Set<Network.Provider> defaultInternalLbProvider = new HashSet<Network.Provider>();
                 defaultInternalLbProvider.add(Network.Provider.InternalLbVm);
 
                 internalLbOffProviders.put(Service.Dhcp, defaultVpcProvider);
@@ -512,12 +513,12 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                     _networkOfferingDao.update(offering.getId(), offering);
                 }
 
-                Map<Network.Service, Set<Network.Provider>> netscalerServiceProviders = new HashMap<Network.Service, Set<Network.Provider>>();
-                Set<Network.Provider> vrProvider = new HashSet<Network.Provider>();
+                final Map<Network.Service, Set<Network.Provider>> netscalerServiceProviders = new HashMap<Network.Service, Set<Network.Provider>>();
+                final Set<Network.Provider> vrProvider = new HashSet<Network.Provider>();
                 vrProvider.add(Provider.VirtualRouter);
-                Set<Network.Provider> sgProvider = new HashSet<Network.Provider>();
+                final Set<Network.Provider> sgProvider = new HashSet<Network.Provider>();
                 sgProvider.add(Provider.SecurityGroupProvider);
-                Set<Network.Provider> nsProvider = new HashSet<Network.Provider>();
+                final Set<Network.Provider> nsProvider = new HashSet<Network.Provider>();
                 nsProvider.add(Provider.Netscaler);
                 netscalerServiceProviders.put(Service.Dhcp, vrProvider);
                 netscalerServiceProviders.put(Service.Dns, vrProvider);
@@ -526,10 +527,10 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                 netscalerServiceProviders.put(Service.StaticNat, nsProvider);
                 netscalerServiceProviders.put(Service.Lb, nsProvider);
 
-                Map<Service, Map<Capability, String>> serviceCapabilityMap = new HashMap<Service, Map<Capability, String>>();
-                Map<Capability, String> elb = new HashMap<Capability, String>();
+                final Map<Service, Map<Capability, String>> serviceCapabilityMap = new HashMap<Service, Map<Capability, String>>();
+                final Map<Capability, String> elb = new HashMap<Capability, String>();
                 elb.put(Capability.ElasticLb, "true");
-                Map<Capability, String> eip = new HashMap<Capability, String>();
+                final Map<Capability, String> eip = new HashMap<Capability, String>();
                 eip.put(Capability.ElasticIp, "true");
                 serviceCapabilityMap.put(Service.Lb, elb);
                 serviceCapabilityMap.put(Service.StaticNat, eip);
@@ -549,7 +550,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         AssignIpAddressSearch.and("dc", AssignIpAddressSearch.entity().getDataCenterId(), Op.EQ);
         AssignIpAddressSearch.and("allocated", AssignIpAddressSearch.entity().getAllocatedTime(), Op.NULL);
         AssignIpAddressSearch.and("vlanId", AssignIpAddressSearch.entity().getVlanId(), Op.IN);
-        SearchBuilder<VlanVO> vlanSearch = _vlanDao.createSearchBuilder();
+        final SearchBuilder<VlanVO> vlanSearch = _vlanDao.createSearchBuilder();
         vlanSearch.and("type", vlanSearch.entity().getVlanType(), Op.EQ);
         vlanSearch.and("networkId", vlanSearch.entity().getNetworkId(), Op.EQ);
         AssignIpAddressSearch.join("vlan", vlanSearch, vlanSearch.entity().getId(), AssignIpAddressSearch.entity().getVlanId(), JoinType.INNER);
@@ -560,10 +561,10 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         AssignIpAddressFromPodVlanSearch.and("allocated", AssignIpAddressFromPodVlanSearch.entity().getAllocatedTime(), Op.NULL);
         AssignIpAddressFromPodVlanSearch.and("vlanId", AssignIpAddressFromPodVlanSearch.entity().getVlanId(), Op.IN);
 
-        SearchBuilder<VlanVO> podVlanSearch = _vlanDao.createSearchBuilder();
+        final SearchBuilder<VlanVO> podVlanSearch = _vlanDao.createSearchBuilder();
         podVlanSearch.and("type", podVlanSearch.entity().getVlanType(), Op.EQ);
         podVlanSearch.and("networkId", podVlanSearch.entity().getNetworkId(), Op.EQ);
-        SearchBuilder<PodVlanMapVO> podVlanMapSB = _podVlanMapDao.createSearchBuilder();
+        final SearchBuilder<PodVlanMapVO> podVlanMapSB = _podVlanMapDao.createSearchBuilder();
         podVlanMapSB.and("podId", podVlanMapSB.entity().getPodId(), Op.EQ);
         AssignIpAddressFromPodVlanSearch.join("podVlanMapSB", podVlanMapSB, podVlanMapSB.entity().getVlanDbId(), AssignIpAddressFromPodVlanSearch.entity().getVlanId(),
                 JoinType.INNER);
@@ -584,7 +585,8 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
 
     @Override
     public boolean start() {
-        _executor.scheduleWithFixedDelay(new NetworkGarbageCollector(), NetworkGcInterval.value(), NetworkGcInterval.value(), TimeUnit.SECONDS);
+        final int netGcInterval = NumbersUtil.parseInt(_configDao.getValue(NetworkGcInterval.key()), 60);
+        _executor.scheduleWithFixedDelay(new NetworkGarbageCollector(), netGcInterval, netGcInterval, TimeUnit.SECONDS);
         return true;
     }
 
@@ -598,7 +600,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
     }
 
     @Override
-    public List<? extends Network> setupNetwork(Account owner, NetworkOffering offering, DeploymentPlan plan, String name, String displayText, boolean isDefault)
+    public List<? extends Network> setupNetwork(final Account owner, final NetworkOffering offering, final DeploymentPlan plan, final String name, final String displayText, final boolean isDefault)
             throws ConcurrentOperationException {
         return setupNetwork(owner, offering, null, plan, name, displayText, false, null, null, null, null, true);
     }
@@ -606,27 +608,27 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
     @Override
     @DB
     public List<? extends Network> setupNetwork(final Account owner, final NetworkOffering offering, final Network predefined, final DeploymentPlan plan, final String name,
-            final String displayText, boolean errorIfAlreadySetup, final Long domainId, final ACLType aclType, final Boolean subdomainAccess, final Long vpcId,
+            final String displayText, final boolean errorIfAlreadySetup, final Long domainId, final ACLType aclType, final Boolean subdomainAccess, final Long vpcId,
             final Boolean isDisplayNetworkEnabled) throws ConcurrentOperationException {
 
-        Account locked = _accountDao.acquireInLockTable(owner.getId());
+        final Account locked = _accountDao.acquireInLockTable(owner.getId());
         if (locked == null) {
             throw new ConcurrentOperationException("Unable to acquire lock on " + owner);
         }
 
         try {
             if (predefined == null
-                    || (offering.getTrafficType() != TrafficType.Guest && predefined.getCidr() == null && predefined.getBroadcastUri() == null && !(predefined
+                    || offering.getTrafficType() != TrafficType.Guest && predefined.getCidr() == null && predefined.getBroadcastUri() == null && !(predefined
                             .getBroadcastDomainType() == BroadcastDomainType.Vlan || predefined.getBroadcastDomainType() == BroadcastDomainType.Lswitch || predefined
-                            .getBroadcastDomainType() == BroadcastDomainType.Vxlan))) {
-                List<NetworkVO> configs = _networksDao.listBy(owner.getId(), offering.getId(), plan.getDataCenterId());
+                            .getBroadcastDomainType() == BroadcastDomainType.Vxlan)) {
+                final List<NetworkVO> configs = _networksDao.listBy(owner.getId(), offering.getId(), plan.getDataCenterId());
                 if (configs.size() > 0) {
                     if (s_logger.isDebugEnabled()) {
                         s_logger.debug("Found existing network configuration for offering " + offering + ": " + configs.get(0));
                     }
 
                     if (errorIfAlreadySetup) {
-                        InvalidParameterValueException ex = new InvalidParameterValueException(
+                        final InvalidParameterValueException ex = new InvalidParameterValueException(
                                 "Found existing network configuration (with specified id) for offering (with specified id)");
                         ex.addProxyObject(offering.getUuid(), "offeringId");
                         ex.addProxyObject(configs.get(0).getUuid(), "networkConfigId");
@@ -664,8 +666,8 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                 final long relatedFile = related;
                 Transaction.execute(new TransactionCallbackNoReturn() {
                     @Override
-                    public void doInTransactionWithoutResult(TransactionStatus status) {
-                        NetworkVO vo = new NetworkVO(id, network, offering.getId(), guru.getName(), owner.getDomainId(), owner.getId(), relatedFile, name, displayText, predefined
+                    public void doInTransactionWithoutResult(final TransactionStatus status) {
+                        final NetworkVO vo = new NetworkVO(id, network, offering.getId(), guru.getName(), owner.getDomainId(), owner.getId(), relatedFile, name, displayText, predefined
                                 .getNetworkDomain(), offering.getGuestType(), plan.getDataCenterId(), plan.getPhysicalNetworkId(), aclType, offering.getSpecifyIpRanges(),
                                 vpcId, offering.getRedundantRouter());
                         vo.setDisplayNetwork(isDisplayNetworkEnabled == null ? true : isDisplayNetworkEnabled);
@@ -682,7 +684,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
 
             if (networks.size() < 1) {
                 // see networkOfferingVO.java
-                CloudRuntimeException ex = new CloudRuntimeException("Unable to convert network offering with specified id to network profile");
+                final CloudRuntimeException ex = new CloudRuntimeException("Unable to convert network offering with specified id to network profile");
                 ex.addProxyObject(offering.getUuid(), "offeringId");
                 throw ex;
             }
@@ -701,11 +703,11 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
 
         Transaction.execute(new TransactionCallbackWithExceptionNoReturn<InsufficientCapacityException>() {
             @Override
-            public void doInTransactionWithoutResult(TransactionStatus status) throws InsufficientCapacityException {
+            public void doInTransactionWithoutResult(final TransactionStatus status) throws InsufficientCapacityException {
                 int deviceId = 0;
                 int size = 0;
-                for (Network ntwk : networks.keySet()) {
-                    List<? extends NicProfile> profiles = networks.get(ntwk);
+                for (final Network ntwk : networks.keySet()) {
+                    final List<? extends NicProfile> profiles = networks.get(ntwk);
                     if (profiles != null && !profiles.isEmpty()) {
                         size = size + profiles.size();
                     } else {
@@ -713,14 +715,14 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                     }
                 }
 
-                boolean[] deviceIds = new boolean[size];
+                final boolean[] deviceIds = new boolean[size];
                 Arrays.fill(deviceIds, false);
 
-                List<NicProfile> nics = new ArrayList<NicProfile>(size);
+                final List<NicProfile> nics = new ArrayList<NicProfile>(size);
                 NicProfile defaultNic = null;
 
-                for (Map.Entry<? extends Network, List<? extends NicProfile>> network : networks.entrySet()) {
-                    Network config = network.getKey();
+                for (final Map.Entry<? extends Network, List<? extends NicProfile>> network : networks.entrySet()) {
+                    final Network config = network.getKey();
                     List<? extends NicProfile> requestedProfiles = network.getValue();
                     if (requestedProfiles == null) {
                         requestedProfiles = new ArrayList<NicProfile>();
@@ -729,9 +731,9 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                         requestedProfiles.add(null);
                     }
 
-                    for (NicProfile requested : requestedProfiles) {
+                    for (final NicProfile requested : requestedProfiles) {
                         Boolean isDefaultNic = false;
-                        if (vm != null && (requested != null && requested.isDefaultNic())) {
+                        if (vm != null && requested != null && requested.isDefaultNic()) {
                             isDefaultNic = true;
                         }
 
@@ -739,7 +741,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                             deviceId++;
                         }
 
-                        Pair<NicProfile, Integer> vmNicPair = allocateNic(requested, config, isDefaultNic, deviceId, vm);
+                        final Pair<NicProfile, Integer> vmNicPair = allocateNic(requested, config, isDefaultNic, deviceId, vm);
                         NicProfile vmNic = null;
                         if (vmNicPair != null) {
                             vmNic = vmNicPair.first();
@@ -749,7 +751,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                             deviceId = vmNicPair.second();
                         }
 
-                        int devId = vmNic.getDeviceId();
+                        final int devId = vmNic.getDeviceId();
                         if (devId > deviceIds.length) {
                             throw new IllegalArgumentException("Device id for nic is too large: " + vmNic);
                         }
@@ -784,17 +786,17 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
 
     @DB
     @Override
-    public Pair<NicProfile, Integer> allocateNic(NicProfile requested, Network network, Boolean isDefaultNic, int deviceId, VirtualMachineProfile vm)
+    public Pair<NicProfile, Integer> allocateNic(final NicProfile requested, final Network network, final Boolean isDefaultNic, int deviceId, final VirtualMachineProfile vm)
             throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException {
 
-        NetworkVO ntwkVO = _networksDao.findById(network.getId());
+        final NetworkVO ntwkVO = _networksDao.findById(network.getId());
         s_logger.debug("Allocating nic for vm " + vm.getVirtualMachine() + " in network " + network + " with requested profile " + requested);
-        NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, ntwkVO.getGuruName());
+        final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, ntwkVO.getGuruName());
 
         if (requested != null && requested.getMode() == null) {
             requested.setMode(network.getMode());
         }
-        NicProfile profile = guru.allocate(network, requested, vm);
+        final NicProfile profile = guru.allocate(network, requested, vm);
         if (profile == null) {
             return null;
         }
@@ -815,14 +817,14 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
 
         vo = _nicDao.persist(vo);
 
-        Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId());
-        NicProfile vmNic = new NicProfile(vo, network, vo.getBroadcastUri(), vo.getIsolationUri(), networkRate, _networkModel.isSecurityGroupSupportedInNetwork(network),
+        final Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId());
+        final NicProfile vmNic = new NicProfile(vo, network, vo.getBroadcastUri(), vo.getIsolationUri(), networkRate, _networkModel.isSecurityGroupSupportedInNetwork(network),
                 _networkModel.getNetworkTag(vm.getHypervisorType(), network));
 
         return new Pair<NicProfile, Integer>(vmNic, Integer.valueOf(deviceId));
     }
 
-    protected Integer applyProfileToNic(NicVO vo, NicProfile profile, Integer deviceId) {
+    protected Integer applyProfileToNic(final NicVO vo, final NicProfile profile, Integer deviceId) {
         if (profile.getDeviceId() != null) {
             vo.setDeviceId(profile.getDeviceId());
         } else if (deviceId != null) {
@@ -863,7 +865,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         return deviceId;
     }
 
-    protected void applyProfileToNicForRelease(NicVO vo, NicProfile profile) {
+    protected void applyProfileToNicForRelease(final NicVO vo, final NicProfile profile) {
         vo.setIPv4Gateway(profile.getIPv4Gateway());
         vo.setAddressFormat(profile.getFormat());
         vo.setIPv4Address(profile.getIPv4Address());
@@ -877,15 +879,15 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         vo.setIPv4Netmask(profile.getIPv4Netmask());
     }
 
-    protected void applyProfileToNetwork(NetworkVO network, NetworkProfile profile) {
+    protected void applyProfileToNetwork(final NetworkVO network, final NetworkProfile profile) {
         network.setBroadcastUri(profile.getBroadcastUri());
         network.setDns1(profile.getDns1());
         network.setDns2(profile.getDns2());
         network.setPhysicalNetworkId(profile.getPhysicalNetworkId());
     }
 
-    protected NicTO toNicTO(NicVO nic, NicProfile profile, NetworkVO config) {
-        NicTO to = new NicTO();
+    protected NicTO toNicTO(final NicVO nic, final NicProfile profile, final NetworkVO config) {
+        final NicTO to = new NicTO();
         to.setDeviceId(nic.getDeviceId());
         to.setBroadcastType(config.getBroadcastDomainType());
         to.setType(config.getTrafficType());
@@ -910,7 +912,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
             to.setDns2(profile.getIPv4Dns2());
         }
 
-        Integer networkRate = _networkModel.getNetworkRate(config.getId(), null);
+        final Integer networkRate = _networkModel.getNetworkRate(config.getId(), null);
         to.setNetworkRateMbps(networkRate);
 
         to.setUuid(config.getUuid());
@@ -918,20 +920,20 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         return to;
     }
 
-    boolean isNetworkImplemented(NetworkVO network) {
-        Network.State state = network.getState();
+    boolean isNetworkImplemented(final NetworkVO network) {
+        final Network.State state = network.getState();
         if (state == Network.State.Implemented) {
             return true;
         } else if (state == Network.State.Setup) {
-            DataCenterVO zone = _dcDao.findById(network.getDataCenterId());
-            if (!isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()) || (zone.getNetworkType() == NetworkType.Basic)) {
+            final DataCenterVO zone = _dcDao.findById(network.getDataCenterId());
+            if (!isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()) || zone.getNetworkType() == NetworkType.Basic) {
                 return true;
             }
         }
         return false;
     }
 
-    Pair<NetworkGuru, NetworkVO> implementNetwork(long networkId, DeployDestination dest, ReservationContext context, boolean isRouter) throws ConcurrentOperationException,
+    Pair<NetworkGuru, NetworkVO> implementNetwork(final long networkId, final DeployDestination dest, final ReservationContext context, final boolean isRouter) throws ConcurrentOperationException,
     ResourceUnavailableException, InsufficientCapacityException {
         Pair<NetworkGuru, NetworkVO> implemented = null;
         if (!isRouter) {
@@ -942,8 +944,8 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
             // preparing VR nics. This flow creates issues in dealing with network state transitions. The original call
             // puts network in "Implementing" state and then the nested call again tries to put it into same state resulting
             // in issues. In order to avoid it, implementNetwork() call for VR is replaced with below code.
-            NetworkVO network = _networksDao.findById(networkId);
-            NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
+            final NetworkVO network = _networksDao.findById(networkId);
+            final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
             implemented = new Pair<NetworkGuru, NetworkVO>(guru, network);
         }
         return implemented;
@@ -951,12 +953,12 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
 
     @Override
     @DB
-    public Pair<NetworkGuru, NetworkVO> implementNetwork(long networkId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
+    public Pair<NetworkGuru, NetworkVO> implementNetwork(final long networkId, final DeployDestination dest, final ReservationContext context) throws ConcurrentOperationException,
     ResourceUnavailableException, InsufficientCapacityException {
-        Pair<NetworkGuru, NetworkVO> implemented = new Pair<NetworkGuru, NetworkVO>(null, null);
+        final Pair<NetworkGuru, NetworkVO> implemented = new Pair<NetworkGuru, NetworkVO>(null, null);
 
         NetworkVO network = _networksDao.findById(networkId);
-        NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
+        final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
         if (isNetworkImplemented(network)) {
             s_logger.debug("Network id=" + networkId + " is already implemented");
             implemented.set(guru, network);
@@ -967,7 +969,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         network = _networksDao.acquireInLockTable(networkId, NetworkLockTimeout.value());
         if (network == null) {
             // see NetworkVO.java
-            ConcurrentOperationException ex = new ConcurrentOperationException("Unable to acquire network configuration");
+            final ConcurrentOperationException ex = new ConcurrentOperationException("Unable to acquire network configuration");
             ex.addProxyObject(_entityMgr.findById(Network.class, networkId).getUuid());
             throw ex;
         }
@@ -987,7 +989,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                 s_logger.debug("Asking " + guru.getName() + " to implement " + network);
             }
 
-            NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
+            final NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
 
             network.setReservationId(context.getReservationId());
             if (isSharedNetworkWithServices(network)) {
@@ -996,7 +998,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                 stateTransitTo(network, Event.ImplementNetwork);
             }
 
-            Network result = guru.implement(network, offering, dest, context);
+            final Network result = guru.implement(network, offering, dest, context);
             network.setCidr(result.getCidr());
             network.setBroadcastUri(result.getBroadcastUri());
             network.setGateway(result.getGateway());
@@ -1017,7 +1019,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
             _networksDao.update(network.getId(), network);
             implemented.set(guru, network);
             return implemented;
-        } catch (NoTransitionException e) {
+        } catch (final NoTransitionException e) {
             s_logger.error(e.getMessage());
             return null;
         } finally {
@@ -1030,13 +1032,13 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                     } else {
                         stateTransitTo(network, Event.OperationFailed);
                     }
-                } catch (NoTransitionException e) {
+                } catch (final NoTransitionException e) {
                     s_logger.error(e.getMessage());
                 }
 
                 try {
                     shutdownNetwork(networkId, context, false);
-                } catch (Exception e) {
+                } catch (final Exception e) {
                     // Don't throw this exception as it would hide the original thrown exception, just log
                     s_logger.error("Exception caught while shutting down a network as part of a failed implementation", e);
                 }
@@ -1050,7 +1052,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
     }
 
     @Override
-    public void implementNetworkElementsAndResources(DeployDestination dest, ReservationContext context, Network network, NetworkOffering offering)
+    public void implementNetworkElementsAndResources(final DeployDestination dest, final ReservationContext context, final Network network, final NetworkOffering offering)
             throws ConcurrentOperationException, InsufficientAddressCapacityException, ResourceUnavailableException, InsufficientCapacityException {
 
         // Associate a source NAT IP (if one isn't already associated with the network) if this is a
@@ -1058,18 +1060,18 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         //     2) network has sourceNat service
         //     3) network offering does not support a shared source NAT rule
 
-        boolean sharedSourceNat = offering.getSharedSourceNat();
-        DataCenter zone = _dcDao.findById(network.getDataCenterId());
+        final boolean sharedSourceNat = offering.getSharedSourceNat();
+        final DataCenter zone = _dcDao.findById(network.getDataCenterId());
 
         if (!sharedSourceNat && _networkModel.areServicesSupportedInNetwork(network.getId(), Service.SourceNat)
-                && (network.getGuestType() == Network.GuestType.Isolated || (network.getGuestType() == Network.GuestType.Shared && zone.getNetworkType() == NetworkType.Advanced))) {
+                && (network.getGuestType() == Network.GuestType.Isolated || network.getGuestType() == Network.GuestType.Shared && zone.getNetworkType() == NetworkType.Advanced)) {
 
             List<IPAddressVO> ips = null;
-            Account owner = _entityMgr.findById(Account.class, network.getAccountId());
+            final Account owner = _entityMgr.findById(Account.class, network.getAccountId());
             if (network.getVpcId() != null) {
                 ips = _ipAddressDao.listByAssociatedVpc(network.getVpcId(), true);
                 if (ips.isEmpty()) {
-                    Vpc vpc = _vpcMgr.getActiveVpc(network.getVpcId());
+                    final Vpc vpc = _vpcMgr.getActiveVpc(network.getVpcId());
                     s_logger.debug("Creating a source nat ip for vpc " + vpc);
                     _vpcMgr.assignSourceNatIpAddressToVpc(owner, vpc);
                 }
@@ -1082,8 +1084,8 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
             }
         }
         // get providers to implement
-        List<Provider> providersToImplement = getNetworkProviders(network.getId());
-        for (NetworkElement element : networkElements) {
+        final List<Provider> providersToImplement = getNetworkProviders(network.getId());
+        for (final NetworkElement element : networkElements) {
             if (providersToImplement.contains(element.getProvider())) {
                 if (!_networkModel.isProviderEnabledInPhysicalNetwork(_networkModel.getPhysicalNetworkId(network), element.getProvider().getName())) {
                     // The physicalNetworkId will not get translated into a uuid by the reponse serializer,
@@ -1099,15 +1101,15 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                 }
 
                 if (!element.implement(network, offering, dest, context)) {
-                    CloudRuntimeException ex = new CloudRuntimeException("Failed to implement provider " + element.getProvider().getName() + " for network with specified id");
+                    final CloudRuntimeException ex = new CloudRuntimeException("Failed to implement provider " + element.getProvider().getName() + " for network with specified id");
                     ex.addProxyObject(network.getUuid(), "networkId");
                     throw ex;
                 }
             }
         }
 
-        for (NetworkElement element : networkElements) {
-            if ((element instanceof AggregatedCommandExecutor) && (providersToImplement.contains(element.getProvider()))) {
+        for (final NetworkElement element : networkElements) {
+            if (element instanceof AggregatedCommandExecutor && providersToImplement.contains(element.getProvider())) {
                 ((AggregatedCommandExecutor)element).prepareAggregatedExecution(network, dest);
             }
         }
@@ -1118,17 +1120,17 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
             if (!reprogramNetworkRules(network.getId(), CallContext.current().getCallingAccount(), network)) {
                 s_logger.warn("Failed to re-program the network as a part of network " + network + " implement");
                 // see DataCenterVO.java
-                ResourceUnavailableException ex = new ResourceUnavailableException("Unable to apply network rules as a part of network " + network + " implement", DataCenter.class,
+                final ResourceUnavailableException ex = new ResourceUnavailableException("Unable to apply network rules as a part of network " + network + " implement", DataCenter.class,
                         network.getDataCenterId());
                 ex.addProxyObject(_entityMgr.findById(DataCenter.class, network.getDataCenterId()).getUuid());
                 throw ex;
             }
-            for (NetworkElement element : networkElements) {
-                if ((element instanceof AggregatedCommandExecutor) && (providersToImplement.contains(element.getProvider()))) {
+            for (final NetworkElement element : networkElements) {
+                if (element instanceof AggregatedCommandExecutor && providersToImplement.contains(element.getProvider())) {
                     if (!((AggregatedCommandExecutor)element).completeAggregatedExecution(network, dest)) {
                         s_logger.warn("Failed to re-program the network as a part of network " + network + " implement due to aggregated commands execution failure!");
                         // see DataCenterVO.java
-                        ResourceUnavailableException ex = new ResourceUnavailableException("Unable to apply network rules as a part of network " + network + " implement", DataCenter.class,
+                        final ResourceUnavailableException ex = new ResourceUnavailableException("Unable to apply network rules as a part of network " + network + " implement", DataCenter.class,
                                 network.getDataCenterId());
                         ex.addProxyObject(_entityMgr.findById(DataCenter.class, network.getDataCenterId()).getUuid());
                         throw ex;
@@ -1136,8 +1138,8 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                 }
             }
         } finally {
-            for (NetworkElement element : networkElements) {
-                if ((element instanceof AggregatedCommandExecutor) && (providersToImplement.contains(element.getProvider()))) {
+            for (final NetworkElement element : networkElements) {
+                if (element instanceof AggregatedCommandExecutor && providersToImplement.contains(element.getProvider())) {
                     ((AggregatedCommandExecutor)element).cleanupAggregatedExecution(network, dest);
                 }
             }
@@ -1145,15 +1147,15 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
     }
 
     // This method re-programs the rules/ips for existing network
-    protected boolean reprogramNetworkRules(long networkId, Account caller, Network network) throws ResourceUnavailableException {
+    protected boolean reprogramNetworkRules(final long networkId, final Account caller, final Network network) throws ResourceUnavailableException {
         boolean success = true;
 
         //Apply egress rules first to effect the egress policy early on the guest traffic
-        List<FirewallRuleVO> firewallEgressRulesToApply = _firewallDao.listByNetworkPurposeTrafficType(networkId, Purpose.Firewall, FirewallRule.TrafficType.Egress);
-        NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
-        DataCenter zone = _dcDao.findById(network.getDataCenterId());
+        final List<FirewallRuleVO> firewallEgressRulesToApply = _firewallDao.listByNetworkPurposeTrafficType(networkId, Purpose.Firewall, FirewallRule.TrafficType.Egress);
+        final NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
+        final DataCenter zone = _dcDao.findById(network.getDataCenterId());
         if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Firewall) && _networkModel.areServicesSupportedInNetwork(network.getId(), Service.Firewall)
-                && (network.getGuestType() == Network.GuestType.Isolated || (network.getGuestType() == Network.GuestType.Shared && zone.getNetworkType() == NetworkType.Advanced))) {
+                && (network.getGuestType() == Network.GuestType.Isolated || network.getGuestType() == Network.GuestType.Shared && zone.getNetworkType() == NetworkType.Advanced)) {
             // add default egress rule to accept the traffic
             _firewallMgr.applyDefaultEgressFirewallRule(network.getId(), offering.getEgressDefaultPolicy(), true);
         }
@@ -1176,7 +1178,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         }
 
         // apply firewall rules
-        List<FirewallRuleVO> firewallIngressRulesToApply = _firewallDao.listByNetworkPurposeTrafficType(networkId, Purpose.Firewall, FirewallRule.TrafficType.Ingress);
+        final List<FirewallRuleVO> firewallIngressRulesToApply = _firewallDao.listByNetworkPurposeTrafficType(networkId, Purpose.Firewall, FirewallRule.TrafficType.Ingress);
         if (!_firewallMgr.applyFirewallRules(firewallIngressRulesToApply, false, caller)) {
             s_logger.warn("Failed to reapply Ingress firewall rule(s) as a part of network id=" + networkId + " restart");
             success = false;
@@ -1207,9 +1209,9 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         }
 
         // apply vpn rules
-        List<? extends RemoteAccessVpn> vpnsToReapply = _vpnMgr.listRemoteAccessVpns(networkId);
+        final List<? extends RemoteAccessVpn> vpnsToReapply = _vpnMgr.listRemoteAccessVpns(networkId);
         if (vpnsToReapply != null) {
-            for (RemoteAccessVpn vpn : vpnsToReapply) {
+            for (final RemoteAccessVpn vpn : vpnsToReapply) {
                 // Start remote access vpn per ip
                 if (_vpnMgr.startRemoteAccessVpn(vpn.getServerAddressId(), false) == null) {
                     s_logger.warn("Failed to reapply vpn rules as a part of network id=" + networkId + " restart");
@@ -1227,16 +1229,16 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         return success;
     }
 
-    protected boolean prepareElement(NetworkElement element, Network network, NicProfile profile, VirtualMachineProfile vmProfile, DeployDestination dest,
-            ReservationContext context) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
+    protected boolean prepareElement(final NetworkElement element, final Network network, final NicProfile profile, final VirtualMachineProfile vmProfile, final DeployDestination dest,
+            final ReservationContext context) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException {
         element.prepare(network, profile, vmProfile, dest, context);
         if (vmProfile.getType() == Type.User && element.getProvider() != null) {
             if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Dhcp)
                     && _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp, element.getProvider()) && element instanceof DhcpServiceProvider) {
-                DhcpServiceProvider sp = (DhcpServiceProvider)element;
-                Map<Capability, String> dhcpCapabilities = element.getCapabilities().get(Service.Dhcp);
-                String supportsMultipleSubnets = dhcpCapabilities.get(Capability.DhcpAccrossMultipleSubnets);
-                if ((supportsMultipleSubnets != null && Boolean.valueOf(supportsMultipleSubnets)) && profile.getIPv6Address() == null) {
+                final DhcpServiceProvider sp = (DhcpServiceProvider)element;
+                final Map<Capability, String> dhcpCapabilities = element.getCapabilities().get(Service.Dhcp);
+                final String supportsMultipleSubnets = dhcpCapabilities.get(Capability.DhcpAccrossMultipleSubnets);
+                if (supportsMultipleSubnets != null && Boolean.valueOf(supportsMultipleSubnets) && profile.getIPv6Address() == null) {
                     if (!sp.configDhcpSupportForSubnet(network, profile, vmProfile, dest, context)) {
                         return false;
                     }
@@ -1247,7 +1249,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
             }
             if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.UserData)
                     && _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.UserData, element.getProvider()) && element instanceof UserDataServiceProvider) {
-                UserDataServiceProvider sp = (UserDataServiceProvider)element;
+                final UserDataServiceProvider sp = (UserDataServiceProvider)element;
                 if(!sp.addPasswordAndUserdata(network, profile, vmProfile, dest, context)){
                     return false;
                 }
@@ -1260,7 +1262,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
     protected void updateNic(final NicVO nic, final long networkId, final int count) {
         Transaction.execute(new TransactionCallbackNoReturn() {
             @Override
-            public void doInTransactionWithoutResult(TransactionStatus status) {
+            public void doInTransactionWithoutResult(final TransactionStatus status) {
                 _nicDao.update(nic.getId(), nic);
 
                 if (nic.getVmType() == VirtualMachine.Type.User) {
@@ -1269,7 +1271,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                 }
 
                 if (nic.getVmType() == VirtualMachine.Type.User
-                        || (nic.getVmType() == VirtualMachine.Type.DomainRouter && _networksDao.findById(networkId).getTrafficType() == TrafficType.Guest)) {
+                        || nic.getVmType() == VirtualMachine.Type.DomainRouter && _networksDao.findById(networkId).getTrafficType() == TrafficType.Guest) {
                     _networksDao.setCheckForGc(networkId);
                 }
             }
@@ -1277,9 +1279,9 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
     }
 
     @Override
-    public void prepare(VirtualMachineProfile vmProfile, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ConcurrentOperationException,
+    public void prepare(final VirtualMachineProfile vmProfile, final DeployDestination dest, final ReservationContext context) throws InsufficientCapacityException, ConcurrentOperationException,
     ResourceUnavailableException {
-        List<NicVO> nics = _nicDao.listByVmId(vmProfile.getId());
+        final List<NicVO> nics = _nicDao.listByVmId(vmProfile.getId());
 
         // we have to implement default nics first - to ensure that default network elements start up first in multiple
         //nics case
@@ -1287,35 +1289,35 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         Collections.sort(nics, new Comparator<NicVO>() {
 
             @Override
-            public int compare(NicVO nic1, NicVO nic2) {
-                boolean isDefault1 = nic1.isDefaultNic();
-                boolean isDefault2 = nic2.isDefaultNic();
+            public int compare(final NicVO nic1, final NicVO nic2) {
+                final boolean isDefault1 = nic1.isDefaultNic();
+                final boolean isDefault2 = nic2.isDefaultNic();
 
-                return (isDefault1 ^ isDefault2) ? ((isDefault1 ^ true) ? 1 : -1) : 0;
+                return isDefault1 ^ isDefault2 ? isDefault1 ^ true ? 1 : -1 : 0;
             }
         });
 
-        for (NicVO nic : nics) {
-            Pair<NetworkGuru, NetworkVO> implemented = implementNetwork(nic.getNetworkId(), dest, context, vmProfile.getVirtualMachine().getType() == Type.DomainRouter);
+        for (final NicVO nic : nics) {
+            final Pair<NetworkGuru, NetworkVO> implemented = implementNetwork(nic.getNetworkId(), dest, context, vmProfile.getVirtualMachine().getType() == Type.DomainRouter);
             if (implemented == null || implemented.first() == null) {
                 s_logger.warn("Failed to implement network id=" + nic.getNetworkId() + " as a part of preparing nic id=" + nic.getId());
                 throw new CloudRuntimeException("Failed to implement network id=" + nic.getNetworkId() + " as a part preparing nic id=" + nic.getId());
             }
 
-            NetworkVO network = implemented.second();
-            NicProfile profile = prepareNic(vmProfile, dest, context, nic.getId(), network);
+            final NetworkVO network = implemented.second();
+            final NicProfile profile = prepareNic(vmProfile, dest, context, nic.getId(), network);
             vmProfile.addNic(profile);
         }
     }
 
     @Override
-    public NicProfile prepareNic(VirtualMachineProfile vmProfile, DeployDestination dest, ReservationContext context, long nicId, Network network)
+    public NicProfile prepareNic(final VirtualMachineProfile vmProfile, final DeployDestination dest, final ReservationContext context, final long nicId, final Network network)
             throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException, InsufficientCapacityException,
             ResourceUnavailableException {
 
-        Integer networkRate = _networkModel.getNetworkRate(network.getId(), vmProfile.getId());
-        NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
-        NicVO nic = _nicDao.findById(nicId);
+        final Integer networkRate = _networkModel.getNetworkRate(network.getId(), vmProfile.getId());
+        final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
+        final NicVO nic = _nicDao.findById(nicId);
 
         NicProfile profile = null;
         if (nic.getReservationStrategy() == Nic.ReservationStrategy.Start) {
@@ -1327,7 +1329,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                 broadcastUri = network.getBroadcastUri();
             }
 
-            URI isolationUri = nic.getIsolationUri();
+            final URI isolationUri = nic.getIsolationUri();
 
             profile = new NicProfile(nic, network, broadcastUri, isolationUri,
 
@@ -1357,8 +1359,8 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
             updateNic(nic, network.getId(), 1);
         }
 
-        List<Provider> providersToImplement = getNetworkProviders(network.getId());
-        for (NetworkElement element : networkElements) {
+        final List<Provider> providersToImplement = getNetworkProviders(network.getId());
+        for (final NetworkElement element : networkElements) {
             if (providersToImplement.contains(element.getProvider())) {
                 if (!_networkModel.isProviderEnabledInPhysicalNetwork(_networkModel.getPhysicalNetworkId(network), element.getProvider().getName())) {
                     throw new CloudRuntimeException("Service provider " + element.getProvider().getName() + " either doesn't exist or is not enabled in physical network id: "
@@ -1379,28 +1381,28 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
     }
 
     @Override
-    public void prepareNicForMigration(VirtualMachineProfile vm, DeployDestination dest) {
+    public void prepareNicForMigration(final VirtualMachineProfile vm, final DeployDestination dest) {
         if(vm.getType().equals(VirtualMachine.Type.DomainRouter) && (vm.getHypervisorType().equals(HypervisorType.KVM) || vm.getHypervisorType().equals(HypervisorType.VMware))) {
             //Include nics hot plugged and not stored in DB
             prepareAllNicsForMigration(vm, dest);
             return;
         }
-        List<NicVO> nics = _nicDao.listByVmId(vm.getId());
-        ReservationContext context = new ReservationContextImpl(UUID.randomUUID().toString(), null, null);
-        for (NicVO nic : nics) {
-            NetworkVO network = _networksDao.findById(nic.getNetworkId());
-            Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId());
+        final List<NicVO> nics = _nicDao.listByVmId(vm.getId());
+        final ReservationContext context = new ReservationContextImpl(UUID.randomUUID().toString(), null, null);
+        for (final NicVO nic : nics) {
+            final NetworkVO network = _networksDao.findById(nic.getNetworkId());
+            final Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId());
 
-            NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
-            NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate, _networkModel.isSecurityGroupSupportedInNetwork(network),
+            final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
+            final NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate, _networkModel.isSecurityGroupSupportedInNetwork(network),
                     _networkModel.getNetworkTag(vm.getHypervisorType(), network));
             if (guru instanceof NetworkMigrationResponder) {
                 if (!((NetworkMigrationResponder)guru).prepareMigration(profile, network, vm, dest, context)) {
                     s_logger.error("NetworkGuru " + guru + " prepareForMigration failed."); // XXX: Transaction error
                 }
             }
-            List<Provider> providersToImplement = getNetworkProviders(network.getId());
-            for (NetworkElement element : networkElements) {
+            final List<Provider> providersToImplement = getNetworkProviders(network.getId());
+            for (final NetworkElement element : networkElements) {
                 if (providersToImplement.contains(element.getProvider())) {
                     if (!_networkModel.isProviderEnabledInPhysicalNetwork(_networkModel.getPhysicalNetworkId(network), element.getProvider().getName())) {
                         throw new CloudRuntimeException("Service provider " + element.getProvider().getName() + " either doesn't exist or is not enabled in physical network id: "
@@ -1424,27 +1426,27 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
     Once clean fix is added by stored dynamically nics is DB, this workaround won't be needed
      */
     @Override
-    public void prepareAllNicsForMigration(VirtualMachineProfile vm, DeployDestination dest) {
-        List<NicVO> nics = _nicDao.listByVmId(vm.getId());
-        ReservationContext context = new ReservationContextImpl(UUID.randomUUID().toString(), null, null);
+    public void prepareAllNicsForMigration(final VirtualMachineProfile vm, final DeployDestination dest) {
+        final List<NicVO> nics = _nicDao.listByVmId(vm.getId());
+        final ReservationContext context = new ReservationContextImpl(UUID.randomUUID().toString(), null, null);
         Long guestNetworkId = null;
-        for (NicVO nic : nics) {
-            NetworkVO network = _networksDao.findById(nic.getNetworkId());
+        for (final NicVO nic : nics) {
+            final NetworkVO network = _networksDao.findById(nic.getNetworkId());
             if(network.getTrafficType().equals(TrafficType.Guest) && network.getGuestType().equals(GuestType.Isolated)){
                 guestNetworkId = network.getId();
             }
-            Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId());
+            final Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId());
 
-            NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
-            NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate,
+            final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
+            final NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate,
                     _networkModel.isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag(vm.getHypervisorType(), network));
             if(guru instanceof NetworkMigrationResponder){
                 if(!((NetworkMigrationResponder) guru).prepareMigration(profile, network, vm, dest, context)){
                     s_logger.error("NetworkGuru "+guru+" prepareForMigration failed."); // XXX: Transaction error
                 }
             }
-            List<Provider> providersToImplement = getNetworkProviders(network.getId());
-            for (NetworkElement element : networkElements) {
+            final List<Provider> providersToImplement = getNetworkProviders(network.getId());
+            for (final NetworkElement element : networkElements) {
                 if (providersToImplement.contains(element.getProvider())) {
                     if (!_networkModel.isProviderEnabledInPhysicalNetwork(_networkModel.getPhysicalNetworkId(network), element.getProvider().getName())) {
                         throw new CloudRuntimeException("Service provider " + element.getProvider().getName() + " either doesn't exist or is not enabled in physical network id: " + network.getPhysicalNetworkId());
@@ -1460,23 +1462,23 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
             vm.addNic(profile);
         }
 
-        List<String> addedURIs = new ArrayList<String>();
+        final List<String> addedURIs = new ArrayList<String>();
         if(guestNetworkId != null){
-            List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedNetwork(guestNetworkId, null);
-            for (IPAddressVO userIp : publicIps){
-                PublicIp publicIp = PublicIp.createFromAddrAndVlan(userIp, _vlanDao.findById(userIp.getVlanId()));
-                URI broadcastUri = BroadcastDomainType.Vlan.toUri(publicIp.getVlanTag());
-                long ntwkId = publicIp.getNetworkId();
-                Nic nic = _nicDao.findByNetworkIdInstanceIdAndBroadcastUri(ntwkId, vm.getId(),
+            final List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedNetwork(guestNetworkId, null);
+            for (final IPAddressVO userIp : publicIps){
+                final PublicIp publicIp = PublicIp.createFromAddrAndVlan(userIp, _vlanDao.findById(userIp.getVlanId()));
+                final URI broadcastUri = BroadcastDomainType.Vlan.toUri(publicIp.getVlanTag());
+                final long ntwkId = publicIp.getNetworkId();
+                final Nic nic = _nicDao.findByNetworkIdInstanceIdAndBroadcastUri(ntwkId, vm.getId(),
                         broadcastUri.toString());
                 if(nic == null && !addedURIs.contains(broadcastUri.toString())){
                     //Nic details are not available in DB
                     //Create nic profile for migration
                     s_logger.debug("Creating nic profile for migration. BroadcastUri: "+broadcastUri.toString()+" NetworkId: "+ntwkId+" Vm: "+vm.getId());
-                    NetworkVO network = _networksDao.findById(ntwkId);
-                    Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId());
-                    NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
-                    NicProfile profile = new NicProfile();
+                    final NetworkVO network = _networksDao.findById(ntwkId);
+                    final Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId());
+                    final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
+                    final NicProfile profile = new NicProfile();
                     profile.setDeviceId(255); //dummyId
                     profile.setIPv4Address(userIp.getAddress().toString());
                     profile.setIPv4Netmask(publicIp.getNetmask());
@@ -1498,8 +1500,8 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         }
     }
 
-    private NicProfile findNicProfileById(VirtualMachineProfile vm, long id) {
-        for (NicProfile nic : vm.getNics()) {
+    private NicProfile findNicProfileById(final VirtualMachineProfile vm, final long id) {
+        for (final NicProfile nic : vm.getNics()) {
             if (nic.getId() == id) {
                 return nic;
             }
@@ -1508,19 +1510,19 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
     }
 
     @Override
-    public void commitNicForMigration(VirtualMachineProfile src, VirtualMachineProfile dst) {
-        for (NicProfile nicSrc : src.getNics()) {
-            NetworkVO network = _networksDao.findById(nicSrc.getNetworkId());
-            NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
-            NicProfile nicDst = findNicProfileById(dst, nicSrc.getId());
-            ReservationContext src_context = new ReservationContextImpl(nicSrc.getReservationId(), null, null);
-            ReservationContext dst_context = new ReservationContextImpl(nicDst.getReservationId(), null, null);
+    public void commitNicForMigration(final VirtualMachineProfile src, final VirtualMachineProfile dst) {
+        for (final NicProfile nicSrc : src.getNics()) {
+            final NetworkVO network = _networksDao.findById(nicSrc.getNetworkId());
+            final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
+            final NicProfile nicDst = findNicProfileById(dst, nicSrc.getId());
+            final ReservationContext src_context = new ReservationContextImpl(nicSrc.getReservationId(), null, null);
+            final ReservationContext dst_context = new ReservationContextImpl(nicDst.getReservationId(), null, null);
 
             if (guru instanceof NetworkMigrationResponder) {
                 ((NetworkMigrationResponder)guru).commitMigration(nicSrc, network, src, src_context, dst_context);
             }
-            List<Provider> providersToImplement = getNetworkProviders(network.getId());
-            for (NetworkElement element : networkElements) {
+            final List<Provider> providersToImplement = getNetworkProviders(network.getId());
+            for (final NetworkElement element : networkElements) {
                 if (providersToImplement.contains(element.getProvider())) {
                     if (!_networkModel.isProviderEnabledInPhysicalNetwork(_networkModel.getPhysicalNetworkId(network), element.getProvider().getName())) {
                         throw new CloudRuntimeException("Service provider " + element.getProvider().getName() + " either doesn't exist or is not enabled in physical network id: "
@@ -1532,26 +1534,26 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                 }
             }
             // update the reservation id
-            NicVO nicVo = _nicDao.findById(nicDst.getId());
+            final NicVO nicVo = _nicDao.findById(nicDst.getId());
             nicVo.setReservationId(nicDst.getReservationId());
             _nicDao.persist(nicVo);
         }
     }
 
     @Override
-    public void rollbackNicForMigration(VirtualMachineProfile src, VirtualMachineProfile dst) {
-        for (NicProfile nicDst : dst.getNics()) {
-            NetworkVO network = _networksDao.findById(nicDst.getNetworkId());
-            NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
-            NicProfile nicSrc = findNicProfileById(src, nicDst.getId());
-            ReservationContext src_context = new ReservationContextImpl(nicSrc.getReservationId(), null, null);
-            ReservationContext dst_context = new ReservationContextImpl(nicDst.getReservationId(), null, null);
+    public void rollbackNicForMigration(final VirtualMachineProfile src, final VirtualMachineProfile dst) {
+        for (final NicProfile nicDst : dst.getNics()) {
+            final NetworkVO network = _networksDao.findById(nicDst.getNetworkId());
+            final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
+            final NicProfile nicSrc = findNicProfileById(src, nicDst.getId());
+            final ReservationContext src_context = new ReservationContextImpl(nicSrc.getReservationId(), null, null);
+            final ReservationContext dst_context = new ReservationContextImpl(nicDst.getReservationId(), null, null);
 
             if (guru instanceof NetworkMigrationResponder) {
                 ((NetworkMigrationResponder)guru).rollbackMigration(nicDst, network, dst, src_context, dst_context);
             }
-            List<Provider> providersToImplement = getNetworkProviders(network.getId());
-            for (NetworkElement element : networkElements) {
+            final List<Provider> providersToImplement = getNetworkProviders(network.getId());
+            for (final NetworkElement element : networkElements) {
                 if (providersToImplement.contains(element.getProvider())) {
                     if (!_networkModel.isProviderEnabledInPhysicalNetwork(_networkModel.getPhysicalNetworkId(network), element.getProvider().getName())) {
                         throw new CloudRuntimeException("Service provider " + element.getProvider().getName() + " either doesn't exist or is not enabled in physical network id: "
@@ -1567,38 +1569,38 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
 
     @Override
     @DB
-    public void release(VirtualMachineProfile vmProfile, boolean forced) throws ConcurrentOperationException, ResourceUnavailableException {
-        List<NicVO> nics = _nicDao.listByVmId(vmProfile.getId());
-        for (NicVO nic : nics) {
+    public void release(final VirtualMachineProfile vmProfile, final boolean forced) throws ConcurrentOperationException, ResourceUnavailableException {
+        final List<NicVO> nics = _nicDao.listByVmId(vmProfile.getId());
+        for (final NicVO nic : nics) {
             releaseNic(vmProfile, nic.getId());
         }
     }
 
     @Override
     @DB
-    public void releaseNic(VirtualMachineProfile vmProfile, Nic nic) throws ConcurrentOperationException, ResourceUnavailableException {
+    public void releaseNic(final VirtualMachineProfile vmProfile, final Nic nic) throws ConcurrentOperationException, ResourceUnavailableException {
         releaseNic(vmProfile, nic.getId());
     }
 
     @DB
     protected void releaseNic(final VirtualMachineProfile vmProfile, final long nicId) throws ConcurrentOperationException, ResourceUnavailableException {
-        Pair<Network, NicProfile> networkToRelease = Transaction.execute(new TransactionCallback<Pair<Network, NicProfile>>() {
+        final Pair<Network, NicProfile> networkToRelease = Transaction.execute(new TransactionCallback<Pair<Network, NicProfile>>() {
             @Override
-            public Pair<Network, NicProfile> doInTransaction(TransactionStatus status) {
-                NicVO nic = _nicDao.lockRow(nicId, true);
+            public Pair<Network, NicProfile> doInTransaction(final TransactionStatus status) {
+                final NicVO nic = _nicDao.lockRow(nicId, true);
                 if (nic == null) {
                     throw new ConcurrentOperationException("Unable to acquire lock on nic " + nic);
                 }
 
-                Nic.State originalState = nic.getState();
-                NetworkVO network = _networksDao.findById(nic.getNetworkId());
+                final Nic.State originalState = nic.getState();
+                final NetworkVO network = _networksDao.findById(nic.getNetworkId());
 
                 if (originalState == Nic.State.Reserved || originalState == Nic.State.Reserving) {
                     if (nic.getReservationStrategy() == Nic.ReservationStrategy.Start) {
-                        NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
+                        final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
                         nic.setState(Nic.State.Releasing);
                         _nicDao.update(nic.getId(), nic);
-                        NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), null, _networkModel
+                        final NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), null, _networkModel
                                 .isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag(vmProfile.getHypervisorType(), network));
                         if (guru.release(profile, vmProfile, nic.getReservationId())) {
                             applyProfileToNicForRelease(nic, profile);
@@ -1623,10 +1625,10 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
 
         // cleanup the entry in vm_network_map
         if(vmProfile.getType().equals(VirtualMachine.Type.User)) {
-            NicVO nic = _nicDao.findById(nicId);
+            final NicVO nic = _nicDao.findById(nicId);
             if(nic != null) {
-                NetworkVO vmNetwork = _networksDao.findById(nic.getNetworkId());
-                VMNetworkMapVO vno = _vmNetworkMapDao.findByVmAndNetworkId(vmProfile.getVirtualMachine().getId(), vmNetwork.getId());
+                final NetworkVO vmNetwork = _networksDao.findById(nic.getNetworkId());
+                final VMNetworkMapVO vno = _vmNetworkMapDao.findByVmAndNetworkId(vmProfile.getVirtualMachine().getId(), vmNetwork.getId());
                 if(vno != null) {
                     _vmNetworkMapDao.remove(vno.getId());
                 }
@@ -1634,10 +1636,10 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         }
 
         if (networkToRelease != null) {
-            Network network = networkToRelease.first();
-            NicProfile profile = networkToRelease.second();
-            List<Provider> providersToImplement = getNetworkProviders(network.getId());
-            for (NetworkElement element : networkElements) {
+            final Network network = networkToRelease.first();
+            final NicProfile profile = networkToRelease.second();
+            final List<Provider> providersToImplement = getNetworkProviders(network.getId());
+            for (final NetworkElement element : networkElements) {
                 if (providersToImplement.contains(element.getProvider())) {
                     if (s_logger.isDebugEnabled()) {
                         s_logger.debug("Asking " + element.getName() + " to release " + profile);
@@ -1651,38 +1653,38 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
     }
 
     @Override
-    public void cleanupNics(VirtualMachineProfile vm) {
+    public void cleanupNics(final VirtualMachineProfile vm) {
         if (s_logger.isDebugEnabled()) {
             s_logger.debug("Cleaning network for vm: " + vm.getId());
         }
 
-        List<NicVO> nics = _nicDao.listByVmId(vm.getId());
-        for (NicVO nic : nics) {
+        final List<NicVO> nics = _nicDao.listByVmId(vm.getId());
+        for (final NicVO nic : nics) {
             removeNic(vm, nic);
         }
     }
 
     @Override
-    public void removeNic(VirtualMachineProfile vm, Nic nic) {
+    public void removeNic(final VirtualMachineProfile vm, final Nic nic) {
         removeNic(vm, _nicDao.findById(nic.getId()));
     }
 
-    protected void removeNic(VirtualMachineProfile vm, NicVO nic) {
+    protected void removeNic(final VirtualMachineProfile vm, final NicVO nic) {
 
         if (nic.getReservationStrategy() == Nic.ReservationStrategy.Start && nic.getState() != Nic.State.Allocated) {
             // Nics with reservation strategy 'Start' should go through release phase in the Nic life cycle.
             // Ensure that release is performed before Nic is to be removed to avoid resource leaks.
             try {
                 releaseNic(vm, nic.getId());
-            } catch (Exception ex) {
+            } catch (final Exception ex) {
                 s_logger.warn("Failed to release nic: " + nic.toString() + " as part of remove operation due to", ex);
             }
         }
 
         nic.setState(Nic.State.Deallocating);
         _nicDao.update(nic.getId(), nic);
-        NetworkVO network = _networksDao.findById(nic.getNetworkId());
-        NicProfile profile = new NicProfile(nic, network, null, null, null, _networkModel.isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag(
+        final NetworkVO network = _networksDao.findById(nic.getNetworkId());
+        final NicProfile profile = new NicProfile(nic, network, null, null, null, _networkModel.isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag(
                 vm.getHypervisorType(), network));
 
         /*
@@ -1690,17 +1692,17 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
          * because the nic is now being removed.
          */
         if (nic.getReservationStrategy() == Nic.ReservationStrategy.Create) {
-            List<Provider> providersToImplement = getNetworkProviders(network.getId());
-            for (NetworkElement element : networkElements) {
+            final List<Provider> providersToImplement = getNetworkProviders(network.getId());
+            for (final NetworkElement element : networkElements) {
                 if (providersToImplement.contains(element.getProvider())) {
                     if (s_logger.isDebugEnabled()) {
                         s_logger.debug("Asking " + element.getName() + " to release " + nic);
                     }
                     try {
                         element.release(network, profile, vm, null);
-                    } catch (ConcurrentOperationException ex) {
+                    } catch (final ConcurrentOperationException ex) {
                         s_logger.warn("release failed during the nic " + nic.toString() + " removeNic due to ", ex);
-                    } catch (ResourceUnavailableException ex) {
+                    } catch (final ResourceUnavailableException ex) {
                         s_logger.warn("release failed during the nic " + nic.toString() + " removeNic due to ", ex);
                     }
                 }
@@ -1713,14 +1715,14 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                 && network.getGuestType() == GuestType.Shared
                 && isLastNicInSubnet(nic)) {
             // remove the dhcpservice ip if this is the last nic in subnet.
-            DhcpServiceProvider dhcpServiceProvider = getDhcpServiceProvider(network);
+            final DhcpServiceProvider dhcpServiceProvider = getDhcpServiceProvider(network);
             if (dhcpServiceProvider != null
                     && isDhcpAccrossMultipleSubnetsSupported(dhcpServiceProvider)) {
                 removeDhcpServiceInSubnet(nic);
             }
         }
 
-        NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
+        final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
         guru.deallocate(network, profile, vm);
         _nicDao.remove(nic.getId());
 
@@ -1731,17 +1733,17 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         }
     }
 
-    public boolean isDhcpAccrossMultipleSubnetsSupported(DhcpServiceProvider dhcpServiceProvider) {
+    public boolean isDhcpAccrossMultipleSubnetsSupported(final DhcpServiceProvider dhcpServiceProvider) {
 
-        Map<Network.Capability, String> capabilities = dhcpServiceProvider.getCapabilities().get(Network.Service.Dhcp);
-        String supportsMultipleSubnets = capabilities.get(Network.Capability.DhcpAccrossMultipleSubnets);
+        final Map<Network.Capability, String> capabilities = dhcpServiceProvider.getCapabilities().get(Network.Service.Dhcp);
+        final String supportsMultipleSubnets = capabilities.get(Network.Capability.DhcpAccrossMultipleSubnets);
         if (supportsMultipleSubnets != null && Boolean.valueOf(supportsMultipleSubnets)) {
             return true;
         }
         return false;
     }
 
-    private boolean isLastNicInSubnet(NicVO nic) {
+    private boolean isLastNicInSubnet(final NicVO nic) {
         if (_nicDao.listByNetworkIdTypeAndGatewayAndBroadcastUri(nic.getNetworkId(), VirtualMachine.Type.User, nic.getIPv4Gateway(), nic.getBroadcastUri()).size() > 1) {
             return false;
         }
@@ -1750,18 +1752,18 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
 
     @DB
     @Override
-    public void removeDhcpServiceInSubnet(Nic nic) {
-        Network network = _networksDao.findById(nic.getNetworkId());
-        DhcpServiceProvider dhcpServiceProvider = getDhcpServiceProvider(network);
+    public void removeDhcpServiceInSubnet(final Nic nic) {
+        final Network network = _networksDao.findById(nic.getNetworkId());
+        final DhcpServiceProvider dhcpServiceProvider = getDhcpServiceProvider(network);
         try {
             final NicIpAliasVO ipAlias = _nicIpAliasDao.findByGatewayAndNetworkIdAndState(nic.getIPv4Gateway(), network.getId(), NicIpAlias.State.active);
             if (ipAlias != null) {
                 ipAlias.setState(NicIpAlias.State.revoked);
                 Transaction.execute(new TransactionCallbackNoReturn() {
                     @Override
-                    public void doInTransactionWithoutResult(TransactionStatus status) {
+                    public void doInTransactionWithoutResult(final TransactionStatus status) {
                         _nicIpAliasDao.update(ipAlias.getId(), ipAlias);
-                        IPAddressVO aliasIpaddressVo = _publicIpAddressDao.findByIpAndSourceNetworkId(ipAlias.getNetworkId(), ipAlias.getIp4Address());
+                        final IPAddressVO aliasIpaddressVo = _publicIpAddressDao.findByIpAndSourceNetworkId(ipAlias.getNetworkId(), ipAlias.getIp4Address());
                         _publicIpAddressDao.unassignIpAddress(aliasIpaddressVo.getId());
                     }
                 });
@@ -1769,7 +1771,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                     s_logger.warn("Failed to remove the ip alias on the router, marking it as removed in db and freed the allocated ip " + ipAlias.getIp4Address());
                 }
             }
-        } catch (ResourceUnavailableException e) {
+        } catch (final ResourceUnavailableException e) {
             //failed to remove the dhcpconfig on the router.
             s_logger.info("Unable to delete the ip alias due to unable to contact the virtualrouter.");
         }
@@ -1777,16 +1779,16 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
     }
 
     @Override
-    public void expungeNics(VirtualMachineProfile vm) {
-        List<NicVO> nics = _nicDao.listByVmIdIncludingRemoved(vm.getId());
-        for (NicVO nic : nics) {
+    public void expungeNics(final VirtualMachineProfile vm) {
+        final List<NicVO> nics = _nicDao.listByVmIdIncludingRemoved(vm.getId());
+        for (final NicVO nic : nics) {
             _nicDao.expunge(nic.getId());
         }
     }
 
     @Override
     @DB
-    public Network createGuestNetwork(long networkOfferingId, final String name, final String displayText, final String gateway, final String cidr, String vlanId,
+    public Network createGuestNetwork(final long networkOfferingId, final String name, final String displayText, final String gateway, final String cidr, String vlanId,
             String networkDomain, final Account owner, final Long domainId, final PhysicalNetwork pNtwk, final long zoneId, final ACLType aclType, Boolean subdomainAccess,
             final Long vpcId, final String ip6Gateway, final String ip6Cidr, final Boolean isDisplayNetworkEnabled, final String isolatedPvlan)
                     throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {
@@ -1807,7 +1809,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         // Validate network offering
         if (ntwkOff.getState() != NetworkOffering.State.Enabled) {
             // see NetworkOfferingVO
-            InvalidParameterValueException ex = new InvalidParameterValueException("Can't use specified network offering id as its stat is not " + NetworkOffering.State.Enabled);
+            final InvalidParameterValueException ex = new InvalidParameterValueException("Can't use specified network offering id as its stat is not " + NetworkOffering.State.Enabled);
             ex.addProxyObject(ntwkOff.getUuid(), "networkOfferingId");
             throw ex;
         }
@@ -1815,7 +1817,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         // Validate physical network
         if (pNtwk.getState() != PhysicalNetwork.State.Enabled) {
             // see PhysicalNetworkVO.java
-            InvalidParameterValueException ex = new InvalidParameterValueException("Specified physical network id is" + " in incorrect state:" + pNtwk.getState());
+            final InvalidParameterValueException ex = new InvalidParameterValueException("Specified physical network id is" + " in incorrect state:" + pNtwk.getState());
             ex.addProxyObject(pNtwk.getUuid(), "physicalNetworkId");
             throw ex;
         }
@@ -1838,7 +1840,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
             }
 
             // Only one guest network is supported in Basic zone
-            List<NetworkVO> guestNetworks = _networksDao.listByZoneAndTrafficType(zone.getId(), TrafficType.Guest);
+            final List<NetworkVO> guestNetworks = _networksDao.listByZoneAndTrafficType(zone.getId(), TrafficType.Guest);
             if (!guestNetworks.isEmpty()) {
                 throw new InvalidParameterValueException("Can't have more than one Guest network in zone with network type " + NetworkType.Basic);
             }
@@ -1883,7 +1885,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                 if (_networkModel.areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat)) {
                     throw new InvalidParameterValueException("Service SourceNat is not allowed in security group enabled zone");
                 }
-                if (!(_networkModel.areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SecurityGroup))) {
+                if (!_networkModel.areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SecurityGroup)) {
                     throw new InvalidParameterValueException("network must have SecurityGroup provider in security group enabled zone");
                 }
             }
@@ -1896,7 +1898,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
 
         //TODO(VXLAN): Support VNI specified
         // VlanId can be specified only when network offering supports it
-        boolean vlanSpecified = (vlanId != null);
+        final boolean vlanSpecified = vlanId != null;
         if (vlanSpecified != ntwkOff.getSpecifyVlan()) {
             if (vlanSpecified) {
                 throw new InvalidParameterValueException("Can't specify vlan; corresponding offering says specifyVlan=false");
@@ -1911,30 +1913,30 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
                 throw new InvalidParameterValueException("The VLAN tag " + vlanId + " is already being used for dynamic vlan allocation for the guest network in zone "
                         + zone.getName());
             }
-            String uri = BroadcastDomainType.fromString(vlanId).toString();
+            final String uri = BroadcastDomainType.fromString(vlanId).toString();
             // For Isolated networks, don't allow to create network with vlan that already exists in the zone
             if (ntwkOff.getGuestType() == GuestType.Isolated) {
                 if (_networksDao.countByZoneAndUri(zoneId, uri) > 0) {
                     throw new InvalidParameterValueException("Network with vlan " + vlanId + " already exists in zone " + zoneId);
                 } else {
-                    List<DataCenterVnetVO> dcVnets = _datacenterVnetDao.findVnet(zoneId, vlanId.toString());
+                    final List<DataCenterVnetVO> dcVnets = _datacenterVnetDao.findVnet(zoneId, vlanId.toString());
                     //for the network that is created as part of private gateway,
                     //the vnet is not coming from the data center vnet table, so the list can be empty
                     if (!dcVnets.isEmpty()) {
-                        DataCenterVnetVO dcVnet = dcVnets.get(0);
+                        final DataCenterVnetVO dcVnet = dcVnets.get(0);
                         // Fail network creation if specified vlan is dedicated to a different account
                         if (dcVnet.getAccountGuestVlanMapId() != null) {
-                            Long accountGuestVlanMapId = dcVnet.getAccountGuestVlanMapId();
-                            AccountGuestVlanMapVO map = _accountGuestVlanMapDao.findById(accountGuestVlanMapId);
+                            final Long accountGuestVlanMapId = dcVnet.getAccountGuestVlanMapId();
+                            final AccountGuestVlanMapVO map = _accountGuestVlanMapDao.findById(accountGuestVlanMapId);
                             if (map.getAccountId() != owner.getAccountId()) {
                                 throw new InvalidParameterValueException("Vlan " + vlanId + " is dedicated to a different account");
                             }
                             // Fail network creation if owner has a dedicated range of vlans but the specified vlan belongs to the system pool
                         } else {
-                            List<AccountGuestVlanMapVO> maps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByAccount(owner.getAccountId());
+                            final List<AccountGuestVlanMapVO> maps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByAccount(owner.getAccountId());
                             if (maps != null && !maps.isEmpty()) {
-                                int vnetsAllocatedToAccount = _datacenterVnetDao.countVnetsAllocatedToAccount(zoneId, owner.getAccountId());
-                                int vnetsDedicatedToAccount = _datacenterVnetDao.countVnetsDedicatedToAccount(zoneId, owner.getAccountId());
+                                final int vnetsAllocatedToAccount = _datacenterVnetDao.countVnetsAllocatedToAccount(zoneId, owner.getAccountId());
+                                final int vnetsDedicatedToAccount = _datacenterVnetDao.countVnetsDedicatedToAccount(zoneId, owner.getAccountId());
                                 if (vnetsAllocatedToAccount < vnetsDedicatedToAccount) {
                                     throw new InvalidParameterValueException("Specified vlan " + vlanId + " doesn't belong" + " to the vlan range dedicated to the owner "
                                             + owner.getAccountName());
@@ -1955,9 +1957,9 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
 
         // If networkDomain is not specified, take it from the global configuration
         if (_networkModel.areServicesSupportedByNetworkOffering(networkOfferingId, Service.Dns)) {
-            Map<Network.Capability, String> dnsCapabilities = _networkModel.getNetworkOfferingServiceCapabilities(_entityMgr.findById(NetworkOffering.class, networkOfferingId),
+            final Map<Network.Capability, String> dnsCapabilities = _networkModel.getNetworkOfferingServiceCapabilities(_entityMgr.findById(NetworkOffering.class, networkOfferingId),
                     Service.Dns);
-            String isUpdateDnsSupported = dnsCapabilities.get(Capability.AllowDnsSuffixModification);
+            final String isUpdateDnsSupported = dnsCapabilities.get(Capability.AllowDnsSuffixModification);
             if (isUpdateDnsSupported == null || !Boolean.valueOf(isUpdateDnsSupported)) {
                 if (networkDomain != null) {
                     // TBD: NetworkOfferingId and zoneId. Send uuids instead.
@@ -1991,10 +1993,10 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
         // In Advance zone Cidr for Shared networks and Isolated networks w/o source nat service can't be NULL - 2.2.x
         // limitation, remove after we introduce support for multiple ip ranges
         // with different Cidrs for the same Shared network
-        boolean cidrRequired = zone.getNetworkType() == NetworkType.Advanced
+        final boolean cidrRequired = zone.getNetworkType() == NetworkType.Advanced
                 && ntwkOff.getTrafficType() == TrafficType.Guest
-                && (ntwkOff.getGuestType() == GuestType.Shared || (ntwkOff.getGuestType() == GuestType.Isolated && !_networkModel.areServicesSupportedByNetworkOffering(
-                        ntwkOff.getId(), Service.SourceNat)));
+                && (ntwkOff.getGuestType() == GuestType.Shared || ntwkOff.getGuestType() == GuestType.Isolated && !_networkModel.areServicesSupportedByNetworkOffering(
+                        ntwkOff.getId(), Service.SourceNat));
         if (cidr == null && ip6Cidr == null && cidrRequired) {
             throw new InvalidParameterValueException("StartIp/endIp/gateway/netmask are required when create network of" + " type " + Network.GuestType.Shared
                     + " and

<TRUNCATED>

[2/9] git commit: updated refs/heads/4.7 to ff89587

Posted by re...@apache.org.
CLOUDSTACK-9154 - Returns the guest iterface that is marked as added

   - Force a restart of keepalived if conntrackd is not running or configuration has changed


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/7988f51a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/7988f51a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/7988f51a

Branch: refs/heads/4.7
Commit: 7988f51ac07782ad9b9873c32438fd7cdb24edba
Parents: 9be76b3
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Thu Dec 17 14:20:59 2015 +0100
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Tue Dec 22 14:52:05 2015 +0100

----------------------------------------------------------------------
 .../patches/debian/config/opt/cloud/bin/cs/CsAddress.py  |  5 ++++-
 .../debian/config/opt/cloud/bin/cs/CsRedundant.py        | 11 +++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7988f51a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
index 24d75e5..d320d0a 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py
@@ -52,7 +52,7 @@ class CsAddress(CsDataBag):
         """
         ipr = []
         for ip in self.get_ips():
-            if ip.is_guest():
+            if ip.is_guest() and ip.is_added():
                 ipr.append(ip)
         if len(ipr) > 0:
             return sorted(ipr)[-1]
@@ -189,6 +189,9 @@ class CsInterface:
         if "nw_type" in self.address and self.address['nw_type'] in ['public']:
             return True
         return False
+    
+    def is_added(self):
+        return self.get_attr("add")
 
     def to_str(self):
         pprint(self.address)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7988f51a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
index d853eb9..f975871 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
@@ -108,7 +108,6 @@ class CsRedundant(object):
             CsHelper.service("keepalived", "stop")
             return
 
-
         CsHelper.mkdir(self.CS_RAMDISK_DIR, 0755, False)
         CsHelper.mount_tmpfs(self.CS_RAMDISK_DIR)
         CsHelper.mkdir(self.CS_ROUTER_DIR, 0755, False)
@@ -148,7 +147,7 @@ class CsRedundant(object):
         conntrackd_temp_bkp = "%s/%s" % (self.CS_TEMPLATES_DIR, "conntrackd.conf.templ.bkp")
         
         CsHelper.copy(conntrackd_template_conf, conntrackd_temp_bkp)
-        
+
         conntrackd_tmpl = CsFile(conntrackd_template_conf)
         conntrackd_tmpl.section("Multicast {", "}", [
                       "IPv4_address 225.0.0.50\n",
@@ -164,10 +163,14 @@ class CsRedundant(object):
         conntrackd_conf = CsFile(self.CONNTRACKD_CONF)
 
         is_equals = conntrackd_tmpl.compare(conntrackd_conf)
+
+        force_keepalived_restart = False
         proc = CsProcess(['/etc/conntrackd/conntrackd.conf'])
-        if not proc.find() or not is_equals:
+
+        if not proc.find() and not is_equals:
             CsHelper.copy(conntrackd_template_conf, self.CONNTRACKD_CONF)
             CsHelper.service("conntrackd", "restart")
+            force_keepalived_restart = True
 
         # Restore the template file and remove the backup.
         CsHelper.copy(conntrackd_temp_bkp, conntrackd_template_conf)
@@ -185,7 +188,7 @@ class CsRedundant(object):
         heartbeat_cron.commit()
 
         proc = CsProcess(['/usr/sbin/keepalived'])
-        if not proc.find() or keepalived_conf.is_changed():
+        if not proc.find() or keepalived_conf.is_changed() or force_keepalived_restart:
             keepalived_conf.commit()
             CsHelper.service("keepalived", "restart")