Adding Vagrantfile and update to tox.ini to fix tox env

- Adding Vagrantfile with necessary package installation steps to allow
  dev environment to be brought up with all necessary OS packages
- modified tox.ini to allow installation of pip modules from external
  source
- fix all flake8 issues
- added .testr.conf to satisfy tox testing requirements
- added simple unit test to fix gate
- fix docs build

Co-Authored-By: Vipul Sabhaya <vipuls@gmail.com>
Change-Id: Ifca9e5c483adb688546a76368d9b821da7371829
This commit is contained in:
Min Pae 2014-11-13 14:44:30 -08:00 committed by Vipul Sabhaya
parent c0dd57e3fa
commit fc28e371e5
24 changed files with 432 additions and 35 deletions

4
.gitignore vendored
View File

@ -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/

4
.gitreview Normal file
View File

@ -0,0 +1,4 @@
[gerrit]
host=review.openstack.org
port=29418
project=stackforge/cue.git

4
.testr.conf Normal file
View File

@ -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

23
Vagrantfile vendored Normal file
View File

@ -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

View File

@ -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)
CONF.register_opts(API_SERVICE_OPTS, opt_group)

View File

@ -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,

View File

@ -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()

View File

@ -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

View File

@ -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__)

View File

@ -1,4 +1,4 @@
from oslo import i18n
i18n.install('cue')
i18n.install('cue')

View File

@ -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

View File

@ -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")

View File

@ -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

View File

@ -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')

View File

@ -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.

0
cue/tests/__init__.py Normal file
View File

View File

19
cue/tests/unit/base.py Normal file
View File

@ -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

View File

View File

@ -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()

268
doc/source/conf.py Normal file
View File

@ -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
# "<project> v<release> 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 <link> 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

49
doc/source/index.rst Normal file
View File

@ -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`

View File

@ -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

View File

@ -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}