Refactor to support changes made in engine config overhaul
* Updated all files to reflect changes in engine configuration overhaul. * Cleaned up post-install processes and improved post-install reporting of where configs are being copied to. * Moved ConfigSectionInterface class to opencafe Change-Id: If0ddf88563c3ff7cf9971221e19b5f4666db295f
This commit is contained in:
parent
fb4e181779
commit
c9227f7920
1
MANIFEST.in
Normal file
1
MANIFEST.in
Normal file
@ -0,0 +1 @@
|
|||||||
|
include LICENSE README*
|
@ -15,8 +15,6 @@ limitations under the License.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
__title__ = 'cloudcafe'
|
__title__ = 'cloudcafe'
|
||||||
__version__ = '0.0.1'
|
|
||||||
#__build__ = 0x010100
|
|
||||||
__author__ = 'Rackspace Cloud QE'
|
__author__ = 'Rackspace Cloud QE'
|
||||||
__license__ = 'Internal Only'
|
__license__ = 'Apache License Version 2.0'
|
||||||
__copyright__ = 'Copyright 2013 Rackspace Inc.'
|
__copyright__ = 'Copyright 2013 Rackspace Inc.'
|
||||||
|
@ -14,36 +14,5 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
|
||||||
from cafe.engine.models.data_interfaces import\
|
from cafe.engine.models.data_interfaces import\
|
||||||
BaseConfigSectionInterface, ConfigEnvironmentVariableError
|
ConfigSectionInterface
|
||||||
|
|
||||||
_TEST_CONFIG_FILE_ENV_VAR = 'CONFIG_FILE'
|
|
||||||
|
|
||||||
|
|
||||||
class ConfigSectionInterface(BaseConfigSectionInterface):
|
|
||||||
def __init__(self, config_file_path=None, section_name=None):
|
|
||||||
section_name = (section_name or
|
|
||||||
getattr(self, 'SECTION_NAME', None) or
|
|
||||||
getattr(self, 'CONFIG_SECTION_NAME', None))
|
|
||||||
|
|
||||||
config_file_path = config_file_path or self.default_config_file
|
|
||||||
|
|
||||||
super(ConfigSectionInterface, self).__init__(config_file_path,
|
|
||||||
section_name)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def default_config_file(self):
|
|
||||||
test_config_file_path = None
|
|
||||||
try:
|
|
||||||
test_config_file_path = os.environ[_TEST_CONFIG_FILE_ENV_VAR]
|
|
||||||
except KeyError:
|
|
||||||
msg = "'{0}' environment variable was not set.".format(
|
|
||||||
_TEST_CONFIG_FILE_ENV_VAR)
|
|
||||||
raise ConfigEnvironmentVariableError(msg)
|
|
||||||
except Exception as exception:
|
|
||||||
print ("Unexpected exception when attempting to access '{1}'"
|
|
||||||
" environment variable.".format(_TEST_CONFIG_FILE_ENV_VAR))
|
|
||||||
raise exception
|
|
||||||
|
|
||||||
return test_config_file_path
|
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
# Configure path for py.test
|
# Configure path for py.test
|
||||||
import os
|
import os
|
||||||
|
|
||||||
os.environ["CCTNG_CONFIG_FILE"] = os.path.join(
|
os.environ["OPENCAFE_ENGINE_CONFIG_FILE"] = os.path.join(
|
||||||
os.path.dirname(__file__),
|
os.path.dirname(__file__),
|
||||||
"unittest.json.config"
|
"unittest.engine.config"
|
||||||
)
|
)
|
||||||
os.environ["MOCK"] = 'True'
|
|
||||||
|
|
||||||
os.environ["OSTNG_CONFIG_FILE"] = os.path.join(
|
os.environ["MOCK"] = 'True'
|
||||||
os.path.dirname(__file__),
|
|
||||||
"unittest.json.config"
|
|
||||||
)
|
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
[CCTNG_ENGINE]
|
[OPENCAFE_ENGINE]
|
||||||
use_verbose_logging=false
|
use_verbose_logging=false
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
httpretty
|
httpretty
|
||||||
mock
|
mock
|
||||||
unittest2
|
unittest2
|
||||||
IPy
|
IPy
|
170
setup.py
170
setup.py
@ -16,44 +16,116 @@ limitations under the License.
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import cloudcafe
|
|
||||||
import platform
|
|
||||||
import shutil
|
import shutil
|
||||||
|
import textwrap
|
||||||
|
|
||||||
# These imports are only possible on Linux/OSX
|
|
||||||
if platform.system().lower() != 'windows':
|
|
||||||
import pwd
|
|
||||||
import grp
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
from setuptools.command.install import install as _install
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from distutils.core import setup, find_packages
|
from distutils.core import setup, find_packages
|
||||||
|
from distutils.command.install import install as _install
|
||||||
|
|
||||||
if sys.argv[-1] == 'publish':
|
if sys.argv[-1] == 'publish':
|
||||||
os.system('python setup.py sdist upload')
|
os.system('python setup.py sdist upload')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
requires = open('pip-requires').readlines()
|
|
||||||
|
|
||||||
|
def print_cafe_mug():
|
||||||
|
print('\n'.join(["\t\t _ _ _",
|
||||||
|
"\t\t ( ` )_ ",
|
||||||
|
"\t\t ( ) `) _",
|
||||||
|
"\t\t(____(__.___`)__)",
|
||||||
|
"\t\t",
|
||||||
|
"\t\t ( (",
|
||||||
|
"\t\t ) )",
|
||||||
|
"\t\t ......... ",
|
||||||
|
"\t\t | |___ ",
|
||||||
|
"\t\t | |_ |",
|
||||||
|
"\t\t | :-) |_| |",
|
||||||
|
"\t\t | |___|",
|
||||||
|
"\t\t |_______|",
|
||||||
|
"\t\t=== CloudCAFE ==="]))
|
||||||
|
print("========================================================")
|
||||||
|
print("CloudCAFE Framework installed")
|
||||||
|
print("========================================================")
|
||||||
|
|
||||||
|
|
||||||
|
def install_default_configs():
|
||||||
|
from cafe.configurator.managers import (
|
||||||
|
EngineDirectoryManager, PlatformManager)
|
||||||
|
|
||||||
|
opencafe_root_dir = EngineDirectoryManager.OPENCAFE_ROOT_DIR
|
||||||
|
|
||||||
|
twrap = textwrap.TextWrapper(
|
||||||
|
initial_indent='* ', subsequent_indent=' ', break_long_words=False)
|
||||||
|
print twrap.fill(
|
||||||
|
'Installing reference configuration files in ...'.format(
|
||||||
|
opencafe_root_dir))
|
||||||
|
|
||||||
|
twrap = textwrap.TextWrapper(
|
||||||
|
initial_indent=' ', subsequent_indent=' ', break_long_words=False)
|
||||||
|
|
||||||
|
_printed = []
|
||||||
|
for root, subFolders, files in os.walk('configs'):
|
||||||
|
for file_ in files:
|
||||||
|
source = os.path.join(root, file_)
|
||||||
|
destination_dir = os.path.join(opencafe_root_dir, root)
|
||||||
|
destination_file = os.path.join(destination_dir, file_)
|
||||||
|
|
||||||
|
try:
|
||||||
|
#Create the expected directory structure if it doesn't already
|
||||||
|
#exist.
|
||||||
|
os.makedirs(destination_dir)
|
||||||
|
print twrap.fill('Creating path: {0}'.format(destination_dir))
|
||||||
|
except OSError:
|
||||||
|
#File exsits. This is ok and expected.
|
||||||
|
pass
|
||||||
|
|
||||||
|
shutil.copyfile(source, destination_file)
|
||||||
|
if destination_dir not in _printed:
|
||||||
|
print twrap.fill('{0}'.format(destination_dir))
|
||||||
|
_printed.append(destination_dir)
|
||||||
|
|
||||||
|
if not PlatformManager.USING_WINDOWS:
|
||||||
|
uid = PlatformManager.get_user_uid()
|
||||||
|
gid = PlatformManager.get_user_gid()
|
||||||
|
os.chown(destination_file, uid, gid)
|
||||||
|
|
||||||
|
|
||||||
|
#Post-install engine configuration
|
||||||
|
def _post_install(dir):
|
||||||
|
install_default_configs()
|
||||||
|
print_cafe_mug()
|
||||||
|
|
||||||
|
|
||||||
|
class install(_install):
|
||||||
|
def run(self):
|
||||||
|
_install.run(self)
|
||||||
|
self.execute(
|
||||||
|
_post_install, (self.install_lib,),
|
||||||
|
msg="Running post install tasks...")
|
||||||
|
|
||||||
|
|
||||||
|
requires = open('pip-requires').readlines()
|
||||||
setup(
|
setup(
|
||||||
name='cloudcafe',
|
name='cloudcafe',
|
||||||
version=cloudcafe.__version__,
|
version='0.0.1',
|
||||||
description='CloudCAFE is an implementation of the Open CAFE Framework specifically designed to test deployed versions of OpenStack',
|
description=(
|
||||||
|
'CloudCAFE is an implementation of the Open CAFE Framework '
|
||||||
|
'specifically designed to test deployed versions of OpenStack'),
|
||||||
long_description='{0}\n\n{1}'.format(
|
long_description='{0}\n\n{1}'.format(
|
||||||
open('README.md').read(),
|
open('README.md').read(),
|
||||||
open('HISTORY.rst').read()),
|
open('HISTORY.rst').read()),
|
||||||
author='Rackspace Cloud QE',
|
author='Rackspace Cloud QE',
|
||||||
author_email='cloud-cafe@lists.rackspace.com',
|
author_email='cloud-cafe@lists.rackspace.com',
|
||||||
url='http://rackspace.com',
|
url='http://rackspace.com',
|
||||||
packages=find_packages(exclude=[]),
|
packages=find_packages(),
|
||||||
package_data={'': ['LICENSE', 'NOTICE']},
|
|
||||||
package_dir={'cloudcafe': 'cloudcafe'},
|
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
install_requires=requires,
|
install_requires=requires,
|
||||||
license=open('LICENSE').read(),
|
license=open('LICENSE').read(),
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
#https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
|
||||||
classifiers=(
|
classifiers=(
|
||||||
'Development Status :: 1 - Planning',
|
'Development Status :: 1 - Planning',
|
||||||
'Intended Audience :: Developers',
|
'Intended Audience :: Developers',
|
||||||
@ -62,73 +134,5 @@ setup(
|
|||||||
'Operating System :: POSIX :: Linux',
|
'Operating System :: POSIX :: Linux',
|
||||||
'Programming Language :: Python',
|
'Programming Language :: Python',
|
||||||
'Programming Language :: Python :: 2.6',
|
'Programming Language :: Python :: 2.6',
|
||||||
'Programming Language :: Python :: 2.7',
|
'Programming Language :: Python :: 2.7',),
|
||||||
#'Programming Language :: Python :: 3',
|
cmdclass={'install': install})
|
||||||
#'Programming Language :: Python :: 3.0',
|
|
||||||
#'Programming Language :: Python :: 3.1',
|
|
||||||
#'Programming Language :: Python :: 3.2',
|
|
||||||
#'Programming Language :: Python :: 3.3',
|
|
||||||
)
|
|
||||||
)
|
|
||||||
# real_prefix should only be set under a virtualenv
|
|
||||||
using_virtualenv = hasattr(sys, 'real_prefix')
|
|
||||||
|
|
||||||
''' @todo: need to clean this up or do it with puppet/chef '''
|
|
||||||
# Default Config Options
|
|
||||||
root_dir = "{0}/.cloudcafe".format(os.path.expanduser("~"))
|
|
||||||
config_dir = "{0}/configs".format(root_dir)
|
|
||||||
|
|
||||||
# Build Default directories
|
|
||||||
if(os.path.exists("{0}/engine.config".format(config_dir)) == False):
|
|
||||||
raise Exception("Core CAFE Engine configuration not found")
|
|
||||||
else:
|
|
||||||
# Copy over the default configurations
|
|
||||||
if(os.path.exists("~install")):
|
|
||||||
os.remove("~install")
|
|
||||||
# Report
|
|
||||||
print('\n'.join(["\t\t _ _ _",
|
|
||||||
"\t\t ( ` )_ ",
|
|
||||||
"\t\t ( ) `) _",
|
|
||||||
"\t\t(____(__.___`)__)",
|
|
||||||
"\t\t",
|
|
||||||
"\t\t ( (",
|
|
||||||
"\t\t ) )",
|
|
||||||
"\t\t ......... ",
|
|
||||||
"\t\t | |___ ",
|
|
||||||
"\t\t | |_ |",
|
|
||||||
"\t\t | :-) |_| |",
|
|
||||||
"\t\t | |___|",
|
|
||||||
"\t\t |_______|",
|
|
||||||
"\t\t=== CloudCAFE ==="]))
|
|
||||||
print("========================================================")
|
|
||||||
print("CloudCAFE Framework installed")
|
|
||||||
print("========================================================")
|
|
||||||
else:
|
|
||||||
# State file
|
|
||||||
temp = open("~install", "w")
|
|
||||||
temp.close()
|
|
||||||
|
|
||||||
# Get uid and gid of the current user to set permissions (Linux/OSX only)
|
|
||||||
if platform.system().lower() != 'windows':
|
|
||||||
if using_virtualenv:
|
|
||||||
working_user = os.getenv("USER")
|
|
||||||
else:
|
|
||||||
working_user = os.getenv("SUDO_USER")
|
|
||||||
|
|
||||||
uid = pwd.getpwnam(working_user).pw_uid
|
|
||||||
gid = pwd.getpwnam(working_user).pw_gid
|
|
||||||
|
|
||||||
config_dirs = os.listdir("configs")
|
|
||||||
for dir in config_dirs:
|
|
||||||
if not os.path.exists("{0}/{1}".format(config_dir, dir)):
|
|
||||||
print("Installing configurations for: {0}".format("{0}/{1}".format(config_dir, dir)))
|
|
||||||
os.makedirs("{0}/{1}".format(config_dir, dir))
|
|
||||||
# Fix the directory permissions
|
|
||||||
if platform.system().lower() != 'windows':
|
|
||||||
os.chown("{0}/{1}".format(config_dir, dir), uid, gid)
|
|
||||||
for file in os.listdir("configs/{0}".format(dir)):
|
|
||||||
print("Installing {0}/{1}/{2}".format(config_dir, dir, file))
|
|
||||||
shutil.copy2("configs/{0}/{1}".format(dir, file), "{0}/{1}/{2}".format(config_dir, dir, file))
|
|
||||||
# Fix the directory permissions
|
|
||||||
if platform.system().lower() != 'windows':
|
|
||||||
os.chown("{0}/{1}/{2}".format(config_dir, dir, file), uid, gid)
|
|
||||||
|
2
unittest.engine.config
Normal file
2
unittest.engine.config
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[OPENCAFE_ENGINE]
|
||||||
|
logging_verbosity = STANDARD
|
@ -1,2 +0,0 @@
|
|||||||
[CCTNG_ENGINE]
|
|
||||||
use_verbose_logging = false
|
|
Loading…
x
Reference in New Issue
Block a user