import os_client_config
import shade
+from tempest.lib.common.utils import data_utils
from xtesting.core import testcase
from functest.utils import config
from functest.utils import env
+from functest.utils import functest_utils
-class NewProject(object):
+class NewProject():
"""Ease creating new projects/users"""
# pylint: disable=too-many-instance-attributes
"""Create projects/users"""
assert self.orig_cloud
assert self.case_name
- self.password = str(uuid.uuid4())
+ self.password = data_utils.rand_password().replace('%', '!')
+ self.__logger.debug("password: %s", self.password)
self.domain = self.orig_cloud.get_domain(
name_or_id=self.orig_cloud.auth.get(
"project_domain_name", "Default"))
cloud_config=osconfig.get_one_cloud())
self.__logger.debug("new cloud %s", self.cloud.auth)
+ def get_environ(self):
+ "Get new environ"
+ environ = dict(
+ os.environ,
+ OS_USERNAME=self.user.name,
+ OS_PROJECT_NAME=self.project.name,
+ OS_PROJECT_ID=self.project.id,
+ OS_PASSWORD=self.password)
+ try:
+ del environ['OS_TENANT_NAME']
+ del environ['OS_TENANT_ID']
+ except Exception: # pylint: disable=broad-except
+ pass
+ return environ
+
def clean(self):
"""Remove projects/users"""
try:
__logger = logging.getLogger(__name__)
cidr = '192.168.120.0/24'
shared_network = False
+ allow_no_fip = False
def __init__(self, **kwargs):
if "case_name" not in kwargs:
try:
self.ext_net = self.get_external_network(self.cloud)
except Exception: # pylint: disable=broad-except
+ self.ext_net = None
self.__logger.exception("Cannot get the external network")
self.guid = str(uuid.uuid4())
self.network = None
@staticmethod
def get_public_auth_url(cloud):
"""Get Keystone public endpoint"""
- keystone_id = cloud.search_services('keystone')[0].id
+ keystone_id = functest_utils.search_services(cloud, 'keystone')[0].id
endpoint = cloud.search_endpoints(
filters={'interface': 'public',
'service_id': keystone_id})[0].url
Raises: expection on error
"""
assert self.cloud
- assert self.ext_net
+ if not self.allow_no_fip:
+ assert self.ext_net
provider = {}
if hasattr(config.CONF, '{}_network_type'.format(self.case_name)):
provider["network_type"] = getattr(
self.router = self.cloud.create_router(
name='{}-router_{}'.format(self.case_name, self.guid),
- ext_gateway_net_id=self.ext_net.id)
+ ext_gateway_net_id=self.ext_net.id if self.ext_net else None)
self.__logger.debug("router: %s", self.router)
self.cloud.add_router_interface(self.router, subnet_id=self.subnet.id)