Add tenant_id getting in integration tests

Added ability to get Tenant id if it is not specified in parameters.

Change-Id: I64f80de94a3b4392506ce31a93b4490c14f1ef4c
Closes-bug: 1301466
This commit is contained in:
Vadim Rovachev 2014-04-02 20:10:53 +04:00
parent 1976adcfeb
commit 19a025a609
4 changed files with 13 additions and 9 deletions

View File

@ -22,9 +22,6 @@ In this case all tests will be launched except disabled tests.
Tests can be disabled in the ``/sahara/tests/integration/configs/config.py``
file or in the ``/sahara/tests/integration/configs/itest.conf``.
**NOTE:** Both ``OS_TENANT_ID`` and ``OS_TENANT_NAME`` must be specified in the
config file.
If you want to run integration tests for one plugin, you should use the
corresponding tox env:

View File

@ -43,9 +43,6 @@ COMMON_CONFIG_OPTS = [
cfg.StrOpt('OS_TENANT_NAME',
default='admin',
help='Tenant name for OpenStack.'),
cfg.StrOpt('OS_TENANT_ID',
default=None,
help='Tenant ID for OpenStack.'),
cfg.StrOpt('OS_AUTH_URL',
default='http://127.0.0.1:5000/v2.0',
help='URL for OpenStack.'),

View File

@ -9,9 +9,6 @@
# Tenant name for OpenStack (string value)
#OS_TENANT_NAME = 'admin'
# Tenant ID for OpenStack (string value)
#OS_TENANT_ID = <None>
# URL for OpenStack (string value)
#OS_AUTH_URL = 'http://127.0.0.1:5000/v2.0'

View File

@ -19,6 +19,7 @@ import telnetlib
import time
import uuid
from keystoneclient.v2_0 import client as keystone_client
from neutronclient.v2_0 import client as neutron_client
from novaclient.v1_1 import client as nova_client
import saharaclient.client as sahara_client
@ -82,6 +83,18 @@ class ITestCase(testtools.TestCase, testtools.testcase.WithAttributes,
self.common_config.SAHARA_HOST, self.common_config.SAHARA_PORT
)
keystone = keystone_client.Client(
username=self.common_config.OS_USERNAME,
password=self.common_config.OS_PASSWORD,
tenant_name=self.common_config.OS_TENANT_NAME,
auth_url=self.common_config.OS_AUTH_URL)
keystone.management_url = self.common_config.OS_AUTH_URL
self.common_config.OS_TENANT_ID = [
tenant.id for tenant in keystone.tenants.list()
if tenant.name == self.common_config.OS_TENANT_NAME][0]
self.sahara = sahara_client.Client(
version=self.common_config.SAHARA_API_VERSION,
username=self.common_config.OS_USERNAME,