diff --git a/config.json.sample b/config.json.sample new file mode 100644 index 00000000..950ef5a4 --- /dev/null +++ b/config.json.sample @@ -0,0 +1,48 @@ +{ + "app_address": "x.x.x.x:8000", + + "test_mode": "DOCKER", + + "tempest_url": + "https://github.com/openstack/tempest/archive/stable/havana.zip", + + "tempest_config": + { + "identity": + { + "uri": "http://x.x.x.x:5000/v2.0/", + "uri_v3": "http://x.x.x.x:5000/v3/", + "region": "RegionOne", + "username": "demo", + "tenant_name": "demo", + "alt_username": "alt_demo", + "alt_tenant_name": "alt_demo", + "admin_username": "admin", + "admin_tenant_name": "admin" + }, + "compute": + { + "image_ref": "a8d70acb-f1c4-4171-b0ce-d73e5de21a9d", + "image_ref_alt": "6182b1da-e64d-4440-b0ef-c0afa4d77abb", + "flavor_ref": "1", + "flavor_ref_alt": "1", + "image_ssh_user": "root", + "image_ssh_password": "password", + "image_alt_ssh_user": "root", + "image_alt_ssh_password": "password" + }, + "cli": + { + "enable": "False" + } + }, + + "tempest_testcases": + { + "testcases": + [ + "tempest.api.compute.admin.test_flavors", + "tempest.api.compute.admin.test_availability_zone" + ] + } +} diff --git a/refstack/refstack_config.py b/refstack/refstack_config.py new file mode 100644 index 00000000..a99d7679 --- /dev/null +++ b/refstack/refstack_config.py @@ -0,0 +1,62 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2014 IBM Corp. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import json +import os.path +from refstack.utils import INSTANCE_FOLDER_PATH + + +class RefStackConfig(object): + '''Utility class to process config file.''' + + refstack_config = {} + + config_file_name = os.path.join(INSTANCE_FOLDER_PATH, 'config.json') + + working_dir = os.path.join(INSTANCE_FOLDER_PATH, 'tmpfiles') + + def __init__(self, file_name=None): + '''Load the JSON data from the config file.''' + if file_name: + self.config_file_name = file_name + if os.path.isfile(self.config_file_name): + self.refstack_config = json.load(open(self.config_file_name)) + if not os.path.exists(self.working_dir): + os.makedirs(self.working_dir) + + def get_working_dir(self): + '''Return working directory.''' + return self.working_dir + + def get_app_address(self): + '''Return address of the Web App server.''' + return self.refstack_config["app_address"] + + def get_tempest_url(self): + '''Return the URL for tempest test code download.''' + return self.refstack_config["tempest_url"] + + def get_tempest_config(self): + '''Return customized tempest config parameters.''' + return self.refstack_config["tempest_config"] + + def get_tempest_testcases(self): + '''Return a JSON of tempest testcase.''' + return self.refstack_config["tempest_testcases"] + + def get_test_mode(self): + '''Return the tempest test mode.''' + return self.refstack_config["test_mode"]