本文整理汇总了Python中marvin.lib.base.Template.copy方法的典型用法代码示例。如果您正苦于以下问题:Python Template.copy方法的具体用法?Python Template.copy怎么用?Python Template.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marvin.lib.base.Template
的用法示例。
在下文中一共展示了Template.copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_09_copy_delete_template
# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import copy [as 别名]
def test_09_copy_delete_template(self):
cmd = listZones.listZonesCmd()
zones = self.apiclient.listZones(cmd)
if not isinstance(zones, list):
raise Exception("Failed to find zones.")
if len(zones) < 2:
self.skipTest(
"Skipping test due to there are less than two zones.")
return
self.sourceZone = zones[0]
self.destZone = zones[1]
template = Template.create(
self.apiclient,
self.services["template"],
self.volume.id,
account=self.account.name,
domainid=self.account.domainid
)
self.cleanup.append(template)
self.debug("Created template with ID: %s" % template.id)
list_template_response = Template.list(
self.apiclient,
templatefilter=\
self.services["templatefilter"],
id=template.id
)
self.assertEqual(
isinstance(list_template_response, list),
True,
"Check list response returns a valid list"
)
#Verify template response to check whether template added successfully
self.assertNotEqual(
len(list_template_response),
0,
"Check template available in List Templates"
)
#Copy template from zone1 to zone2
copytemplate = Template.copy(
cls.apiclient,
zoneid=cls.sourceZone.id,
destzoneid = cls.destZone.id
)
cls._cleanup.append(cls.copytemplate)
list_template_response = Template.list(
self.apiclient,
templatefilter=self.services["template"]["templatefilter"],
id=self.template.id,
zoneid=self.destZone.id
)
self.assertEqual(
list_template_response,
None,
"Check template available in List Templates"
)
self.deltemplate = list_template_response[0]
self.debug("Deleting template: %s" % self.deltemplate)
# Delete the template
self.deltemplate.delete(self.apiclient)
self.debug("Delete template: %s successful" % self.deltemplate)
copytemplate = Template.copy(
self.apiclient,
zoneid=self.sourceZone.id,
destzoneid = self.destZone.id
)
removed = cls.dbclient.execute("select removed from template_zone_ref where zone_id='%s' and template_id='%s';" % self.destZone.id, self.template.id)
self.assertEqual(
removed,
NULL,
"Removed state is not correct."
)
return
示例2: test_04_copy_template
# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import copy [as 别名]
def test_04_copy_template(self):
"""
@Desc: Test to copy Template from one zone to another
@steps:
Step1: Listing Zones available for a user
Step2: Verifying if the zones listed are greater than 1.
If Yes continuing.
If not halting the test.
Step3: Listing all the templates for a user in zone1
Step4: Verifying that no templates are listed
Step5: Listing all the templates for a user in zone2
Step6: Verifying that no templates are listed
Step7: Creating a Template in zone 1
Step8: Listing all the Templates again for a user in zone1
Step9: Verifying that list size is 1
Step10: Listing all the templates for a user in zone2
Step11: Verifying that no templates are listed
Step12: Copying the template created in step7 from zone1 to zone2
Step13: Listing all the templates for a user in zone2
Step14: Verifying that list size is 1
Step15: Listing all the Templates for a user in zone1
Step16: Verifying that list size is 1
"""
# Listing Zones available for a user
zones_list = Zone.list(
self.userapiclient,
available=True
)
status = validateList(zones_list)
self.assertEquals(
PASS,
status[0],
"Failed to list Zones"
)
if not len(zones_list) > 1:
self.fail("Enough zones doesnot exists to copy template")
else:
# Listing all the Templates for a User in Zone 1
list_templates_zone1 = Template.list(
self.userapiclient,
listall=self.services["listall"],
templatefilter=self.services["templatefilter"],
zoneid=zones_list[0].id
)
# Verifying that no Templates are listed
self.assertIsNone(
list_templates_zone1,
"Templates listed for newly created User in Zone1"
)
# Listing all the Templates for a User in Zone 2
list_templates_zone2 = Template.list(
self.userapiclient,
listall=self.services["listall"],
templatefilter=self.services["templatefilter"],
zoneid=zones_list[1].id
)
# Verifying that no Templates are listed
self.assertIsNone(
list_templates_zone2,
"Templates listed for newly created User in Zone2"
)
self.services["template"]["url"] = "http://10.147.28.7/templates/ttylinux_pv.vhd"
self.services["template"]["format"] = "VHD"
self.services["template"]["ostype"] = self.services["ostype"]
#Listing Hypervisors in Zone 1
hypervisor_list = Hypervisor.list(
self.apiClient,
zoneid=zones_list[0].id
)
status = validateList(zones_list)
self.assertEquals(
PASS,
status[0],
"Failed to list Hypervisors in Zone 1"
)
# Creating aTemplate in Zone 1
template_created = Template.register(
self.userapiclient,
self.services["template"],
zones_list[0].id,
hypervisor=hypervisor_list[0].name
)
self.assertIsNotNone(
template_created,
"Template creation failed"
)
self.cleanup.append(template_created)
# Listing all the Templates for a User in Zone 1
list_templates_zone1 = Template.list(
self.userapiclient,
listall=self.services["listall"],
templatefilter=self.services["templatefilter"],
zoneid=zones_list[0].id
)
status = validateList(list_templates_zone1)
self.assertEquals(
PASS,
status[0],
"Templates creation failed in Zone1"
)
#.........这里部分代码省略.........