|
63 | 63 | from marvin.codes import (PASS, FAILED, ISOLATED_NETWORK, VPC_NETWORK, |
64 | 64 | BASIC_ZONE, FAIL, NAT_RULE, STATIC_NAT_RULE, |
65 | 65 | 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, |
66 | 69 | RESOURCE_CPU, RESOURCE_MEMORY, PUBLIC_TRAFFIC, |
67 | 70 | GUEST_TRAFFIC, MANAGEMENT_TRAFFIC, STORAGE_TRAFFIC, |
68 | 71 | VMWAREDVS) |
@@ -1392,6 +1395,20 @@ def matchResourceCount(apiclient, expectedCount, resourceType, |
1392 | 1395 | resourceCount = resourceholderlist[0].cputotal |
1393 | 1396 | elif resourceType == RESOURCE_MEMORY: |
1394 | 1397 | 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 |
1395 | 1412 | assert str(resourceCount) == str(expectedCount),\ |
1396 | 1413 | "Resource count %s should match with the expected resource count %s" %\ |
1397 | 1414 | (resourceCount, expectedCount) |
@@ -1452,7 +1469,36 @@ def isDomainResourceCountEqualToExpectedCount(apiclient, domainid, expectedcount |
1452 | 1469 | isExceptionOccured = True |
1453 | 1470 | return [isExceptionOccured, reasonForException, isResourceCountEqual] |
1454 | 1471 |
|
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 | + |
1456 | 1502 | if resourcecount == expectedcount: |
1457 | 1503 | isResourceCountEqual = True |
1458 | 1504 | return [isExceptionOccured, reasonForException, isResourceCountEqual] |
|
0 commit comments