You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2022/11/14 14:39:42 UTC

[GitHub] [cloudstack] CharlesQueiroz opened a new pull request, #6899: Count Resource Virtual Router

CharlesQueiroz opened a new pull request, #6899:
URL: https://github.com/apache/cloudstack/pull/6899

   ### Description
   
   Currently the virtual router resources are not counted
   towards domain resource count. Only the CPU/MEM of user
   virtual machine are counted. If some customers have
   VR's with higher cpu/memory values than the default value of
   1 core, 256MB RAM then they are consuming extra resources
   which are not counted towards the resource calculation
   of the domain/account.
   
   So two global settings are added to this change
   
   ```
   "resource.count.running.routers" and "resource.count.running.routers.type"
   
   "resource.count.running.routers" can have either true of false
   "resource.count.running.routers.type" can have either "all" or "delta"
   The default value is "all"
   
   If "resource.count.running.routers" is true, then if
   "resource.count.running.routers.type" is "all", then all VR resources
   are counted towards the domain resource consumption
   
   For example: If VR is running with 4 cores, and 4GB ram, then all 4 cores
   and 4 GB are added to domain resource consumption
   
   If "resource.count.running.routers.type" is "delta" then the diff
   between the current VR CPU/ram and the default VR offering CPU/ram
   is considered for domain resource calculation.
   
   For example: If VR is running with 4 cores and 4Gb ram, then
   3 cores and 4gb-0.25Gb will be counted for resource consumption
   
   If "resource.count.running.routers" is false, then even if VR
   has higher CPU/ram, then its not counted towards domain resource
   consumption
   
   Test cases:
   
   It can be tested using.
   
   nosetests --with-marvin --marvin-config=<your test config file>.cfg test_router_resources.py
   ```
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [x] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup that may add test cases)
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] CharlesQueiroz commented on a diff in pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
CharlesQueiroz commented on code in PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#discussion_r1047967241


##########
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java:
##########
@@ -44,7 +44,7 @@
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-
+import com.googlecode.ipv6.IPv6Network;

Review Comment:
   @weizhouapache sorry, man... I don't get the point. This means: "don't import IPv6Network"? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland commented on a diff in pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on code in PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#discussion_r1065443471


##########
.travis.yml:
##########
@@ -173,6 +173,7 @@ env:
 
     - TESTS="component/test_regions_accounts
              component/test_routers
+             component/test_router_resources

Review Comment:
   travis has been phased out. You'll need to add this to github actions now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1354642269

   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1335081994

   <b>Trillian Build Failed (tid-5361)<b/>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland commented on a diff in pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on code in PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#discussion_r1038021658


##########
test/integration/component/test_router_resources.py:
##########
@@ -0,0 +1,824 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Test case for router resources
+"""
+
+# Import local modules
+
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import (scaleSystemVm,
+                                  stopRouter,
+                                  startRouter,
+                                  restartNetwork,
+                                  updateConfiguration)
+from marvin.lib.utils import (cleanup_resources)
+from marvin.lib.base import (NetworkOffering,
+                             ServiceOffering,
+                             VirtualMachine,
+                             Account,
+                             Domain,
+                             Network,
+                             Router,
+                             destroyRouter,
+                             Zone,
+                             updateResourceCount)
+from marvin.lib.common import (get_zone,
+                               get_template,
+                               get_domain,
+                               list_virtual_machines,
+                               list_networks,
+                               list_configurations,
+                               list_routers,
+                               list_service_offering)
+
+import logging
+
+class TestRouterResources(cloudstackTestCase):
+
+    @classmethod
+    def setupClass(cls):
+        cls.testClient = super(
+            TestRouterResources, cls
+        ).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+
+        cls.services = cls.testClient.getParsedTestDataConfig()
+        zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.zone = Zone(zone.__dict__)
+        cls.template = get_template(cls.apiclient, cls.zone.id)
+        cls._cleanup = []
+
+        cls.logger = logging.getLogger("TestRouterResources")
+        cls.stream_handler = logging.StreamHandler()
+        cls.logger.setLevel(logging.DEBUG)
+        cls.logger.addHandler(cls.stream_handler)
+
+        # Get Zone, Domain and templates
+        cls.domain = get_domain(cls.apiclient)
+
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offerings"]["big"]
+        )
+
+        # Create new domain1
+        cls.domain1 = Domain.create(
+            cls.apiclient,
+            services=cls.services["acl"]["domain1"],
+            parentdomainid=cls.domain.id)
+
+        # Create account1
+        cls.account1 = Account.create(
+            cls.apiclient,
+            cls.services["acl"]["accountD1"],
+            domainid=cls.domain1.id
+        )
+
+        # Create Network Offering with all the services
+        cls.network_offering = NetworkOffering.create(
+            cls.apiclient,
+            cls.services["isolated_network_offering"]
+        )
+        # Enable Network offering
+        cls.network_offering.update(cls.apiclient, state='Enabled')
+
+        cls.network = Network.create(
+            cls.apiclient,
+            cls.services["isolated_network"],
+            accountid=cls.account1.name,
+            domainid=cls.account1.domainid,
+            networkofferingid=cls.network_offering.id,
+            zoneid=cls.zone.id
+        )
+
+        virtualmachine = VirtualMachine.create(
+            cls.apiclient,
+            services=cls.services["virtual_machine_userdata"],
+            accountid=cls.account1.name,
+            domainid=cls.account1.domainid,
+            serviceofferingid=cls.service_offering.id,
+            networkids=cls.network.id,
+            templateid=cls.template.id,
+            zoneid=cls.zone.id
+        )

Review Comment:
   ```suggestion
           virtualmachine = VirtualMachine.create(
               cls.apiclient,
               services=cls.services["virtual_machine_userdata"],
               accountid=cls.account1.name,
               domainid=cls.account1.domainid,
               serviceofferingid=cls.service_offering.id,
               networkids=cls.network.id,
               templateid=cls.template.id,
               zoneid=cls.zone.id
           )
           cls._cleanup.append(virtualmachine)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1313860766

   @acs-robot a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] soreana commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
soreana commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1313868481

   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] CharlesQueiroz commented on a diff in pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
CharlesQueiroz commented on code in PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#discussion_r1027320266


##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -2108,6 +2256,16 @@ private void advanceStop(final VMInstanceVO vm, final boolean cleanUpEvenIfUnabl
         }
     }
 
+    private void changeVrCountResourceBy(VirtualMachine.Type type, long domainId, ServiceOffering offering, Account owner, boolean decrement) {

Review Comment:
   done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] sonarcloud[bot] commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1313951638

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache_cloudstack&pullRequest=6899)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6899&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6899&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6899&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=CODE_SMELL) [32 Code Smells](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=CODE_SMELL)
   
   [![2.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '2.0%')](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6899&metric=new_coverage&view=list) [2.0% Coverage](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6899&metric=new_coverage&view=list)  
   [![13.3%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/20-16px.png '13.3%')](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6899&metric=new_duplicated_lines_density&view=list) [13.3% Duplication](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6899&metric=new_duplicated_lines_density&view=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] sonarcloud[bot] commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1318679855

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache_cloudstack&pullRequest=6899)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6899&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6899&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6899&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=CODE_SMELL)
   
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6899&metric=new_coverage&view=list) [1.9% Coverage](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6899&metric=new_coverage&view=list)  
   [![12.5%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/20-16px.png '12.5%')](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6899&metric=new_duplicated_lines_density&view=list) [12.5% Duplication](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6899&metric=new_duplicated_lines_density&view=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] acs-robot commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
acs-robot commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1318798553

   Found UI changes, kicking a new UI QA build
   @blueorangutan ui


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland commented on a diff in pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on code in PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#discussion_r1035653160


##########
test/integration/component/test_router_resources.py:
##########
@@ -0,0 +1,824 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Test case for router resources
+"""
+
+# Import local modules
+
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import (scaleSystemVm,
+                                  stopRouter,
+                                  startRouter,
+                                  restartNetwork,
+                                  updateConfiguration)
+from marvin.lib.utils import (cleanup_resources)
+from marvin.lib.base import (NetworkOffering,
+                             ServiceOffering,
+                             VirtualMachine,
+                             Account,
+                             Domain,
+                             Network,
+                             Router,
+                             destroyRouter,
+                             Zone,
+                             updateResourceCount)
+from marvin.lib.common import (get_zone,
+                               get_template,
+                               get_domain,
+                               list_virtual_machines,
+                               list_networks,
+                               list_configurations,
+                               list_routers,
+                               list_service_offering)
+
+import logging
+
+class TestRouterResources(cloudstackTestCase):
+
+    @classmethod
+    def setupClass(cls):
+        cls.testClient = super(
+            TestRouterResources, cls
+        ).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+
+        cls.services = cls.testClient.getParsedTestDataConfig()
+        zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.zone = Zone(zone.__dict__)
+        cls.template = get_template(cls.apiclient, cls.zone.id)
+        cls._cleanup = []
+
+        cls.logger = logging.getLogger("TestRouterResources")
+        cls.stream_handler = logging.StreamHandler()
+        cls.logger.setLevel(logging.DEBUG)
+        cls.logger.addHandler(cls.stream_handler)
+
+        # Get Zone, Domain and templates
+        cls.domain = get_domain(cls.apiclient)
+
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offerings"]["big"]
+        )
+
+        # Create new domain1
+        cls.domain1 = Domain.create(
+            cls.apiclient,
+            services=cls.services["acl"]["domain1"],
+            parentdomainid=cls.domain.id)

Review Comment:
   please add to `_cleanup` immediately



##########
test/integration/component/test_router_resources.py:
##########
@@ -0,0 +1,824 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Test case for router resources
+"""
+
+# Import local modules
+
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import (scaleSystemVm,
+                                  stopRouter,
+                                  startRouter,
+                                  restartNetwork,
+                                  updateConfiguration)
+from marvin.lib.utils import (cleanup_resources)
+from marvin.lib.base import (NetworkOffering,
+                             ServiceOffering,
+                             VirtualMachine,
+                             Account,
+                             Domain,
+                             Network,
+                             Router,
+                             destroyRouter,
+                             Zone,
+                             updateResourceCount)
+from marvin.lib.common import (get_zone,
+                               get_template,
+                               get_domain,
+                               list_virtual_machines,
+                               list_networks,
+                               list_configurations,
+                               list_routers,
+                               list_service_offering)
+
+import logging
+
+class TestRouterResources(cloudstackTestCase):
+
+    @classmethod
+    def setupClass(cls):
+        cls.testClient = super(
+            TestRouterResources, cls
+        ).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+
+        cls.services = cls.testClient.getParsedTestDataConfig()
+        zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.zone = Zone(zone.__dict__)
+        cls.template = get_template(cls.apiclient, cls.zone.id)
+        cls._cleanup = []
+
+        cls.logger = logging.getLogger("TestRouterResources")
+        cls.stream_handler = logging.StreamHandler()
+        cls.logger.setLevel(logging.DEBUG)
+        cls.logger.addHandler(cls.stream_handler)
+
+        # Get Zone, Domain and templates
+        cls.domain = get_domain(cls.apiclient)
+
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offerings"]["big"]
+        )
+
+        # Create new domain1
+        cls.domain1 = Domain.create(
+            cls.apiclient,
+            services=cls.services["acl"]["domain1"],
+            parentdomainid=cls.domain.id)
+
+        # Create account1
+        cls.account1 = Account.create(
+            cls.apiclient,
+            cls.services["acl"]["accountD1"],
+            domainid=cls.domain1.id
+        )
+
+        # Create Network Offering with all the services
+        cls.network_offering = NetworkOffering.create(
+            cls.apiclient,
+            cls.services["isolated_network_offering"]
+        )

Review Comment:
   please add to `_cleanup` immediately



##########
test/integration/component/test_router_resources.py:
##########
@@ -0,0 +1,824 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Test case for router resources
+"""
+
+# Import local modules
+
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import (scaleSystemVm,
+                                  stopRouter,
+                                  startRouter,
+                                  restartNetwork,
+                                  updateConfiguration)
+from marvin.lib.utils import (cleanup_resources)
+from marvin.lib.base import (NetworkOffering,
+                             ServiceOffering,
+                             VirtualMachine,
+                             Account,
+                             Domain,
+                             Network,
+                             Router,
+                             destroyRouter,
+                             Zone,
+                             updateResourceCount)
+from marvin.lib.common import (get_zone,
+                               get_template,
+                               get_domain,
+                               list_virtual_machines,
+                               list_networks,
+                               list_configurations,
+                               list_routers,
+                               list_service_offering)
+
+import logging
+
+class TestRouterResources(cloudstackTestCase):
+
+    @classmethod
+    def setupClass(cls):
+        cls.testClient = super(
+            TestRouterResources, cls
+        ).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+
+        cls.services = cls.testClient.getParsedTestDataConfig()
+        zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.zone = Zone(zone.__dict__)
+        cls.template = get_template(cls.apiclient, cls.zone.id)
+        cls._cleanup = []
+
+        cls.logger = logging.getLogger("TestRouterResources")
+        cls.stream_handler = logging.StreamHandler()
+        cls.logger.setLevel(logging.DEBUG)
+        cls.logger.addHandler(cls.stream_handler)
+
+        # Get Zone, Domain and templates
+        cls.domain = get_domain(cls.apiclient)
+
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offerings"]["big"]
+        )
+
+        # Create new domain1
+        cls.domain1 = Domain.create(
+            cls.apiclient,
+            services=cls.services["acl"]["domain1"],
+            parentdomainid=cls.domain.id)
+
+        # Create account1
+        cls.account1 = Account.create(
+            cls.apiclient,
+            cls.services["acl"]["accountD1"],
+            domainid=cls.domain1.id
+        )
+
+        # Create Network Offering with all the services
+        cls.network_offering = NetworkOffering.create(
+            cls.apiclient,
+            cls.services["isolated_network_offering"]
+        )
+        # Enable Network offering
+        cls.network_offering.update(cls.apiclient, state='Enabled')
+
+        cls.network = Network.create(
+            cls.apiclient,
+            cls.services["isolated_network"],
+            accountid=cls.account1.name,
+            domainid=cls.account1.domainid,
+            networkofferingid=cls.network_offering.id,
+            zoneid=cls.zone.id
+        )
+
+        virtualmachine = VirtualMachine.create(
+            cls.apiclient,
+            services=cls.services["virtual_machine_userdata"],
+            accountid=cls.account1.name,
+            domainid=cls.account1.domainid,
+            serviceofferingid=cls.service_offering.id,
+            networkids=cls.network.id,
+            templateid=cls.template.id,
+            zoneid=cls.zone.id
+        )
+
+        vms = list_virtual_machines(
+            cls.apiclient,
+            account=cls.account1.name,
+            domainid=cls.account1.domainid,
+            id=virtualmachine.id
+        )
+        vm = vms[0]
+
+        # get vm cpu and memory values
+        cls.vm_cpu_count = vm.cpunumber
+        cls.vm_mem_count = vm.memory
+
+        routers = list_routers(
+            cls.apiclient,
+            account=cls.account1.name,
+            domainid=cls.account1.domainid
+        )
+
+        router = routers[0]
+
+        router_so_id = router.serviceofferingid
+
+        list_service_response = list_service_offering(
+            cls.apiclient,
+            id=router_so_id,
+            issystem="true",
+            systemvmtype="domainrouter",
+            listall="true"
+        )
+
+        # Get default router service offering cpu and memory values
+        cls.default_vr_cpu = list_service_response[0].cpunumber
+        cls.default_vr_ram = list_service_response[0].memory
+
+        cls._cleanup.append(virtualmachine)
+        cls._cleanup.append(cls.network)
+
+        # Disable Network offering
+        cls.network_offering.update(cls.apiclient, state='Disabled')
+        cls._cleanup.append(cls.network_offering)
+        cls._cleanup.append(cls.account1)
+        cls._cleanup.append(cls.domain1)

Review Comment:
   too late ;)



##########
server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java:
##########
@@ -987,11 +1000,59 @@ public long countCpusForAccount(long accountId) {
         for (UserVmJoinVO vm : userVms) {
             cputotal += Long.valueOf(vm.getCpu());
         }
-        return cputotal;
+

Review Comment:
   can you extract the new bits in this method into separate methods, please?



##########
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java:
##########
@@ -1135,6 +1145,13 @@ private String validateConfigurationValue(final String name, String value, final
             return errMsg;
         }
 
+        if (VirtualMachineManager.ResourceCountRoutersType.key().equalsIgnoreCase(name)
+                && (!resourceCountRoutersTypeValues.contains(value) || isBlank(value))) {
+            final String msg = "Possible values are: delta or all.";
+            s_logger.error(msg);
+            throw new InvalidParameterValueException(msg);
+        }

Review Comment:
   please extract this to a method with a clear name, something that explains why the check is needed.



##########
test/integration/component/test_router_resources.py:
##########
@@ -0,0 +1,824 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Test case for router resources
+"""
+
+# Import local modules
+
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import (scaleSystemVm,
+                                  stopRouter,
+                                  startRouter,
+                                  restartNetwork,
+                                  updateConfiguration)
+from marvin.lib.utils import (cleanup_resources)
+from marvin.lib.base import (NetworkOffering,
+                             ServiceOffering,
+                             VirtualMachine,
+                             Account,
+                             Domain,
+                             Network,
+                             Router,
+                             destroyRouter,
+                             Zone,
+                             updateResourceCount)
+from marvin.lib.common import (get_zone,
+                               get_template,
+                               get_domain,
+                               list_virtual_machines,
+                               list_networks,
+                               list_configurations,
+                               list_routers,
+                               list_service_offering)
+
+import logging
+
+class TestRouterResources(cloudstackTestCase):
+
+    @classmethod
+    def setupClass(cls):
+        cls.testClient = super(
+            TestRouterResources, cls
+        ).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+
+        cls.services = cls.testClient.getParsedTestDataConfig()
+        zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.zone = Zone(zone.__dict__)
+        cls.template = get_template(cls.apiclient, cls.zone.id)
+        cls._cleanup = []
+
+        cls.logger = logging.getLogger("TestRouterResources")
+        cls.stream_handler = logging.StreamHandler()
+        cls.logger.setLevel(logging.DEBUG)
+        cls.logger.addHandler(cls.stream_handler)
+
+        # Get Zone, Domain and templates
+        cls.domain = get_domain(cls.apiclient)
+
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offerings"]["big"]
+        )
+
+        # Create new domain1
+        cls.domain1 = Domain.create(
+            cls.apiclient,
+            services=cls.services["acl"]["domain1"],
+            parentdomainid=cls.domain.id)
+
+        # Create account1
+        cls.account1 = Account.create(
+            cls.apiclient,
+            cls.services["acl"]["accountD1"],
+            domainid=cls.domain1.id
+        )

Review Comment:
   please add to `_cleanup` immediately



##########
test/integration/component/test_router_resources.py:
##########
@@ -0,0 +1,824 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Test case for router resources
+"""
+
+# Import local modules
+
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import (scaleSystemVm,
+                                  stopRouter,
+                                  startRouter,
+                                  restartNetwork,
+                                  updateConfiguration)
+from marvin.lib.utils import (cleanup_resources)
+from marvin.lib.base import (NetworkOffering,
+                             ServiceOffering,
+                             VirtualMachine,
+                             Account,
+                             Domain,
+                             Network,
+                             Router,
+                             destroyRouter,
+                             Zone,
+                             updateResourceCount)
+from marvin.lib.common import (get_zone,
+                               get_template,
+                               get_domain,
+                               list_virtual_machines,
+                               list_networks,
+                               list_configurations,
+                               list_routers,
+                               list_service_offering)
+
+import logging
+
+class TestRouterResources(cloudstackTestCase):
+
+    @classmethod
+    def setupClass(cls):
+        cls.testClient = super(
+            TestRouterResources, cls
+        ).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+
+        cls.services = cls.testClient.getParsedTestDataConfig()
+        zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.zone = Zone(zone.__dict__)
+        cls.template = get_template(cls.apiclient, cls.zone.id)
+        cls._cleanup = []
+
+        cls.logger = logging.getLogger("TestRouterResources")
+        cls.stream_handler = logging.StreamHandler()
+        cls.logger.setLevel(logging.DEBUG)
+        cls.logger.addHandler(cls.stream_handler)
+
+        # Get Zone, Domain and templates
+        cls.domain = get_domain(cls.apiclient)
+
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offerings"]["big"]
+        )
+
+        # Create new domain1
+        cls.domain1 = Domain.create(
+            cls.apiclient,
+            services=cls.services["acl"]["domain1"],
+            parentdomainid=cls.domain.id)
+
+        # Create account1
+        cls.account1 = Account.create(
+            cls.apiclient,
+            cls.services["acl"]["accountD1"],
+            domainid=cls.domain1.id
+        )
+
+        # Create Network Offering with all the services
+        cls.network_offering = NetworkOffering.create(
+            cls.apiclient,
+            cls.services["isolated_network_offering"]
+        )
+        # Enable Network offering
+        cls.network_offering.update(cls.apiclient, state='Enabled')
+
+        cls.network = Network.create(
+            cls.apiclient,
+            cls.services["isolated_network"],
+            accountid=cls.account1.name,
+            domainid=cls.account1.domainid,
+            networkofferingid=cls.network_offering.id,
+            zoneid=cls.zone.id
+        )

Review Comment:
   please add to `_cleanup` immediately



##########
test/integration/component/test_router_resources.py:
##########
@@ -0,0 +1,824 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Test case for router resources
+"""
+
+# Import local modules
+
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import (scaleSystemVm,
+                                  stopRouter,
+                                  startRouter,
+                                  restartNetwork,
+                                  updateConfiguration)
+from marvin.lib.utils import (cleanup_resources)
+from marvin.lib.base import (NetworkOffering,
+                             ServiceOffering,
+                             VirtualMachine,
+                             Account,
+                             Domain,
+                             Network,
+                             Router,
+                             destroyRouter,
+                             Zone,
+                             updateResourceCount)
+from marvin.lib.common import (get_zone,
+                               get_template,
+                               get_domain,
+                               list_virtual_machines,
+                               list_networks,
+                               list_configurations,
+                               list_routers,
+                               list_service_offering)
+
+import logging
+
+class TestRouterResources(cloudstackTestCase):
+
+    @classmethod
+    def setupClass(cls):
+        cls.testClient = super(
+            TestRouterResources, cls
+        ).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+
+        cls.services = cls.testClient.getParsedTestDataConfig()
+        zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.zone = Zone(zone.__dict__)
+        cls.template = get_template(cls.apiclient, cls.zone.id)
+        cls._cleanup = []
+
+        cls.logger = logging.getLogger("TestRouterResources")
+        cls.stream_handler = logging.StreamHandler()
+        cls.logger.setLevel(logging.DEBUG)
+        cls.logger.addHandler(cls.stream_handler)
+
+        # Get Zone, Domain and templates
+        cls.domain = get_domain(cls.apiclient)
+
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offerings"]["big"]
+        )
+
+        # Create new domain1
+        cls.domain1 = Domain.create(
+            cls.apiclient,
+            services=cls.services["acl"]["domain1"],
+            parentdomainid=cls.domain.id)
+
+        # Create account1
+        cls.account1 = Account.create(
+            cls.apiclient,
+            cls.services["acl"]["accountD1"],
+            domainid=cls.domain1.id
+        )
+
+        # Create Network Offering with all the services
+        cls.network_offering = NetworkOffering.create(
+            cls.apiclient,
+            cls.services["isolated_network_offering"]
+        )
+        # Enable Network offering
+        cls.network_offering.update(cls.apiclient, state='Enabled')
+
+        cls.network = Network.create(
+            cls.apiclient,
+            cls.services["isolated_network"],
+            accountid=cls.account1.name,
+            domainid=cls.account1.domainid,
+            networkofferingid=cls.network_offering.id,
+            zoneid=cls.zone.id
+        )
+
+        virtualmachine = VirtualMachine.create(
+            cls.apiclient,
+            services=cls.services["virtual_machine_userdata"],
+            accountid=cls.account1.name,
+            domainid=cls.account1.domainid,
+            serviceofferingid=cls.service_offering.id,
+            networkids=cls.network.id,
+            templateid=cls.template.id,
+            zoneid=cls.zone.id
+        )
+
+        vms = list_virtual_machines(
+            cls.apiclient,
+            account=cls.account1.name,
+            domainid=cls.account1.domainid,
+            id=virtualmachine.id
+        )
+        vm = vms[0]
+
+        # get vm cpu and memory values
+        cls.vm_cpu_count = vm.cpunumber
+        cls.vm_mem_count = vm.memory
+
+        routers = list_routers(
+            cls.apiclient,
+            account=cls.account1.name,
+            domainid=cls.account1.domainid
+        )
+
+        router = routers[0]
+
+        router_so_id = router.serviceofferingid
+
+        list_service_response = list_service_offering(
+            cls.apiclient,
+            id=router_so_id,
+            issystem="true",
+            systemvmtype="domainrouter",
+            listall="true"
+        )
+
+        # Get default router service offering cpu and memory values
+        cls.default_vr_cpu = list_service_response[0].cpunumber
+        cls.default_vr_ram = list_service_response[0].memory
+
+        cls._cleanup.append(virtualmachine)
+        cls._cleanup.append(cls.network)
+
+        # Disable Network offering
+        cls.network_offering.update(cls.apiclient, state='Disabled')
+        cls._cleanup.append(cls.network_offering)
+        cls._cleanup.append(cls.account1)
+        cls._cleanup.append(cls.domain1)
+
+    @classmethod
+    def tearDownClass(cls):
+        try:
+            cleanup_resources(cls.apiclient, cls._cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return
+
+    def setUp(self):
+        self.apiclient = self.testClient.getApiClient()
+        self.cleanup = []
+        return
+
+    def tearDown(self):
+        try:
+            cleanup_resources(self.apiclient, self.cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return

Review Comment:
   ```suggestion
           super(TestRouterResources, self).tearDown()
   ```



##########
server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java:
##########
@@ -1011,7 +1072,51 @@ public long calculateMemoryForAccount(long accountId) {
         for (UserVmJoinVO vm : userVms) {
             ramtotal += Long.valueOf(vm.getRamSize());
         }
-        return ramtotal;
+

Review Comment:
   Can you extract the new parts of this method into separate methods please?



##########
server/src/main/java/com/cloud/network/router/NetworkHelperImpl.java:
##########
@@ -568,6 +588,10 @@ public DomainRouterVO deployRouter(final RouterDeploymentDefinition routerDeploy
                         destroyRouter(router.getId(), _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM), User.UID_SYSTEM);
                         continue;
                     } else {
+                        // If router can't be started then decrement the resource count
+                        if (Boolean.TRUE.equals(VirtualMachineManager.ResourceCountRouters.valueIn(owner.getDomainId()))) {
+                            _itMgr.decrementVrResourceCount(routerOffering, owner,true);
+                        }

Review Comment:
   re-use



##########
test/integration/component/test_router_resources.py:
##########
@@ -0,0 +1,824 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Test case for router resources
+"""
+
+# Import local modules
+
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import (scaleSystemVm,
+                                  stopRouter,
+                                  startRouter,
+                                  restartNetwork,
+                                  updateConfiguration)
+from marvin.lib.utils import (cleanup_resources)
+from marvin.lib.base import (NetworkOffering,
+                             ServiceOffering,
+                             VirtualMachine,
+                             Account,
+                             Domain,
+                             Network,
+                             Router,
+                             destroyRouter,
+                             Zone,
+                             updateResourceCount)
+from marvin.lib.common import (get_zone,
+                               get_template,
+                               get_domain,
+                               list_virtual_machines,
+                               list_networks,
+                               list_configurations,
+                               list_routers,
+                               list_service_offering)
+
+import logging
+
+class TestRouterResources(cloudstackTestCase):
+
+    @classmethod
+    def setupClass(cls):
+        cls.testClient = super(
+            TestRouterResources, cls
+        ).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+
+        cls.services = cls.testClient.getParsedTestDataConfig()
+        zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.zone = Zone(zone.__dict__)
+        cls.template = get_template(cls.apiclient, cls.zone.id)
+        cls._cleanup = []
+
+        cls.logger = logging.getLogger("TestRouterResources")
+        cls.stream_handler = logging.StreamHandler()
+        cls.logger.setLevel(logging.DEBUG)
+        cls.logger.addHandler(cls.stream_handler)
+
+        # Get Zone, Domain and templates
+        cls.domain = get_domain(cls.apiclient)
+
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offerings"]["big"]
+        )

Review Comment:
   please add `cls.service_offering` to `cls._cleanup` immediately i.e.
   ```suggestion
           cls.service_offering = ServiceOffering.create(
               cls.apiclient,
               cls.services["service_offerings"]["big"]
           )
           cls._cleanup.append(cls.service_offering)
   ```
   if you wait till later and an exception occurs we get left with garbage in our env after the test run.



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -2094,10 +2238,14 @@ private void advanceStop(final VMInstanceVO vm, final boolean cleanUpEvenIfUnabl
 
             boolean result = stateTransitTo(vm, Event.OperationSucceeded, null);
             if (result) {
+                ServiceOfferingVO offering = _offeringDao.findById(vm.getId(), vm.getServiceOfferingId());
                 if (VirtualMachine.Type.User.equals(vm.type) && ResourceCountRunningVMsonly.value()) {
-                    ServiceOfferingVO offering = _offeringDao.findById(vm.getId(), vm.getServiceOfferingId());
-                    resourceCountDecrement(vm.getAccountId(),new Long(offering.getCpu()), new Long(offering.getRamSize()));
+                    //update resource count if stop successfully

Review Comment:
   this comment should not be necessary, if the code is clear (or it could be a javadoc for an extracted method)



##########
test/integration/component/test_router_resources.py:
##########
@@ -0,0 +1,824 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Test case for router resources
+"""
+
+# Import local modules
+
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import (scaleSystemVm,
+                                  stopRouter,
+                                  startRouter,
+                                  restartNetwork,
+                                  updateConfiguration)
+from marvin.lib.utils import (cleanup_resources)
+from marvin.lib.base import (NetworkOffering,
+                             ServiceOffering,
+                             VirtualMachine,
+                             Account,
+                             Domain,
+                             Network,
+                             Router,
+                             destroyRouter,
+                             Zone,
+                             updateResourceCount)
+from marvin.lib.common import (get_zone,
+                               get_template,
+                               get_domain,
+                               list_virtual_machines,
+                               list_networks,
+                               list_configurations,
+                               list_routers,
+                               list_service_offering)
+
+import logging
+
+class TestRouterResources(cloudstackTestCase):
+
+    @classmethod
+    def setupClass(cls):
+        cls.testClient = super(
+            TestRouterResources, cls
+        ).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+
+        cls.services = cls.testClient.getParsedTestDataConfig()
+        zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.zone = Zone(zone.__dict__)
+        cls.template = get_template(cls.apiclient, cls.zone.id)
+        cls._cleanup = []
+
+        cls.logger = logging.getLogger("TestRouterResources")
+        cls.stream_handler = logging.StreamHandler()
+        cls.logger.setLevel(logging.DEBUG)
+        cls.logger.addHandler(cls.stream_handler)
+
+        # Get Zone, Domain and templates
+        cls.domain = get_domain(cls.apiclient)
+
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offerings"]["big"]
+        )
+
+        # Create new domain1
+        cls.domain1 = Domain.create(
+            cls.apiclient,
+            services=cls.services["acl"]["domain1"],
+            parentdomainid=cls.domain.id)
+
+        # Create account1
+        cls.account1 = Account.create(
+            cls.apiclient,
+            cls.services["acl"]["accountD1"],
+            domainid=cls.domain1.id
+        )
+
+        # Create Network Offering with all the services
+        cls.network_offering = NetworkOffering.create(
+            cls.apiclient,
+            cls.services["isolated_network_offering"]
+        )
+        # Enable Network offering
+        cls.network_offering.update(cls.apiclient, state='Enabled')
+
+        cls.network = Network.create(
+            cls.apiclient,
+            cls.services["isolated_network"],
+            accountid=cls.account1.name,
+            domainid=cls.account1.domainid,
+            networkofferingid=cls.network_offering.id,
+            zoneid=cls.zone.id
+        )
+
+        virtualmachine = VirtualMachine.create(
+            cls.apiclient,
+            services=cls.services["virtual_machine_userdata"],
+            accountid=cls.account1.name,
+            domainid=cls.account1.domainid,
+            serviceofferingid=cls.service_offering.id,
+            networkids=cls.network.id,
+            templateid=cls.template.id,
+            zoneid=cls.zone.id
+        )
+
+        vms = list_virtual_machines(
+            cls.apiclient,
+            account=cls.account1.name,
+            domainid=cls.account1.domainid,
+            id=virtualmachine.id
+        )
+        vm = vms[0]
+
+        # get vm cpu and memory values
+        cls.vm_cpu_count = vm.cpunumber
+        cls.vm_mem_count = vm.memory
+
+        routers = list_routers(
+            cls.apiclient,
+            account=cls.account1.name,
+            domainid=cls.account1.domainid
+        )
+
+        router = routers[0]
+
+        router_so_id = router.serviceofferingid
+
+        list_service_response = list_service_offering(
+            cls.apiclient,
+            id=router_so_id,
+            issystem="true",
+            systemvmtype="domainrouter",
+            listall="true"
+        )
+
+        # Get default router service offering cpu and memory values
+        cls.default_vr_cpu = list_service_response[0].cpunumber
+        cls.default_vr_ram = list_service_response[0].memory
+
+        cls._cleanup.append(virtualmachine)
+        cls._cleanup.append(cls.network)
+
+        # Disable Network offering
+        cls.network_offering.update(cls.apiclient, state='Disabled')
+        cls._cleanup.append(cls.network_offering)
+        cls._cleanup.append(cls.account1)
+        cls._cleanup.append(cls.domain1)
+
+    @classmethod
+    def tearDownClass(cls):
+        try:
+            cleanup_resources(cls.apiclient, cls._cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return

Review Comment:
   ```suggestion
           super(TestRouterResources, cls).tearDownClass()
   ```



##########
test/integration/component/test_router_resources.py:
##########
@@ -0,0 +1,824 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Test case for router resources
+"""
+
+# Import local modules
+
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import (scaleSystemVm,
+                                  stopRouter,
+                                  startRouter,
+                                  restartNetwork,
+                                  updateConfiguration)
+from marvin.lib.utils import (cleanup_resources)
+from marvin.lib.base import (NetworkOffering,
+                             ServiceOffering,
+                             VirtualMachine,
+                             Account,
+                             Domain,
+                             Network,
+                             Router,
+                             destroyRouter,
+                             Zone,
+                             updateResourceCount)
+from marvin.lib.common import (get_zone,
+                               get_template,
+                               get_domain,
+                               list_virtual_machines,
+                               list_networks,
+                               list_configurations,
+                               list_routers,
+                               list_service_offering)
+
+import logging
+
+class TestRouterResources(cloudstackTestCase):
+
+    @classmethod
+    def setupClass(cls):
+        cls.testClient = super(
+            TestRouterResources, cls
+        ).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+
+        cls.services = cls.testClient.getParsedTestDataConfig()
+        zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.zone = Zone(zone.__dict__)
+        cls.template = get_template(cls.apiclient, cls.zone.id)
+        cls._cleanup = []
+
+        cls.logger = logging.getLogger("TestRouterResources")
+        cls.stream_handler = logging.StreamHandler()
+        cls.logger.setLevel(logging.DEBUG)
+        cls.logger.addHandler(cls.stream_handler)
+
+        # Get Zone, Domain and templates
+        cls.domain = get_domain(cls.apiclient)
+
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offerings"]["big"]
+        )
+
+        # Create new domain1
+        cls.domain1 = Domain.create(
+            cls.apiclient,
+            services=cls.services["acl"]["domain1"],
+            parentdomainid=cls.domain.id)
+
+        # Create account1
+        cls.account1 = Account.create(
+            cls.apiclient,
+            cls.services["acl"]["accountD1"],
+            domainid=cls.domain1.id
+        )
+
+        # Create Network Offering with all the services
+        cls.network_offering = NetworkOffering.create(
+            cls.apiclient,
+            cls.services["isolated_network_offering"]
+        )
+        # Enable Network offering
+        cls.network_offering.update(cls.apiclient, state='Enabled')
+
+        cls.network = Network.create(
+            cls.apiclient,
+            cls.services["isolated_network"],
+            accountid=cls.account1.name,
+            domainid=cls.account1.domainid,
+            networkofferingid=cls.network_offering.id,
+            zoneid=cls.zone.id
+        )
+
+        virtualmachine = VirtualMachine.create(
+            cls.apiclient,
+            services=cls.services["virtual_machine_userdata"],
+            accountid=cls.account1.name,
+            domainid=cls.account1.domainid,
+            serviceofferingid=cls.service_offering.id,
+            networkids=cls.network.id,
+            templateid=cls.template.id,
+            zoneid=cls.zone.id
+        )
+
+        vms = list_virtual_machines(
+            cls.apiclient,
+            account=cls.account1.name,
+            domainid=cls.account1.domainid,
+            id=virtualmachine.id
+        )
+        vm = vms[0]
+
+        # get vm cpu and memory values
+        cls.vm_cpu_count = vm.cpunumber
+        cls.vm_mem_count = vm.memory
+
+        routers = list_routers(
+            cls.apiclient,
+            account=cls.account1.name,
+            domainid=cls.account1.domainid
+        )
+
+        router = routers[0]
+
+        router_so_id = router.serviceofferingid
+
+        list_service_response = list_service_offering(
+            cls.apiclient,
+            id=router_so_id,
+            issystem="true",
+            systemvmtype="domainrouter",
+            listall="true"
+        )
+
+        # Get default router service offering cpu and memory values
+        cls.default_vr_cpu = list_service_response[0].cpunumber
+        cls.default_vr_ram = list_service_response[0].memory
+
+        cls._cleanup.append(virtualmachine)
+        cls._cleanup.append(cls.network)
+
+        # Disable Network offering
+        cls.network_offering.update(cls.apiclient, state='Disabled')
+        cls._cleanup.append(cls.network_offering)
+        cls._cleanup.append(cls.account1)
+        cls._cleanup.append(cls.domain1)

Review Comment:
   also you can use the super call to do the cleaning but they need to be in the order of creation for that.



##########
test/integration/component/test_router_resources.py:
##########
@@ -0,0 +1,824 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Test case for router resources
+"""
+
+# Import local modules
+
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import (scaleSystemVm,
+                                  stopRouter,
+                                  startRouter,
+                                  restartNetwork,
+                                  updateConfiguration)
+from marvin.lib.utils import (cleanup_resources)
+from marvin.lib.base import (NetworkOffering,
+                             ServiceOffering,
+                             VirtualMachine,
+                             Account,
+                             Domain,
+                             Network,
+                             Router,
+                             destroyRouter,
+                             Zone,
+                             updateResourceCount)
+from marvin.lib.common import (get_zone,
+                               get_template,
+                               get_domain,
+                               list_virtual_machines,
+                               list_networks,
+                               list_configurations,
+                               list_routers,
+                               list_service_offering)
+
+import logging
+
+class TestRouterResources(cloudstackTestCase):
+
+    @classmethod
+    def setupClass(cls):
+        cls.testClient = super(
+            TestRouterResources, cls
+        ).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+
+        cls.services = cls.testClient.getParsedTestDataConfig()
+        zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.zone = Zone(zone.__dict__)
+        cls.template = get_template(cls.apiclient, cls.zone.id)
+        cls._cleanup = []
+
+        cls.logger = logging.getLogger("TestRouterResources")
+        cls.stream_handler = logging.StreamHandler()
+        cls.logger.setLevel(logging.DEBUG)
+        cls.logger.addHandler(cls.stream_handler)
+
+        # Get Zone, Domain and templates
+        cls.domain = get_domain(cls.apiclient)
+
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offerings"]["big"]
+        )
+
+        # Create new domain1
+        cls.domain1 = Domain.create(
+            cls.apiclient,
+            services=cls.services["acl"]["domain1"],
+            parentdomainid=cls.domain.id)
+
+        # Create account1
+        cls.account1 = Account.create(
+            cls.apiclient,
+            cls.services["acl"]["accountD1"],
+            domainid=cls.domain1.id
+        )
+
+        # Create Network Offering with all the services
+        cls.network_offering = NetworkOffering.create(
+            cls.apiclient,
+            cls.services["isolated_network_offering"]
+        )
+        # Enable Network offering
+        cls.network_offering.update(cls.apiclient, state='Enabled')
+
+        cls.network = Network.create(
+            cls.apiclient,
+            cls.services["isolated_network"],
+            accountid=cls.account1.name,
+            domainid=cls.account1.domainid,
+            networkofferingid=cls.network_offering.id,
+            zoneid=cls.zone.id
+        )
+
+        virtualmachine = VirtualMachine.create(
+            cls.apiclient,
+            services=cls.services["virtual_machine_userdata"],
+            accountid=cls.account1.name,
+            domainid=cls.account1.domainid,
+            serviceofferingid=cls.service_offering.id,
+            networkids=cls.network.id,
+            templateid=cls.template.id,
+            zoneid=cls.zone.id
+        )

Review Comment:
   please add to `_cleanup` immediately



##########
server/src/main/java/com/cloud/network/router/NetworkHelperImpl.java:
##########
@@ -502,6 +510,14 @@ public DomainRouterVO deployRouter(final RouterDeploymentDefinition routerDeploy
         // failed both times, throw the exception up
         final List<HypervisorType> hypervisors = getHypervisors(routerDeploymentDefinition);
 
+        // Increment the resource count with router offering.
+        // If router can't be deployed or started, decrement the resources.
+        // If resource.count.running.vms is false, increment resource count.
+        if (Boolean.TRUE.equals(VirtualMachineManager.ResourceCountRouters.valueIn(owner.getDomainId()))) {
+            _itMgr.incrementVrResourceCount(routerOffering,
+                    owner, true);
+        }

Review Comment:
   please extract this



##########
server/src/main/java/com/cloud/network/router/NetworkHelperImpl.java:
##########
@@ -262,8 +262,16 @@ public VirtualRouter destroyRouter(final long routerId, final Account caller, fi
             return null;
         }
 
+
+
         _accountMgr.checkAccess(caller, null, true, router);
 
+        final Account owner = _accountMgr.getAccount(router.getAccountId());
+        ServiceOfferingVO routerOffering = _serviceOfferingDao.findById(router.getServiceOfferingId());
+        if (Boolean.TRUE.equals(VirtualMachineManager.ResourceCountRouters.valueIn(router.getDomainId()))) {
+            _itMgr.decrementVrResourceCount(routerOffering, owner, true);
+        }

Review Comment:
   can you extract this?



##########
server/src/main/java/com/cloud/network/router/NetworkHelperImpl.java:
##########
@@ -551,6 +567,10 @@ public DomainRouterVO deployRouter(final RouterDeploymentDefinition routerDeploy
                     s_logger.debug("Failed to allocate the VR with hypervisor type " + hType + ", retrying one more time");
                     continue;
                 } else {
+                    // If VR can't be deployed then decrement the resource count
+                    if (Boolean.TRUE.equals(VirtualMachineManager.ResourceCountRouters.valueIn(owner.getDomainId()))) {
+                        _itMgr.decrementVrResourceCount(routerOffering, owner,true);
+                    }

Review Comment:
   sounds like a utility method and the comment as javadoc. Can you extracta and reuse this, please?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1330542337

   @soreana a Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] github-actions[bot] commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1342975996

   This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1313926779

   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. LL-JID 266


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] acs-robot commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
acs-robot commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1313860055

   Found UI changes, kicking a new UI QA build
   @blueorangutan ui


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] soreana commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
soreana commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1318808140

   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] CharlesQueiroz commented on a diff in pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
CharlesQueiroz commented on code in PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#discussion_r1026364855


##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,6 +1413,131 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Function to increment the VR resource count
+     *
+     * If the global setting resource.count.router is true then the VR
+     * resource count will be considered as well
+     * If the global setting resource.count.router.type is "all" then
+     * all VR resource count will be considered else the diff between
+     * the current VR service offering and the default offering will
+     * be considered
+     *
+     * @param offering
+     * @param owner
+     * @param isDeployOrDestroy
+     */
+    @Override
+    public void incrementVrResourceCount(ServiceOffering offering,
+                                         Account owner,
+                                         boolean isDeployOrDestroy) {
+        // During router deployment/destroy, we increment the resource
+        // count only if resource.count.running.vms is false else
+        // we increment it during VR start/stop. Same applies for
+        // decrementing resource count.
+        if (isDeployOrDestroy == ResourceCountRunningVMsonly.value()) {
+            return;
+        }
+        ServiceOffering defaultRouterOffering = null;
+        String globalRouterOffering = _configDao.getValue("router.service.offering");
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        int cpuCount = 0;
+        int memoryCount = 0;
+        // Count VR resources for domain if global setting is true
+        // if value is "all" count all VR resources else get diff of
+        // current VR offering and default VR offering
+        if (ResourceCountRoutersType.valueIn(owner.getDomainId())
+                .equalsIgnoreCase(COUNT_ALL_VR_RESOURCES)) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (ResourceCountRoutersType.valueIn(owner.getDomainId())
+                .equalsIgnoreCase(COUNT_DELTA_VR_RESOURCES)) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        // Check if resource count can be allocated to account/domain
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException("Unable to deploy/start routers due to " + ex.getMessage());
+        }
+
+        // Increment the resource count
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Incrementing the CPU count with value " + cpuCount + " and " +
+                    "RAM value with " + memoryCount);
+        }
+        _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.cpu, new Long(cpuCount));
+        _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.memory, new Long(memoryCount));
+    }
+
+    /**
+     * Function to decrement the VR resource count
+     *
+     * @param offering
+     * @param owner
+     * @param isDeployOrDestroy
+     */
+    @Override
+    public void decrementVrResourceCount(ServiceOffering offering,
+                                         Account owner,
+                                         boolean isDeployOrDestroy) {
+        if (isDeployOrDestroy == ResourceCountRunningVMsonly.value()) {
+            return;
+        }
+
+        ServiceOffering defaultRouterOffering = null;
+        String globalRouterOffering = _configDao.getValue("router.service.offering");
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        int cpuCount = 0;
+        int memoryCount = 0;
+
+        // Since we already incremented the resource count for the domain,
+        // decrement it if the VR can't be started
+        if (ResourceCountRoutersType.valueIn(owner.getDomainId())
+                .equalsIgnoreCase(COUNT_ALL_VR_RESOURCES)) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (ResourceCountRoutersType.valueIn(owner.getDomainId())
+                .equalsIgnoreCase(COUNT_DELTA_VR_RESOURCES)) {
+            cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+        }
+
+        // Decrement resource count if flag is true
+        if (s_logger.isDebugEnabled()) {
+            s_logger.error("Decrementing cpu resource count with value " + cpuCount +
+                    " and memory resource with value " + memoryCount);
+        }
+        _resourceLimitMgr.decrementResourceCount(owner.getAccountId(), ResourceType.cpu, new Long(cpuCount));
+        _resourceLimitMgr.decrementResourceCount(owner.getAccountId(), ResourceType.memory, new Long(memoryCount));
+    }

Review Comment:
   done.



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,6 +1413,131 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Function to increment the VR resource count
+     *
+     * If the global setting resource.count.router is true then the VR
+     * resource count will be considered as well
+     * If the global setting resource.count.router.type is "all" then
+     * all VR resource count will be considered else the diff between
+     * the current VR service offering and the default offering will
+     * be considered
+     *
+     * @param offering
+     * @param owner
+     * @param isDeployOrDestroy
+     */
+    @Override
+    public void incrementVrResourceCount(ServiceOffering offering,
+                                         Account owner,
+                                         boolean isDeployOrDestroy) {
+        // During router deployment/destroy, we increment the resource
+        // count only if resource.count.running.vms is false else
+        // we increment it during VR start/stop. Same applies for
+        // decrementing resource count.
+        if (isDeployOrDestroy == ResourceCountRunningVMsonly.value()) {
+            return;
+        }
+        ServiceOffering defaultRouterOffering = null;
+        String globalRouterOffering = _configDao.getValue("router.service.offering");
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        int cpuCount = 0;
+        int memoryCount = 0;
+        // Count VR resources for domain if global setting is true
+        // if value is "all" count all VR resources else get diff of
+        // current VR offering and default VR offering
+        if (ResourceCountRoutersType.valueIn(owner.getDomainId())
+                .equalsIgnoreCase(COUNT_ALL_VR_RESOURCES)) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (ResourceCountRoutersType.valueIn(owner.getDomainId())
+                .equalsIgnoreCase(COUNT_DELTA_VR_RESOURCES)) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        // Check if resource count can be allocated to account/domain
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException("Unable to deploy/start routers due to " + ex.getMessage());
+        }
+
+        // Increment the resource count
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Incrementing the CPU count with value " + cpuCount + " and " +
+                    "RAM value with " + memoryCount);
+        }
+        _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.cpu, new Long(cpuCount));
+        _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.memory, new Long(memoryCount));

Review Comment:
   done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] CharlesQueiroz commented on a diff in pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
CharlesQueiroz commented on code in PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#discussion_r1027320198


##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering
+     *
+     * @param offering VR service offering
+     * @param defaultRouterOffering default VR service offering
+     * @param owner account
+     * @return a Pair of cpu and ram
+     */
+    private Pair<Long, Long> resolveCpuAndMemoryCount(ServiceOffering offering, ServiceOffering defaultRouterOffering, Account owner) {
+        Integer cpuCount = 0;
+        Integer memoryCount = 0;
+        if (COUNT_ALL_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (COUNT_DELTA_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        return Pair.of(cpuCount.longValue(), memoryCount.longValue());
+    }
+
+    private void validateResouceCount(Pair<Long, Long> cpuMemoryCount, Account owner) {
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException("Unable to deploy/start routers due to " + ex.getMessage());
+        }
+    }
+
+    /**
+     * Check if resource count can be allocated to account/domain
+     *
+     * @param cpuMemoryCount a Pair of cpu and ram
+     * @param owner the account
+     */
+    private void calculateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner, boolean isIncrement) {
+        validateResouceCount(cpuMemoryCount, owner);

Review Comment:
   done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] stephankruggg commented on a diff in pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
stephankruggg commented on code in PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#discussion_r1031726305


##########
engine/api/src/main/java/com/cloud/vm/VirtualMachineManager.java:
##########
@@ -70,22 +71,49 @@ public interface VirtualMachineManager extends Manager {
     ConfigKey<Boolean> VmConfigDriveForceHostCacheUse = new ConfigKey<>("Advanced", Boolean.class, "vm.configdrive.force.host.cache.use", "false",
             "If true, config drive is forced to create on the host cache storage. Currently only supported for KVM.", true, ConfigKey.Scope.Zone);
 
-    ConfigKey<Boolean> ResourceCountRunningVMsonly = new ConfigKey<Boolean>("Advanced", Boolean.class, "resource.count.running.vms.only", "false",
+    ConfigKey<Boolean> ResourceCountRunningVMsonly = new ConfigKey<>("Advanced", Boolean.class, "resource.count.running.vms.only", "false",
             "Count the resources of only running VMs in resource limitation.", true);
 
-    ConfigKey<Boolean> AllowExposeHypervisorHostnameAccountLevel = new ConfigKey<Boolean>("Advanced", Boolean.class, "account.allow.expose.host.hostname",
+    ConfigKey<Boolean> AllowExposeHypervisorHostnameAccountLevel = new ConfigKey<>("Advanced", Boolean.class, "account.allow.expose.host.hostname",
             "false", "If set to true, it allows the hypervisor host name on which the VM is spawned on to be exposed to the VM", true, ConfigKey.Scope.Account);
 
-    ConfigKey<Boolean> AllowExposeHypervisorHostname = new ConfigKey<Boolean>("Advanced", Boolean.class, "global.allow.expose.host.hostname",
+    ConfigKey<Boolean> AllowExposeHypervisorHostname = new ConfigKey<>("Advanced", Boolean.class, "global.allow.expose.host.hostname",
             "false", "If set to true, it allows the hypervisor host name on which the VM is spawned on to be exposed to the VM", true, ConfigKey.Scope.Global);
 
     ConfigKey<Boolean> AllowExposeDomainInMetadata = new ConfigKey<>("Advanced", Boolean.class, "metadata.allow.expose.domain",
             "false", "If set to true, it allows the VM's domain to be seen in metadata.", true, ConfigKey.Scope.Domain);
 
+    static final ConfigKey<Integer> VmServiceOfferingMaxCPUCores = new ConfigKey<>("Advanced",
+            Integer.class,
+            "vm.serviceoffering.cpu.cores.max",
+            "0",
+            "Maximum CPU cores for vm service offering. If 0 - no limitation",

Review Comment:
   ```suggestion
               "Maximum number of CPU cores for VM service offering. If 0 - no limitation",
   ```



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true

Review Comment:
   ```suggestion
        * Counts VR resources for the domain if global setting is true.
   ```



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering
+     *
+     * @param offering VR service offering
+     * @param defaultRouterOffering default VR service offering
+     * @param owner account
+     * @return a Pair of cpu and ram
+     */
+    private Pair<Long, Long> resolveCpuAndMemoryCount(ServiceOffering offering, ServiceOffering defaultRouterOffering, Account owner) {
+        Integer cpuCount = 0;
+        Integer memoryCount = 0;
+        if (COUNT_ALL_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (COUNT_DELTA_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        return Pair.of(cpuCount.longValue(), memoryCount.longValue());
+    }
+
+    private void validateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner) {
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException(String.format("Unable to deploy/start routers due to {}", ex.getMessage()));
+        }
+    }
+
+    /**
+     * Check if resource count can be allocated to account/domain
+     *
+     * @param cpuMemoryCount a Pair of cpu and ram
+     * @param owner the account
+     */
+    private void calculateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner, boolean isIncrement) {
+        validateResourceCount(cpuMemoryCount, owner);
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+
+        // Increment the resource count
+        if (s_logger.isDebugEnabled()) {
+            if(isIncrement) {

Review Comment:
   ```suggestion
               if (isIncrement) {
   ```



##########
server/src/main/java/com/cloud/network/router/NetworkHelperImpl.java:
##########
@@ -502,6 +510,14 @@ public DomainRouterVO deployRouter(final RouterDeploymentDefinition routerDeploy
         // failed both times, throw the exception up
         final List<HypervisorType> hypervisors = getHypervisors(routerDeploymentDefinition);
 
+        // Increment the resource count with router offering.
+        // If router can't be deployed or started, decrement the resources.
+        // If resource.count.running.vms is false then increment resource count

Review Comment:
   ```suggestion
           // If resource.count.running.vms is false, increment resource count.
   ```



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of

Review Comment:
   ```suggestion
        * If the value is "all", counts all VR resources, otherwise get the difference between
   ```



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.

Review Comment:
   ```suggestion
        * Returns the service offering by the given configuration.
   ```



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering
+     *
+     * @param offering VR service offering
+     * @param defaultRouterOffering default VR service offering
+     * @param owner account
+     * @return a Pair of cpu and ram
+     */
+    private Pair<Long, Long> resolveCpuAndMemoryCount(ServiceOffering offering, ServiceOffering defaultRouterOffering, Account owner) {
+        Integer cpuCount = 0;
+        Integer memoryCount = 0;
+        if (COUNT_ALL_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (COUNT_DELTA_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        return Pair.of(cpuCount.longValue(), memoryCount.longValue());
+    }
+
+    private void validateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner) {
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException(String.format("Unable to deploy/start routers due to {}", ex.getMessage()));
+        }
+    }
+
+    /**
+     * Check if resource count can be allocated to account/domain
+     *
+     * @param cpuMemoryCount a Pair of cpu and ram
+     * @param owner the account
+     */
+    private void calculateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner, boolean isIncrement) {
+        validateResourceCount(cpuMemoryCount, owner);
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+
+        // Increment the resource count
+        if (s_logger.isDebugEnabled()) {
+            if(isIncrement) {
+                s_logger.debug(String.format("Incrementing the CPU count with value %s and RAM value with %s", cpuCount, memoryCount));
+            } else {
+                s_logger.debug(String.format("Decrementing cpu resource count with value %s and memory resource with value %s",cpuCount, memoryCount));

Review Comment:
   ```suggestion
                   s_logger.debug(String.format("Decrementing CPU resource count with value %s and memory resource with value %s.",cpuCount, memoryCount));
   ```



##########
engine/api/src/main/java/com/cloud/vm/VirtualMachineManager.java:
##########
@@ -70,22 +71,49 @@ public interface VirtualMachineManager extends Manager {
     ConfigKey<Boolean> VmConfigDriveForceHostCacheUse = new ConfigKey<>("Advanced", Boolean.class, "vm.configdrive.force.host.cache.use", "false",
             "If true, config drive is forced to create on the host cache storage. Currently only supported for KVM.", true, ConfigKey.Scope.Zone);
 
-    ConfigKey<Boolean> ResourceCountRunningVMsonly = new ConfigKey<Boolean>("Advanced", Boolean.class, "resource.count.running.vms.only", "false",
+    ConfigKey<Boolean> ResourceCountRunningVMsonly = new ConfigKey<>("Advanced", Boolean.class, "resource.count.running.vms.only", "false",
             "Count the resources of only running VMs in resource limitation.", true);
 
-    ConfigKey<Boolean> AllowExposeHypervisorHostnameAccountLevel = new ConfigKey<Boolean>("Advanced", Boolean.class, "account.allow.expose.host.hostname",
+    ConfigKey<Boolean> AllowExposeHypervisorHostnameAccountLevel = new ConfigKey<>("Advanced", Boolean.class, "account.allow.expose.host.hostname",
             "false", "If set to true, it allows the hypervisor host name on which the VM is spawned on to be exposed to the VM", true, ConfigKey.Scope.Account);
 
-    ConfigKey<Boolean> AllowExposeHypervisorHostname = new ConfigKey<Boolean>("Advanced", Boolean.class, "global.allow.expose.host.hostname",
+    ConfigKey<Boolean> AllowExposeHypervisorHostname = new ConfigKey<>("Advanced", Boolean.class, "global.allow.expose.host.hostname",
             "false", "If set to true, it allows the hypervisor host name on which the VM is spawned on to be exposed to the VM", true, ConfigKey.Scope.Global);
 
     ConfigKey<Boolean> AllowExposeDomainInMetadata = new ConfigKey<>("Advanced", Boolean.class, "metadata.allow.expose.domain",
             "false", "If set to true, it allows the VM's domain to be seen in metadata.", true, ConfigKey.Scope.Domain);
 
+    static final ConfigKey<Integer> VmServiceOfferingMaxCPUCores = new ConfigKey<>("Advanced",
+            Integer.class,
+            "vm.serviceoffering.cpu.cores.max",
+            "0",
+            "Maximum CPU cores for vm service offering. If 0 - no limitation",
+            true
+    );
+
+    static final ConfigKey<Integer> VmServiceOfferingMaxRAMSize = new ConfigKey<>("Advanced",
+            Integer.class,
+            "vm.serviceoffering.ram.size.max",
+            "0",
+            "Maximum RAM size in MB for vm service offering. If 0 - no limitation",

Review Comment:
   ```suggestion
               "Maximum RAM size in MB for VM service offering. If 0 - no limitation",
   ```



##########
engine/api/src/main/java/com/cloud/vm/VirtualMachineManager.java:
##########
@@ -70,22 +71,49 @@ public interface VirtualMachineManager extends Manager {
     ConfigKey<Boolean> VmConfigDriveForceHostCacheUse = new ConfigKey<>("Advanced", Boolean.class, "vm.configdrive.force.host.cache.use", "false",
             "If true, config drive is forced to create on the host cache storage. Currently only supported for KVM.", true, ConfigKey.Scope.Zone);
 
-    ConfigKey<Boolean> ResourceCountRunningVMsonly = new ConfigKey<Boolean>("Advanced", Boolean.class, "resource.count.running.vms.only", "false",
+    ConfigKey<Boolean> ResourceCountRunningVMsonly = new ConfigKey<>("Advanced", Boolean.class, "resource.count.running.vms.only", "false",
             "Count the resources of only running VMs in resource limitation.", true);
 
-    ConfigKey<Boolean> AllowExposeHypervisorHostnameAccountLevel = new ConfigKey<Boolean>("Advanced", Boolean.class, "account.allow.expose.host.hostname",
+    ConfigKey<Boolean> AllowExposeHypervisorHostnameAccountLevel = new ConfigKey<>("Advanced", Boolean.class, "account.allow.expose.host.hostname",
             "false", "If set to true, it allows the hypervisor host name on which the VM is spawned on to be exposed to the VM", true, ConfigKey.Scope.Account);
 
-    ConfigKey<Boolean> AllowExposeHypervisorHostname = new ConfigKey<Boolean>("Advanced", Boolean.class, "global.allow.expose.host.hostname",
+    ConfigKey<Boolean> AllowExposeHypervisorHostname = new ConfigKey<>("Advanced", Boolean.class, "global.allow.expose.host.hostname",
             "false", "If set to true, it allows the hypervisor host name on which the VM is spawned on to be exposed to the VM", true, ConfigKey.Scope.Global);
 
     ConfigKey<Boolean> AllowExposeDomainInMetadata = new ConfigKey<>("Advanced", Boolean.class, "metadata.allow.expose.domain",
             "false", "If set to true, it allows the VM's domain to be seen in metadata.", true, ConfigKey.Scope.Domain);
 
+    static final ConfigKey<Integer> VmServiceOfferingMaxCPUCores = new ConfigKey<>("Advanced",
+            Integer.class,
+            "vm.serviceoffering.cpu.cores.max",
+            "0",
+            "Maximum CPU cores for vm service offering. If 0 - no limitation",
+            true
+    );
+
+    static final ConfigKey<Integer> VmServiceOfferingMaxRAMSize = new ConfigKey<>("Advanced",
+            Integer.class,
+            "vm.serviceoffering.ram.size.max",
+            "0",
+            "Maximum RAM size in MB for vm service offering. If 0 - no limitation",
+            true
+    );
+
+    ConfigKey<Boolean> ResourceCountRouters = new ConfigKey<>("Advanced", Boolean.class, "resource.count.routers",
+            "false","Count the CPU and memory resource count of virtual routers towards domain resource calculation",
+            true, ConfigKey.Scope.Domain);
+
+    ConfigKey<String> ResourceCountRoutersType = new ConfigKey<>("Advanced", String.class, "resource.count.routers.type", "all",
+            "Possible values are all and delta. If value is all then entire VR cpu and ram are counted else diff " +

Review Comment:
   ```suggestion
               "Possible values are all and delta. If the value is all then the entire VR CPU and RAM are counted, otherwise the difference " +
   ```



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering
+     *
+     * @param offering VR service offering
+     * @param defaultRouterOffering default VR service offering
+     * @param owner account
+     * @return a Pair of cpu and ram
+     */
+    private Pair<Long, Long> resolveCpuAndMemoryCount(ServiceOffering offering, ServiceOffering defaultRouterOffering, Account owner) {
+        Integer cpuCount = 0;
+        Integer memoryCount = 0;
+        if (COUNT_ALL_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (COUNT_DELTA_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        return Pair.of(cpuCount.longValue(), memoryCount.longValue());
+    }
+
+    private void validateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner) {
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException(String.format("Unable to deploy/start routers due to {}", ex.getMessage()));
+        }
+    }
+
+    /**
+     * Check if resource count can be allocated to account/domain
+     *
+     * @param cpuMemoryCount a Pair of cpu and ram
+     * @param owner the account
+     */
+    private void calculateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner, boolean isIncrement) {
+        validateResourceCount(cpuMemoryCount, owner);
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+
+        // Increment the resource count
+        if (s_logger.isDebugEnabled()) {
+            if(isIncrement) {
+                s_logger.debug(String.format("Incrementing the CPU count with value %s and RAM value with %s", cpuCount, memoryCount));

Review Comment:
   ```suggestion
                   s_logger.debug(String.format("Incrementing the CPU count with value %s and RAM value with %s.", cpuCount, memoryCount));
   ```



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering

Review Comment:
   ```suggestion
        * current VR offering and default VR offering.
   ```



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering
+     *
+     * @param offering VR service offering
+     * @param defaultRouterOffering default VR service offering
+     * @param owner account
+     * @return a Pair of cpu and ram
+     */
+    private Pair<Long, Long> resolveCpuAndMemoryCount(ServiceOffering offering, ServiceOffering defaultRouterOffering, Account owner) {
+        Integer cpuCount = 0;
+        Integer memoryCount = 0;
+        if (COUNT_ALL_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (COUNT_DELTA_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        return Pair.of(cpuCount.longValue(), memoryCount.longValue());
+    }
+
+    private void validateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner) {
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException(String.format("Unable to deploy/start routers due to {}", ex.getMessage()));
+        }
+    }
+
+    /**
+     * Check if resource count can be allocated to account/domain

Review Comment:
   ```suggestion
        * Checks if resource count can be allocated to the account/domain.
   ```



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering
+     *
+     * @param offering VR service offering
+     * @param defaultRouterOffering default VR service offering
+     * @param owner account
+     * @return a Pair of cpu and ram

Review Comment:
   ```suggestion
        * @return a Pair of CPU and RAM
   ```



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering
+     *
+     * @param offering VR service offering
+     * @param defaultRouterOffering default VR service offering
+     * @param owner account
+     * @return a Pair of cpu and ram
+     */
+    private Pair<Long, Long> resolveCpuAndMemoryCount(ServiceOffering offering, ServiceOffering defaultRouterOffering, Account owner) {
+        Integer cpuCount = 0;
+        Integer memoryCount = 0;
+        if (COUNT_ALL_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (COUNT_DELTA_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        return Pair.of(cpuCount.longValue(), memoryCount.longValue());
+    }
+
+    private void validateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner) {
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException(String.format("Unable to deploy/start routers due to {}", ex.getMessage()));
+        }
+    }
+
+    /**
+     * Check if resource count can be allocated to account/domain
+     *
+     * @param cpuMemoryCount a Pair of cpu and ram
+     * @param owner the account
+     */
+    private void calculateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner, boolean isIncrement) {
+        validateResourceCount(cpuMemoryCount, owner);
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+
+        // Increment the resource count
+        if (s_logger.isDebugEnabled()) {
+            if(isIncrement) {
+                s_logger.debug(String.format("Incrementing the CPU count with value %s and RAM value with %s", cpuCount, memoryCount));
+            } else {
+                s_logger.debug(String.format("Decrementing cpu resource count with value %s and memory resource with value %s",cpuCount, memoryCount));
+            }
+        }
+
+        if(isIncrement) {
+            _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.cpu, cpuCount);
+            _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.memory, memoryCount);
+        } else {
+            _resourceLimitMgr.decrementResourceCount(owner.getAccountId(), ResourceType.cpu, cpuCount);
+            _resourceLimitMgr.decrementResourceCount(owner.getAccountId(), ResourceType.memory, memoryCount);
+        }
+    }
+
+    /**
+     * Function to increment the VR resource count
+     * If the global setting resource.count.router is true then the VR
+     * resource count will be considered as well
+     * If the global setting resource.count.router.type is "all" then
+     * all VR resource count will be considered else the diff between

Review Comment:
   ```suggestion
        * the total VR resource count will be considered, otherwise the difference between
   ```



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering
+     *
+     * @param offering VR service offering
+     * @param defaultRouterOffering default VR service offering
+     * @param owner account
+     * @return a Pair of cpu and ram
+     */
+    private Pair<Long, Long> resolveCpuAndMemoryCount(ServiceOffering offering, ServiceOffering defaultRouterOffering, Account owner) {
+        Integer cpuCount = 0;
+        Integer memoryCount = 0;
+        if (COUNT_ALL_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (COUNT_DELTA_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        return Pair.of(cpuCount.longValue(), memoryCount.longValue());
+    }
+
+    private void validateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner) {
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException(String.format("Unable to deploy/start routers due to {}", ex.getMessage()));

Review Comment:
   ```suggestion
               throw new CloudRuntimeException(String.format("Unable to deploy/start routers due to {}.", ex.getMessage()));
   ```



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering
+     *
+     * @param offering VR service offering
+     * @param defaultRouterOffering default VR service offering
+     * @param owner account
+     * @return a Pair of cpu and ram
+     */
+    private Pair<Long, Long> resolveCpuAndMemoryCount(ServiceOffering offering, ServiceOffering defaultRouterOffering, Account owner) {
+        Integer cpuCount = 0;
+        Integer memoryCount = 0;
+        if (COUNT_ALL_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (COUNT_DELTA_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        return Pair.of(cpuCount.longValue(), memoryCount.longValue());
+    }
+
+    private void validateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner) {
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException(String.format("Unable to deploy/start routers due to {}", ex.getMessage()));
+        }
+    }
+
+    /**
+     * Check if resource count can be allocated to account/domain
+     *
+     * @param cpuMemoryCount a Pair of cpu and ram
+     * @param owner the account
+     */
+    private void calculateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner, boolean isIncrement) {
+        validateResourceCount(cpuMemoryCount, owner);
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+
+        // Increment the resource count
+        if (s_logger.isDebugEnabled()) {
+            if(isIncrement) {
+                s_logger.debug(String.format("Incrementing the CPU count with value %s and RAM value with %s", cpuCount, memoryCount));
+            } else {
+                s_logger.debug(String.format("Decrementing cpu resource count with value %s and memory resource with value %s",cpuCount, memoryCount));
+            }
+        }
+
+        if(isIncrement) {
+            _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.cpu, cpuCount);
+            _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.memory, memoryCount);
+        } else {
+            _resourceLimitMgr.decrementResourceCount(owner.getAccountId(), ResourceType.cpu, cpuCount);
+            _resourceLimitMgr.decrementResourceCount(owner.getAccountId(), ResourceType.memory, memoryCount);
+        }
+    }
+
+    /**
+     * Function to increment the VR resource count
+     * If the global setting resource.count.router is true then the VR
+     * resource count will be considered as well

Review Comment:
   ```suggestion
        * resource count will be considered as well.
   ```



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering
+     *
+     * @param offering VR service offering
+     * @param defaultRouterOffering default VR service offering
+     * @param owner account
+     * @return a Pair of cpu and ram
+     */
+    private Pair<Long, Long> resolveCpuAndMemoryCount(ServiceOffering offering, ServiceOffering defaultRouterOffering, Account owner) {
+        Integer cpuCount = 0;
+        Integer memoryCount = 0;
+        if (COUNT_ALL_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (COUNT_DELTA_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        return Pair.of(cpuCount.longValue(), memoryCount.longValue());
+    }
+
+    private void validateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner) {
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException(String.format("Unable to deploy/start routers due to {}", ex.getMessage()));
+        }
+    }
+
+    /**
+     * Check if resource count can be allocated to account/domain
+     *
+     * @param cpuMemoryCount a Pair of cpu and ram
+     * @param owner the account
+     */
+    private void calculateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner, boolean isIncrement) {
+        validateResourceCount(cpuMemoryCount, owner);
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+
+        // Increment the resource count
+        if (s_logger.isDebugEnabled()) {
+            if(isIncrement) {
+                s_logger.debug(String.format("Incrementing the CPU count with value %s and RAM value with %s", cpuCount, memoryCount));
+            } else {
+                s_logger.debug(String.format("Decrementing cpu resource count with value %s and memory resource with value %s",cpuCount, memoryCount));
+            }
+        }
+
+        if(isIncrement) {
+            _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.cpu, cpuCount);
+            _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.memory, memoryCount);
+        } else {
+            _resourceLimitMgr.decrementResourceCount(owner.getAccountId(), ResourceType.cpu, cpuCount);
+            _resourceLimitMgr.decrementResourceCount(owner.getAccountId(), ResourceType.memory, memoryCount);
+        }
+    }
+
+    /**
+     * Function to increment the VR resource count
+     * If the global setting resource.count.router is true then the VR
+     * resource count will be considered as well
+     * If the global setting resource.count.router.type is "all" then
+     * all VR resource count will be considered else the diff between
+     * the current VR service offering and the default offering will
+     * be considered.
+     * During router deployment/destroy, we increment the resource
+     * count only if resource.count.running.vms is false else

Review Comment:
   ```suggestion
        * count only if resource.count.running.vms is false, otherwise
   ```



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering
+     *
+     * @param offering VR service offering
+     * @param defaultRouterOffering default VR service offering
+     * @param owner account
+     * @return a Pair of cpu and ram
+     */
+    private Pair<Long, Long> resolveCpuAndMemoryCount(ServiceOffering offering, ServiceOffering defaultRouterOffering, Account owner) {
+        Integer cpuCount = 0;
+        Integer memoryCount = 0;
+        if (COUNT_ALL_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (COUNT_DELTA_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        return Pair.of(cpuCount.longValue(), memoryCount.longValue());
+    }
+
+    private void validateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner) {
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException(String.format("Unable to deploy/start routers due to {}", ex.getMessage()));
+        }
+    }
+
+    /**
+     * Check if resource count can be allocated to account/domain
+     *
+     * @param cpuMemoryCount a Pair of cpu and ram
+     * @param owner the account
+     */
+    private void calculateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner, boolean isIncrement) {
+        validateResourceCount(cpuMemoryCount, owner);
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+
+        // Increment the resource count
+        if (s_logger.isDebugEnabled()) {
+            if(isIncrement) {
+                s_logger.debug(String.format("Incrementing the CPU count with value %s and RAM value with %s", cpuCount, memoryCount));
+            } else {
+                s_logger.debug(String.format("Decrementing cpu resource count with value %s and memory resource with value %s",cpuCount, memoryCount));
+            }
+        }
+
+        if(isIncrement) {
+            _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.cpu, cpuCount);
+            _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.memory, memoryCount);
+        } else {
+            _resourceLimitMgr.decrementResourceCount(owner.getAccountId(), ResourceType.cpu, cpuCount);
+            _resourceLimitMgr.decrementResourceCount(owner.getAccountId(), ResourceType.memory, memoryCount);
+        }
+    }
+
+    /**
+     * Function to increment the VR resource count
+     * If the global setting resource.count.router is true then the VR
+     * resource count will be considered as well
+     * If the global setting resource.count.router.type is "all" then
+     * all VR resource count will be considered else the diff between
+     * the current VR service offering and the default offering will
+     * be considered.
+     * During router deployment/destroy, we increment the resource
+     * count only if resource.count.running.vms is false else
+     * we increment it during VR start/stop. Same applies for
+     * decrementing resource count.
+     *
+     * @param offering VR service offering
+     * @param owner account
+     * @param isDeployOrDestroy true if router is being deployed/destroyed
+     */
+    @Override
+    public void incrementVrResourceCount(ServiceOffering offering, Account owner, boolean isDeployOrDestroy) {
+        if (isDeployOrDestroy == Boolean.TRUE.equals(ResourceCountRunningVMsonly.value())) {
+            return;
+        }
+
+        final ServiceOffering defaultRouterOffering = getServiceOfferingByConfig("router.service.offering");
+        final Pair<Long, Long> cpuMemoryCount = resolveCpuAndMemoryCount(offering, defaultRouterOffering, owner);
+        calculateResourceCount(cpuMemoryCount, owner, true);
+    }
+
+    /**
+     * Function to decrement the VR resource count

Review Comment:
   ```suggestion
        * Decrements the VR resource count.
   ```



##########
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java:
##########
@@ -1135,6 +1145,13 @@ private String validateConfigurationValue(final String name, String value, final
             return errMsg;
         }
 
+        if (VirtualMachineManager.ResourceCountRoutersType.key().equalsIgnoreCase(name)
+                && (!resourceCountRoutersTypeValues.contains(value) || isBlank(value))) {
+            final String msg = "Possible values are - delta or all";

Review Comment:
   ```suggestion
               final String msg = "Possible values are: delta or all.";
   ```



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering
+     *
+     * @param offering VR service offering
+     * @param defaultRouterOffering default VR service offering
+     * @param owner account
+     * @return a Pair of cpu and ram
+     */
+    private Pair<Long, Long> resolveCpuAndMemoryCount(ServiceOffering offering, ServiceOffering defaultRouterOffering, Account owner) {
+        Integer cpuCount = 0;
+        Integer memoryCount = 0;
+        if (COUNT_ALL_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (COUNT_DELTA_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        return Pair.of(cpuCount.longValue(), memoryCount.longValue());
+    }
+
+    private void validateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner) {
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException(String.format("Unable to deploy/start routers due to {}", ex.getMessage()));
+        }
+    }
+
+    /**
+     * Check if resource count can be allocated to account/domain
+     *
+     * @param cpuMemoryCount a Pair of cpu and ram
+     * @param owner the account
+     */
+    private void calculateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner, boolean isIncrement) {
+        validateResourceCount(cpuMemoryCount, owner);
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+
+        // Increment the resource count
+        if (s_logger.isDebugEnabled()) {
+            if(isIncrement) {
+                s_logger.debug(String.format("Incrementing the CPU count with value %s and RAM value with %s", cpuCount, memoryCount));
+            } else {
+                s_logger.debug(String.format("Decrementing cpu resource count with value %s and memory resource with value %s",cpuCount, memoryCount));
+            }
+        }
+
+        if(isIncrement) {
+            _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.cpu, cpuCount);
+            _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.memory, memoryCount);
+        } else {
+            _resourceLimitMgr.decrementResourceCount(owner.getAccountId(), ResourceType.cpu, cpuCount);
+            _resourceLimitMgr.decrementResourceCount(owner.getAccountId(), ResourceType.memory, memoryCount);
+        }
+    }
+
+    /**
+     * Function to increment the VR resource count

Review Comment:
   ```suggestion
        * Increments the VR resource count.
   ```



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -2108,6 +2256,16 @@ private void advanceStop(final VMInstanceVO vm, final boolean cleanUpEvenIfUnabl
         }
     }
 
+    private void updateVrCountResourceBy(VirtualMachine.Type type, long domainId, ServiceOffering offering, Account owner, boolean decrement) {
+        if (VirtualMachine.Type.DomainRouter.equals(type) && Boolean.TRUE.equals(ResourceCountRouters.valueIn(domainId))) {
+            if(decrement) {

Review Comment:
   ```suggestion
               if (decrement) {
   ```



##########
server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java:
##########
@@ -1049,11 +1051,15 @@ public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationExcep
 
         HypervisorType hypervisorType = _volsDao.getHypervisorType(volume.getId());
         if (!SupportedHypervisorsForVolResize.contains(hypervisorType)) {
-            throw new InvalidParameterValueException("Hypervisor " + hypervisorType + " does not support volume resize");
+            throw new InvalidParameterValueException(String.format("Hypervisor %s does not support volume resize", hypervisorType));

Review Comment:
   ```suggestion
               throw new InvalidParameterValueException(String.format("Hypervisor %s does not support volume resize.", hypervisorType));
   ```



##########
server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java:
##########
@@ -1049,11 +1051,15 @@ public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationExcep
 
         HypervisorType hypervisorType = _volsDao.getHypervisorType(volume.getId());
         if (!SupportedHypervisorsForVolResize.contains(hypervisorType)) {
-            throw new InvalidParameterValueException("Hypervisor " + hypervisorType + " does not support volume resize");
+            throw new InvalidParameterValueException(String.format("Hypervisor %s does not support volume resize", hypervisorType));
+        }
+
+        if (!SupportedHypervisorsForRootDiskSizeOverride.contains(hypervisorType)) {
+            throw new InvalidParameterValueException(String.format("Hypervisor %s does not support  rootdisksize override", hypervisorType));

Review Comment:
   ```suggestion
               throw new InvalidParameterValueException(String.format("Hypervisor %s does not support rootdisksize override.", hypervisorType));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] soreana commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
soreana commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1330541667

   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] github-actions[bot] commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1361190445

   This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1346156947

   @CharlesQueiroz you have conflicts, can you have a look?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] BryanMLima commented on a diff in pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
BryanMLima commented on code in PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#discussion_r1026832716


##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering
+     *
+     * @param offering VR service offering
+     * @param defaultRouterOffering default VR service offering
+     * @param owner account
+     * @return a Pair of cpu and ram
+     */
+    private Pair<Long, Long> resolveCpuAndMemoryCount(ServiceOffering offering, ServiceOffering defaultRouterOffering, Account owner) {
+        Integer cpuCount = 0;
+        Integer memoryCount = 0;
+        if (COUNT_ALL_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (COUNT_DELTA_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        return Pair.of(cpuCount.longValue(), memoryCount.longValue());
+    }
+
+    private void validateResouceCount(Pair<Long, Long> cpuMemoryCount, Account owner) {
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException("Unable to deploy/start routers due to " + ex.getMessage());
+        }
+    }
+
+    /**
+     * Check if resource count can be allocated to account/domain
+     *
+     * @param cpuMemoryCount a Pair of cpu and ram
+     * @param owner the account
+     */
+    private void calculateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner, boolean isIncrement) {
+        validateResouceCount(cpuMemoryCount, owner);

Review Comment:
   ```suggestion
           validateResourceCount(cpuMemoryCount, owner);
   ```



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering
+     *
+     * @param offering VR service offering
+     * @param defaultRouterOffering default VR service offering
+     * @param owner account
+     * @return a Pair of cpu and ram
+     */
+    private Pair<Long, Long> resolveCpuAndMemoryCount(ServiceOffering offering, ServiceOffering defaultRouterOffering, Account owner) {
+        Integer cpuCount = 0;
+        Integer memoryCount = 0;
+        if (COUNT_ALL_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (COUNT_DELTA_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        return Pair.of(cpuCount.longValue(), memoryCount.longValue());
+    }
+
+    private void validateResouceCount(Pair<Long, Long> cpuMemoryCount, Account owner) {

Review Comment:
   ```suggestion
       private void validateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner) {
   ```
   There is a typo in the method name.



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering
+     *
+     * @param offering VR service offering
+     * @param defaultRouterOffering default VR service offering
+     * @param owner account
+     * @return a Pair of cpu and ram
+     */
+    private Pair<Long, Long> resolveCpuAndMemoryCount(ServiceOffering offering, ServiceOffering defaultRouterOffering, Account owner) {
+        Integer cpuCount = 0;
+        Integer memoryCount = 0;
+        if (COUNT_ALL_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (COUNT_DELTA_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        return Pair.of(cpuCount.longValue(), memoryCount.longValue());
+    }
+
+    private void validateResouceCount(Pair<Long, Long> cpuMemoryCount, Account owner) {
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException("Unable to deploy/start routers due to " + ex.getMessage());
+        }
+    }
+
+    /**
+     * Check if resource count can be allocated to account/domain
+     *
+     * @param cpuMemoryCount a Pair of cpu and ram
+     * @param owner the account
+     */
+    private void calculateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner, boolean isIncrement) {
+        validateResouceCount(cpuMemoryCount, owner);
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+
+        // Increment the resource count
+        if (s_logger.isDebugEnabled()) {
+            if(isIncrement) {
+                s_logger.debug(String.format("Incrementing the CPU count with value %s and RAM value with %s", cpuCount, memoryCount));
+            } else {
+                s_logger.debug(String.format("Decrementing cpu resource count with value %s and memory resource with value %s",cpuCount, memoryCount));
+            }
+        }
+
+        if(isIncrement) {
+            _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.cpu, cpuCount);
+            _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.memory, memoryCount);
+        } else {
+            _resourceLimitMgr.decrementResourceCount(owner.getAccountId(), ResourceType.cpu, cpuCount);
+            _resourceLimitMgr.decrementResourceCount(owner.getAccountId(), ResourceType.memory, memoryCount);
+        }
+    }
+
+    /**
+     * Function to increment the VR resource count
+     * If the global setting resource.count.router is true then the VR
+     * resource count will be considered as well
+     * If the global setting resource.count.router.type is "all" then
+     * all VR resource count will be considered else the diff between
+     * the current VR service offering and the default offering will
+     * be considered
+     *
+     * @param offering
+     * @param owner
+     * @param isDeployOrDestroy
+     */
+    @Override
+    public void incrementVrResourceCount(ServiceOffering offering, Account owner, boolean isDeployOrDestroy) {
+        // During router deployment/destroy, we increment the resource
+        // count only if resource.count.running.vms is false else
+        // we increment it during VR start/stop. Same applies for
+        // decrementing resource count.

Review Comment:
   This could be inside the javadoc of this method.



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -2108,6 +2256,16 @@ private void advanceStop(final VMInstanceVO vm, final boolean cleanUpEvenIfUnabl
         }
     }
 
+    private void changeVrCountResourceBy(VirtualMachine.Type type, long domainId, ServiceOffering offering, Account owner, boolean decrement) {

Review Comment:
   ```suggestion
       private void updateVrCountResourceBy(VirtualMachine.Type type, long domainId, ServiceOffering offering, Account owner, boolean decrement) {
   ```
   Update is more clear IMHO.



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering
+     *
+     * @param offering VR service offering
+     * @param defaultRouterOffering default VR service offering
+     * @param owner account
+     * @return a Pair of cpu and ram
+     */
+    private Pair<Long, Long> resolveCpuAndMemoryCount(ServiceOffering offering, ServiceOffering defaultRouterOffering, Account owner) {
+        Integer cpuCount = 0;
+        Integer memoryCount = 0;
+        if (COUNT_ALL_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (COUNT_DELTA_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        return Pair.of(cpuCount.longValue(), memoryCount.longValue());
+    }
+
+    private void validateResouceCount(Pair<Long, Long> cpuMemoryCount, Account owner) {
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException("Unable to deploy/start routers due to " + ex.getMessage());

Review Comment:
   ```suggestion
               throw new CloudRuntimeException(String.format("Unable to deploy/start routers due to %s.", ex.getMessage()));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] codecov[bot] commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1335069753

   # [Codecov](https://codecov.io/gh/apache/cloudstack/pull/6899?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#6899](https://codecov.io/gh/apache/cloudstack/pull/6899?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (91796b6) into [main](https://codecov.io/gh/apache/cloudstack/commit/296035d9a57caa62260a666da726ec45b6801c4b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (296035d) will **increase** coverage by `0.52%`.
   > The diff coverage is `37.00%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##               main    #6899      +/-   ##
   ============================================
   + Coverage     10.34%   10.87%   +0.52%     
   - Complexity     6610     7120     +510     
   ============================================
     Files          2451     2485      +34     
     Lines        242340   245693    +3353     
     Branches      37924    38363     +439     
   ============================================
   + Hits          25070    26719    +1649     
   - Misses       214182   215702    +1520     
   - Partials       3088     3272     +184     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/cloudstack/pull/6899?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...estration/service/NetworkOrchestrationService.java](https://codecov.io/gh/apache/cloudstack/pull/6899/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZW5naW5lL2FwaS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvY2xvdWRzdGFjay9lbmdpbmUvb3JjaGVzdHJhdGlvbi9zZXJ2aWNlL05ldHdvcmtPcmNoZXN0cmF0aW9uU2VydmljZS5qYXZh) | `100.00% <ø> (ø)` | |
   | [...pi/src/main/java/com/cloud/alert/AlertManager.java](https://codecov.io/gh/apache/cloudstack/pull/6899/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZW5naW5lL2NvbXBvbmVudHMtYXBpL3NyYy9tYWluL2phdmEvY29tL2Nsb3VkL2FsZXJ0L0FsZXJ0TWFuYWdlci5qYXZh) | `100.00% <ø> (ø)` | |
   | [...n/java/com/cloud/vm/VirtualMachineProfileImpl.java](https://codecov.io/gh/apache/cloudstack/pull/6899/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZW5naW5lL2NvbXBvbmVudHMtYXBpL3NyYy9tYWluL2phdmEvY29tL2Nsb3VkL3ZtL1ZpcnR1YWxNYWNoaW5lUHJvZmlsZUltcGwuamF2YQ==) | `36.44% <0.00%> (-0.70%)` | :arrow_down: |
   | [...n/java/com/cloud/vm/VirtualMachineManagerImpl.java](https://codecov.io/gh/apache/cloudstack/pull/6899/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZW5naW5lL29yY2hlc3RyYXRpb24vc3JjL21haW4vamF2YS9jb20vY2xvdWQvdm0vVmlydHVhbE1hY2hpbmVNYW5hZ2VySW1wbC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...tack/engine/orchestration/NetworkOrchestrator.java](https://codecov.io/gh/apache/cloudstack/pull/6899/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZW5naW5lL29yY2hlc3RyYXRpb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2Nsb3Vkc3RhY2svZW5naW5lL29yY2hlc3RyYXRpb24vTmV0d29ya09yY2hlc3RyYXRvci5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...stack/engine/orchestration/VolumeOrchestrator.java](https://codecov.io/gh/apache/cloudstack/pull/6899/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZW5naW5lL29yY2hlc3RyYXRpb24vc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2Nsb3Vkc3RhY2svZW5naW5lL29yY2hlc3RyYXRpb24vVm9sdW1lT3JjaGVzdHJhdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...n/java/com/cloud/capacity/dao/CapacityDaoImpl.java](https://codecov.io/gh/apache/cloudstack/pull/6899/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZW5naW5lL3NjaGVtYS9zcmMvbWFpbi9qYXZhL2NvbS9jbG91ZC9jYXBhY2l0eS9kYW8vQ2FwYWNpdHlEYW9JbXBsLmphdmE=) | `3.24% <0.00%> (-0.13%)` | :arrow_down: |
   | [...ema/src/main/java/com/cloud/network/vpc/VpcVO.java](https://codecov.io/gh/apache/cloudstack/pull/6899/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZW5naW5lL3NjaGVtYS9zcmMvbWFpbi9qYXZhL2NvbS9jbG91ZC9uZXR3b3JrL3ZwYy9WcGNWTy5qYXZh) | `14.86% <0.00%> (-1.81%)` | :arrow_down: |
   | [.../network/vpc/dao/VpcOfferingServiceMapDaoImpl.java](https://codecov.io/gh/apache/cloudstack/pull/6899/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZW5naW5lL3NjaGVtYS9zcmMvbWFpbi9qYXZhL2NvbS9jbG91ZC9uZXR3b3JrL3ZwYy9kYW8vVnBjT2ZmZXJpbmdTZXJ2aWNlTWFwRGFvSW1wbC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...ma/src/main/java/com/cloud/projects/ProjectVO.java](https://codecov.io/gh/apache/cloudstack/pull/6899/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZW5naW5lL3NjaGVtYS9zcmMvbWFpbi9qYXZhL2NvbS9jbG91ZC9wcm9qZWN0cy9Qcm9qZWN0Vk8uamF2YQ==) | `8.33% <0.00%> (+0.43%)` | :arrow_up: |
   | ... and [248 more](https://codecov.io/gh/apache/cloudstack/pull/6899/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1330613386

   Packaging result: :heavy_check_mark: el7 :heavy_multiplication_x: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 4676


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1357357221

   <b>Trillian Build Failed (tid-5554)<b/>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1383861898

   @CharlesQueiroz I am moving this to milestone 4.18.1. please move back to 4.18.0 if you manage to fix this in time.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1313870146

   @soreana a Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] CharlesQueiroz commented on pull request #6899: Count Resource Virtual Router

Posted by "CharlesQueiroz (via GitHub)" <gi...@apache.org>.
CharlesQueiroz commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1440377488

   > is this no longer an issue (as you closed it)?
   
   Hi @DaanHoogland. I closed it because I created a new one from the main, and it was a suggestion from weizhouapache too. It will be more simple to manage some eventual problems. (I suppose). Do you see any trouble or have any other suggestions? pls, let me know.  


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] CharlesQueiroz commented on pull request #6899: Count Resource Virtual Router

Posted by "CharlesQueiroz (via GitHub)" <gi...@apache.org>.
CharlesQueiroz commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1440442041

   > No @CharlesQueiroz, I was just wondering and hoping you haven't lost courage ;)
   
   Absolutely not! hehe. I'm trying to understand how I can be more useful to the project starting with small tasks to be aware of all the processes. Like a soldier :)  


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1318601197

   @acs-robot a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1318807947

   UI build: :heavy_check_mark:
   Live QA URL: http://qa.cloudstack.cloud:8080/client/pr/6899 (LL-JID-254)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1334656528

   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 4733


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1335103047

   <b>Trillian Build Failed (tid-5363)<b/>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] soreana commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
soreana commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1334617346

   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] soreana commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
soreana commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1351537478

   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1351981117

   @weizhouapache a Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1354783846

   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 4997


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland commented on pull request #6899: Count Resource Virtual Router

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1441349581

   > > No @CharlesQueiroz, I was just wondering and hoping you haven't lost courage ;)
   > 
   > Absolutely not! hehe. I'm trying to understand how I can be more useful to the project starting with small tasks to be aware of all the processes. Like a soldier :)
   
   great, next time you can just `git push --force ` if you need to.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1327933522

   Packaging result: :heavy_multiplication_x: el7 :heavy_multiplication_x: el8 :heavy_multiplication_x: debian :heavy_multiplication_x: suse15. SL-JID 4647


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] weizhouapache commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1351980405

   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] weizhouapache commented on a diff in pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on code in PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#discussion_r1048559943


##########
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java:
##########
@@ -1135,6 +1145,8 @@ private String validateConfigurationValue(final String name, String value, final
             return errMsg;
         }
 
+        isValueDeltaOrAll(name, value);

Review Comment:
   @CharlesQueiroz 
   can you rename the method to indicate what the value is ?



##########
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java:
##########
@@ -44,7 +44,7 @@
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-
+import com.googlecode.ipv6.IPv6Network;

Review Comment:
   @CharlesQueiroz 
   you remove the import from line 288 and import in line 47.
   it is better to import it in line 288



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1351540213

   @soreana a Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] weizhouapache commented on a diff in pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on code in PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#discussion_r1037973030


##########
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java:
##########
@@ -44,7 +44,7 @@
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-
+import com.googlecode.ipv6.IPv6Network;

Review Comment:
   revert this change ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1334617804

   @soreana a Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1357334360

   @DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1318607410

   UI build: :heavy_check_mark:
   Live QA URL: http://qa.cloudstack.cloud:8080/client/pr/6899 (LL-JID-253)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1357456209

   <b>Trillian Build Failed (tid-5563)<b/>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1357471477

   @CharlesQueiroz , the test environments mysteriously stop logging after 
   ```
   2022-12-19 10:45:55,415 DEBUG [o.a.c.f.c.i.ConfigDepotImpl] (main:null) (logid:) Retrieving keys from ConfigurationManagerImpl
   ```
   Can you have a look at your changes in that class, please?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1357333352

   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1354644819

   @DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland commented on a diff in pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on code in PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#discussion_r1050681709


##########
test/integration/component/test_router_resources.py:
##########
@@ -0,0 +1,824 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Test case for router resources
+"""
+
+# Import local modules
+
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import (scaleSystemVm,
+                                  stopRouter,
+                                  startRouter,
+                                  restartNetwork,
+                                  updateConfiguration)
+from marvin.lib.utils import (cleanup_resources)
+from marvin.lib.base import (NetworkOffering,
+                             ServiceOffering,
+                             VirtualMachine,
+                             Account,
+                             Domain,
+                             Network,
+                             Router,
+                             destroyRouter,
+                             Zone,
+                             updateResourceCount)
+from marvin.lib.common import (get_zone,
+                               get_template,
+                               get_domain,
+                               list_virtual_machines,
+                               list_networks,
+                               list_configurations,
+                               list_routers,
+                               list_service_offering)
+
+import logging
+
+class TestRouterResources(cloudstackTestCase):
+
+    @classmethod
+    def setupClass(cls):
+        cls.testClient = super(
+            TestRouterResources, cls
+        ).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+
+        cls.services = cls.testClient.getParsedTestDataConfig()
+        zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.zone = Zone(zone.__dict__)
+        cls.template = get_template(cls.apiclient, cls.zone.id)
+        cls._cleanup = []
+
+        cls.logger = logging.getLogger("TestRouterResources")
+        cls.stream_handler = logging.StreamHandler()
+        cls.logger.setLevel(logging.DEBUG)
+        cls.logger.addHandler(cls.stream_handler)
+
+        # Get Zone, Domain and templates
+        cls.domain = get_domain(cls.apiclient)
+
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
+
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offerings"]["big"]
+        )
+
+        # Create new domain1
+        cls.domain1 = Domain.create(
+            cls.apiclient,
+            services=cls.services["acl"]["domain1"],
+            parentdomainid=cls.domain.id)
+
+        # Create account1
+        cls.account1 = Account.create(
+            cls.apiclient,
+            cls.services["acl"]["accountD1"],
+            domainid=cls.domain1.id
+        )
+
+        # Create Network Offering with all the services
+        cls.network_offering = NetworkOffering.create(
+            cls.apiclient,
+            cls.services["isolated_network_offering"]
+        )
+        # Enable Network offering
+        cls.network_offering.update(cls.apiclient, state='Enabled')
+
+        cls.network = Network.create(
+            cls.apiclient,
+            cls.services["isolated_network"],
+            accountid=cls.account1.name,
+            domainid=cls.account1.domainid,
+            networkofferingid=cls.network_offering.id,
+            zoneid=cls.zone.id
+        )
+
+        virtualmachine = VirtualMachine.create(
+            cls.apiclient,
+            services=cls.services["virtual_machine_userdata"],
+            accountid=cls.account1.name,
+            domainid=cls.account1.domainid,
+            serviceofferingid=cls.service_offering.id,
+            networkids=cls.network.id,
+            templateid=cls.template.id,
+            zoneid=cls.zone.id
+        )
+
+        vms = list_virtual_machines(
+            cls.apiclient,
+            account=cls.account1.name,
+            domainid=cls.account1.domainid,
+            id=virtualmachine.id
+        )
+        vm = vms[0]
+
+        # get vm cpu and memory values
+        cls.vm_cpu_count = vm.cpunumber
+        cls.vm_mem_count = vm.memory
+
+        routers = list_routers(
+            cls.apiclient,
+            account=cls.account1.name,
+            domainid=cls.account1.domainid
+        )
+
+        router = routers[0]
+
+        router_so_id = router.serviceofferingid
+
+        list_service_response = list_service_offering(
+            cls.apiclient,
+            id=router_so_id,
+            issystem="true",
+            systemvmtype="domainrouter",
+            listall="true"
+        )
+
+        # Get default router service offering cpu and memory values
+        cls.default_vr_cpu = list_service_response[0].cpunumber
+        cls.default_vr_ram = list_service_response[0].memory
+
+        cls._cleanup.append(virtualmachine)
+        cls._cleanup.append(cls.network)
+
+        # Disable Network offering
+        cls.network_offering.update(cls.apiclient, state='Disabled')
+        cls._cleanup.append(cls.network_offering)
+        cls._cleanup.append(cls.account1)
+        cls._cleanup.append(cls.domain1)
+
+    @classmethod
+    def tearDownClass(cls):
+        try:
+            cleanup_resources(cls.apiclient, cls._cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return

Review Comment:
   @CharlesQueiroz the parent class implements a cleanup of a reverse list of added objects and does some extra for some types. Please use it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] GutoVeronezi commented on a diff in pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
GutoVeronezi commented on code in PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#discussion_r1021929299


##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1047,6 +1049,13 @@ public void orchestrateStart(final String vmUuid, final Map<VirtualMachineProfil
             resourceCountIncrement(owner.getAccountId(),new Long(offering.getCpu()), new Long(offering.getRamSize()));
         }
 
+        // Increment the VR resource count if the global setting is set to true
+        // and resource.count.running.vms is also true
+        if (VirtualMachine.Type.DomainRouter.equals(vm.type) &&
+                ResourceCountRouters.valueIn(owner.getDomainId())) {

Review Comment:
   As this statement is repeated along the code, it could be turned to a method.



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1351,6 +1360,12 @@ public void orchestrateStart(final String vmUuid, final Map<VirtualMachineProfil
                 if (VirtualMachine.Type.User.equals(vm.type) && ResourceCountRunningVMsonly.value()) {
                     resourceCountDecrement(owner.getAccountId(),new Long(offering.getCpu()), new Long(offering.getRamSize()));
                 }
+                // Decrement VR resource count if the VR can't be started

Review Comment:
   As the comment was intended to be a literal description of the following line, it is not necessary.



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1047,6 +1049,13 @@ public void orchestrateStart(final String vmUuid, final Map<VirtualMachineProfil
             resourceCountIncrement(owner.getAccountId(),new Long(offering.getCpu()), new Long(offering.getRamSize()));
         }
 
+        // Increment the VR resource count if the global setting is set to true
+        // and resource.count.running.vms is also true

Review Comment:
   As the comment was intended to be a literal description of the following line, it is not necessary.



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,6 +1413,131 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Function to increment the VR resource count
+     *
+     * If the global setting resource.count.router is true then the VR
+     * resource count will be considered as well
+     * If the global setting resource.count.router.type is "all" then
+     * all VR resource count will be considered else the diff between
+     * the current VR service offering and the default offering will
+     * be considered
+     *
+     * @param offering
+     * @param owner
+     * @param isDeployOrDestroy
+     */
+    @Override
+    public void incrementVrResourceCount(ServiceOffering offering,
+                                         Account owner,
+                                         boolean isDeployOrDestroy) {
+        // During router deployment/destroy, we increment the resource
+        // count only if resource.count.running.vms is false else
+        // we increment it during VR start/stop. Same applies for
+        // decrementing resource count.
+        if (isDeployOrDestroy == ResourceCountRunningVMsonly.value()) {
+            return;
+        }
+        ServiceOffering defaultRouterOffering = null;
+        String globalRouterOffering = _configDao.getValue("router.service.offering");
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        int cpuCount = 0;
+        int memoryCount = 0;
+        // Count VR resources for domain if global setting is true
+        // if value is "all" count all VR resources else get diff of
+        // current VR offering and default VR offering
+        if (ResourceCountRoutersType.valueIn(owner.getDomainId())
+                .equalsIgnoreCase(COUNT_ALL_VR_RESOURCES)) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (ResourceCountRoutersType.valueIn(owner.getDomainId())
+                .equalsIgnoreCase(COUNT_DELTA_VR_RESOURCES)) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        // Check if resource count can be allocated to account/domain
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException("Unable to deploy/start routers due to " + ex.getMessage());
+        }
+
+        // Increment the resource count
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Incrementing the CPU count with value " + cpuCount + " and " +
+                    "RAM value with " + memoryCount);
+        }
+        _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.cpu, new Long(cpuCount));
+        _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.memory, new Long(memoryCount));

Review Comment:
   This method can be separated in smaller methods, with the comments being turned into javadocs. It would be more readable and easier to add unit tests.



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,6 +1413,131 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Function to increment the VR resource count
+     *
+     * If the global setting resource.count.router is true then the VR
+     * resource count will be considered as well
+     * If the global setting resource.count.router.type is "all" then
+     * all VR resource count will be considered else the diff between
+     * the current VR service offering and the default offering will
+     * be considered
+     *
+     * @param offering
+     * @param owner
+     * @param isDeployOrDestroy
+     */
+    @Override
+    public void incrementVrResourceCount(ServiceOffering offering,
+                                         Account owner,
+                                         boolean isDeployOrDestroy) {
+        // During router deployment/destroy, we increment the resource
+        // count only if resource.count.running.vms is false else
+        // we increment it during VR start/stop. Same applies for
+        // decrementing resource count.
+        if (isDeployOrDestroy == ResourceCountRunningVMsonly.value()) {
+            return;
+        }
+        ServiceOffering defaultRouterOffering = null;
+        String globalRouterOffering = _configDao.getValue("router.service.offering");
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        int cpuCount = 0;
+        int memoryCount = 0;
+        // Count VR resources for domain if global setting is true
+        // if value is "all" count all VR resources else get diff of
+        // current VR offering and default VR offering
+        if (ResourceCountRoutersType.valueIn(owner.getDomainId())
+                .equalsIgnoreCase(COUNT_ALL_VR_RESOURCES)) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (ResourceCountRoutersType.valueIn(owner.getDomainId())
+                .equalsIgnoreCase(COUNT_DELTA_VR_RESOURCES)) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        // Check if resource count can be allocated to account/domain
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException("Unable to deploy/start routers due to " + ex.getMessage());
+        }
+
+        // Increment the resource count
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Incrementing the CPU count with value " + cpuCount + " and " +
+                    "RAM value with " + memoryCount);
+        }
+        _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.cpu, new Long(cpuCount));
+        _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.memory, new Long(memoryCount));
+    }
+
+    /**
+     * Function to decrement the VR resource count
+     *
+     * @param offering
+     * @param owner
+     * @param isDeployOrDestroy
+     */
+    @Override
+    public void decrementVrResourceCount(ServiceOffering offering,
+                                         Account owner,
+                                         boolean isDeployOrDestroy) {
+        if (isDeployOrDestroy == ResourceCountRunningVMsonly.value()) {
+            return;
+        }
+
+        ServiceOffering defaultRouterOffering = null;
+        String globalRouterOffering = _configDao.getValue("router.service.offering");
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        int cpuCount = 0;
+        int memoryCount = 0;
+
+        // Since we already incremented the resource count for the domain,
+        // decrement it if the VR can't be started
+        if (ResourceCountRoutersType.valueIn(owner.getDomainId())
+                .equalsIgnoreCase(COUNT_ALL_VR_RESOURCES)) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (ResourceCountRoutersType.valueIn(owner.getDomainId())
+                .equalsIgnoreCase(COUNT_DELTA_VR_RESOURCES)) {
+            cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+        }
+
+        // Decrement resource count if flag is true
+        if (s_logger.isDebugEnabled()) {
+            s_logger.error("Decrementing cpu resource count with value " + cpuCount +
+                    " and memory resource with value " + memoryCount);
+        }
+        _resourceLimitMgr.decrementResourceCount(owner.getAccountId(), ResourceType.cpu, new Long(cpuCount));
+        _resourceLimitMgr.decrementResourceCount(owner.getAccountId(), ResourceType.memory, new Long(memoryCount));
+    }

Review Comment:
   This method can be separated in smaller methods, with the comments being turned into javadocs. It would be more readable and easier to add unit tests.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1318799350

   @acs-robot a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland commented on pull request #6899: Count Resource Virtual Router

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1440187530

   @CharlesQueiroz is this no longer an issue (as you closed it)?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] soreana commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
soreana commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1327932961

   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] soreana commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
soreana commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1322414883

   @DaanHoogland Can we also have this one in 4.18 please? :-)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1335003273

   @DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] CharlesQueiroz commented on a diff in pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
CharlesQueiroz commented on code in PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#discussion_r1027320107


##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Method to return the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Count VR resources for domain if global setting is true
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering
+     *
+     * @param offering VR service offering
+     * @param defaultRouterOffering default VR service offering
+     * @param owner account
+     * @return a Pair of cpu and ram
+     */
+    private Pair<Long, Long> resolveCpuAndMemoryCount(ServiceOffering offering, ServiceOffering defaultRouterOffering, Account owner) {
+        Integer cpuCount = 0;
+        Integer memoryCount = 0;
+        if (COUNT_ALL_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (COUNT_DELTA_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        return Pair.of(cpuCount.longValue(), memoryCount.longValue());
+    }
+
+    private void validateResouceCount(Pair<Long, Long> cpuMemoryCount, Account owner) {
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException("Unable to deploy/start routers due to " + ex.getMessage());

Review Comment:
   done.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1318862887

   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. LL-JID 280


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] soreana commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
soreana commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1319948257

   @blueorangutan package


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] nvazquez commented on a diff in pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
nvazquez commented on code in PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#discussion_r1038193298


##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Returns the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);

Review Comment:
   Instead of the configDao, can we access the setting via `VirtualNetworkApplianceManager.VirtualRouterServiceOffering` (for `router.service.offering`)?



##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1398,15 +1405,152 @@ private void logBootModeParameters(Map<VirtualMachineProfile.Param, Object> para
         }
     }
 
+    /**
+     * Returns the service offering by the given configuration.
+     *
+     * @param configName name of the config
+     * @return the service offering found or null if not found
+     */
+    public ServiceOffering getServiceOfferingByConfig(String configName) {
+        ServiceOffering defaultRouterOffering = null;
+        final String globalRouterOffering = configDao.getValue(configName);
+
+        if (globalRouterOffering != null) {
+            defaultRouterOffering = _serviceOfferingDao.findByUuid(globalRouterOffering);
+        }
+
+        if (defaultRouterOffering == null) {
+            defaultRouterOffering =  _serviceOfferingDao.findByName(ServiceOffering.routerDefaultOffUniqueName);
+        }
+
+        return defaultRouterOffering;
+    }
+
+    /**
+     * Counts VR resources for the domain if global setting is true.
+     * if value is "all" count all VR resources else get diff of
+     * current VR offering and default VR offering
+     *
+     * @param offering VR service offering
+     * @param defaultRouterOffering default VR service offering
+     * @param owner account
+     * @return a Pair of cpu and ram
+     */
+    private Pair<Long, Long> resolveCpuAndMemoryCount(ServiceOffering offering, ServiceOffering defaultRouterOffering, Account owner) {
+        Integer cpuCount = 0;
+        Integer memoryCount = 0;
+        if (COUNT_ALL_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            cpuCount = offering.getCpu();
+            memoryCount = offering.getRamSize();
+        } else if (COUNT_DELTA_VR_RESOURCES.equalsIgnoreCase(ResourceCountRoutersType.valueIn(owner.getDomainId()))) {
+            // Default offering value can be greater than current offering value
+            if (offering.getCpu() >= defaultRouterOffering.getCpu()) {
+                cpuCount = offering.getCpu() - defaultRouterOffering.getCpu();
+            }
+            if (offering.getRamSize() >= defaultRouterOffering.getRamSize()) {
+                memoryCount = offering.getRamSize() - defaultRouterOffering.getRamSize();
+            }
+        }
+
+        return Pair.of(cpuCount.longValue(), memoryCount.longValue());
+    }
+
+    private void validateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner) {
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+        try {
+            if (cpuCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.cpu, cpuCount);
+            }
+            if (memoryCount > 0) {
+                _resourceLimitMgr.checkResourceLimit(owner, ResourceType.memory, memoryCount);
+            }
+        } catch (ResourceAllocationException ex) {
+            throw new CloudRuntimeException(String.format("Unable to deploy/start routers due to {}", ex.getMessage()));
+        }
+    }
+
+    /**
+     * Check if resource count can be allocated to account/domain
+     *
+     * @param cpuMemoryCount a Pair of cpu and ram
+     * @param owner the account
+     */
+    private void calculateResourceCount(Pair<Long, Long> cpuMemoryCount, Account owner, boolean isIncrement) {
+        validateResourceCount(cpuMemoryCount, owner);
+        final Long cpuCount = cpuMemoryCount.first();
+        final Long memoryCount = cpuMemoryCount.second();
+
+        // Increment the resource count
+        if (s_logger.isDebugEnabled()) {
+            if(isIncrement) {
+                s_logger.debug(String.format("Incrementing the CPU count with value %s and RAM value with %s", cpuCount, memoryCount));
+            } else {
+                s_logger.debug(String.format("Decrementing cpu resource count with value %s and memory resource with value %s",cpuCount, memoryCount));
+            }
+        }
+
+        if(isIncrement) {
+            _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.cpu, cpuCount);
+            _resourceLimitMgr.incrementResourceCount(owner.getAccountId(), ResourceType.memory, memoryCount);
+        } else {
+            _resourceLimitMgr.decrementResourceCount(owner.getAccountId(), ResourceType.cpu, cpuCount);
+            _resourceLimitMgr.decrementResourceCount(owner.getAccountId(), ResourceType.memory, memoryCount);
+        }
+    }
+
+    /**
+     * Function to increment the VR resource count
+     * If the global setting resource.count.router is true then the VR
+     * resource count will be considered as well
+     * If the global setting resource.count.router.type is "all" then
+     * all VR resource count will be considered else the diff between
+     * the current VR service offering and the default offering will
+     * be considered.
+     * During router deployment/destroy, we increment the resource
+     * count only if resource.count.running.vms is false else
+     * we increment it during VR start/stop. Same applies for
+     * decrementing resource count.
+     *
+     * @param offering VR service offering
+     * @param owner account
+     * @param isDeployOrDestroy true if router is being deployed/destroyed
+     */
+    @Override
+    public void incrementVrResourceCount(ServiceOffering offering, Account owner, boolean isDeployOrDestroy) {
+        if (isDeployOrDestroy == Boolean.TRUE.equals(ResourceCountRunningVMsonly.value())) {
+            return;
+        }
+
+        final ServiceOffering defaultRouterOffering = getServiceOfferingByConfig("router.service.offering");

Review Comment:
   Actually here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1335057478

   <b>Trillian Build Failed (tid-5359)<b/>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] boring-cyborg[bot] commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1313858751

   Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
   Here are some useful points:
   - In case of a new feature add useful documentation (raise doc PR at https://github.com/apache/cloudstack-documentation)
   - Be patient and persistent. It might take some time to get a review or get the final approval from the committers.
   - Pay attention to the quality of your code, ensure tests are passing and your PR doesn't have conflicts.
   - Please follow [ASF Code of Conduct](https://github.com/apache/.github/blob/main/.github/CODE_OF_CONDUCT.md) for all communication including (but not limited to) comments on Pull Requests, Issues, Mailing list and Slack.
   - Be sure to read the [CloudStack Coding Conventions](https://cwiki.apache.org/confluence/display/CLOUDSTACK/Coding+conventions).
   Apache CloudStack is a community-driven project and together we are making it better 🚀.
   In case of doubts contact the developers at:
   Mailing List: dev@cloudstack.apache.org (https://cloudstack.apache.org/mailing-lists.html)
   Slack: https://apachecloudstack.slack.com/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1352076877

   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_multiplication_x: debian :heavy_check_mark: suse15. SL-JID 4943


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] CharlesQueiroz commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
CharlesQueiroz commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1350303339

   @DaanHoogland, sorry for the delay. The conflict was solved. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] sonarcloud[bot] commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1365232683

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache_cloudstack&pullRequest=6899)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6899&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6899&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6899&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=CODE_SMELL) [9 Code Smells](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=CODE_SMELL)
   
   [![1.7%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '1.7%')](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6899&metric=new_coverage&view=list) [1.7% Coverage](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6899&metric=new_coverage&view=list)  
   [![1.6%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.6%')](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6899&metric=new_duplicated_lines_density&view=list) [1.6% Duplication](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6899&metric=new_duplicated_lines_density&view=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland commented on pull request #6899: Count Resource Virtual Router

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1440421128

   No @CharlesQueiroz I was just wondering and hoping you haven't lost courage ;)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1376866444

   @CharlesQueiroz are you still looking at this? There are conflicts.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1351620765

   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_multiplication_x: debian :heavy_check_mark: suse15. SL-JID 4940


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] CharlesQueiroz commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
CharlesQueiroz commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1357535280

   Yes. Let me check... 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1327933122

   @soreana a Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1313868220

   UI build: :heavy_check_mark:
   Live QA URL: http://qa.cloudstack.cloud:8080/client/pr/6899 (LL-JID-241)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1335003138

   @weizhouapache can you review this, given time?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] DaanHoogland commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1335002580

   @blueorangutan test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1335011223

   <b>Trillian Build Failed (tid-5355)<b/>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] acs-robot commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
acs-robot commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1318600819

   Found UI changes, kicking a new UI QA build
   @blueorangutan ui


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] blueorangutan commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1318808730

   @soreana a Jenkins job has been kicked to build packages. It will be bundled with  KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] CharlesQueiroz commented on a diff in pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
CharlesQueiroz commented on code in PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#discussion_r1025340891


##########
engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java:
##########
@@ -1047,6 +1049,13 @@ public void orchestrateStart(final String vmUuid, final Map<VirtualMachineProfil
             resourceCountIncrement(owner.getAccountId(),new Long(offering.getCpu()), new Long(offering.getRamSize()));
         }
 
+        // Increment the VR resource count if the global setting is set to true
+        // and resource.count.running.vms is also true
+        if (VirtualMachine.Type.DomainRouter.equals(vm.type) &&
+                ResourceCountRouters.valueIn(owner.getDomainId())) {

Review Comment:
   done!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] sonarcloud[bot] commented on pull request #6899: Count Resource Virtual Router

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #6899:
URL: https://github.com/apache/cloudstack/pull/6899#issuecomment-1318881092

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache_cloudstack&pullRequest=6899)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6899&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6899&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_cloudstack&pullRequest=6899&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache_cloudstack&pullRequest=6899&resolved=false&types=CODE_SMELL)
   
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6899&metric=new_coverage&view=list) [1.9% Coverage](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6899&metric=new_coverage&view=list)  
   [![13.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/20-16px.png '13.0%')](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6899&metric=new_duplicated_lines_density&view=list) [13.0% Duplication](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=6899&metric=new_duplicated_lines_density&view=list)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [cloudstack] CharlesQueiroz closed pull request #6899: Count Resource Virtual Router

Posted by "CharlesQueiroz (via GitHub)" <gi...@apache.org>.
CharlesQueiroz closed pull request #6899: Count Resource Virtual Router
URL: https://github.com/apache/cloudstack/pull/6899


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org