CLOUDSTACK-7996: Fixed the script test_tags.py - Tags and Template should belong to the User Account to test the case

(cherry picked from commit b0d74ad6fc68fd7022ec6cf378736430f0908a75)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Chandan Purushothama 2014-12-01 14:33:29 -08:00 committed by Rohit Yadav
parent 535c037428
commit 1b7a100688

View File

@ -212,6 +212,12 @@ class TestResourceTags(cloudstackTestCase):
cls.services["account"], cls.services["account"],
admin=True, admin=True,
) )
cls.user_api_client = cls.testClient.getUserApiClient(
UserName=cls.account.name,
DomainName=cls.account.domain
)
# Create service offerings, disk offerings etc # Create service offerings, disk offerings etc
cls.service_offering = ServiceOffering.create( cls.service_offering = ServiceOffering.create(
cls.api_client, cls.api_client,
@ -943,14 +949,14 @@ class TestResourceTags(cloudstackTestCase):
try: try:
self.debug("Stopping the virtual machine: %s" % self.vm_1.name) self.debug("Stopping the virtual machine: %s" % self.vm_1.name)
#Stop virtual machine #Stop virtual machine
self.vm_1.stop(self.apiclient) self.vm_1.stop(self.user_api_client)
except Exception as e: except Exception as e:
self.fail("Failed to stop VM: %s" % e) self.fail("Failed to stop VM: %s" % e)
timeout = self.services["timeout"] timeout = self.services["timeout"]
while True: while True:
list_volume = Volume.list( list_volume = Volume.list(
self.apiclient, self.user_api_client,
virtualmachineid=self.vm_1.id, virtualmachineid=self.vm_1.id,
type='ROOT', type='ROOT',
listall=True listall=True
@ -969,18 +975,18 @@ class TestResourceTags(cloudstackTestCase):
self.vm_1.name) self.vm_1.name)
#Create template from volume #Create template from volume
template = Template.create( template = Template.create(
self.apiclient, self.user_api_client,
self.services["template"], self.services["template"],
self.volume.id self.volume.id
) )
self.cleanup.append(template) self.cleanup.append(template)
self.debug("Created the template(%s). Now restarting the userVm: %s" % self.debug("Created the template(%s). Now restarting the userVm: %s" %
(template.name, self.vm_1.name)) (template.name, self.vm_1.name))
self.vm_1.start(self.apiclient) self.vm_1.start(self.user_api_client)
self.debug("Creating a tag for the template") self.debug("Creating a tag for the template")
tag = Tag.create( tag = Tag.create(
self.apiclient, self.user_api_client,
resourceIds=template.id, resourceIds=template.id,
resourceType='Template', resourceType='Template',
tags={'OS': 'CentOS'} tags={'OS': 'CentOS'}
@ -988,11 +994,9 @@ class TestResourceTags(cloudstackTestCase):
self.debug("Tag created: %s" % tag.__dict__) self.debug("Tag created: %s" % tag.__dict__)
tags = Tag.list( tags = Tag.list(
self.apiclient, self.user_api_client,
listall=True, listall=True,
resourceType='Template', resourceType='Template',
account=self.account.name,
domainid=self.account.domainid,
key='OS', key='OS',
value='CentOS' value='CentOS'
) )
@ -1008,7 +1012,7 @@ class TestResourceTags(cloudstackTestCase):
) )
Template.list( Template.list(
self.apiclient, self.user_api_client,
templatefilter=\ templatefilter=\
self.services["template"]["templatefilter"], self.services["template"]["templatefilter"],
listall=True, listall=True,
@ -1019,7 +1023,7 @@ class TestResourceTags(cloudstackTestCase):
self.debug("Deleting the created tag..") self.debug("Deleting the created tag..")
try: try:
tag.delete( tag.delete(
self.apiclient, self.user_api_client,
resourceIds=template.id, resourceIds=template.id,
resourceType='Template', resourceType='Template',
tags={'OS': 'CentOS'} tags={'OS': 'CentOS'}
@ -1029,11 +1033,9 @@ class TestResourceTags(cloudstackTestCase):
self.debug("Verifying if tag is actually deleted!") self.debug("Verifying if tag is actually deleted!")
tags = Tag.list( tags = Tag.list(
self.apiclient, self.user_api_client,
listall=True, listall=True,
resourceType='Template', resourceType='Template',
account=self.account.name,
domainid=self.account.domainid,
key='OS', key='OS',
value='CentOS' value='CentOS'
) )