summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYang (Gabriel) Yu <Gabriel.yuyang@huawei.com>2018-05-17 11:19:14 +0800
committerYang (Gabriel) Yu <Gabriel.yuyang@huawei.com>2018-05-19 00:40:56 +0800
commit265d35dd56247e855002c05cc4f11b39514700c5 (patch)
treec2a768e9dfd1528bdf3891e6e3dd0ac7211a0229
parentef2a091e17a37e06228346faa417870592c9a797 (diff)
bug-fix: idenity env not defined
OS_TENANT_NAME is wrongly used in getting openstack project information and is deprecated in keystone v3. Use OS_PROJECT_NAME to fix Change-Id: I941c612989ea5373ccf8a9d2e88ebd3eabcece73 Signed-off-by: Yang (Gabriel) Yu <Gabriel.yuyang@huawei.com>
-rw-r--r--utils/env_prepare/quota_prepare.py35
1 files changed, 23 insertions, 12 deletions
diff --git a/utils/env_prepare/quota_prepare.py b/utils/env_prepare/quota_prepare.py
index 8dcdf3d6..367f7613 100644
--- a/utils/env_prepare/quota_prepare.py
+++ b/utils/env_prepare/quota_prepare.py
@@ -66,17 +66,28 @@ def quota_env_prepare():
"credential used, it should be set as True."
.format(insecure))
- tenant_name = os.getenv("OS_TENANT_NAME")
- cmd = ("openstack {} project list | grep ".format(insecure_option) +
- tenant_name +
- " | awk '{print $2}'")
-
- result = commands.getstatusoutput(cmd)
- if result[0] == 0 and 'exception' not in result[1]:
- LOG.info("Get %s project id is %s" % (tenant_name, result[1]))
+ quota_name = os.getenv("OS_PROJECT_NAME")
+ if quota_name:
+ cmd = ("openstack {} project list | grep ".format(insecure_option) +
+ quota_name +
+ " | awk '{print $2}'")
+ result = commands.getstatusoutput(cmd)
+ if result[0] == 0 and 'exception' not in result[1]:
+ LOG.info("Get %s project name is %s" % (quota_name, result[1]))
+ else:
+ LOG.error("can't get openstack project name")
+ return 1
else:
- LOG.error("can't get openstack project id")
- return 1
+ quota_name = os.getenv("OS_TENANT_NAME")
+ cmd = ("openstack {} tenant list | grep ".format(insecure_option) +
+ quota_name +
+ " | awk '{print $2}'")
+ result = commands.getstatusoutput(cmd)
+ if result[0] == 0 and 'exception' not in result[1]:
+ LOG.info("Get %s tenant name is %s" % (quota_name, result[1]))
+ else:
+ LOG.error("can't get openstack tenant name")
+ return 1
openstack_id = result[1]
@@ -85,7 +96,7 @@ def quota_env_prepare():
nova_q = nova_client.quotas.get(openstack_id).to_dict()
neutron_q = neutron_client.show_quota(openstack_id)
- LOG.info(tenant_name + "tenant nova and neutron quota(previous) :")
+ LOG.info(quota_name + " nova and neutron quotas (previous) :")
LOG.info(nova_q)
LOG.info(neutron_q)
@@ -96,7 +107,7 @@ def quota_env_prepare():
nova_q = nova_client.quotas.get(openstack_id).to_dict()
neutron_q = neutron_client.show_quota(openstack_id)
- LOG.info(tenant_name + "tenant nova and neutron quota(now) :")
+ LOG.info(quota_name + " nova and neutron quotas (now) :")
LOG.info(nova_q)
LOG.info(neutron_q)
return 0