From 6750645d2e6a687b9f9d064b3e333e880f17b3e8 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Tue, 19 Dec 2017 09:08:05 +0000 Subject: Deprecate authentication variable OS_TENANT_NAME OS_TENANT_NAME was deprecated as authentication variable in Keystone when moved from v2 to v3, in Icehouse (2014). Because this project doesn't support oldest versions, by default the only identification API version supported is v3. JIRA: YARDSTICK-902 Change-Id: I273fb0151ba583f7c8a5a809e5e8864e92c27d31 Signed-off-by: Rodolfo Alonso Hernandez --- ansible/roles/convert_openrc/tasks/main.yml | 10 +---- .../roles/create_storperf_admin_rc/tasks/main.yml | 9 ---- .../templates/storperf_admin-rc.j2 | 4 +- docs/testing/user/userguide/04-installation.rst | 4 +- .../testing/user/userguide/05-yardstick_plugin.rst | 9 ++-- docs/testing/user/userguide/08-api.rst | 1 - gui/app/scripts/controllers/main.js | 4 +- tests/ci/prepare_storperf_admin-rc.sh | 5 +-- .../scenarios/networking/sfc_openstack.py | 16 +++---- yardstick/common/openstack_utils.py | 51 ++++++++-------------- 10 files changed, 36 insertions(+), 77 deletions(-) diff --git a/ansible/roles/convert_openrc/tasks/main.yml b/ansible/roles/convert_openrc/tasks/main.yml index 1606b0bc5..be621f0af 100644 --- a/ansible/roles/convert_openrc/tasks/main.yml +++ b/ansible/roles/convert_openrc/tasks/main.yml @@ -29,14 +29,8 @@ auth_url: "{{ openrc.OS_AUTH_URL }}" password: "{{ openrc.OS_PASSWORD }}" username: "{{ openrc.OS_USERNAME }}" - project_name: "{{ openrc.OS_PROJECT_NAME }}" -# tenant_name: "{{ openrc.OS_TENANT_NAME }}" + project_name: "{{ openrc.OS_PROJECT_NAME|default(openrc.OS_TENANT_NAME) }}" project_domain_name: "{{ openrc.OS_PROJECT_DOMAIN_NAME }}" -# user_domain_name: "{{ openrc.OS_USER_DOMAIN_NAME }}" - # BUGS: We need to specify identity_api_version == 3, but we can't do it here - # because it is not the write place - # we need to set it via OS_IDENTITY_API_VERSION or clouds.yaml -# identity_api_version: "{{ openrc.OS_IDENTITY_API_VERSION }}" - debug: var=os_auth @@ -44,7 +38,7 @@ clouds: demo: # must specify API version here - identity_api_version: "{{ openrc.OS_IDENTITY_API_VERSION }}" + identity_api_version: "{{ openrc.OS_IDENTITY_API_VERSION|default(3) }}" auth: "{{ os_auth }}" - template: diff --git a/ansible/roles/create_storperf_admin_rc/tasks/main.yml b/ansible/roles/create_storperf_admin_rc/tasks/main.yml index bd1418e89..f63d1d814 100644 --- a/ansible/roles/create_storperf_admin_rc/tasks/main.yml +++ b/ansible/roles/create_storperf_admin_rc/tasks/main.yml @@ -12,15 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. --- -- name: Fetch TENANT_ID - os_project_facts: - name: admin - environment: "{{ openrc }}" - -- name: Fetch TENANT_ID - set_fact: - os_tenant_id: "{{ openstack_projects[0].id }}" - - name: Create storperf_admin-rc template: src: storperf_admin-rc.j2 diff --git a/ansible/roles/create_storperf_admin_rc/templates/storperf_admin-rc.j2 b/ansible/roles/create_storperf_admin_rc/templates/storperf_admin-rc.j2 index 410ab24df..888e87118 100644 --- a/ansible/roles/create_storperf_admin_rc/templates/storperf_admin-rc.j2 +++ b/ansible/roles/create_storperf_admin_rc/templates/storperf_admin-rc.j2 @@ -1,7 +1,5 @@ OS_AUTH_URL="{{ openrc.OS_AUTH_URL }}" OS_USERNAME="{{ openrc.OS_USERNAME|default('admin') }}" OS_PASSWORD="{{ openrc.OS_PASSWORD|default('console') }}" -OS_TENANT_NAME="{{ openrc.OS_TENANT_NAME|default('admin') }}" OS_VOLUME_API_VERSION="{{ openrc.OS_VOLUME_API_VERSION|default('2') }}" -OS_PROJECT_NAME="{{ openrc.OS_PROJECT_NAME|default(openrc.OS_TENANT_NAME) }}" -OS_TENANT_ID="{{ os_tenant_id }}" +OS_PROJECT_NAME="{{ openrc.OS_PROJECT_NAME|openrc.OS_TENANT_NAME|default('admin') }}" diff --git a/docs/testing/user/userguide/04-installation.rst b/docs/testing/user/userguide/04-installation.rst index 5bb64e3bb..cac814667 100644 --- a/docs/testing/user/userguide/04-installation.rst +++ b/docs/testing/user/userguide/04-installation.rst @@ -172,13 +172,13 @@ Environment variables in the ``openrc`` file have to include at least:: OS_AUTH_URL OS_USERNAME OS_PASSWORD - OS_TENANT_NAME + OS_PROJECT_NAME EXTERNAL_NETWORK A sample ``openrc`` file may look like this:: export OS_PASSWORD=console - export OS_TENANT_NAME=admin + export OS_PROJECT_NAME=admin export OS_AUTH_URL=http://172.16.1.222:35357/v2.0 export OS_USERNAME=admin export OS_VOLUME_API_VERSION=2 diff --git a/docs/testing/user/userguide/05-yardstick_plugin.rst b/docs/testing/user/userguide/05-yardstick_plugin.rst index ec0b49ff1..679ce7900 100644 --- a/docs/testing/user/userguide/05-yardstick_plugin.rst +++ b/docs/testing/user/userguide/05-yardstick_plugin.rst @@ -49,7 +49,7 @@ environment and other dependencies: 3. Make sure Jump Host have access to the OpenStack Controller API. 4. Make sure Jump Host must have internet connectivity for downloading docker image. 5. You need to know where to get basic openstack Keystone authorization info, such as - OS_PASSWORD, OS_TENANT_NAME, OS_AUTH_URL, OS_USERNAME. + OS_PASSWORD, OS_PROJECT_NAME, OS_AUTH_URL, OS_USERNAME. 6. To run a Storperf container, you need to have OpenStack Controller environment variables defined and passed to Storperf container. The best way to do this is to put environment variables in a "storperf_admin-rc" file. The storperf_admin-rc @@ -58,8 +58,6 @@ environment and other dependencies: * OS_AUTH_URL * OS_USERNAME * OS_PASSWORD -* OS_TENANT_ID -* OS_TENANT_NAME * OS_PROJECT_NAME * OS_PROJECT_ID * OS_USER_DOMAIN_ID @@ -76,8 +74,9 @@ test/ci/prepare_storperf_admin-rc.sh USERNAME=${OS_USERNAME:-admin} PASSWORD=${OS_PASSWORD:-console} + # OS_TENANT_NAME is still present to keep backward compatibility with legacy + # deployments, but should be replaced by OS_PROJECT_NAME. TENANT_NAME=${OS_TENANT_NAME:-admin} - TENANT_ID=`openstack project show admin|grep '\bid\b' |awk -F '|' '{print $3}'|sed -e 's/^[[:space:]]*//'` PROJECT_NAME=${OS_PROJECT_NAME:-$TENANT_NAME} PROJECT_ID=`openstack project show admin|grep '\bid\b' |awk -F '|' '{print $3}'|sed -e 's/^[[:space:]]*//'` USER_DOMAIN_ID=${OS_USER_DOMAIN_ID:-default} @@ -90,8 +89,6 @@ test/ci/prepare_storperf_admin-rc.sh echo "OS_PASSWORD="$PASSWORD >> ~/storperf_admin-rc echo "OS_PROJECT_NAME="$PROJECT_NAME >> ~/storperf_admin-rc echo "OS_PROJECT_ID="$PROJECT_ID >> ~/storperf_admin-rc - echo "OS_TENANT_NAME="$TENANT_NAME >> ~/storperf_admin-rc - echo "OS_TENANT_ID="$TENANT_ID >> ~/storperf_admin-rc echo "OS_USER_DOMAIN_ID="$USER_DOMAIN_ID >> ~/storperf_admin-rc diff --git a/docs/testing/user/userguide/08-api.rst b/docs/testing/user/userguide/08-api.rst index ff6e62228..92fa408c8 100644 --- a/docs/testing/user/userguide/08-api.rst +++ b/docs/testing/user/userguide/08-api.rst @@ -252,7 +252,6 @@ Example:: "OS_PASSWORD": "console", "OS_PROJECT_DOMAIN_NAME": "default", "OS_PROJECT_NAME": "admin", - "OS_TENANT_NAME": "admin", "OS_USERNAME": "admin", "OS_USER_DOMAIN_NAME": "default" }, diff --git a/gui/app/scripts/controllers/main.js b/gui/app/scripts/controllers/main.js index ceec83fa9..dc5c32670 100644 --- a/gui/app/scripts/controllers/main.js +++ b/gui/app/scripts/controllers/main.js @@ -107,7 +107,7 @@ angular.module('yardStickGui2App') $scope.envInfo = [ { name: 'OS_USERNAME', value: '' }, { name: 'OS_PASSWORD', value: '' }, - { name: 'OS_TENANT_NAME', value: '' }, + { name: 'OS_PROJECT_NAME', value: '' }, { name: 'EXTERNAL_NETWORK', value: '' } ]; @@ -298,7 +298,7 @@ angular.module('yardStickGui2App') $scope.envInfo = [ { name: 'OS_USERNAME', value: '' }, { name: 'OS_PASSWORD', value: '' }, - { name: 'OS_TENANT_NAME', value: '' }, + { name: 'OS_PROJECT_NAME', value: '' }, { name: 'EXTERNAL_NETWORK', value: '' } ]; $scope.displayOpenrcFile = null; diff --git a/tests/ci/prepare_storperf_admin-rc.sh b/tests/ci/prepare_storperf_admin-rc.sh index 558375e62..ef7c2297e 100755 --- a/tests/ci/prepare_storperf_admin-rc.sh +++ b/tests/ci/prepare_storperf_admin-rc.sh @@ -15,8 +15,9 @@ AUTH_URL=${OS_AUTH_URL} USERNAME=${OS_USERNAME:-admin} PASSWORD=${OS_PASSWORD:-console} +# OS_TENANT_NAME is still present to keep backward compatibility with legacy +# deployments, but should be replaced by OS_PROJECT_NAME. TENANT_NAME=${OS_TENANT_NAME:-admin} -TENANT_ID=`openstack project show admin|grep '\bid\b' |awk -F '|' '{print $3}'|sed -e 's/^[[:space:]]*//'` PROJECT_NAME=${OS_PROJECT_NAME:-$TENANT_NAME} PROJECT_ID=`openstack project show admin|grep '\bid\b' |awk -F '|' '{print $3}'|sed -e 's/^[[:space:]]*//'` @@ -30,8 +31,6 @@ echo "OS_USERNAME="$USERNAME >> ~/storperf_admin-rc echo "OS_PASSWORD="$PASSWORD >> ~/storperf_admin-rc echo "OS_PROJECT_NAME="$PROJECT_NAME >> ~/storperf_admin-rc echo "OS_PROJECT_ID="$PROJECT_ID >> ~/storperf_admin-rc -echo "OS_TENANT_NAME="$TENANT_NAME >> ~/storperf_admin-rc -echo "OS_TENANT_ID="$TENANT_ID >> ~/storperf_admin-rc echo "OS_USER_DOMAIN_ID="$USER_DOMAIN_ID >> ~/storperf_admin-rc echo "OS_PROJECT_DOMAIN_NAME="$OS_PROJECT_DOMAIN_NAME >> ~/storperf_admin-rc echo "OS_USER_DOMAIN_NAME="$OS_USER_DOMAIN_NAME >> ~/storperf_admin-rc diff --git a/yardstick/benchmark/scenarios/networking/sfc_openstack.py b/yardstick/benchmark/scenarios/networking/sfc_openstack.py index d5feabbbe..aaab2131a 100644 --- a/yardstick/benchmark/scenarios/networking/sfc_openstack.py +++ b/yardstick/benchmark/scenarios/networking/sfc_openstack.py @@ -34,11 +34,13 @@ def get_credentials(service): # pragma: no cover # The most common way to pass these info to the script is to do it through # environment variables. + # NOTE(ralonsoh): OS_TENANT_NAME is deprecated. + project_name = os.environ.get('OS_PROJECT_NAME', 'admin') creds.update({ "username": os.environ.get('OS_USERNAME', "admin"), password: os.environ.get("OS_PASSWORD", 'admin'), "auth_url": os.environ.get("OS_AUTH_URL"), - tenant: os.environ.get("OS_TENANT_NAME", "admin"), + tenant: os.environ.get("OS_TENANT_NAME", project_name), }) cacert = os.environ.get("OS_CACERT") if cacert is not None: @@ -59,7 +61,7 @@ def get_instances(nova_client): # pragma: no cover try: instances = nova_client.servers.list(search_opts={'all_tenants': 1}) return instances - except Exception as e: + except Exception as e: # pylint: disable=broad-except print("Error [get_instances(nova_client)]:", e) return None @@ -72,7 +74,7 @@ def get_SFs(nova_client): # pragma: no cover if "sfc_test" not in instance.name: SFs.append(instance) return SFs - except Exception as e: + except Exception as e: # pylint: disable=broad-except print("Error [get_SFs(nova_client)]:", e) return None @@ -93,7 +95,7 @@ def create_floating_ips(neutron_client): # pragma: no cover ip_json = neutron_client.create_floatingip({'floatingip': props}) fip_addr = ip_json['floatingip']['floating_ip_address'] ips.append(fip_addr) - except Exception as e: + except Exception as e: # pylint: disable=broad-except print("Error [create_floating_ip(neutron_client)]:", e) return None return ips @@ -106,7 +108,7 @@ def floatIPtoSFs(SFs, floatips): # pragma: no cover SF.add_floating_ip(floatips[i]) i = i + 1 return True - except Exception as e: + except Exception as e: # pylint: disable=broad-except print(("Error [add_floating_ip(nova_client, '%s', '%s')]:" % (SF, floatips[i]), e)) return False @@ -122,7 +124,3 @@ def get_an_IP(): # pragma: no cover floatips = create_floating_ips(neutron_client) floatIPtoSFs(SFs, floatips) return floatips - - -if __name__ == '__main__': # pragma: no cover - get_an_IP() diff --git a/yardstick/common/openstack_utils.py b/yardstick/common/openstack_utils.py index 8f666e268..e3f67baa5 100644 --- a/yardstick/common/openstack_utils.py +++ b/yardstick/common/openstack_utils.py @@ -33,38 +33,22 @@ DEFAULT_API_VERSION = '2' # CREDENTIALS # ********************************************* def get_credentials(): - """Returns a creds dictionary filled with parsed from env""" - creds = {} - - keystone_api_version = os.getenv('OS_IDENTITY_API_VERSION') - - if keystone_api_version is None or keystone_api_version == '2': - keystone_v3 = False - tenant_env = 'OS_TENANT_NAME' - tenant = 'tenant_name' - else: - keystone_v3 = True - tenant_env = 'OS_PROJECT_NAME' - tenant = 'project_name' - - # The most common way to pass these info to the script is to do it - # through environment variables. - creds.update({ - "username": os.environ.get("OS_USERNAME"), - "password": os.environ.get("OS_PASSWORD"), - "auth_url": os.environ.get("OS_AUTH_URL"), - tenant: os.environ.get(tenant_env) - }) - - if keystone_v3: - if os.getenv('OS_USER_DOMAIN_NAME') is not None: - creds.update({ - "user_domain_name": os.getenv('OS_USER_DOMAIN_NAME') - }) - if os.getenv('OS_PROJECT_DOMAIN_NAME') is not None: - creds.update({ - "project_domain_name": os.getenv('OS_PROJECT_DOMAIN_NAME') - }) + """Returns a creds dictionary filled with parsed from env + + Keystone API version used is 3; v2 was deprecated in 2014 (Icehouse). Along + with this deprecation, environment variable 'OS_TENANT_NAME' is replaced by + 'OS_PROJECT_NAME'. + """ + creds = {'username': os.environ.get('OS_USERNAME'), + 'password': os.environ.get('OS_PASSWORD'), + 'auth_url': os.environ.get('OS_AUTH_URL'), + 'project_name': os.environ.get('OS_PROJECT_NAME') + } + + if os.getenv('OS_USER_DOMAIN_NAME'): + creds['user_domain_name'] = os.getenv('OS_USER_DOMAIN_NAME') + if os.getenv('OS_PROJECT_DOMAIN_NAME'): + creds['project_domain_name'] = os.getenv('OS_PROJECT_DOMAIN_NAME') return creds @@ -294,8 +278,7 @@ def create_instance_and_wait_for_active(json_body): # pragma: no cover VM_BOOT_TIMEOUT = 180 nova_client = get_nova_client() instance = create_instance(json_body) - count = VM_BOOT_TIMEOUT / SLEEP - for _ in range(count, -1, -1): + for _ in range(int(VM_BOOT_TIMEOUT / SLEEP)): status = get_instance_status(nova_client, instance) if status.lower() == "active": return instance -- cgit 1.2.3-korg