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 2020/10/01 00:00:35 UTC

[GitHub] [cloudstack] ravening opened a new pull request #4362: Match template tags with host tag for vm deployment

ravening opened a new pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362


   
   ## Description
   <!--- Describe your changes in detail -->
   1. Match the template tags with host tags for VM deployment/migration
   2. Allow updating templates/isos with template tag by admin
   3. Allow adding template tag while registering/creating template/iso
   4. Allow searching templates/isos using template tags
   
   If a template has a template tag then deploy the VM which uses this
   template on hosts that match the template tags. If no suitable
   hosts are found then throw an exception
   
   Similarly, match the template tag with host tags while starting or
   migrating a VM to a different host
   
   <!-- For new features, provide link to FS, dev ML discussion etc. -->
   <!-- In case of bug fix, the expected and actual behaviours, steps to reproduce. -->
   
   <!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be closed when this PR gets merged -->
   <!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" -->
   <!-- Fixes: # -->
   
   ## Types of changes
   <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
   - [X] Bug fix (non-breaking change which fixes an issue)
   - [X] Enhancement (improves an existing feature and functionality)
   
   
   ## Screenshots (if appropriate):
   
   ## How Has This Been Tested?
   <!-- Please describe in detail how you tested your changes. -->
   <!-- Include details of your testing environment, and the tests you ran to -->
   <!-- see how your change affects other areas of the code, etc. -->
   
   test 1
   
   add different tag to template than hosts
   try to deploy. it should fail
   try to migrating existing vm. it should fail
   
   
   test 2
   
   remove all the tags on template
   add tags to hosts
   try to deploy vm 
   it can be deployed on any host
   try to migrate it.
   migration should be possible
   stop/start is also possible
   
   
   test 3
   
   add tag to template
   remove tags from host
   try to deploy vm
   deployment should fail
   try to migrate already created vm with template tag
   migration should fail
   
   
   test 4
   
   set same template tag on template and only one host
   try to deploy vm
   it should deploy vm on host with matching tag
   
   
   test 5
   
   ow try to migrate above created vm having specific tag
   migration should fail as other hosts have either no tags or different tag
   
   
   test 6
   
   stop the above created vm
   try to start of different host
   start should fail as the tags dont match
   
   
   test 7
   
   now remove the tag from the template of the above created vm
   try to migrate it
   it should work fine
   
   
   test 8
   
   
   remove all tags from everyhwere
   select any vm and set service offering tag as "ubuntu"
   now set host tag as "windows" for all hosts
   try to start/deploymigrate vm
   it should not start/deploy/migrate as tags dont match
   
   
   
   test 9
   
   
   now set service offering tag as "windows"
   try to start/deploy/migrate
   it should successfully start/deploy/migrate on/to any host
   
   
   
   Same steps for iso as well
   
   <!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/master/CONTRIBUTING.md) document -->
   


----------------------------------------------------------------
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.

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



[GitHub] [cloudstack] blueorangutan commented on pull request #4362: Match template tags with host tag for vm deployment

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


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


-- 
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 #4362: Match template tags with host tag for vm deployment

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


   this pr also has some changes on api: create/update/list template/iso by admin


----------------------------------------------------------------
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.

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



[GitHub] [cloudstack] blueorangutan commented on pull request #4362: Match template tags with host tag for vm deployment

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


   <b>Trillian test result (tid-2091)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 36329 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4362-t2091-kvm-centos7.zip
   Smoke tests completed. 89 look OK, 0 have errors
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   


-- 
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] sureshanaparti commented on pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#issuecomment-868300162


   @ravening any update on 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.

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



[GitHub] [cloudstack] nvazquez commented on pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
nvazquez commented on pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#issuecomment-1043768699


   Hi @ravening can you please fix the 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] weizhouapache commented on pull request #4362: Match template tags with host tag for vm deployment

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


   as #4452 has been merged, build will fail.


----------------------------------------------------------------
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.

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



[GitHub] [cloudstack] blueorangutan commented on pull request #4362: Match template tags with host tag for vm deployment

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


   @DaanHoogland a Jenkins job has been kicked to build packages. 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 a change in pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on a change in pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#discussion_r692848847



##########
File path: server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
##########
@@ -3672,6 +3676,10 @@ else if (!template.isPublicTemplate() && caller.getType() != Account.ACCOUNT_TYP
             sc.addAnd("dataCenterId", SearchCriteria.Op.SC, zoneSc);
         }
 
+        if (templateTag != null && !templateTag.equalsIgnoreCase("")) {

Review comment:
       templateTag is unknown here, @ravening .




-- 
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 change in pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
weizhouapache commented on a change in pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#discussion_r692928496



##########
File path: server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
##########
@@ -3672,6 +3676,10 @@ else if (!template.isPublicTemplate() && caller.getType() != Account.ACCOUNT_TYP
             sc.addAnd("dataCenterId", SearchCriteria.Op.SC, zoneSc);
         }
 
+        if (templateTag != null && !templateTag.equalsIgnoreCase("")) {

Review comment:
       @ravening could you please fix 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] nvazquez commented on a change in pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
nvazquez commented on a change in pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#discussion_r709732271



##########
File path: server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
##########
@@ -3672,6 +3676,10 @@ else if (!template.isPublicTemplate() && caller.getType() != Account.ACCOUNT_TYP
             sc.addAnd("dataCenterId", SearchCriteria.Op.SC, zoneSc);
         }
 
+        if (templateTag != null && !templateTag.equalsIgnoreCase("")) {

Review comment:
       @DaanHoogland can you explain why? As far as I see it is being passed as a parameter to `templateChecks()`




-- 
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 change in pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on a change in pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#discussion_r710075403



##########
File path: server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
##########
@@ -3672,6 +3676,10 @@ else if (!template.isPublicTemplate() && caller.getType() != Account.ACCOUNT_TYP
             sc.addAnd("dataCenterId", SearchCriteria.Op.SC, zoneSc);
         }
 
+        if (templateTag != null && !templateTag.equalsIgnoreCase("")) {

Review comment:
       it was a build error @nvazquez , If it's fixed, it's fixed.




-- 
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] ravening commented on pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
ravening commented on pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#issuecomment-723486373


   > @ravening could you give me some of the use cases for this change please, I'm not quite following.
   
   @PaulAngus if template has a tag "windows" then the VM's created using this template should be deployed on hosts with tags "windows". Same thing for templates having tags like "linux", "Unix" it any other tag.
   
   So we should not deploy templates having "windows" tag on hosts having "linux" tag
   
   Hope it's clear


----------------------------------------------------------------
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.

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



[GitHub] [cloudstack] DaanHoogland commented on pull request #4362: Match template tags with host tag for vm deployment

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


   I created a template with no tag
   I have two hosts
   one host as no tags
   the other one has a tag "none"
   I deploy a VM
   result: 
   ![image](https://user-images.githubusercontent.com/2486961/133775287-a6abf492-9f70-4ea5-813c-f33ebff0fb52.png)
   ```
   2021-09-17 11:26:32,657 DEBUG [c.c.a.ApiServlet] (qtp769798433-15:ctx-9d0ad7da) (logid:30c456f4) ===START===  172.16.250.3 -- GET  jobId=f29d9a58-fd07-4186-bc85-ea2cc60ac1f3&command=queryAsyncJobResult&response=json
   2021-09-17 11:26:32,661 DEBUG [c.c.a.ApiServer] (qtp769798433-15:ctx-9d0ad7da ctx-89672168) (logid:30c456f4) CIDRs from which account 'Acct[e423f3e7-16f6-11ec-a2d3-1e00b900043d-admin] -- Account {"id": 2, "name": "admin", "uuid": "e423f3e7-16f6-11ec-a2d3-1e00b900043d"}' is allowed to perform API calls: 0.0.0.0/0,::/0
   2021-09-17 11:26:32,669 DEBUG [c.c.a.ApiServlet] (qtp769798433-15:ctx-9d0ad7da ctx-89672168) (logid:30c456f4) ===END===  172.16.250.3 -- GET  jobId=f29d9a58-fd07-4186-bc85-ea2cc60ac1f3&command=queryAsyncJobResult&response=json
   2021-09-17 11:26:32,670 DEBUG [c.c.r.ResourceLimitManagerImpl] (API-Job-Executor-47:ctx-5239873f job-69 ctx-448d1fc4) (logid:f29d9a58) Updating resource Type = volume count for Account = 2 Operation = decreasing Amount = 1
   2021-09-17 11:26:32,673 DEBUG [c.c.r.ResourceLimitManagerImpl] (API-Job-Executor-47:ctx-5239873f job-69 ctx-448d1fc4) (logid:f29d9a58) Updating resource Type = primary_storage count for Account = 2 Operation = decreasing Amount = (50.00 MB) 52428800
   2021-09-17 11:26:32,680 WARN  [c.c.a.AlertManagerImpl] (API-Job-Executor-47:ctx-5239873f job-69 ctx-448d1fc4) (logid:f29d9a58) alertType=[8] dataCenterId=[1] podId=[null] clusterId=[null] message=[Failed to deploy Vm with Id: 7, on Host with Id: null].
   2021-09-17 11:26:32,683 WARN  [c.c.a.AlertManagerImpl] (API-Job-Executor-47:ctx-5239873f job-69 ctx-448d1fc4) (logid:f29d9a58) No recipients set in 'alert.email.addresses', skipping sending alert with subject: Failed to deploy Vm with Id: 7, on Host with Id: null and content: Failed to deploy Vm with Id: 7, on Host with Id: null
   2021-09-17 11:26:32,685 DEBUG [c.c.r.ResourceLimitManagerImpl] (API-Job-Executor-47:ctx-5239873f job-69 ctx-448d1fc4) (logid:f29d9a58) Updating resource Type = user_vm count for Account = 2 Operation = decreasing Amount = 1
   2021-09-17 11:26:32,689 DEBUG [c.c.r.ResourceLimitManagerImpl] (API-Job-Executor-47:ctx-5239873f job-69 ctx-448d1fc4) (logid:f29d9a58) Updating resource Type = cpu count for Account = 2 Operation = decreasing Amount = 1
   2021-09-17 11:26:32,692 DEBUG [c.c.r.ResourceLimitManagerImpl] (API-Job-Executor-47:ctx-5239873f job-69 ctx-448d1fc4) (logid:f29d9a58) Updating resource Type = memory count for Account = 2 Operation = decreasing Amount = 512
   2021-09-17 11:26:32,699 ERROR [c.c.a.ApiAsyncJobDispatcher] (API-Job-Executor-47:ctx-5239873f job-69) (logid:f29d9a58) Unexpected exception while executing org.apache.cloudstack.api.command.admin.vm.DeployVMCmdByAdmin
   com.cloud.utils.exception.CloudRuntimeException: No suitable host found for follow compute offering tags: 
           at com.cloud.host.dao.HostDaoImpl.findHostByComputeOfferings(HostDaoImpl.java:1255)
           at com.cloud.host.dao.HostDaoImpl.listByHostTag(HostDaoImpl.java:770)
           at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
           at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
           at java.base/java.lang.reflect.Method.invoke(Method.java:566)
           at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
           at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
           at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
           at com.cloud.utils.db.TransactionContextInterceptor.invoke(TransactionContextInterceptor.java:34)
           at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
           at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
           at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
           at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
           at com.sun.proxy.$Proxy46.listByHostTag(Unknown Source)
           at com.cloud.agent.manager.allocator.impl.FirstFitAllocator.allocateTo(FirstFitAllocator.java:177)
           at com.cloud.agent.manager.allocator.impl.FirstFitAllocator.allocateTo(FirstFitAllocator.java:106)
           at com.cloud.agent.manager.allocator.impl.FirstFitRoutingAllocator.allocateTo(FirstFitRoutingAllocator.java:41)
           at com.cloud.deploy.DeploymentPlanningManagerImpl.findSuitableHosts(DeploymentPlanningManagerImpl.java:1541)
           at com.cloud.deploy.DeploymentPlanningManagerImpl.checkClustersforDestination(DeploymentPlanningManagerImpl.java:1212)
           at com.cloud.deploy.DeploymentPlanningManagerImpl.planDeployment(DeploymentPlanningManagerImpl.java:539)
           at org.apache.cloudstack.engine.cloud.entity.api.VMEntityManagerImpl.reserveVirtualMachine(VMEntityManagerImpl.java:203)
           at org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityImpl.reserve(VirtualMachineEntityImpl.java:202)
           at com.cloud.vm.UserVmManagerImpl.startVirtualMachine(UserVmManagerImpl.java:5090)
           at com.cloud.vm.UserVmManagerImpl.startVirtualMachine(UserVmManagerImpl.java:4617)
           at com.cloud.vm.UserVmManagerImpl.startVirtualMachine(UserVmManagerImpl.java:4606)
           at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   ```
   not sure if these are new, but I see a number of 
   ```
   021-09-17 11:24:09,054 DEBUG [o.a.c.f.j.i.AsyncJobManagerImpl] (API-Job-Executor-43:ctx-e44070b0 job-65) (logid:97bfaefa) Complete async job-65, jobStatus: FAILED, resultCode: 530, result: org.apache.cloudstack.api.response.ExceptionResponse/null/{"uuidList":[],"errorcode":"431","errortext":"Invalid resource type: Host"}
   ```
   as well
   
   i'll update with more logs if i find out more.


-- 
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 pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
nvazquez commented on pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#issuecomment-920875304


   @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] DaanHoogland commented on pull request #4362: Match template tags with host tag for vm deployment

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


   good functionality, clear description and sane as far as I can tell. 
   @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 pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
nvazquez commented on pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#issuecomment-897324891


   Ping @ravening 


-- 
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] ravening commented on pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
ravening commented on pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#issuecomment-922840067


   > follow up:
   > when I remove the tag from the host the template still won't deploy.
   > setting the tag "none" onboth the template and one of the hosts, the deploy proceeds, and a VM ends out on the tagged host.
   > @ravening, can you look at my scenario, please?
   
   @DaanHoogland i will look into it and get back to you


-- 
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] PaulAngus commented on pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
PaulAngus commented on pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#issuecomment-723486044


   @ravening could you give me some of the use cases for this change please, I'm not quite following.


----------------------------------------------------------------
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.

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



[GitHub] [cloudstack] nvazquez commented on pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
nvazquez commented on pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#issuecomment-912181099


   Ping @ravening 


-- 
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 removed a comment on pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
weizhouapache removed a comment on pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#issuecomment-702012421


   this pr also has some changes on api: create/update/list template/iso by admin


----------------------------------------------------------------
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.

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



[GitHub] [cloudstack] shwstppr commented on pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
shwstppr commented on pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#issuecomment-766726421


   @ravening Needs conflicts to be resolved. Moving to 4.16.0.0 milestone based on base branch please update if needed


----------------------------------------------------------------
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.

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



[GitHub] [cloudstack] nvazquez commented on pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
nvazquez commented on pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#issuecomment-920910684


   @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] ravening commented on pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
ravening commented on pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#issuecomment-767489204


   > @ravening Needs conflicts to be resolved. Moving to 4.16.0.0 milestone based on base branch please update if needed
   
   @shwstppr resolved 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.

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



[GitHub] [cloudstack] weizhouapache closed pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
weizhouapache closed pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362


   


----------------------------------------------------------------
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.

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



[GitHub] [cloudstack] DaanHoogland commented on pull request #4362: Match template tags with host tag for vm deployment

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


   running test_host_tags.py, I get
   ```
   Test template/host tag ... === TestName: test_01_template_host_tag | Status : EXCEPTION ===
   ERROR
   
   ======================================================================
   ERROR: Test template/host tag
   ----------------------------------------------------------------------
   Traceback (most recent call last):
     File "/marvin/tests/component/test_host_tags.py", line 210, in test_01_template_host_tag
       cls.vm_3.start(cls.apiclient, hostid = host.id)
     File "/usr/local/lib/python3.6/site-packages/marvin/lib/base.py", line 722, in start
       apiclient.startVirtualMachine(cmd)
     File "/usr/local/lib/python3.6/site-packages/marvin/cloudstackAPI/cloudstackAPIClient.py", line 4014, in startVirtualMachine
       response = self.connection.marvinRequest(command, response_type=response, method=method)
     File "/usr/local/lib/python3.6/site-packages/marvin/cloudstackConnection.py", line 381, in marvinRequest
       raise e
     File "/usr/local/lib/python3.6/site-packages/marvin/cloudstackConnection.py", line 376, in marvinRequest
       raise self.__lastError
     File "/usr/local/lib/python3.6/site-packages/marvin/cloudstackConnection.py", line 105, in __poll
       % async_response)
   Exception: Job failed: {accountid : 'e423f3e7-16f6-11ec-a2d3-1e00b900043d', userid : 'e4251d92-16f6-11ec-a2d3-1e00b900043d', cmd : 'org.apache.cloudstack.api.command.admin.vm.StartVMCmdByAdmin', jobstatus : 2, jobprocstatus : 0, jobresultcode : 530, jobresulttype : 'object', jobresult : {errorcode : 431, errortext : 'The virtual machine dd283411-86dd-4b94-866c-3d32dd72a89c (Test VM) is already running'}, jobinstancetype : 'VirtualMachine', jobinstanceid : 'dd283411-86dd-4b94-866c-3d32dd72a89c', created : '2021-09-17T10:44:08+0000', completed : '2021-09-17T10:44:08+0000', jobid : '0e11e39a-3329-4cdd-820f-6f904480b5f1'}
   ```
   running test_template_tags.py
   ```
   executing /usr/local/bin/nosetests --with-xunit --xunit-file=/marvin/MarvinLogs/test_template_tags.py.xml --with-marvin --marvin-config=/marvin/pr4362-t2092-kvm-centos7-advanced-cfg --hypervisor=kvm -s -a tags=advanced tests/component/test_template_tags.py
   
   ==== Marvin Init Started ====
   
   === Marvin Parse Config Successful ===
   
   === Marvin Setting TestData Successful===
   
   ==== Log Folder Path: /marvin/MarvinLogs/Sep_17_2021_11_08_00_IQNIPQ All logs will be available here ====
   
   === Marvin Init Logging Successful===
   
   ==== Marvin Init Successful ====
   === TestName: test_01_update_template_tags | Status : SUCCESS ===
   
   === TestName: test_02_register_template_with_tags | Status : SUCCESS ===
   ```


-- 
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 change in pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
nvazquez commented on a change in pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#discussion_r710091723



##########
File path: server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
##########
@@ -3672,6 +3676,10 @@ else if (!template.isPublicTemplate() && caller.getType() != Account.ACCOUNT_TYP
             sc.addAnd("dataCenterId", SearchCriteria.Op.SC, zoneSc);
         }
 
+        if (templateTag != null && !templateTag.equalsIgnoreCase("")) {

Review comment:
       Copy, was checking the lastest changes so wasn't seeing why it was unknown, seems good 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] blueorangutan commented on pull request #4362: Match template tags with host tag for vm deployment

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


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


-- 
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 #4362: Match template tags with host tag for vm deployment

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


   follow up:
   when I remove the tag from the host the template still won't deploy.
   setting the tag "none" onboth the template and one of the hosts, the deploy proceeds, and a VM ends out on the tagged host.
   @ravening, can you look at my scenario, 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 #4362: Match template tags with host tag for vm deployment

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


   @nvazquez a Jenkins job has been kicked to build packages. 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] shwstppr commented on pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
shwstppr commented on pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#issuecomment-766726421


   @ravening Needs conflicts to be resolved. Moving to 4.16.0.0 milestone based on base branch please update if needed


----------------------------------------------------------------
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.

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



[GitHub] [cloudstack] DaanHoogland commented on a change in pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on a change in pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#discussion_r710951148



##########
File path: test/integration/component/test_host_tags.py
##########
@@ -0,0 +1,232 @@
+# 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.
+""" tests for host tags (host, service offering, template)
+"""
+# Import Local Modules
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import cleanup_resources, validateList
+from marvin.lib.base import (Account,
+                             VirtualMachine,
+                             Iso,
+                             Host,
+                             Template,
+                             ServiceOffering,
+                             Domain)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_hosts)
+from marvin.codes import FAILED, PASS
+import time
+
+class TestHostTags(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.testClient = super(TestHostTags, cls).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+        cls.hypervisor = cls.testClient.getHypervisorInfo()
+        cls.services = cls.testClient.getParsedTestDataConfig()
+
+        # Get Zone, Domain and templates
+        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.domain = get_domain(cls.apiclient)
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+        )
+        cls.skip = False
+        if cls.template == FAILED:
+            cls.skip = True
+            return
+
+        cls.account = Account.create(
+            cls.apiclient,
+            cls.services["account"],
+            admin=True,
+        )
+
+        # Create service offerings, disk offerings etc
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offering"]
+        )
+
+        cls.services["iso"]["zoneid"] = cls.zone.id
+        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+        cls.services["virtual_machine"]["template"] = cls.template.id
+
+        cls.hosts = list_hosts(
+            cls.apiclient,
+            zoneid=cls.zone.id,
+            type='Routing',
+            resourcestate='Enabled'
+        )
+        cls._cleanup = [
+            cls.account,
+            cls.service_offering
+        ]
+        return
+
+    @classmethod
+    def tearDownClass(cls):
+        try:
+            # Cleanup resources used
+            print("Cleanup resources used")
+            cleanup_resources(cls.apiclient, cls._cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return

Review comment:
       ```suggestion
       @classmethod
       def tearDownClass(cls):
           super(TestHostTags, cls).tearDownClass()
   ```

##########
File path: test/integration/component/test_host_tags.py
##########
@@ -0,0 +1,232 @@
+# 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.
+""" tests for host tags (host, service offering, template)
+"""
+# Import Local Modules
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import cleanup_resources, validateList
+from marvin.lib.base import (Account,
+                             VirtualMachine,
+                             Iso,
+                             Host,
+                             Template,
+                             ServiceOffering,
+                             Domain)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_hosts)
+from marvin.codes import FAILED, PASS
+import time
+
+class TestHostTags(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.testClient = super(TestHostTags, cls).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+        cls.hypervisor = cls.testClient.getHypervisorInfo()
+        cls.services = cls.testClient.getParsedTestDataConfig()
+
+        # Get Zone, Domain and templates
+        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.domain = get_domain(cls.apiclient)
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+        )
+        cls.skip = False
+        if cls.template == FAILED:
+            cls.skip = True
+            return
+
+        cls.account = Account.create(
+            cls.apiclient,
+            cls.services["account"],
+            admin=True,
+        )
+
+        # Create service offerings, disk offerings etc
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offering"]
+        )
+
+        cls.services["iso"]["zoneid"] = cls.zone.id
+        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+        cls.services["virtual_machine"]["template"] = cls.template.id
+
+        cls.hosts = list_hosts(
+            cls.apiclient,
+            zoneid=cls.zone.id,
+            type='Routing',
+            resourcestate='Enabled'
+        )
+        cls._cleanup = [
+            cls.account,
+            cls.service_offering
+        ]

Review comment:
       ```suggestion
   ```

##########
File path: test/integration/component/test_host_tags.py
##########
@@ -0,0 +1,232 @@
+# 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.
+""" tests for host tags (host, service offering, template)
+"""
+# Import Local Modules
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import cleanup_resources, validateList
+from marvin.lib.base import (Account,
+                             VirtualMachine,
+                             Iso,
+                             Host,
+                             Template,
+                             ServiceOffering,
+                             Domain)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_hosts)
+from marvin.codes import FAILED, PASS
+import time
+
+class TestHostTags(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.testClient = super(TestHostTags, cls).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+        cls.hypervisor = cls.testClient.getHypervisorInfo()
+        cls.services = cls.testClient.getParsedTestDataConfig()
+
+        # Get Zone, Domain and templates
+        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.domain = get_domain(cls.apiclient)
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+        )
+        cls.skip = False
+        if cls.template == FAILED:
+            cls.skip = True
+            return
+
+        cls.account = Account.create(
+            cls.apiclient,
+            cls.services["account"],
+            admin=True,
+        )
+
+        # Create service offerings, disk offerings etc
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offering"]
+        )
+
+        cls.services["iso"]["zoneid"] = cls.zone.id
+        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+        cls.services["virtual_machine"]["template"] = cls.template.id
+
+        cls.hosts = list_hosts(
+            cls.apiclient,
+            zoneid=cls.zone.id,
+            type='Routing',
+            resourcestate='Enabled'
+        )
+        cls._cleanup = [
+            cls.account,
+            cls.service_offering
+        ]
+        return
+
+    @classmethod
+    def tearDownClass(cls):
+        try:
+            # Cleanup resources used
+            print("Cleanup resources used")
+            cleanup_resources(cls.apiclient, cls._cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return
+
+    def setUp(self):
+        if self.skip:
+            self.skipTest("skip test")
+        self.apiclient = self.testClient.getApiClient()
+        self.cleanup = []
+        return
+
+    def tearDown(self):
+        try:
+            # Clean up, terminate the created accounts, domains etc
+            cleanup_resources(self.apiclient, self.cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+        if not isinstance(self.template, Template):
+            self.template = Template(self.template.__dict__)
+        Template.update(self.template, self.apiclient, templatetag="")
+        for host in self.hosts:
+            Host.update(self.apiclient, id=host.id, hosttags="")
+
+        return

Review comment:
       ```suggestion
       def tearDown(self):
           if not isinstance(self.template, Template):
               self.template = Template(self.template.__dict__)
           Template.update(self.template, self.apiclient, templatetag="")
           for host in self.hosts:
               Host.update(self.apiclient, id=host.id, hosttags="")
           super(TestHostTags, self).tearDown()
   ```
   
   I'm not sure about doing the super call after the host updating but if it throws an exception the hosts won't get updated.

##########
File path: test/integration/component/test_template_tags.py
##########
@@ -0,0 +1,437 @@
+# 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.
+""" tests for template/iso tags
+"""
+from nose.plugins.attrib import attr
+from marvin.cloudstackAPI import listZones, updateIso
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import cleanup_resources
+from marvin.lib.base import (Account,
+                             Iso,
+                             Template,
+                             Domain,
+                             Zone)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_isos)
+import logging
+import time
+
+class TestTemplateTags(cloudstackTestCase):
+    @classmethod
+    def setUpClass(cls):
+        cls.testClient = super(TestTemplateTags, cls).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+        cls.services = cls.testClient.getParsedTestDataConfig()
+
+        # Get Zone, Domain and templates
+        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.services['mode'] = cls.zone.networktype
+        cls.services["iso1"]["zoneid"] = cls.zone.id
+        cls.logger = logging.getLogger("TestTemplateTags")
+        cls.domain = get_domain(cls.apiclient)
+
+        cls._cleanup = []
+        cls.unsupportedHypervisor = False
+        cls.hypervisor = cls.testClient.getHypervisorInfo()
+        if cls.hypervisor.lower() in ['lxc']:
+            cls.unsupportedHypervisor = True
+            return
+
+        # 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
+        )
+
+        if cls.hypervisor.lower() in ['kvm', "simulator"]:
+            # register template
+            cls.template = Template.register(cls.apiclient,
+                                             cls.services["test_templates"]["kvm"],
+                                             zoneid=cls.zone.id,
+                                             domainid=cls.domain1.id,
+                                             account=cls.account1.name,
+                                             hypervisor=cls.hypervisor.lower())
+            cls.services["test_templates"]["kvm"]["name"] = cls.account1.name
+
+            cls.iso = Iso.create(
+                cls.apiclient,
+                cls.services["iso1"],
+                account=cls.account1.name,
+                domainid=cls.account1.domainid
+            )
+
+            cls._cleanup.append(cls.template)

Review comment:
       ```suggestion
   ```

##########
File path: test/integration/component/test_host_tags.py
##########
@@ -0,0 +1,232 @@
+# 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.
+""" tests for host tags (host, service offering, template)
+"""
+# Import Local Modules
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import cleanup_resources, validateList
+from marvin.lib.base import (Account,
+                             VirtualMachine,
+                             Iso,
+                             Host,
+                             Template,
+                             ServiceOffering,
+                             Domain)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_hosts)
+from marvin.codes import FAILED, PASS
+import time
+
+class TestHostTags(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.testClient = super(TestHostTags, cls).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+        cls.hypervisor = cls.testClient.getHypervisorInfo()
+        cls.services = cls.testClient.getParsedTestDataConfig()
+
+        # Get Zone, Domain and templates
+        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.domain = get_domain(cls.apiclient)
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+        )
+        cls.skip = False
+        if cls.template == FAILED:
+            cls.skip = True
+            return
+
+        cls.account = Account.create(
+            cls.apiclient,
+            cls.services["account"],
+            admin=True,
+        )
+
+        # Create service offerings, disk offerings etc
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offering"]
+        )

Review comment:
       ```suggestion
           cls.service_offering = ServiceOffering.create(
               cls.apiclient,
               cls.services["service_offering"]
           )
           cls._cleanup.append(cls.service_offering)
   ```

##########
File path: test/integration/component/test_host_tags.py
##########
@@ -0,0 +1,232 @@
+# 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.
+""" tests for host tags (host, service offering, template)
+"""
+# Import Local Modules
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import cleanup_resources, validateList
+from marvin.lib.base import (Account,
+                             VirtualMachine,
+                             Iso,
+                             Host,
+                             Template,
+                             ServiceOffering,
+                             Domain)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_hosts)
+from marvin.codes import FAILED, PASS
+import time
+
+class TestHostTags(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.testClient = super(TestHostTags, cls).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+        cls.hypervisor = cls.testClient.getHypervisorInfo()
+        cls.services = cls.testClient.getParsedTestDataConfig()
+
+        # Get Zone, Domain and templates
+        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.domain = get_domain(cls.apiclient)
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+        )
+        cls.skip = False
+        if cls.template == FAILED:
+            cls.skip = True
+            return
+
+        cls.account = Account.create(
+            cls.apiclient,
+            cls.services["account"],
+            admin=True,
+        )
+
+        # Create service offerings, disk offerings etc
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offering"]
+        )
+
+        cls.services["iso"]["zoneid"] = cls.zone.id
+        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+        cls.services["virtual_machine"]["template"] = cls.template.id
+
+        cls.hosts = list_hosts(
+            cls.apiclient,
+            zoneid=cls.zone.id,
+            type='Routing',
+            resourcestate='Enabled'
+        )
+        cls._cleanup = [
+            cls.account,
+            cls.service_offering
+        ]
+        return
+
+    @classmethod
+    def tearDownClass(cls):
+        try:
+            # Cleanup resources used
+            print("Cleanup resources used")
+            cleanup_resources(cls.apiclient, cls._cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return
+
+    def setUp(self):
+        if self.skip:
+            self.skipTest("skip test")
+        self.apiclient = self.testClient.getApiClient()
+        self.cleanup = []
+        return
+
+    def tearDown(self):
+        try:
+            # Clean up, terminate the created accounts, domains etc
+            cleanup_resources(self.apiclient, self.cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+        if not isinstance(self.template, Template):
+            self.template = Template(self.template.__dict__)
+        Template.update(self.template, self.apiclient, templatetag="")
+        for host in self.hosts:
+            Host.update(self.apiclient, id=host.id, hosttags="")
+
+        return
+
+    def set_host_tag(self, hostid, hosttag):
+        Host.update(self.apiclient, id=hostid, hosttags=hosttag)
+
+    def set_template_tag(self, tag):
+        if not isinstance(self.template, Template):
+            self.template = Template(self.template.__dict__)
+        Template.update(self.template, self.apiclient, templatetag=tag)
+
+    @attr(tags=["advanced", "advancedsg", "basic"], required_hardware="false")
+    def test_01_template_host_tag(cls):
+        """ Test template/host tag
+        """
+        # Validate the following
+        # 1. Update template tag to 'template'. Deploy vm, it should fail
+        # 2. Update all hosts tag to 'host'. Deploy vm, it should fail
+        # 3. Update template tag to NULL, Deploy vm, it should succeed. stop/start/migrate should work
+        # 4. Update template tag to 'host', stop/start/migrate should work
+        # 5. Update template tag to 'template'. start/migrate should fail
+        # 6. Update a host tag to 'template'. 
+        # 6.1 vm should be started on the host. migrate should fail
+        # 6.2 start vm on other hosts, it should fail
+
+        # 1. Update template tag to 'template'. Deploy vm, it should fail
+        cls.set_template_tag("template")
+        try:
+            cls.vm_1 = VirtualMachine.create(
+                cls.apiclient,
+                cls.services["virtual_machine"],
+                accountid=cls.account.name,
+                domainid=cls.account.domainid,
+                serviceofferingid=cls.service_offering.id,
+            )
+            cls.fail("Deploy vm_1 should fail")
+        except Exception as e:
+            cls.debug("Failed to deploy vm_1 as expected")
+
+        # 2. Update all hosts tag to 'host'. Deploy vm, it should fail
+        for host in cls.hosts:
+            cls.set_host_tag(host.id, "host")
+
+        try:
+            cls.vm_2 = VirtualMachine.create(
+                cls.apiclient,
+                cls.services["virtual_machine"],
+                accountid=cls.account.name,
+                domainid=cls.account.domainid,
+                serviceofferingid=cls.service_offering.id,
+            )

Review comment:
       ```suggestion
               cls.vm_2 = VirtualMachine.create(
                   cls.apiclient,
                   cls.services["virtual_machine"],
                   accountid=cls.account.name,
                   domainid=cls.account.domainid,
                   serviceofferingid=cls.service_offering.id,
               )
               cls.cleanup.append(cls.vm_2)
   ```

##########
File path: test/integration/component/test_host_tags.py
##########
@@ -0,0 +1,232 @@
+# 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.
+""" tests for host tags (host, service offering, template)
+"""
+# Import Local Modules
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import cleanup_resources, validateList
+from marvin.lib.base import (Account,
+                             VirtualMachine,
+                             Iso,
+                             Host,
+                             Template,
+                             ServiceOffering,
+                             Domain)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_hosts)
+from marvin.codes import FAILED, PASS
+import time
+
+class TestHostTags(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.testClient = super(TestHostTags, cls).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+        cls.hypervisor = cls.testClient.getHypervisorInfo()
+        cls.services = cls.testClient.getParsedTestDataConfig()
+
+        # Get Zone, Domain and templates
+        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.domain = get_domain(cls.apiclient)
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+        )
+        cls.skip = False
+        if cls.template == FAILED:
+            cls.skip = True
+            return
+
+        cls.account = Account.create(
+            cls.apiclient,
+            cls.services["account"],
+            admin=True,
+        )

Review comment:
       ```suggestion
           cls._cleanup = []
           cls.account = Account.create(
               cls.apiclient,
               cls.services["account"],
               admin=True,
           )
           cls._cleanup.append(cls.account)
   ```

##########
File path: test/integration/component/test_template_tags.py
##########
@@ -0,0 +1,437 @@
+# 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.
+""" tests for template/iso tags
+"""
+from nose.plugins.attrib import attr
+from marvin.cloudstackAPI import listZones, updateIso
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import cleanup_resources
+from marvin.lib.base import (Account,
+                             Iso,
+                             Template,
+                             Domain,
+                             Zone)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_isos)
+import logging
+import time
+
+class TestTemplateTags(cloudstackTestCase):
+    @classmethod
+    def setUpClass(cls):
+        cls.testClient = super(TestTemplateTags, cls).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+        cls.services = cls.testClient.getParsedTestDataConfig()
+
+        # Get Zone, Domain and templates
+        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.services['mode'] = cls.zone.networktype
+        cls.services["iso1"]["zoneid"] = cls.zone.id
+        cls.logger = logging.getLogger("TestTemplateTags")
+        cls.domain = get_domain(cls.apiclient)
+
+        cls._cleanup = []
+        cls.unsupportedHypervisor = False
+        cls.hypervisor = cls.testClient.getHypervisorInfo()
+        if cls.hypervisor.lower() in ['lxc']:
+            cls.unsupportedHypervisor = True
+            return
+
+        # 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:
       ```suggestion
           cls.domain1 = Domain.create(
               cls.apiclient,
               services=cls.services["acl"]["domain1"],
               parentdomainid=cls.domain.id)
           cls._cleanup.append(cls.domain1)
   
           cls.account1 = Account.create(
               cls.apiclient,
               cls.services["acl"]["accountD1"],
               domainid=cls.domain1.id
           )
           cls._cleanup.append(cls.account1)
   ```

##########
File path: test/integration/component/test_template_tags.py
##########
@@ -0,0 +1,437 @@
+# 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.
+""" tests for template/iso tags
+"""
+from nose.plugins.attrib import attr
+from marvin.cloudstackAPI import listZones, updateIso
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import cleanup_resources
+from marvin.lib.base import (Account,
+                             Iso,
+                             Template,
+                             Domain,
+                             Zone)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_isos)
+import logging
+import time
+
+class TestTemplateTags(cloudstackTestCase):
+    @classmethod
+    def setUpClass(cls):
+        cls.testClient = super(TestTemplateTags, cls).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+        cls.services = cls.testClient.getParsedTestDataConfig()
+
+        # Get Zone, Domain and templates
+        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.services['mode'] = cls.zone.networktype
+        cls.services["iso1"]["zoneid"] = cls.zone.id
+        cls.logger = logging.getLogger("TestTemplateTags")
+        cls.domain = get_domain(cls.apiclient)
+
+        cls._cleanup = []
+        cls.unsupportedHypervisor = False
+        cls.hypervisor = cls.testClient.getHypervisorInfo()
+        if cls.hypervisor.lower() in ['lxc']:
+            cls.unsupportedHypervisor = True
+            return
+
+        # 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
+        )
+
+        if cls.hypervisor.lower() in ['kvm', "simulator"]:
+            # register template
+            cls.template = Template.register(cls.apiclient,
+                                             cls.services["test_templates"]["kvm"],
+                                             zoneid=cls.zone.id,
+                                             domainid=cls.domain1.id,
+                                             account=cls.account1.name,
+                                             hypervisor=cls.hypervisor.lower())
+            cls.services["test_templates"]["kvm"]["name"] = cls.account1.name
+
+            cls.iso = Iso.create(
+                cls.apiclient,
+                cls.services["iso1"],
+                account=cls.account1.name,
+                domainid=cls.account1.domainid
+            )
+
+            cls._cleanup.append(cls.template)
+            cls._cleanup.append(cls.iso)
+        else:
+            return
+
+        cls._cleanup.append(cls.account1)
+        cls._cleanup.append(cls.domain1)

Review comment:
       ```suggestion
   ```

##########
File path: test/integration/component/test_template_tags.py
##########
@@ -0,0 +1,437 @@
+# 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.
+""" tests for template/iso tags
+"""
+from nose.plugins.attrib import attr
+from marvin.cloudstackAPI import listZones, updateIso
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import cleanup_resources
+from marvin.lib.base import (Account,
+                             Iso,
+                             Template,
+                             Domain,
+                             Zone)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_isos)
+import logging
+import time
+
+class TestTemplateTags(cloudstackTestCase):
+    @classmethod
+    def setUpClass(cls):
+        cls.testClient = super(TestTemplateTags, cls).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+        cls.services = cls.testClient.getParsedTestDataConfig()
+
+        # Get Zone, Domain and templates
+        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.services['mode'] = cls.zone.networktype
+        cls.services["iso1"]["zoneid"] = cls.zone.id
+        cls.logger = logging.getLogger("TestTemplateTags")
+        cls.domain = get_domain(cls.apiclient)
+
+        cls._cleanup = []
+        cls.unsupportedHypervisor = False
+        cls.hypervisor = cls.testClient.getHypervisorInfo()
+        if cls.hypervisor.lower() in ['lxc']:
+            cls.unsupportedHypervisor = True
+            return
+
+        # 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
+        )
+
+        if cls.hypervisor.lower() in ['kvm', "simulator"]:
+            # register template
+            cls.template = Template.register(cls.apiclient,
+                                             cls.services["test_templates"]["kvm"],
+                                             zoneid=cls.zone.id,
+                                             domainid=cls.domain1.id,
+                                             account=cls.account1.name,
+                                             hypervisor=cls.hypervisor.lower())

Review comment:
       ```suggestion
               cls.template = Template.register(cls.apiclient,
                                                cls.services["test_templates"]["kvm"],
                                                zoneid=cls.zone.id,
                                                domainid=cls.domain1.id,
                                                account=cls.account1.name,
                                                hypervisor=cls.hypervisor.lower())
               cls._cleanup.append(cls.template)
   ```

##########
File path: test/integration/component/test_template_tags.py
##########
@@ -0,0 +1,437 @@
+# 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.
+""" tests for template/iso tags
+"""
+from nose.plugins.attrib import attr
+from marvin.cloudstackAPI import listZones, updateIso
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import cleanup_resources
+from marvin.lib.base import (Account,
+                             Iso,
+                             Template,
+                             Domain,
+                             Zone)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_isos)
+import logging
+import time
+
+class TestTemplateTags(cloudstackTestCase):
+    @classmethod
+    def setUpClass(cls):
+        cls.testClient = super(TestTemplateTags, cls).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+        cls.services = cls.testClient.getParsedTestDataConfig()
+
+        # Get Zone, Domain and templates
+        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.services['mode'] = cls.zone.networktype
+        cls.services["iso1"]["zoneid"] = cls.zone.id
+        cls.logger = logging.getLogger("TestTemplateTags")
+        cls.domain = get_domain(cls.apiclient)
+
+        cls._cleanup = []
+        cls.unsupportedHypervisor = False
+        cls.hypervisor = cls.testClient.getHypervisorInfo()
+        if cls.hypervisor.lower() in ['lxc']:
+            cls.unsupportedHypervisor = True
+            return
+
+        # 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
+        )
+
+        if cls.hypervisor.lower() in ['kvm', "simulator"]:
+            # register template
+            cls.template = Template.register(cls.apiclient,
+                                             cls.services["test_templates"]["kvm"],
+                                             zoneid=cls.zone.id,
+                                             domainid=cls.domain1.id,
+                                             account=cls.account1.name,
+                                             hypervisor=cls.hypervisor.lower())
+            cls.services["test_templates"]["kvm"]["name"] = cls.account1.name
+
+            cls.iso = Iso.create(
+                cls.apiclient,
+                cls.services["iso1"],
+                account=cls.account1.name,
+                domainid=cls.account1.domainid
+            )
+
+            cls._cleanup.append(cls.template)
+            cls._cleanup.append(cls.iso)
+        else:
+            return
+
+        cls._cleanup.append(cls.account1)
+        cls._cleanup.append(cls.domain1)
+
+    @classmethod
+    def tearDownClass(cls):
+        try:
+            cls.apiclient = super(
+                TestTemplateTags,
+                cls).getClsTestClient().getApiClient()
+            # Cleanup resources used
+            cleanup_resources(cls.apiclient, cls._cleanup)
+
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+        return
+
+    def validate_uploaded_template(self, apiclient, template_id, retries=24, interval=5):
+        """Check if template download will finish in 2 minutes"""
+        while retries > -1:
+            time.sleep(interval)
+            template_response = Template.list(
+                apiclient,
+                id=template_id,
+                zoneid=self.zone.id,
+                templatefilter='self'
+            )
+
+            if isinstance(template_response, list):
+                template = template_response[0]
+                if not hasattr(template, 'status') or not template or not template.status:
+                    retries = retries - 1
+                    continue
+                if 'Failed' in template.status:
+                    raise Exception(
+                        "Failed to download template: status - %s" %
+                        template.status)
+
+                elif template.status == 'Download Complete' and template.isready:
+                    return
+
+                elif 'Downloaded' in template.status:
+                    retries = retries - 1
+                    continue
+
+                elif 'Installing' not in template.status:
+                    if retries >= 0:
+                        retries = retries - 1
+                        continue
+                    raise Exception(
+                        "Error in downloading template: status - %s" %
+                        template.status)
+
+            else:
+                retries = retries - 1
+        raise Exception("Template download failed exception.")
+
+    def verify_upload_iso(self, iso):
+        try:
+            iso.download(self.apiclient)
+        except Exception as e:
+            self.fail("Exception while downloading ISO %s: %s" \
+                      % (iso.id, e))
+
+    def list_templates(self, tag):
+        return Template.list(
+            self.apiclient,
+            templatefilter='all',
+            zoneid=self.zone.id,
+            domainid=self.domain1.id,
+            account=self.account1.name,
+            templatetag=tag
+        )
+
+    def list_isos(self, tag):
+        return list_isos(
+            self.apiclient,
+            account=self.account1.name,
+            domainid=self.account1.domainid,
+            templatetag=tag
+        )
+
+    def update_iso(self, isoid, tag):
+        cmd = updateIso.updateIsoCmd()
+        # Assign new values to attributes
+        cmd.id = isoid
+        cmd.templatetag = tag
+        self.apiclient.updateIso(cmd)
+
+    @attr(tags=["advanced", "basic", "sg"], required_hardware="false")
+    def test_01_update_template_tags(self):
+        """
+        Verify that the template and iso can be updated with new template tags
+        and listing the templates/iso with tags should return the result
+
+        Steps:
+        1. Update the template tag of uploaded template as "TEST_TEMPLATE"
+        2. List all the templates matching the tag "TEST_TEMPLATE"
+        3. Make sure that the count is 1
+        4. Update the iso tag of uploaded iso as "TEST_ISO"
+        5. List all the isos matching the tag "TEST_ISO"
+        6. Make sure that the count is 1
+        7. Now list the template and iso with tag "dummy"
+        8. Make sure that the count is 0
+        :return:
+        """
+        template_tag = "TEST_TEMPLATE"
+        iso_tag = "TEST_ISO"
+
+        self.validate_uploaded_template(self.apiclient, self.template.id)
+
+        list_template_response = self.list_templates(None)
+
+        # Verify template response to check whether template added successfully
+        self.assertEqual(
+            isinstance(list_template_response, list),
+            True,
+            "No templates found"
+        )
+
+        template_response = list_template_response[0]
+        self.assertEqual(
+            template_response.isready,
+            True,
+            "Template state is not ready, it is %s" % template_response.isready
+        )
+
+        # step 1
+        self.template.update(self.apiclient,
+                             templatetag = template_tag)
+
+        # Step 2
+        list_template_response = self.list_templates(template_tag)
+
+        # Step 3
+        self.assertEqual(
+            len(list_template_response),
+            1,
+            "Template tag not updated properly to %s" % template_tag
+        )
+
+        self.verify_upload_iso(self.iso)
+        list_iso_response = self.list_isos(None)
+        self.assertEqual(
+            isinstance(list_iso_response, list),
+            True,
+            "No iso found"
+        )
+
+        # Step 4
+        self.update_iso(self.iso.id, iso_tag)
+
+        # Step 5
+        list_iso_response = self.list_isos(iso_tag)
+
+        # Step 6
+        self.assertEqual(
+            isinstance(list_iso_response, list),
+            True,
+            "Iso tag is not updated properly to %s" % iso_tag
+        )
+        self.assertEqual(
+            len(list_iso_response),
+            1,
+            "Check template available in List ISOs"
+        )
+
+        # Step 7
+        list_template_response = self.list_templates("dummy")
+        self.assertEqual(
+            list_template_response,
+            None,
+            "Template tag should not be updated to dummy"
+        )
+
+        list_iso_response = self.list_isos("dummy")
+
+        # Step 8
+        self.assertEqual(
+            list_iso_response,
+            None,
+            "ISO tag should not be updated to dummy"
+        )
+
+    @attr(tags=["advanced", "basic", "sg"], required_hardware="false")
+    def test_02_register_template_with_tags(self):
+        """
+        Register template and iso with new template tags
+        Verify that it can be registered with tags
+        Listing the templates/iso with tags should return the result
+
+        Steps:
+        1. Register the template with tag "REGISTER_TEMPLATE"
+        2. Register the iso tag of uploaded iso as "REGISTER_ISO"
+        3. List all the templates matching the tag "REGISTER_TEMPLATE"
+        4. Make sure that the count is 1
+        5. List all the isos matching the tag "REGISTER_ISO"
+        6. Make sure that the count is 1
+        7. Update the template tag to "dummy"
+        8. List the templates matching tag "dummy"
+        9. Make sure that the count is 1
+        10. List the iso matching tag "dummy"
+        11. Make sure that the count is 1
+        12. List all the templates matching the tag "REGISTER_TEMPLATE"
+        13. Make sure that the count is 0
+        14. List all the isos matching the tag "REGISTER_ISO"
+        15. Make sure that the count is 0
+        :return:
+        """
+        template_tag = "REGISTER_TEMPLATE"
+        iso_tag = "REGISTER_ISO"
+
+        # Step 1
+        self.services["test_templates"]["kvm"]["templatetag"] = template_tag
+        template1 = Template.register(self.apiclient,
+                                      self.services["test_templates"]["kvm"],
+                                      zoneid=self.zone.id,
+                                      domainid=self.domain1.id,
+                                      account=self.account1.name,
+                                      hypervisor=self.hypervisor.lower()
+                                      )

Review comment:
       I see no instance level `setup()` and `tearDown()`, so this template will never be cleaned ip.

##########
File path: test/integration/component/test_host_tags.py
##########
@@ -0,0 +1,232 @@
+# 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.
+""" tests for host tags (host, service offering, template)
+"""
+# Import Local Modules
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import cleanup_resources, validateList
+from marvin.lib.base import (Account,
+                             VirtualMachine,
+                             Iso,
+                             Host,
+                             Template,
+                             ServiceOffering,
+                             Domain)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_hosts)
+from marvin.codes import FAILED, PASS
+import time
+
+class TestHostTags(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.testClient = super(TestHostTags, cls).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+        cls.hypervisor = cls.testClient.getHypervisorInfo()
+        cls.services = cls.testClient.getParsedTestDataConfig()
+
+        # Get Zone, Domain and templates
+        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.domain = get_domain(cls.apiclient)
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+        )
+        cls.skip = False
+        if cls.template == FAILED:
+            cls.skip = True
+            return
+
+        cls.account = Account.create(
+            cls.apiclient,
+            cls.services["account"],
+            admin=True,
+        )
+
+        # Create service offerings, disk offerings etc
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offering"]
+        )
+
+        cls.services["iso"]["zoneid"] = cls.zone.id
+        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+        cls.services["virtual_machine"]["template"] = cls.template.id
+
+        cls.hosts = list_hosts(
+            cls.apiclient,
+            zoneid=cls.zone.id,
+            type='Routing',
+            resourcestate='Enabled'
+        )
+        cls._cleanup = [
+            cls.account,
+            cls.service_offering
+        ]
+        return
+
+    @classmethod
+    def tearDownClass(cls):
+        try:
+            # Cleanup resources used
+            print("Cleanup resources used")
+            cleanup_resources(cls.apiclient, cls._cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return
+
+    def setUp(self):
+        if self.skip:
+            self.skipTest("skip test")
+        self.apiclient = self.testClient.getApiClient()
+        self.cleanup = []
+        return
+
+    def tearDown(self):
+        try:
+            # Clean up, terminate the created accounts, domains etc
+            cleanup_resources(self.apiclient, self.cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+        if not isinstance(self.template, Template):
+            self.template = Template(self.template.__dict__)
+        Template.update(self.template, self.apiclient, templatetag="")
+        for host in self.hosts:
+            Host.update(self.apiclient, id=host.id, hosttags="")
+
+        return
+
+    def set_host_tag(self, hostid, hosttag):
+        Host.update(self.apiclient, id=hostid, hosttags=hosttag)
+
+    def set_template_tag(self, tag):
+        if not isinstance(self.template, Template):
+            self.template = Template(self.template.__dict__)
+        Template.update(self.template, self.apiclient, templatetag=tag)
+
+    @attr(tags=["advanced", "advancedsg", "basic"], required_hardware="false")
+    def test_01_template_host_tag(cls):
+        """ Test template/host tag
+        """
+        # Validate the following
+        # 1. Update template tag to 'template'. Deploy vm, it should fail
+        # 2. Update all hosts tag to 'host'. Deploy vm, it should fail
+        # 3. Update template tag to NULL, Deploy vm, it should succeed. stop/start/migrate should work
+        # 4. Update template tag to 'host', stop/start/migrate should work
+        # 5. Update template tag to 'template'. start/migrate should fail
+        # 6. Update a host tag to 'template'. 
+        # 6.1 vm should be started on the host. migrate should fail
+        # 6.2 start vm on other hosts, it should fail
+
+        # 1. Update template tag to 'template'. Deploy vm, it should fail
+        cls.set_template_tag("template")
+        try:
+            cls.vm_1 = VirtualMachine.create(
+                cls.apiclient,
+                cls.services["virtual_machine"],
+                accountid=cls.account.name,
+                domainid=cls.account.domainid,
+                serviceofferingid=cls.service_offering.id,
+            )
+            cls.fail("Deploy vm_1 should fail")
+        except Exception as e:
+            cls.debug("Failed to deploy vm_1 as expected")
+
+        # 2. Update all hosts tag to 'host'. Deploy vm, it should fail
+        for host in cls.hosts:
+            cls.set_host_tag(host.id, "host")
+
+        try:
+            cls.vm_2 = VirtualMachine.create(
+                cls.apiclient,
+                cls.services["virtual_machine"],
+                accountid=cls.account.name,
+                domainid=cls.account.domainid,
+                serviceofferingid=cls.service_offering.id,
+            )
+            cls.fail("Deploy vm_2 should fail")
+        except Exception as e:
+            cls.debug("Failed to deploy vm_2 as expected")
+
+        # 3. Update template tag to NULL, Deploy vm, it should succeed. stop/start/migrate should work
+        cls.set_template_tag("")
+        cls.vm_3 = VirtualMachine.create(
+            cls.apiclient,
+            cls.services["virtual_machine"],
+            accountid=cls.account.name,
+            domainid=cls.account.domainid,
+            serviceofferingid=cls.service_offering.id,
+        )

Review comment:
       ```suggestion
           cls.vm_3 = VirtualMachine.create(
               cls.apiclient,
               cls.services["virtual_machine"],
               accountid=cls.account.name,
               domainid=cls.account.domainid,
               serviceofferingid=cls.service_offering.id,
           )
           cls.cleanup.append(cls.vm_3)
   ```

##########
File path: test/integration/component/test_host_tags.py
##########
@@ -0,0 +1,232 @@
+# 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.
+""" tests for host tags (host, service offering, template)
+"""
+# Import Local Modules
+from nose.plugins.attrib import attr
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import cleanup_resources, validateList
+from marvin.lib.base import (Account,
+                             VirtualMachine,
+                             Iso,
+                             Host,
+                             Template,
+                             ServiceOffering,
+                             Domain)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_hosts)
+from marvin.codes import FAILED, PASS
+import time
+
+class TestHostTags(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.testClient = super(TestHostTags, cls).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+        cls.hypervisor = cls.testClient.getHypervisorInfo()
+        cls.services = cls.testClient.getParsedTestDataConfig()
+
+        # Get Zone, Domain and templates
+        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.domain = get_domain(cls.apiclient)
+        cls.template = get_template(
+            cls.apiclient,
+            cls.zone.id,
+        )
+        cls.skip = False
+        if cls.template == FAILED:
+            cls.skip = True
+            return
+
+        cls.account = Account.create(
+            cls.apiclient,
+            cls.services["account"],
+            admin=True,
+        )
+
+        # Create service offerings, disk offerings etc
+        cls.service_offering = ServiceOffering.create(
+            cls.apiclient,
+            cls.services["service_offering"]
+        )
+
+        cls.services["iso"]["zoneid"] = cls.zone.id
+        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+        cls.services["virtual_machine"]["template"] = cls.template.id
+
+        cls.hosts = list_hosts(
+            cls.apiclient,
+            zoneid=cls.zone.id,
+            type='Routing',
+            resourcestate='Enabled'
+        )
+        cls._cleanup = [
+            cls.account,
+            cls.service_offering
+        ]
+        return
+
+    @classmethod
+    def tearDownClass(cls):
+        try:
+            # Cleanup resources used
+            print("Cleanup resources used")
+            cleanup_resources(cls.apiclient, cls._cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return
+
+    def setUp(self):
+        if self.skip:
+            self.skipTest("skip test")
+        self.apiclient = self.testClient.getApiClient()
+        self.cleanup = []
+        return
+
+    def tearDown(self):
+        try:
+            # Clean up, terminate the created accounts, domains etc
+            cleanup_resources(self.apiclient, self.cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+        if not isinstance(self.template, Template):
+            self.template = Template(self.template.__dict__)
+        Template.update(self.template, self.apiclient, templatetag="")
+        for host in self.hosts:
+            Host.update(self.apiclient, id=host.id, hosttags="")
+
+        return
+
+    def set_host_tag(self, hostid, hosttag):
+        Host.update(self.apiclient, id=hostid, hosttags=hosttag)
+
+    def set_template_tag(self, tag):
+        if not isinstance(self.template, Template):
+            self.template = Template(self.template.__dict__)
+        Template.update(self.template, self.apiclient, templatetag=tag)
+
+    @attr(tags=["advanced", "advancedsg", "basic"], required_hardware="false")
+    def test_01_template_host_tag(cls):
+        """ Test template/host tag
+        """
+        # Validate the following
+        # 1. Update template tag to 'template'. Deploy vm, it should fail
+        # 2. Update all hosts tag to 'host'. Deploy vm, it should fail
+        # 3. Update template tag to NULL, Deploy vm, it should succeed. stop/start/migrate should work
+        # 4. Update template tag to 'host', stop/start/migrate should work
+        # 5. Update template tag to 'template'. start/migrate should fail
+        # 6. Update a host tag to 'template'. 
+        # 6.1 vm should be started on the host. migrate should fail
+        # 6.2 start vm on other hosts, it should fail
+
+        # 1. Update template tag to 'template'. Deploy vm, it should fail
+        cls.set_template_tag("template")
+        try:
+            cls.vm_1 = VirtualMachine.create(
+                cls.apiclient,
+                cls.services["virtual_machine"],
+                accountid=cls.account.name,
+                domainid=cls.account.domainid,
+                serviceofferingid=cls.service_offering.id,
+            )

Review comment:
       ```suggestion
               cls.vm_1 = VirtualMachine.create(
                   cls.apiclient,
                   cls.services["virtual_machine"],
                   accountid=cls.account.name,
                   domainid=cls.account.domainid,
                   serviceofferingid=cls.service_offering.id,
               )
               cls.cleanup.append(cls.vm_1)
   ```

##########
File path: test/integration/component/test_template_tags.py
##########
@@ -0,0 +1,437 @@
+# 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.
+""" tests for template/iso tags
+"""
+from nose.plugins.attrib import attr
+from marvin.cloudstackAPI import listZones, updateIso
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import cleanup_resources
+from marvin.lib.base import (Account,
+                             Iso,
+                             Template,
+                             Domain,
+                             Zone)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_isos)
+import logging
+import time
+
+class TestTemplateTags(cloudstackTestCase):
+    @classmethod
+    def setUpClass(cls):
+        cls.testClient = super(TestTemplateTags, cls).getClsTestClient()
+        cls.apiclient = cls.testClient.getApiClient()
+        cls.services = cls.testClient.getParsedTestDataConfig()
+
+        # Get Zone, Domain and templates
+        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+        cls.services['mode'] = cls.zone.networktype
+        cls.services["iso1"]["zoneid"] = cls.zone.id
+        cls.logger = logging.getLogger("TestTemplateTags")
+        cls.domain = get_domain(cls.apiclient)
+
+        cls._cleanup = []
+        cls.unsupportedHypervisor = False
+        cls.hypervisor = cls.testClient.getHypervisorInfo()
+        if cls.hypervisor.lower() in ['lxc']:
+            cls.unsupportedHypervisor = True
+            return
+
+        # 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
+        )
+
+        if cls.hypervisor.lower() in ['kvm', "simulator"]:
+            # register template
+            cls.template = Template.register(cls.apiclient,
+                                             cls.services["test_templates"]["kvm"],
+                                             zoneid=cls.zone.id,
+                                             domainid=cls.domain1.id,
+                                             account=cls.account1.name,
+                                             hypervisor=cls.hypervisor.lower())
+            cls.services["test_templates"]["kvm"]["name"] = cls.account1.name
+
+            cls.iso = Iso.create(
+                cls.apiclient,
+                cls.services["iso1"],
+                account=cls.account1.name,
+                domainid=cls.account1.domainid
+            )
+
+            cls._cleanup.append(cls.template)
+            cls._cleanup.append(cls.iso)
+        else:
+            return
+
+        cls._cleanup.append(cls.account1)
+        cls._cleanup.append(cls.domain1)
+
+    @classmethod
+    def tearDownClass(cls):
+        try:
+            cls.apiclient = super(
+                TestTemplateTags,
+                cls).getClsTestClient().getApiClient()
+            # Cleanup resources used
+            cleanup_resources(cls.apiclient, cls._cleanup)
+
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+        return
+
+    def validate_uploaded_template(self, apiclient, template_id, retries=24, interval=5):
+        """Check if template download will finish in 2 minutes"""
+        while retries > -1:
+            time.sleep(interval)
+            template_response = Template.list(
+                apiclient,
+                id=template_id,
+                zoneid=self.zone.id,
+                templatefilter='self'
+            )
+
+            if isinstance(template_response, list):
+                template = template_response[0]
+                if not hasattr(template, 'status') or not template or not template.status:
+                    retries = retries - 1
+                    continue
+                if 'Failed' in template.status:
+                    raise Exception(
+                        "Failed to download template: status - %s" %
+                        template.status)
+
+                elif template.status == 'Download Complete' and template.isready:
+                    return
+
+                elif 'Downloaded' in template.status:
+                    retries = retries - 1
+                    continue
+
+                elif 'Installing' not in template.status:
+                    if retries >= 0:
+                        retries = retries - 1
+                        continue
+                    raise Exception(
+                        "Error in downloading template: status - %s" %
+                        template.status)
+
+            else:
+                retries = retries - 1
+        raise Exception("Template download failed exception.")
+
+    def verify_upload_iso(self, iso):
+        try:
+            iso.download(self.apiclient)
+        except Exception as e:
+            self.fail("Exception while downloading ISO %s: %s" \
+                      % (iso.id, e))
+
+    def list_templates(self, tag):
+        return Template.list(
+            self.apiclient,
+            templatefilter='all',
+            zoneid=self.zone.id,
+            domainid=self.domain1.id,
+            account=self.account1.name,
+            templatetag=tag
+        )
+
+    def list_isos(self, tag):
+        return list_isos(
+            self.apiclient,
+            account=self.account1.name,
+            domainid=self.account1.domainid,
+            templatetag=tag
+        )
+
+    def update_iso(self, isoid, tag):
+        cmd = updateIso.updateIsoCmd()
+        # Assign new values to attributes
+        cmd.id = isoid
+        cmd.templatetag = tag
+        self.apiclient.updateIso(cmd)
+
+    @attr(tags=["advanced", "basic", "sg"], required_hardware="false")
+    def test_01_update_template_tags(self):
+        """
+        Verify that the template and iso can be updated with new template tags
+        and listing the templates/iso with tags should return the result
+
+        Steps:
+        1. Update the template tag of uploaded template as "TEST_TEMPLATE"
+        2. List all the templates matching the tag "TEST_TEMPLATE"
+        3. Make sure that the count is 1
+        4. Update the iso tag of uploaded iso as "TEST_ISO"
+        5. List all the isos matching the tag "TEST_ISO"
+        6. Make sure that the count is 1
+        7. Now list the template and iso with tag "dummy"
+        8. Make sure that the count is 0
+        :return:
+        """
+        template_tag = "TEST_TEMPLATE"
+        iso_tag = "TEST_ISO"
+
+        self.validate_uploaded_template(self.apiclient, self.template.id)
+
+        list_template_response = self.list_templates(None)
+
+        # Verify template response to check whether template added successfully
+        self.assertEqual(
+            isinstance(list_template_response, list),
+            True,
+            "No templates found"
+        )
+
+        template_response = list_template_response[0]
+        self.assertEqual(
+            template_response.isready,
+            True,
+            "Template state is not ready, it is %s" % template_response.isready
+        )
+
+        # step 1
+        self.template.update(self.apiclient,
+                             templatetag = template_tag)
+
+        # Step 2
+        list_template_response = self.list_templates(template_tag)
+
+        # Step 3
+        self.assertEqual(
+            len(list_template_response),
+            1,
+            "Template tag not updated properly to %s" % template_tag
+        )
+
+        self.verify_upload_iso(self.iso)
+        list_iso_response = self.list_isos(None)
+        self.assertEqual(
+            isinstance(list_iso_response, list),
+            True,
+            "No iso found"
+        )
+
+        # Step 4
+        self.update_iso(self.iso.id, iso_tag)
+
+        # Step 5
+        list_iso_response = self.list_isos(iso_tag)
+
+        # Step 6
+        self.assertEqual(
+            isinstance(list_iso_response, list),
+            True,
+            "Iso tag is not updated properly to %s" % iso_tag
+        )
+        self.assertEqual(
+            len(list_iso_response),
+            1,
+            "Check template available in List ISOs"
+        )
+
+        # Step 7
+        list_template_response = self.list_templates("dummy")
+        self.assertEqual(
+            list_template_response,
+            None,
+            "Template tag should not be updated to dummy"
+        )
+
+        list_iso_response = self.list_isos("dummy")
+
+        # Step 8
+        self.assertEqual(
+            list_iso_response,
+            None,
+            "ISO tag should not be updated to dummy"
+        )
+
+    @attr(tags=["advanced", "basic", "sg"], required_hardware="false")
+    def test_02_register_template_with_tags(self):
+        """
+        Register template and iso with new template tags
+        Verify that it can be registered with tags
+        Listing the templates/iso with tags should return the result
+
+        Steps:
+        1. Register the template with tag "REGISTER_TEMPLATE"
+        2. Register the iso tag of uploaded iso as "REGISTER_ISO"
+        3. List all the templates matching the tag "REGISTER_TEMPLATE"
+        4. Make sure that the count is 1
+        5. List all the isos matching the tag "REGISTER_ISO"
+        6. Make sure that the count is 1
+        7. Update the template tag to "dummy"
+        8. List the templates matching tag "dummy"
+        9. Make sure that the count is 1
+        10. List the iso matching tag "dummy"
+        11. Make sure that the count is 1
+        12. List all the templates matching the tag "REGISTER_TEMPLATE"
+        13. Make sure that the count is 0
+        14. List all the isos matching the tag "REGISTER_ISO"
+        15. Make sure that the count is 0
+        :return:
+        """
+        template_tag = "REGISTER_TEMPLATE"
+        iso_tag = "REGISTER_ISO"
+
+        # Step 1
+        self.services["test_templates"]["kvm"]["templatetag"] = template_tag
+        template1 = Template.register(self.apiclient,
+                                      self.services["test_templates"]["kvm"],
+                                      zoneid=self.zone.id,
+                                      domainid=self.domain1.id,
+                                      account=self.account1.name,
+                                      hypervisor=self.hypervisor.lower()
+                                      )
+        self.services["test_templates"]["kvm"]["name"] = self.account1.name
+
+        # Step 2
+        self.services["iso1"]["templatetag"] = iso_tag
+        iso1 = Iso.create(self.apiclient,
+                          self.services["iso1"],
+                          zoneid=self.zone.id,
+                          account=self.account1.name,
+                          domainid=self.account1.domainid
+                         )

Review comment:
       neither will this ISO




-- 
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 #4362: Match template tags with host tag for vm deployment

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


   @nvazquez 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] nvazquez commented on a change in pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
nvazquez commented on a change in pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#discussion_r709732271



##########
File path: server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
##########
@@ -3672,6 +3676,10 @@ else if (!template.isPublicTemplate() && caller.getType() != Account.ACCOUNT_TYP
             sc.addAnd("dataCenterId", SearchCriteria.Op.SC, zoneSc);
         }
 
+        if (templateTag != null && !templateTag.equalsIgnoreCase("")) {

Review comment:
       @DaanHoogland can you explain why? As far as I see it is being passed as a parameter on `templateChecks()`




-- 
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] sureshanaparti commented on pull request #4362: Match template tags with host tag for vm deployment

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on pull request #4362:
URL: https://github.com/apache/cloudstack/pull/4362#issuecomment-919733634


   ping @ravening, can you fix 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