Update cinder volume quota for new tenant 'vIMS'
authorgrakiss <grakiss.wanglei@huawei.com>
Thu, 31 Dec 2015 01:31:31 +0000 (09:31 +0800)
committermei mei <meimei@huawei.com>
Mon, 4 Jan 2016 01:52:13 +0000 (01:52 +0000)
Change-Id: I26aad4f3989c89a62f66add85e0d88b7fd274425
Signed-off-by: grakiss <grakiss.wanglei@huawei.com>
testcases/functest_utils.py
testcases/vIMS/CI/vIMS.py

index 88c0085..fe0b3be 100644 (file)
@@ -321,6 +321,19 @@ def update_sg_quota(neutron_client, tenant_id, sg_quota, sg_rule_quota):
         print "Error:", sys.exc_info()[0]
         return False
 
+def update_cinder_quota(cinder_client, tenant_id, vols_quota, snapshots_quota,gigabytes_quota):
+    quotas_values = {
+            "volumes": vols_quota,
+            "snapshots": snapshots_quota,
+            "gigabytes": gigabytes_quota
+    }
+
+    try:
+        quotas_default=cinder_client.quotas.update(tenant_id,**quotas_values)
+        return True
+    except:
+        print "Error:", sys.exc_info()[0]
+        return False
 
 def get_private_net(neutron_client):
     # Checks if there is an existing private network
index 12fb775..5a3003f 100644 (file)
@@ -242,6 +242,18 @@ def main():
         logger.error("Failed to update security group quota for tenant %s" %TENANT_NAME)
         exit(-1)
 
+    logger.info("Update cinder quota for this tenant")
+    from cinderclient import client as cinderclient
+
+    creds_cinder = functest_utils.get_credentials("cinder")
+    cinder_client = cinderclient.Client('1',creds_cinder['username'],
+                                        creds_cinder['api_key'],
+                                        creds_cinder['project_id'],
+                                        creds_cinder['auth_url'],
+                                        service_type="volume")
+    if not functest_utils.update_cinder_quota(cinder_client,tenant_id,20,50,1500):
+        logger.error("Failed to update cinder quota for tenant %s" % TENANT_NAME)
+        exit(-1)
 
     ################ CLOUDIFY INITIALISATION ################