本文整理汇总了Python中marvin.lib.base.Template.list方法的典型用法代码示例。如果您正苦于以下问题:Python Template.list方法的具体用法?Python Template.list怎么用?Python Template.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marvin.lib.base.Template
的用法示例。
在下文中一共展示了Template.list方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_03_delete_template
# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import list [as 别名]
def test_03_delete_template(self):
"""Test Delete template
"""
# Validate the following:
# 1. Create a template and verify it is shown in list templates response
# 2. Delete the created template and again verify list template response
# Verify template response for updated attributes
list_template_response = Template.list(
self.apiclient,
templatefilter=\
self.services["template"]["templatefilter"],
id=self.template.id,
zoneid=self.zone.id)
self.assertEqual(
isinstance(list_template_response, list),
True,
"Check for list template response return valid list"
)
self.assertNotEqual(
len(list_template_response),
0,
"Check template available in List Templates"
)
template_response = list_template_response[0]
self.assertEqual(
template_response.id,
self.template.id,
"Template id %s in the list is not matching with created template id %s" %
(template_response.id, self.template.id)
)
self.debug("Deleting template: %s" % self.template)
# Delete the template
self.template.delete(self.apiclient)
self.debug("Delete template: %s successful" % self.template)
list_template_response = Template.list(
self.apiclient,
templatefilter=\
self.services["template"]["templatefilter"],
id=self.template.id,
zoneid=self.zone.id
)
self.assertEqual(
list_template_response,
None,
"Check template available in List Templates"
)
return
示例2: test_08_list_system_templates
# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import list [as 别名]
def test_08_list_system_templates(self):
"""Test System templates are not visible to normal user"""
# Validate the following
# 1. ListTemplates should not show 'SYSTEM' templates for normal user
list_template_response = Template.list(
self.apiclient,
templatefilter='featured',
account=self.user.name,
domainid=self.user.domainid
)
self.assertEqual(
isinstance(list_template_response, list),
True,
"Check list response returns a valid list"
)
self.assertNotEqual(
len(list_template_response),
0,
"Check template available in List Templates"
)
for template in list_template_response:
self.assertNotEqual(
template.templatetype,
'SYSTEM',
"ListTemplates should not list any system templates"
)
return
示例3: test_07_list_public_templates
# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import list [as 别名]
def test_07_list_public_templates(self):
"""Test only public templates are visible to normal user"""
# Validate the following
# 1. ListTemplates should show only 'public' templates for normal user
list_template_response = Template.list(
self.apiclient,
templatefilter='featured',
account=self.user.name,
domainid=self.user.domainid
)
self.assertEqual(
isinstance(list_template_response, list),
True,
"Check list response returns a valid list"
)
self.assertNotEqual(
len(list_template_response),
0,
"Check template available in List Templates"
)
#Template response should list all 'public' templates
for template in list_template_response:
self.assertEqual(
template.ispublic,
True,
"ListTemplates should list only public templates"
)
return
示例4: registerTemplate
# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import list [as 别名]
def registerTemplate(self, inProject=False):
"""Register and download template by default in the account/domain,
in project if stated so"""
try:
builtin_info = get_builtin_template_info(self.apiclient, self.zone.id)
self.services["template_2"]["url"] = builtin_info[0]
self.services["template_2"]["hypervisor"] = builtin_info[1]
self.services["template_2"]["format"] = builtin_info[2]
template = Template.register(self.apiclient,
self.services["template_2"],
zoneid=self.zone.id,
account=self.child_do_admin.name if not inProject else None,
domainid=self.child_do_admin.domainid if not inProject else None,
projectid=self.project.id if inProject else None)
template.download(self.apiclient)
templates = Template.list(self.apiclient,
templatefilter=\
self.services["template_2"]["templatefilter"],
id=template.id)
self.assertEqual(validateList(templates)[0], PASS,\
"templates list validation failed")
self.templateSize = (templates[0].size / (1024**3))
except Exception as e:
return [FAIL, e]
return [PASS, None]
示例5: test_02_create_template_snapshot
# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import list [as 别名]
def test_02_create_template_snapshot(self, value):
"""Test create snapshot and templates from volume
# Validate the following
1. Create root domain/child domain admin account
2. Deploy VM in the account
3. Create snapshot from the virtual machine root volume
4. Create template from the snapshot
5. Verify that the secondary storage count of the account equals
the size of the template"""
response = self.setupAccount(value)
self.assertEqual(response[0], PASS, response[1])
self.virtualMachine = VirtualMachine.create(
self.api_client,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering.id,
)
self.assertNotEqual(self.virtualMachine, FAILED, "VM deployment failed")
apiclient = self.testClient.getUserApiClient(UserName=self.account.name, DomainName=self.account.domain)
self.assertNotEqual(apiclient, FAILED, "Failed to create api client for account: %s" % self.account.name)
try:
self.virtualMachine.stop(apiclient)
except Exception as e:
self.fail("Failed to stop instance: %s" % e)
self.debug("Creating snapshot from ROOT volume: %s" % self.virtualMachine.name)
response = createSnapshotFromVirtualMachineVolume(apiclient, self.account, self.virtualMachine.id)
self.assertEqual(response[0], PASS, response[1])
snapshot = response[1]
snapshotSize = snapshot.physicalsize / (1024 ** 3)
try:
template = Template.create_from_snapshot(apiclient, snapshot=snapshot, services=self.services["template_2"])
except Exception as e:
self.fail("Failed to create template: %s" % e)
templates = Template.list(
apiclient, templatefilter=self.services["template_2"]["templatefilter"], id=template.id
)
self.assertEqual(validateList(templates)[0], PASS, "templates list validation failed")
templateSize = templates[0].size / (1024 ** 3)
expectedSecondaryStorageCount = int(templateSize + snapshotSize)
response = matchResourceCount(
self.apiclient,
expectedSecondaryStorageCount,
resourceType=RESOURCE_SECONDARY_STORAGE,
accountid=self.account.id,
)
self.assertEqual(response[0], PASS, response[1])
return
示例6: test_listtemplate
# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import list [as 别名]
def test_listtemplate(self):
# Register template under one domain admin(root/domain1->account 1)
template_register = Template.register(
self.apiclient,
self.testdata["privatetemplate"],
zoneid=self.zone.id,
hypervisor=self.hypervisor,
account=self.account1.name,
domainid=self.domain1.id)
template_register.download(self.apiclient)
self.download(self.apiclient, template_register.id)
listtemplate = Template.list(
self.apiclient,
zoneid=self.zone.id,
hypervisor=self.hypervisor,
account=self.account2.name,
domainid=self.account2.domainid,
templatefilter="executable")
self.assertEqual(
listtemplate,
None,
"Check templates are not listed - CLOUDSTACK-10149"
)
return
示例7: test_vm_nic_adapter_vmxnet3
# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import list [as 别名]
def test_vm_nic_adapter_vmxnet3(self):
"""
# 1. Register a template for VMware with nicAdapter vmxnet3
# 2. Deploy a VM using this template
# 3. Create an isolated network
# 4. Add network to VM
# 5. Verify that the NIC adapter for VM for both the nics
# is vmxnet3
"""
if self.hypervisor.lower() not in ["vmware"]:
self.skipTest("This test case is written specifically\
for Vmware hypervisor")
# Register a private template in the account with nic adapter vmxnet3
template = Template.register(
self.userapiclient,
self.testdata["configurableData"]["vmxnet3template"],
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid,
details=[{"nicAdapter": self.testdata["configurableData"]["vmxnet3template"]["nicadapter"]}]
)
self.cleanup.append(template)
template.download(self.apiclient)
templates = Template.list(
self.userapiclient,
listall=True,
id=template.id,
templatefilter="self")
self.assertEqual(
validateList(templates)[0],
PASS,
"Templates list validation failed")
self.testdata["virtual_machine"]["zoneid"] = self.zone.id
self.testdata["virtual_machine"]["template"] = template.id
virtual_machine = VirtualMachine.create(
self.apiclient,
self.testdata["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering.id)
isolated_network = Network.create(
self.apiclient,
self.testdata["isolated_network"],
self.account.name,
self.account.domainid,
networkofferingid=self.isolated_network_offering.id)
virtual_machine.add_nic(self.apiclient, isolated_network.id)
# TODO: Add steps to check the Nic Adapter type in VCenter
# using VCenter APIs
return
示例8: test_03_delete_template
# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import list [as 别名]
def test_03_delete_template(self):
"""Test delete template
"""
# Validate the following:
# 1. UI should not show the deleted template
# 2. database (vm_template table) should not contain deleted template
self.debug("Deleting Template ID: %s" % self.template_1.id)
self.template_1.delete(self.apiclient)
list_template_response = Template.list(
self.apiclient,
templatefilter=\
self.services["templatefilter"],
id=self.template_1.id,
account=self.account.name,
domainid=self.account.domainid
)
# Verify template is deleted properly using ListTemplates
self.assertEqual(
list_template_response,
None,
"Check if template exists in List Templates"
)
return
示例9: test_01_create_template
# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import list [as 别名]
def test_01_create_template(self):
"""Test create public & private template
"""
# Validate the following:
# 1. database (vm_template table) should be updated
# with newly created template
# 2. UI should show the newly added template
# 3. ListTemplates API should show the newly added template
#Create template from Virtual machine and Volume ID
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"
)
template_response = list_template_response[0]
self.assertEqual(
template_response.displaytext,
self.services["template"]["displaytext"],
"Check display text of newly created template"
)
name = template_response.name
self.assertEqual(
name.count(self.services["template"]["name"]),
1,
"Check name of newly created template"
)
self.assertEqual(
template_response.ostypeid,
self.services["template"]["ostypeid"],
"Check osTypeID of newly created template"
)
return
示例10: test_01_register_template
# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import list [as 别名]
def test_01_register_template(self, value):
"""Test register template
# Validate the following:
1. Create a root domain admin/ child domain admin account
2. Register and download a template according to hypervisor type
3. Verify that the template is listed
4. Verify that the secondary storage count for the account equals the size
of the template
5. Delete the template
6. Verify that the secondary storage resource count of the account equals 0
"""
response = self.setupAccount(value)
self.assertEqual(response[0], PASS, response[1])
builtin_info = get_builtin_template_info(self.apiclient, self.zone.id)
self.services["template_2"]["url"] = builtin_info[0]
self.services["template_2"]["hypervisor"] = builtin_info[1]
self.services["template_2"]["format"] = builtin_info[2]
try:
template = Template.register(self.apiclient,
self.services["template_2"],
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid,
hypervisor=self.hypervisor)
template.download(self.apiclient)
except Exception as e:
self.fail("Failed to register template: %s" % e)
templates = Template.list(self.apiclient,
templatefilter=\
self.services["template_2"]["templatefilter"],
id=template.id)
self.assertEqual(validateList(templates)[0],PASS,\
"templates list validation failed")
templateSize = (templates[0].size / (1024**3))
expectedCount = templateSize
response = matchResourceCount(
self.apiclient, expectedCount,
RESOURCE_SECONDARY_STORAGE,
accountid=self.account.id)
self.assertEqual(response[0], PASS, response[1])
try:
template.delete(self.apiclient)
except Exception as e:
self.fail("Failed to delete template: %s" % e)
expectedCount = 0
response = matchResourceCount(
self.apiclient, expectedCount,
RESOURCE_SECONDARY_STORAGE,
accountid=self.account.id)
self.assertEqual(response[0], PASS, response[1])
return
示例11: test_03_concurrent_snapshots_create_template
# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import list [as 别名]
def test_03_concurrent_snapshots_create_template(self):
"""Test while parent concurrent snapshot job in progress,create
template from completed snapshot
1.Configure the concurrent.snapshots.threshold.perhost=3
2.Deploy a Linux VM using default CentOS template, use small
service offering, disk offering
3.Perform snapshot on root disk of this newly created VMs(10 vms)
4.while parent concurrent snapshot job in progress,create template
from completed snapshot"""
# Validate the following
# a.Able to create Template from snapshots
# b.check all snapshots jobs are running concurrently on back grounds
# c.listSnapshots should list this newly created snapshot.
self.debug("Create virtual machine and snapshot on ROOT disk")
self.create_Snapshot_VM()
self.debug("Verify whether snapshots were created properly or not?")
self.verify_Snapshots()
self.debug("Fetch the list of snapshots belong to account: %s" %
self.account.name)
snapshots = self.get_Snapshots_For_Account(
self.account.name,
self.account.domainid)
jobs = []
for snapshot in snapshots:
self.debug("Create a template from snapshot: %s" % snapshot.name)
jobs.append(self.create_Template_from_Snapshot(snapshot))
userapiclient = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
# Verify IO usage by submitting the concurrent jobs
self.testClient.submitCmdsAndWait(jobs, apiclient=userapiclient)
self.debug("Verifying if templates are created properly or not?")
templates = Template.list(
self.apiclient,
templatefilter=self.services["template"]["templatefilter"],
account=self.account.name,
domainid=self.account.domainid,
listall=True)
self.assertNotEqual(templates,
None,
"Check if result exists in list item call")
for template in templates:
self.assertEqual(template.isready,
True,
"Check new template state in list templates call")
self.debug("Test completed successfully.")
return
示例12: test_02_list_templates_with_templatefilter_all_domain_admin
# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import list [as 别名]
def test_02_list_templates_with_templatefilter_all_domain_admin(self):
"""
Test list templates with templatefilter=all is not permitted for domain admin
"""
domain_user_api_client = self.testClient.getUserApiClient(
UserName=self.newdomain_account.name,
DomainName=self.newdomain_account.domain)
try:
list_template_response = Template.list(domain_user_api_client, templatefilter='all')
except Exception as e:
self.fail("Domain admin should be able to use templatefilter='all' in listTemplates API call")
示例13: get_builtin_template_info
# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import list [as 别名]
def get_builtin_template_info(apiclient, zoneid):
"""Returns hypervisor specific infor for templates"""
list_template_response = Template.list(apiclient, templatefilter="featured", zoneid=zoneid)
for b_template in list_template_response:
if b_template.templatetype == "BUILTIN":
break
extract_response = Template.extract(apiclient, b_template.id, "HTTP_DOWNLOAD", zoneid)
return extract_response.url, b_template.hypervisor, b_template.format
示例14: test_listtemplate
# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import list [as 别名]
def test_listtemplate(self):
# Register template under one domain admin(root/domain1->account 1)
template_register = Template.register(
self.apiclient,
self.testdata["privatetemplate"],
zoneid=self.zone.id,
hypervisor=self.hypervisor,
account=self.account1.name,
domainid=self.domain1.id,
)
template_register.download(self.apiclient)
# self.cleanup.append(self.template_register)
time.sleep(self.testdata["sleep"])
timeout = self.testdata["timeout"]
while True:
listTemplateResponse = Template.list(
self.apiclient,
templatefilter="all",
id=template_register.id,
account=self.account1.name,
domainid=self.domain1.id,
)
status = validateList(listTemplateResponse)
self.assertEquals(PASS, status[0], "Template creation failed")
listtemplate = Template.list(
self.apiclient,
zoneid=self.zone.id,
hypervisor=self.hypervisor,
account=self.account2.name,
domainid=self.account2.domainid,
templatefilter=self.testdata["templatefilter"],
)
self.assertEqual(listtemplate, None, "Check templates are not listed")
return
示例15: test_01_list_templates_with_templatefilter_all_normal_user
# 需要导入模块: from marvin.lib.base import Template [as 别名]
# 或者: from marvin.lib.base.Template import list [as 别名]
def test_01_list_templates_with_templatefilter_all_normal_user(self):
"""
Test list templates with templatefilter=all is not permitted for normal user
"""
user_api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
try:
list_template_response = Template.list(self.user_api_client, templatefilter='all')
self.fail("Regular User is able to use templatefilter='all' in listTemplates API call")
except Exception as e:
self.debug("ListTemplates API with templatefilter='all' is not permitted for normal user")