mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-7519: Using bound/unbound methods instead of directly calling API methods from test case
Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>
This commit is contained in:
parent
b4f03a1339
commit
81d5dd9bcd
@ -19,19 +19,14 @@
|
|||||||
#Import Local Modules
|
#Import Local Modules
|
||||||
from marvin.codes import FAILED
|
from marvin.codes import FAILED
|
||||||
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
|
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
|
||||||
from marvin.cloudstackAPI import (updateTemplate,
|
|
||||||
extractTemplate,
|
|
||||||
listZones,
|
|
||||||
updateTemplatePermissions,
|
|
||||||
deleteTemplate,
|
|
||||||
copyTemplate)
|
|
||||||
from marvin.lib.utils import random_gen, cleanup_resources
|
from marvin.lib.utils import random_gen, cleanup_resources
|
||||||
from marvin.lib.base import (Account,
|
from marvin.lib.base import (Account,
|
||||||
ServiceOffering,
|
ServiceOffering,
|
||||||
VirtualMachine,
|
VirtualMachine,
|
||||||
DiskOffering,
|
DiskOffering,
|
||||||
Template,
|
Template,
|
||||||
Volume)
|
Volume,
|
||||||
|
Zone)
|
||||||
from marvin.lib.common import (get_domain,
|
from marvin.lib.common import (get_domain,
|
||||||
get_zone,
|
get_zone,
|
||||||
get_template)
|
get_template)
|
||||||
@ -62,7 +57,6 @@ class TestCreateTemplate(cloudstackTestCase):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
|
|
||||||
testClient = super(TestCreateTemplate, cls).getClsTestClient()
|
testClient = super(TestCreateTemplate, cls).getClsTestClient()
|
||||||
cls.apiclient = testClient.getApiClient()
|
cls.apiclient = testClient.getApiClient()
|
||||||
cls.services = testClient.getParsedTestDataConfig()
|
cls.services = testClient.getParsedTestDataConfig()
|
||||||
@ -220,8 +214,7 @@ class TestTemplates(cloudstackTestCase):
|
|||||||
cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
|
cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
|
||||||
cls.services['mode'] = cls.zone.networktype
|
cls.services['mode'] = cls.zone.networktype
|
||||||
#populate second zone id for iso copy
|
#populate second zone id for iso copy
|
||||||
cmd = listZones.listZonesCmd()
|
cls.zones = Zone.list(cls.apiclient)
|
||||||
cls.zones = cls.apiclient.listZones(cmd)
|
|
||||||
if not isinstance(cls.zones, list):
|
if not isinstance(cls.zones, list):
|
||||||
raise Exception("Failed to find zones.")
|
raise Exception("Failed to find zones.")
|
||||||
|
|
||||||
@ -350,15 +343,11 @@ class TestTemplates(cloudstackTestCase):
|
|||||||
new_displayText = random_gen()
|
new_displayText = random_gen()
|
||||||
new_name = random_gen()
|
new_name = random_gen()
|
||||||
|
|
||||||
cmd = updateTemplate.updateTemplateCmd()
|
self.template_1.update(self.apiclient,
|
||||||
# Update template attributes
|
displaytext = new_displayText,
|
||||||
cmd.id = self.template_1.id
|
name = new_name,
|
||||||
cmd.displaytext = new_displayText
|
bootable = self.services["bootable"],
|
||||||
cmd.name = new_name
|
passwordenabled = self.services["passwordenabled"])
|
||||||
cmd.bootable = self.services["bootable"]
|
|
||||||
cmd.passwordenabled = self.services["passwordenabled"]
|
|
||||||
|
|
||||||
self.apiclient.updateTemplate(cmd)
|
|
||||||
|
|
||||||
self.debug("Edited template with new name: %s" % new_name)
|
self.debug("Edited template with new name: %s" % new_name)
|
||||||
|
|
||||||
@ -461,12 +450,10 @@ class TestTemplates(cloudstackTestCase):
|
|||||||
# 3 .ListTemplates should not display the system templates
|
# 3 .ListTemplates should not display the system templates
|
||||||
|
|
||||||
self.debug("Extracting template with ID: %s" % self.template_2.id)
|
self.debug("Extracting template with ID: %s" % self.template_2.id)
|
||||||
|
list_extract_response = Template.extract(self.apiclient,
|
||||||
cmd = extractTemplate.extractTemplateCmd()
|
id=self.template_2.id,
|
||||||
cmd.id = self.template_2.id
|
mode= self.services["template_2"]["mode"],
|
||||||
cmd.mode = self.services["template_2"]["mode"]
|
zoneid=self.zone.id)
|
||||||
cmd.zoneid = self.zone.id
|
|
||||||
list_extract_response = self.apiclient.extractTemplate(cmd)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Format URL to ASCII to retrieve response code
|
# Format URL to ASCII to retrieve response code
|
||||||
@ -513,13 +500,10 @@ class TestTemplates(cloudstackTestCase):
|
|||||||
|
|
||||||
self.debug("Updating Template permissions ID:%s" % self.template_2.id)
|
self.debug("Updating Template permissions ID:%s" % self.template_2.id)
|
||||||
|
|
||||||
cmd = updateTemplatePermissions.updateTemplatePermissionsCmd()
|
self.template_2.updatePermissions(self.apiclient,
|
||||||
# Update template permissions
|
isfeatured = self.services["isfeatured"],
|
||||||
cmd.id = self.template_2.id
|
ispublic = self.services["ispublic"],
|
||||||
cmd.isfeatured = self.services["isfeatured"]
|
isextractable = self.services["isextractable"])
|
||||||
cmd.ispublic = self.services["ispublic"]
|
|
||||||
cmd.isextractable = self.services["isextractable"]
|
|
||||||
self.apiclient.updateTemplatePermissions(cmd)
|
|
||||||
|
|
||||||
list_template_response = Template.list(
|
list_template_response = Template.list(
|
||||||
self.apiclient,
|
self.apiclient,
|
||||||
@ -571,11 +555,10 @@ class TestTemplates(cloudstackTestCase):
|
|||||||
self.services["sourcezoneid"],
|
self.services["sourcezoneid"],
|
||||||
self.services["destzoneid"]
|
self.services["destzoneid"]
|
||||||
))
|
))
|
||||||
cmd = copyTemplate.copyTemplateCmd()
|
|
||||||
cmd.id = self.template_2.id
|
self.template_2.copy(self.apiclient,
|
||||||
cmd.destzoneid = self.services["destzoneid"]
|
sourcezoneid=self.services["sourcezoneid"],
|
||||||
cmd.sourcezoneid = self.services["sourcezoneid"]
|
destzoneid=self.services["destzoneid"])
|
||||||
self.apiclient.copyTemplate(cmd)
|
|
||||||
|
|
||||||
# Verify template is copied to another zone using ListTemplates
|
# Verify template is copied to another zone using ListTemplates
|
||||||
list_template_response = Template.list(
|
list_template_response = Template.list(
|
||||||
@ -639,10 +622,7 @@ class TestTemplates(cloudstackTestCase):
|
|||||||
"Failed to download copied template(ID: %s)" % template_response.id)
|
"Failed to download copied template(ID: %s)" % template_response.id)
|
||||||
|
|
||||||
timeout = timeout - 1
|
timeout = timeout - 1
|
||||||
cmd = deleteTemplate.deleteTemplateCmd()
|
self.template_2.delete(self.apiclient, zoneid=self.services["destzoneid"])
|
||||||
cmd.id = template_response.id
|
|
||||||
cmd.zoneid = self.services["destzoneid"]
|
|
||||||
self.apiclient.deleteTemplate(cmd)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="false")
|
@attr(tags = ["advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="false")
|
||||||
|
|||||||
@ -1183,11 +1183,13 @@ class Template:
|
|||||||
cmd.snapshotid = snapshot.id
|
cmd.snapshotid = snapshot.id
|
||||||
return Template(apiclient.createTemplate(cmd).__dict__)
|
return Template(apiclient.createTemplate(cmd).__dict__)
|
||||||
|
|
||||||
def delete(self, apiclient):
|
def delete(self, apiclient, zoneid=None):
|
||||||
"""Delete Template"""
|
"""Delete Template"""
|
||||||
|
|
||||||
cmd = deleteTemplate.deleteTemplateCmd()
|
cmd = deleteTemplate.deleteTemplateCmd()
|
||||||
cmd.id = self.id
|
cmd.id = self.id
|
||||||
|
if zoneid:
|
||||||
|
cmd.zoneid = zoneid
|
||||||
apiclient.deleteTemplate(cmd)
|
apiclient.deleteTemplate(cmd)
|
||||||
|
|
||||||
def download(self, apiclient, timeout=5, interval=60):
|
def download(self, apiclient, timeout=5, interval=60):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user