X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=utils%2Fenv_prepare%2Fquota_prepare.py;h=8dcdf3d65c47256a8bb9f05b43858a6234f192fa;hb=c9dc6c5ff980c32f82b0533e5a25eabebfbd0c6a;hp=850a46a40c8c26d2a01db2ca87896b97823c2e05;hpb=b26f701ab2327497b0e44f548ea18e24b1e6b0d9;p=bottlenecks.git diff --git a/utils/env_prepare/quota_prepare.py b/utils/env_prepare/quota_prepare.py index 850a46a4..8dcdf3d6 100644 --- a/utils/env_prepare/quota_prepare.py +++ b/utils/env_prepare/quota_prepare.py @@ -22,7 +22,9 @@ neutron_quota = {"subnet": -1, "subnetpool": -1, "router": -1, "port": -1, - "security_group": -1} + "security_group": -1, + "security_group_rule": -1, + "rbac_policy": -1} nova_quota = {"ram": -1, "cores": -1, @@ -40,15 +42,38 @@ nova_quota = {"ram": -1, "injected_file_path_bytes": -1} +def check_https_enabled(): + LOG.debug("Check if https is enabled in OpenStack") + os_auth_url = os.getenv('OS_AUTH_URL') + if os_auth_url.startswith('https'): + LOG.debug("https is enabled") + return True + LOG.debug("https is not enabled") + return False + + def quota_env_prepare(): + https_enabled = check_https_enabled() + insecure_option = '' + insecure = os.getenv('OS_INSECURE',) + if https_enabled: + LOG.info("https is enabled") + if insecure: + if insecure.lower() == "true": + insecure_option = ' --insecure ' + else: + LOG.warn("Env variable OS_INSECURE is {}: if https + no " + "credential used, it should be set as True." + .format(insecure)) + tenant_name = os.getenv("OS_TENANT_NAME") - cmd = ("openstack project list | grep " + + cmd = ("openstack {} project list | grep ".format(insecure_option) + tenant_name + " | awk '{print $2}'") result = commands.getstatusoutput(cmd) - if result[0] == 0: - LOG.info(result[1]) + if result[0] == 0 and 'exception' not in result[1]: + LOG.info("Get %s project id is %s" % (tenant_name, result[1])) else: LOG.error("can't get openstack project id") return 1