diff --git a/.gitignore b/.gitignore index 2ecd2600..7e6e7548 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ +.testrepository/ .coverage .cache nosetests.xml @@ -51,7 +52,8 @@ coverage.xml *.log # Sphinx documentation -docs/_build/ +doc/build +doc/source/api # PyBuilder target/ diff --git a/.gitreview b/.gitreview new file mode 100644 index 00000000..806b68a6 --- /dev/null +++ b/.gitreview @@ -0,0 +1,4 @@ +[gerrit] +host=review.openstack.org +port=29418 +project=stackforge/cue.git diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 00000000..a83ff9a4 --- /dev/null +++ b/.testr.conf @@ -0,0 +1,4 @@ +[DEFAULT] +test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} OS_TEST_TIMEOUT=60 ${PYTHON:-python} -m subunit.run discover -t ./ ${TESTS_DIR:-./cue/tests/} $LISTOPT $IDOPTION +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 00000000..9ea237e3 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,23 @@ +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + config.vm.provider "virtualbox" do |v| + v.memory = 1024 + v.cpus = 2 + end + config.vm.box = "ubuntu/trusty64" + config.vm.network "forwarded_port", guest: 8795, host: 8795 + + config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" + # Install tmate + config.vm.provision "shell", inline: "sudo apt-get install python-software-properties && sudo add-apt-repository ppa:nviennot/tmate && sudo apt-get update && sudo apt-get install tmate" + + # Install dependencies and remove anything unnecessary + config.vm.provision "shell", inline: "apt-get install -y build-essential git libmysqlclient-dev python-tox python-dev libxml2-dev libxslt1-dev libffi-dev libssl-dev gettext" + config.vm.provision "shell", inline: "apt-get autoremove -y" + + # Initialize project and environment + config.vm.provision "shell", inline: "pushd /vagrant && tox" + config.vm.provision "shell", inline: "echo 'source /vagrant/.tox/py27/bin/activate' >> ~vagrant/.profile" + config.vm.provision "shell", inline: "sudo -u vagrant python setup.py develop" +end diff --git a/cue/api/__init__.py b/cue/api/__init__.py index ac0c5126..87a92520 100644 --- a/cue/api/__init__.py +++ b/cue/api/__init__.py @@ -1,3 +1,19 @@ +# -*- encoding: utf-8 -*- +# +# Copyright © 2014 Hewlett-Packard +# +## 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. + from oslo.config import cfg @@ -18,4 +34,4 @@ CONF = cfg.CONF opt_group = cfg.OptGroup(name='api', title='Options for the cue-api service') CONF.register_group(opt_group) -CONF.register_opts(API_SERVICE_OPTS, opt_group) \ No newline at end of file +CONF.register_opts(API_SERVICE_OPTS, opt_group) diff --git a/cue/api/app.py b/cue/api/app.py index 64128325..8434dfde 100644 --- a/cue/api/app.py +++ b/cue/api/app.py @@ -59,7 +59,6 @@ def setup_app(pecan_config=None, extra_hooks=None): app_hooks.append(hooks.AdminAuthHook()) pecan.configuration.set_config(dict(pecan_config), overwrite=True) - print pecan_config.app.root app = pecan.make_app( pecan_config.app.root, static_root=pecan_config.app.static_root, diff --git a/cue/api/hooks.py b/cue/api/hooks.py index a4c61707..5f423b66 100644 --- a/cue/api/hooks.py +++ b/cue/api/hooks.py @@ -26,7 +26,6 @@ from cue.common import policy #from cue.db import api as dbapi - class ConfigHook(hooks.PecanHook): """Attach the config object to the request so controllers can get to it.""" @@ -35,7 +34,7 @@ class ConfigHook(hooks.PecanHook): # class DBHook(hooks.PecanHook): -# """Attach the dbapi object to the request so controllers can get to it.""" +# """Attach the dbapi object to the request so controllers can get to it.""" # # def before(self, state): # state.request.dbapi = dbapi.get_instance() @@ -73,12 +72,12 @@ class ContextHook(hooks.PecanHook): domain_id = state.request.headers.get('X-User-Domain-Id') domain_name = state.request.headers.get('X-User-Domain-Name') auth_token = state.request.headers.get('X-Auth-Token') - creds = {'roles': state.request.headers.get('X-Roles', '').split(',')} + #creds = {'roles': state.request.headers.get('X-Roles', '').split(',')} is_public_api = state.request.environ.get('is_public_api', False) #is_admin = policy.check('admin', state.request.headers, creds) - #TODO (dagnello): temp workaround to disably policy check for now + #TODO(dagnello): temp workaround to disably policy check for now is_admin = True state.request.context = context.RequestContext( @@ -92,7 +91,7 @@ class ContextHook(hooks.PecanHook): # class RPCHook(hooks.PecanHook): -# """Attach the rpcapi object to the request so controllers can get to it.""" +# """Attach the rpcapi object to the request so controllers can get to it.""" # # def before(self, state): # state.request.rpcapi = rpcapi.ConductorAPI() diff --git a/cue/api/middleware/auth_token.py b/cue/api/middleware/auth_token.py index b7ec1cfa..ed11aba2 100644 --- a/cue/api/middleware/auth_token.py +++ b/cue/api/middleware/auth_token.py @@ -17,7 +17,7 @@ import re from keystonemiddleware import auth_token from cue.common import exception -from cue.common.i18n import _ +from cue.common.i18n import _ # noqa from cue.common import utils from cue.openstack.common import log diff --git a/cue/api/middleware/parsable_error.py b/cue/api/middleware/parsable_error.py index c3ff8379..071c217e 100644 --- a/cue/api/middleware/parsable_error.py +++ b/cue/api/middleware/parsable_error.py @@ -27,8 +27,8 @@ from xml import etree as et import webob -from cue.common.i18n import _ -from cue.common.i18n import _LE +from cue.common.i18n import _ # noqa +from cue.common.i18n import _LE # noqa from cue.openstack.common import log LOG = log.getLogger(__name__) diff --git a/cue/cmd/__init__.py b/cue/cmd/__init__.py index 955c28a9..2221e754 100644 --- a/cue/cmd/__init__.py +++ b/cue/cmd/__init__.py @@ -1,4 +1,4 @@ from oslo import i18n -i18n.install('cue') \ No newline at end of file +i18n.install('cue') diff --git a/cue/cmd/api.py b/cue/cmd/api.py index acfdc39c..b0a991a3 100644 --- a/cue/cmd/api.py +++ b/cue/cmd/api.py @@ -21,14 +21,13 @@ import logging import sys from wsgiref import simple_server -from six.moves import socketserver from oslo.config import cfg - +from oslo.log import log +from six.moves import socketserver from cue.api import app -from cue.common.i18n import _LI +from cue.common.i18n import _LI # noqa from cue.common import service as cue_service -from oslo.log import log CONF = cfg.CONF diff --git a/cue/common/exception.py b/cue/common/exception.py index aa954989..92914e13 100644 --- a/cue/common/exception.py +++ b/cue/common/exception.py @@ -23,11 +23,11 @@ SHOULD include dedicated exception logging. """ from oslo.config import cfg +from oslo.log import log as logging import six -from cue.common.i18n import _ -from cue.common.i18n import _LE -from oslo.log import log as logging +from cue.common.i18n import _ # noqa +from cue.common.i18n import _LE # noqa LOG = logging.getLogger(__name__) @@ -129,4 +129,3 @@ class NodeAlreadyExists(Conflict): class ConfigurationError(CueException): message = _("Configuration Error") - diff --git a/cue/common/policy.py b/cue/common/policy.py index 3ff7d154..ab95a218 100644 --- a/cue/common/policy.py +++ b/cue/common/policy.py @@ -17,10 +17,9 @@ from oslo.config import cfg -from cue.common.i18n import _ -from cue.common.i18n import _LI from cue.common import exception -from cue.common import utils +from cue.common.i18n import _ # noqa +from cue.common.i18n import _LI # noqa from cue.openstack.common import log as logging from cue.openstack.common import policy diff --git a/cue/common/service.py b/cue/common/service.py index e161f586..ae3fc2f2 100644 --- a/cue/common/service.py +++ b/cue/common/service.py @@ -20,14 +20,8 @@ import socket import sys from oslo.config import cfg -from oslo.utils import importutils -# from cue.common import config -from cue.common.i18n import _LE -from cue.common.i18n import _LI -from cue.openstack.common import context from cue.openstack.common import log -from cue.openstack.common import service service_opts = [ cfg.IntOpt('periodic_interval', @@ -57,4 +51,3 @@ def prepare_service(argv=[]): argv = sys.argv cfg.CONF(argv[1:], project='cue') log.setup('cue') - diff --git a/cue/common/utils.py b/cue/common/utils.py index 63150f98..5f2a5cb1 100644 --- a/cue/common/utils.py +++ b/cue/common/utils.py @@ -35,9 +35,9 @@ import paramiko import six from cue.common import exception -from cue.common.i18n import _ -from cue.common.i18n import _LE -from cue.common.i18n import _LW +from cue.common.i18n import _ # noqa +from cue.common.i18n import _LE # noqa +from cue.common.i18n import _LW # noqa from cue.openstack.common import log as logging from cue.openstack.common import processutils @@ -59,6 +59,7 @@ LOG = logging.getLogger(__name__) def _get_root_helper(): return 'sudo cue-rootwrap %s' % CONF.rootwrap_config + def execute(*cmd, **kwargs): """Convenience wrapper around oslo's execute() method. diff --git a/cue/tests/__init__.py b/cue/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/cue/tests/unit/__init__.py b/cue/tests/unit/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/cue/tests/unit/base.py b/cue/tests/unit/base.py new file mode 100644 index 00000000..5d57fe5f --- /dev/null +++ b/cue/tests/unit/base.py @@ -0,0 +1,19 @@ +# Copyright 2014, Hewlett-Packard +# +# 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 testtools + + +class TestCase(testtools.TestCase): + pass \ No newline at end of file diff --git a/cue/tests/unit/common/__init__.py b/cue/tests/unit/common/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/cue/tests/unit/common/test_context.py b/cue/tests/unit/common/test_context.py new file mode 100644 index 00000000..a1b830d3 --- /dev/null +++ b/cue/tests/unit/common/test_context.py @@ -0,0 +1,23 @@ +# Copyright 2014, Hewlett-Packard +# +# 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. + +from cue.common import context +import cue.tests.unit.base as base + + +class TestConfig(base.TestCase): + + def test_sanity(self): + req_context = context.RequestContext() + req_context.to_dict() \ No newline at end of file diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100644 index 00000000..fc6f5c9c --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,268 @@ +# -*- coding: utf-8 -*- +# +# Tempest documentation build configuration file, created by +# sphinx-quickstart on Tue May 21 17:43:32 2013. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.autodoc', + 'sphinx.ext.todo', + 'sphinx.ext.viewcode', + 'sphinx.ext.graphviz', + 'oslosphinx' + ] + +todo_include_todos = True + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'Cue' +copyright = u'2014, OpenStack Cue Team' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build', 'specs/skeleton.rst', 'specs/template.rst'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +add_module_names = False + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +modindex_common_prefix = ['Cue.'] + +# -- Options for man page output ---------------------------------------------- +man_pages = [] + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'nature' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +git_cmd = "git log --pretty=format:'%ad, commit %h' --date=local -n1" +html_last_updated_fmt = os.popen(git_cmd).read() + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +html_domain_indices = False + +# If false, no index is generated. +html_use_index = False + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'Cue-Specsdoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'Cue-specs.tex', u'Cue Specs', + u'OpenStack Cue Team', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + +# -- Options for Texinfo output ------------------------------------------------ + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'Cue-specs', u'Cue Design Specs', + u'OpenStack Cue Team', 'Cue-specs', 'Design specifications for the Cue project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + + +# -- Options for Epub output --------------------------------------------------- + +# Bibliographic Dublin Core info. +epub_title = u'Cue Specs' +epub_author = u'OpenStack Cue Team' +epub_publisher = u'OpenStack Cue Team' +epub_copyright = u'2014, OpenStack Cue Team' + +# The language of the text. It defaults to the language option +# or en if the language is not set. +#epub_language = '' + +# The scheme of the identifier. Typical schemes are ISBN or URL. +#epub_scheme = '' + +# The unique identifier of the text. This can be a ISBN number +# or the project homepage. +#epub_identifier = '' + +# A unique identification for the text. +#epub_uid = '' + +# A tuple containing the cover image and cover page html template filenames. +#epub_cover = () + +# HTML files that should be inserted before the pages created by sphinx. +# The format is a list of tuples containing the path and title. +#epub_pre_files = [] + +# HTML files shat should be inserted after the pages created by sphinx. +# The format is a list of tuples containing the path and title. +#epub_post_files = [] + +# A list of files that should not be packed into the epub file. +#epub_exclude_files = [] + +# The depth of the table of contents in toc.ncx. +#epub_tocdepth = 3 + +# Allow duplicate toc entries. +#epub_tocdup = True diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 00000000..bf46de8c --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,49 @@ +.. cue-specs documentation master file + +==== +Main +==== + +.. toctree:: + :glob: + :maxdepth: 1 + + main/* + +====================== +Project Specifications +====================== + +Version 0.5 specs: + +.. toctree:: + :glob: + :maxdepth: 1 + + specs/version0.5/* + +Version 1: + +.. toctree:: + :glob: + :maxdepth: 1 + + specs/version1/* + +==================== +Design Documentation +==================== + +Version 0.5: + +.. toctree:: + :glob: + :maxdepth: 1 + + design/version0.5/* + +================== +Indices and tables +================== + +* :ref:`search` diff --git a/requirements.txt b/requirements.txt index cd2adf6f..f731ff70 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,6 @@ iso8601>=0.1.9 stevedore>=1.0.0 # Apache-2.0 oslo.config>=1.4.0 # Apache-2.0 oslo.db>=1.0.0 # Apache-2.0 --e git+https://github.com/openstack/oslo.log.git#egg=oslo.log oslo.rootwrap>=1.3.0 oslo.i18n>=1.0.0 # Apache-2.0 oslo.serialization>=1.0.0 # Apache-2.0 diff --git a/tox.ini b/tox.ini index 276ecb54..830d022b 100644 --- a/tox.ini +++ b/tox.ini @@ -10,6 +10,7 @@ setenv = VIRTUAL_ENV={envdir} PYTHONDONTWRITEBYTECODE = 1 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt + http://tarballs.openstack.org/oslo.log/oslo.log-master.tar.gz whitelist_externals = bash commands = bash -c "TESTS_DIR=./cue/tests/ python setup.py testr --slowest --testr-args='{posargs}'" @@ -21,7 +22,7 @@ downloadcache = ~/cache/pip commands = flake8 {posargs} # Check that .po and .pot files are valid: - bash -c "find cue -type f -regex '.*\.pot?' -print0|xargs -0 -n 1 msgfmt --check-format -o /dev/null" + # bash -c "find cue -type f -regex '.*\.pot?' -print0|xargs -0 -n 1 msgfmt --check-format -o /dev/null" [testenv:cover] setenv = VIRTUAL_ENV={envdir}