本文整理汇总了Python中marvin.lib.base.Resources.updateCount方法的典型用法代码示例。如果您正苦于以下问题:Python Resources.updateCount方法的具体用法?Python Resources.updateCount怎么用?Python Resources.updateCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marvin.lib.base.Resources
的用法示例。
在下文中一共展示了Resources.updateCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_resource_count
# 需要导入模块: from marvin.lib.base import Resources [as 别名]
# 或者: from marvin.lib.base.Resources import updateCount [as 别名]
def update_resource_count(apiclient, domainid, accountid=None, projectid=None, rtype=None):
"""updates the resource count
0 - VM
1 - Public IP
2 - Volume
3 - Snapshot
4 - Template
5 - Projects
6 - Network
7 - VPC
8 - CPUs
9 - RAM
10 - Primary (shared) storage (Volumes)
11 - Secondary storage (Snapshots, Templates & ISOs)
"""
Resources.updateCount(
apiclient,
domainid=domainid,
account=accountid if accountid else None,
projectid=projectid if projectid else None,
resourcetype=rtype if rtype else None,
)
return
示例2: isDomainResourceCountEqualToExpectedCount
# 需要导入模块: from marvin.lib.base import Resources [as 别名]
# 或者: from marvin.lib.base.Resources import updateCount [as 别名]
def isDomainResourceCountEqualToExpectedCount(apiclient, domainid, expectedcount, resourcetype):
"""Get the resource count of specific domain and match
it with the expected count
Return list [isExceptionOccured, reasonForException, isResourceCountEqual]"""
isResourceCountEqual = False
isExceptionOccured = False
reasonForException = None
try:
response = Resources.updateCount(apiclient, domainid=domainid, resourcetype=resourcetype)
except Exception as e:
reasonForException = "Failed while updating resource count: %s" % e
isExceptionOccured = True
return [isExceptionOccured, reasonForException, isResourceCountEqual]
resourcecount = response[0].resourcecount / (1024 ** 3)
if resourcecount == expectedcount:
isResourceCountEqual = True
return [isExceptionOccured, reasonForException, isResourceCountEqual]
示例3: test_01_updateResourceCount
# 需要导入模块: from marvin.lib.base import Resources [as 别名]
# 或者: from marvin.lib.base.Resources import updateCount [as 别名]
def test_01_updateResourceCount(self):
"""Test update resource count for an account using a custom service offering to deploy a VM.
"""
# This test will execute the following steps to assure resource count update is working properly
# 1. Create an account.
# 2. Start 2 VMs; one with normal service offering and other with a custom service offering
# 3. Call the update resource count method and check the CPU and memory values.
# The two VMs will add up to 3 CPUs and 1024Mb of RAM.
# 4. If the return of updateResourceCount method matches with the expected one, the test passes; otherwise, it fails.
# 5. Remove everything created by deleting the account
vm_1 = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_custom.id,
customcpunumber = 1,
customcpuspeed = 1000,
custommemory = 512
)
self.debug("Deployed VM 1 in account: %s, ID: %s" % (
self.account.name,
vm_1.id
))
vm_2 = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_normal.id
)
self.debug("Deployed VM 2 in account: %s, ID: %s" % (
self.account.name,
vm_2.id
))
resourceCountCpu = Resources.updateCount(
self.apiclient,
resourcetype=8,
account=self.account.name,
domainid=self.account.domainid
)
self.debug("ResourceCount for CPU: %s" % (
resourceCountCpu[0].resourcecount
))
self.assertEqual(
resourceCountCpu[0].resourcecount,
3,
"The number of CPU cores does not seem to be right."
)
resourceCountMemory = Resources.updateCount(
self.apiclient,
resourcetype=9,
account=self.account.name,
domainid=self.account.domainid
)
self.debug("ResourceCount for memory: %s" % (
resourceCountMemory[0].resourcecount
))
self.assertEqual(
resourceCountMemory[0].resourcecount,
1024,
"The memory amount does not seem to be right."
)
return