Skip to content

Commit cc29cba

Browse files
committed
marvin: check resource count of more types
1 parent 6780d2a commit cc29cba

2 files changed

Lines changed: 55 additions & 1 deletion

File tree

tools/marvin/marvin/codes.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@
102102
XEN_SERVER = "XenServer"
103103
ADMIN_ACCOUNT = 'ADMIN_ACCOUNT'
104104
USER_ACCOUNT = 'USER_ACCOUNT'
105+
RESOURCE_USER_VM = 0
106+
RESOURCE_PUBLIC_IP = 1
107+
RESOURCE_VOLUME = 2
108+
RESOURCE_SNAPSHOT = 3
109+
RESOURCE_TEMPLATE = 4
110+
RESOURCE_PROJECT = 5
111+
RESOURCE_NETWORK = 6
112+
RESOURCE_VPC = 7
105113
RESOURCE_CPU = 8
106114
RESOURCE_MEMORY = 9
107115
RESOURCE_PRIMARY_STORAGE = 10

tools/marvin/marvin/lib/common.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@
6363
from marvin.codes import (PASS, FAILED, ISOLATED_NETWORK, VPC_NETWORK,
6464
BASIC_ZONE, FAIL, NAT_RULE, STATIC_NAT_RULE,
6565
RESOURCE_PRIMARY_STORAGE, RESOURCE_SECONDARY_STORAGE,
66+
RESOURCE_USER_VM, RESOURCE_PUBLIC_IP, RESOURCE_VOLUME,
67+
RESOURCE_SNAPSHOT, RESOURCE_TEMPLATE, RESOURCE_PROJECT,
68+
RESOURCE_NETWORK, RESOURCE_VPC,
6669
RESOURCE_CPU, RESOURCE_MEMORY, PUBLIC_TRAFFIC,
6770
GUEST_TRAFFIC, MANAGEMENT_TRAFFIC, STORAGE_TRAFFIC,
6871
VMWAREDVS)
@@ -1392,6 +1395,20 @@ def matchResourceCount(apiclient, expectedCount, resourceType,
13921395
resourceCount = resourceholderlist[0].cputotal
13931396
elif resourceType == RESOURCE_MEMORY:
13941397
resourceCount = resourceholderlist[0].memorytotal
1398+
elif resourceType == RESOURCE_USER_VM:
1399+
resourceCount = resourceholderlist[0].vmtotal
1400+
elif resourceType == RESOURCE_PUBLIC_IP:
1401+
resourceCount = resourceholderlist[0].iptotal
1402+
elif resourceType == RESOURCE_VOLUME:
1403+
resourceCount = resourceholderlist[0].volumetotal
1404+
elif resourceType == RESOURCE_SNAPSHOT:
1405+
resourceCount = resourceholderlist[0].snapshottotal
1406+
elif resourceType == RESOURCE_TEMPLATE:
1407+
resourceCount = resourceholderlist[0].templatetotal
1408+
elif resourceType == RESOURCE_NETWORK:
1409+
resourceCount = resourceholderlist[0].networktotal
1410+
elif resourceType == RESOURCE_VPC:
1411+
resourceCount = resourceholderlist[0].vpctotal
13951412
assert str(resourceCount) == str(expectedCount),\
13961413
"Resource count %s should match with the expected resource count %s" %\
13971414
(resourceCount, expectedCount)
@@ -1452,7 +1469,36 @@ def isDomainResourceCountEqualToExpectedCount(apiclient, domainid, expectedcount
14521469
isExceptionOccured = True
14531470
return [isExceptionOccured, reasonForException, isResourceCountEqual]
14541471

1455-
resourcecount = (response[0].resourcecount / (1024**3))
1472+
if resourcetype == RESOURCE_PRIMARY_STORAGE or resourcetype == RESOURCE_SECONDARY_STORAGE:
1473+
resourcecount = (response[0].resourcecount / (1024**3))
1474+
else:
1475+
resourcecount = response[0].resourcecount
1476+
1477+
if resourcecount == expectedcount:
1478+
isResourceCountEqual = True
1479+
return [isExceptionOccured, reasonForException, isResourceCountEqual]
1480+
1481+
def isAccountResourceCountEqualToExpectedCount(apiclient, domainid, account, expectedcount,
1482+
resourcetype):
1483+
"""Get the resource count of specific account and match
1484+
it with the expected count
1485+
Return list [isExceptionOccured, reasonForException, isResourceCountEqual]"""
1486+
isResourceCountEqual = False
1487+
isExceptionOccured = False
1488+
reasonForException = None
1489+
try:
1490+
response = Resources.updateCount(apiclient, domainid=domainid, account=account,
1491+
resourcetype=resourcetype)
1492+
except Exception as e:
1493+
reasonForException = "Failed while updating resource count: %s" % e
1494+
isExceptionOccured = True
1495+
return [isExceptionOccured, reasonForException, isResourceCountEqual]
1496+
1497+
if resourcetype == RESOURCE_PRIMARY_STORAGE or resourcetype == RESOURCE_SECONDARY_STORAGE:
1498+
resourcecount = (response[0].resourcecount / (1024**3))
1499+
else:
1500+
resourcecount = response[0].resourcecount
1501+
14561502
if resourcecount == expectedcount:
14571503
isResourceCountEqual = True
14581504
return [isExceptionOccured, reasonForException, isResourceCountEqual]

0 commit comments

Comments
 (0)