Browse Source

Repo Init

enables unit testing and heat dependency

Change-Id: I51908e334b7ef3f0a2c200a1dae85de81e418a23
tags/2014.1.rc1
Ivar Lazzaro 4 years ago
parent
commit
15db2af2bb

+ 7
- 0
.coveragerc View File

@@ -0,0 +1,7 @@
1
+[run]
2
+branch = True
3
+source = gbpautomation
4
+omit = gbpautomation/tests/*,gbpautomation/openstack/*
5
+
6
+[report]
7
+ignore-errors = True

+ 21
- 0
.gitignore View File

@@ -0,0 +1,21 @@
1
+*.pyc
2
+*.swp
3
+*~
4
+build
5
+dist
6
+*.egg-info
7
+tags
8
+*.log
9
+heat-test.db
10
+heat.sqlite
11
+.venv
12
+AUTHORS
13
+ChangeLog
14
+templates/cloudformation-examples
15
+.tox
16
+.coverage
17
+.coverage.*
18
+cover
19
+.testrepository
20
+.project
21
+.pydevproject

+ 1
- 1
.gitreview View File

@@ -1,4 +1,4 @@
1 1
 [gerrit]
2 2
 host=review.openstack.org
3 3
 port=29418
4
-project=stackforge/group-based-policy-automation.git
4
+project=stackforge/group-based-policy-automation.git

+ 3
- 0
.mailmap View File

@@ -0,0 +1,3 @@
1
+# Format is:
2
+# <preferred e-mail> <other e-mail 1>
3
+# <preferred e-mail> <other e-mail 2>

+ 7
- 0
.testr.conf View File

@@ -0,0 +1,7 @@
1
+[DEFAULT]
2
+test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
3
+             OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
4
+             OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
5
+             ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION
6
+test_id_option=--load-list $IDFILE
7
+test_list_option=--list

+ 17
- 0
CONTRIBUTING.rst View File

@@ -0,0 +1,17 @@
1
+If you would like to contribute to the development of OpenStack,
2
+you must follow the steps in the "If you're a developer, start here"
3
+section of this page:
4
+
5
+   http://wiki.openstack.org/HowToContribute
6
+
7
+Once those steps have been completed, changes to OpenStack
8
+should be submitted for review via the Gerrit tool, following
9
+the workflow documented at:
10
+
11
+   http://wiki.openstack.org/GerritWorkflow
12
+
13
+Pull requests submitted through GitHub will be ignored.
14
+
15
+Bugs should be filed on Launchpad, not GitHub:
16
+
17
+   https://bugs.launchpad.net/group-based-policy-automation

+ 4
- 0
HACKING.rst View File

@@ -0,0 +1,4 @@
1
+group-based-policy-automation Style Commandments
2
+===============================================
3
+
4
+Read the OpenStack Style Commandments http://docs.openstack.org/developer/hacking/

+ 175
- 0
LICENSE View File

@@ -0,0 +1,175 @@
1
+
2
+                                 Apache License
3
+                           Version 2.0, January 2004
4
+                        http://www.apache.org/licenses/
5
+
6
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+   1. Definitions.
9
+
10
+      "License" shall mean the terms and conditions for use, reproduction,
11
+      and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+      "Licensor" shall mean the copyright owner or entity authorized by
14
+      the copyright owner that is granting the License.
15
+
16
+      "Legal Entity" shall mean the union of the acting entity and all
17
+      other entities that control, are controlled by, or are under common
18
+      control with that entity. For the purposes of this definition,
19
+      "control" means (i) the power, direct or indirect, to cause the
20
+      direction or management of such entity, whether by contract or
21
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+      outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+      "You" (or "Your") shall mean an individual or Legal Entity
25
+      exercising permissions granted by this License.
26
+
27
+      "Source" form shall mean the preferred form for making modifications,
28
+      including but not limited to software source code, documentation
29
+      source, and configuration files.
30
+
31
+      "Object" form shall mean any form resulting from mechanical
32
+      transformation or translation of a Source form, including but
33
+      not limited to compiled object code, generated documentation,
34
+      and conversions to other media types.
35
+
36
+      "Work" shall mean the work of authorship, whether in Source or
37
+      Object form, made available under the License, as indicated by a
38
+      copyright notice that is included in or attached to the work
39
+      (an example is provided in the Appendix below).
40
+
41
+      "Derivative Works" shall mean any work, whether in Source or Object
42
+      form, that is based on (or derived from) the Work and for which the
43
+      editorial revisions, annotations, elaborations, or other modifications
44
+      represent, as a whole, an original work of authorship. For the purposes
45
+      of this License, Derivative Works shall not include works that remain
46
+      separable from, or merely link (or bind by name) to the interfaces of,
47
+      the Work and Derivative Works thereof.
48
+
49
+      "Contribution" shall mean any work of authorship, including
50
+      the original version of the Work and any modifications or additions
51
+      to that Work or Derivative Works thereof, that is intentionally
52
+      submitted to Licensor for inclusion in the Work by the copyright owner
53
+      or by an individual or Legal Entity authorized to submit on behalf of
54
+      the copyright owner. For the purposes of this definition, "submitted"
55
+      means any form of electronic, verbal, or written communication sent
56
+      to the Licensor or its representatives, including but not limited to
57
+      communication on electronic mailing lists, source code control systems,
58
+      and issue tracking systems that are managed by, or on behalf of, the
59
+      Licensor for the purpose of discussing and improving the Work, but
60
+      excluding communication that is conspicuously marked or otherwise
61
+      designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+      "Contributor" shall mean Licensor and any individual or Legal Entity
64
+      on behalf of whom a Contribution has been received by Licensor and
65
+      subsequently incorporated within the Work.
66
+
67
+   2. Grant of Copyright License. Subject to the terms and conditions of
68
+      this License, each Contributor hereby grants to You a perpetual,
69
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+      copyright license to reproduce, prepare Derivative Works of,
71
+      publicly display, publicly perform, sublicense, and distribute the
72
+      Work and such Derivative Works in Source or Object form.
73
+
74
+   3. Grant of Patent License. Subject to the terms and conditions of
75
+      this License, each Contributor hereby grants to You a perpetual,
76
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+      (except as stated in this section) patent license to make, have made,
78
+      use, offer to sell, sell, import, and otherwise transfer the Work,
79
+      where such license applies only to those patent claims licensable
80
+      by such Contributor that are necessarily infringed by their
81
+      Contribution(s) alone or by combination of their Contribution(s)
82
+      with the Work to which such Contribution(s) was submitted. If You
83
+      institute patent litigation against any entity (including a
84
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+      or a Contribution incorporated within the Work constitutes direct
86
+      or contributory patent infringement, then any patent licenses
87
+      granted to You under this License for that Work shall terminate
88
+      as of the date such litigation is filed.
89
+
90
+   4. Redistribution. You may reproduce and distribute copies of the
91
+      Work or Derivative Works thereof in any medium, with or without
92
+      modifications, and in Source or Object form, provided that You
93
+      meet the following conditions:
94
+
95
+      (a) You must give any other recipients of the Work or
96
+          Derivative Works a copy of this License; and
97
+
98
+      (b) You must cause any modified files to carry prominent notices
99
+          stating that You changed the files; and
100
+
101
+      (c) You must retain, in the Source form of any Derivative Works
102
+          that You distribute, all copyright, patent, trademark, and
103
+          attribution notices from the Source form of the Work,
104
+          excluding those notices that do not pertain to any part of
105
+          the Derivative Works; and
106
+
107
+      (d) If the Work includes a "NOTICE" text file as part of its
108
+          distribution, then any Derivative Works that You distribute must
109
+          include a readable copy of the attribution notices contained
110
+          within such NOTICE file, excluding those notices that do not
111
+          pertain to any part of the Derivative Works, in at least one
112
+          of the following places: within a NOTICE text file distributed
113
+          as part of the Derivative Works; within the Source form or
114
+          documentation, if provided along with the Derivative Works; or,
115
+          within a display generated by the Derivative Works, if and
116
+          wherever such third-party notices normally appear. The contents
117
+          of the NOTICE file are for informational purposes only and
118
+          do not modify the License. You may add Your own attribution
119
+          notices within Derivative Works that You distribute, alongside
120
+          or as an addendum to the NOTICE text from the Work, provided
121
+          that such additional attribution notices cannot be construed
122
+          as modifying the License.
123
+
124
+      You may add Your own copyright statement to Your modifications and
125
+      may provide additional or different license terms and conditions
126
+      for use, reproduction, or distribution of Your modifications, or
127
+      for any such Derivative Works as a whole, provided Your use,
128
+      reproduction, and distribution of the Work otherwise complies with
129
+      the conditions stated in this License.
130
+
131
+   5. Submission of Contributions. Unless You explicitly state otherwise,
132
+      any Contribution intentionally submitted for inclusion in the Work
133
+      by You to the Licensor shall be under the terms and conditions of
134
+      this License, without any additional terms or conditions.
135
+      Notwithstanding the above, nothing herein shall supersede or modify
136
+      the terms of any separate license agreement you may have executed
137
+      with Licensor regarding such Contributions.
138
+
139
+   6. Trademarks. This License does not grant permission to use the trade
140
+      names, trademarks, service marks, or product names of the Licensor,
141
+      except as required for reasonable and customary use in describing the
142
+      origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+   7. Disclaimer of Warranty. Unless required by applicable law or
145
+      agreed to in writing, Licensor provides the Work (and each
146
+      Contributor provides its Contributions) on an "AS IS" BASIS,
147
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+      implied, including, without limitation, any warranties or conditions
149
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+      PARTICULAR PURPOSE. You are solely responsible for determining the
151
+      appropriateness of using or redistributing the Work and assume any
152
+      risks associated with Your exercise of permissions under this License.
153
+
154
+   8. Limitation of Liability. In no event and under no legal theory,
155
+      whether in tort (including negligence), contract, or otherwise,
156
+      unless required by applicable law (such as deliberate and grossly
157
+      negligent acts) or agreed to in writing, shall any Contributor be
158
+      liable to You for damages, including any direct, indirect, special,
159
+      incidental, or consequential damages of any character arising as a
160
+      result of this License or out of the use or inability to use the
161
+      Work (including but not limited to damages for loss of goodwill,
162
+      work stoppage, computer failure or malfunction, or any and all
163
+      other commercial damages or losses), even if such Contributor
164
+      has been advised of the possibility of such damages.
165
+
166
+   9. Accepting Warranty or Additional Liability. While redistributing
167
+      the Work or Derivative Works thereof, You may choose to offer,
168
+      and charge a fee for, acceptance of support, warranty, indemnity,
169
+      or other liability obligations and/or rights consistent with this
170
+      License. However, in accepting such obligations, You may act only
171
+      on Your own behalf and on Your sole responsibility, not on behalf
172
+      of any other Contributor, and only if You agree to indemnify,
173
+      defend, and hold each Contributor harmless for any liability
174
+      incurred by, or claims asserted against, such Contributor by reason
175
+      of your accepting any such warranty or additional liability.

+ 6
- 0
MANIFEST.in View File

@@ -0,0 +1,6 @@
1
+include AUTHORS
2
+include ChangeLog
3
+exclude .gitignore
4
+exclude .gitreview
5
+
6
+global-exclude *.pyc

+ 15
- 0
README.rst View File

@@ -0,0 +1,15 @@
1
+===============================
2
+group-based-policy-automation
3
+===============================
4
+
5
+Group Based Policy Automation
6
+
7
+* Free software: Apache license
8
+* Documentation: http://docs.openstack.org/developer/group-based-policy-automation
9
+* Source: http://git.openstack.org/cgit/stackforge/group-based-policy-automation
10
+* Bugs: http://bugs.launchpad.net/group-based-policy-automation
11
+
12
+Features
13
+--------
14
+
15
+* TODO

+ 1
- 0
babel.cfg View File

@@ -0,0 +1 @@
1
+[python: **.py]

+ 75
- 0
doc/source/conf.py View File

@@ -0,0 +1,75 @@
1
+# -*- coding: utf-8 -*-
2
+# Licensed under the Apache License, Version 2.0 (the "License");
3
+# you may not use this file except in compliance with the License.
4
+# You may obtain a copy of the License at
5
+#
6
+#    http://www.apache.org/licenses/LICENSE-2.0
7
+#
8
+# Unless required by applicable law or agreed to in writing, software
9
+# distributed under the License is distributed on an "AS IS" BASIS,
10
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
11
+# implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
15
+import os
16
+import sys
17
+
18
+sys.path.insert(0, os.path.abspath('../..'))
19
+# -- General configuration ----------------------------------------------------
20
+
21
+# Add any Sphinx extension module names here, as strings. They can be
22
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
23
+extensions = [
24
+    'sphinx.ext.autodoc',
25
+    # 'sphinx.ext.intersphinx',
26
+    'oslosphinx'
27
+]
28
+
29
+# autodoc generation is a bit aggressive and a nuisance when doing heavy
30
+# text edit cycles.
31
+# execute "export SPHINX_DEBUG=1" in your terminal to disable
32
+
33
+# The suffix of source filenames.
34
+source_suffix = '.rst'
35
+
36
+# The master toctree document.
37
+master_doc = 'index'
38
+
39
+# General information about the project.
40
+project = u'group-based-policy-automation'
41
+copyright = u'2013, OpenStack Foundation'
42
+
43
+# If true, '()' will be appended to :func: etc. cross-reference text.
44
+add_function_parentheses = True
45
+
46
+# If true, the current module name will be prepended to all description
47
+# unit titles (such as .. function::).
48
+add_module_names = True
49
+
50
+# The name of the Pygments (syntax highlighting) style to use.
51
+pygments_style = 'sphinx'
52
+
53
+# -- Options for HTML output --------------------------------------------------
54
+
55
+# The theme to use for HTML and HTML Help pages.  Major themes that come with
56
+# Sphinx are currently 'default' and 'sphinxdoc'.
57
+# html_theme_path = ["."]
58
+# html_theme = '_theme'
59
+# html_static_path = ['static']
60
+
61
+# Output file base name for HTML help builder.
62
+htmlhelp_basename = '%sdoc' % project
63
+
64
+# Grouping the document tree into LaTeX files. List of tuples
65
+# (source start file, target name, title, author, documentclass
66
+# [howto/manual]).
67
+latex_documents = [
68
+    ('index',
69
+     '%s.tex' % project,
70
+     u'%s Documentation' % project,
71
+     u'OpenStack Foundation', 'manual'),
72
+]
73
+
74
+# Example configuration for intersphinx: refer to the Python standard library.
75
+# intersphinx_mapping = {'http://docs.python.org/': None}

+ 4
- 0
doc/source/contributing.rst View File

@@ -0,0 +1,4 @@
1
+============
2
+Contributing
3
+============
4
+.. include:: ../../CONTRIBUTING.rst

+ 24
- 0
doc/source/index.rst View File

@@ -0,0 +1,24 @@
1
+.. group-based-policy-automation documentation master file, created by
2
+   sphinx-quickstart on Tue Jul  9 22:26:36 2013.
3
+   You can adapt this file completely to your liking, but it should at least
4
+   contain the root `toctree` directive.
5
+
6
+Welcome to group-based-policy-automation's documentation!
7
+========================================================
8
+
9
+Contents:
10
+
11
+.. toctree::
12
+   :maxdepth: 2
13
+
14
+   readme
15
+   installation
16
+   usage
17
+   contributing
18
+
19
+Indices and tables
20
+==================
21
+
22
+* :ref:`genindex`
23
+* :ref:`modindex`
24
+* :ref:`search`

+ 12
- 0
doc/source/installation.rst View File

@@ -0,0 +1,12 @@
1
+============
2
+Installation
3
+============
4
+
5
+At the command line::
6
+
7
+    $ pip install group-based-policy-automation
8
+
9
+Or, if you have virtualenvwrapper installed::
10
+
11
+    $ mkvirtualenv group-based-policy-automation
12
+    $ pip install group-based-policy-automation

+ 1
- 0
doc/source/readme.rst View File

@@ -0,0 +1 @@
1
+.. include:: ../../README.rst

+ 7
- 0
doc/source/usage.rst View File

@@ -0,0 +1,7 @@
1
+========
2
+Usage
3
+========
4
+
5
+To use group-based-policy-automation in a project::
6
+
7
+    import gbpautomation

+ 17
- 0
gbpautomation/__init__.py View File

@@ -0,0 +1,17 @@
1
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
2
+# not use this file except in compliance with the License. You may obtain
3
+# a copy of the License at
4
+#
5
+#      http://www.apache.org/licenses/LICENSE-2.0
6
+#
7
+# Unless required by applicable law or agreed to in writing, software
8
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10
+# License for the specific language governing permissions and limitations
11
+# under the License.
12
+
13
+import pbr.version
14
+
15
+
16
+__version__ = pbr.version.VersionInfo(
17
+    'gbpautomation').version_string()

+ 0
- 0
gbpautomation/heat/__init__.py View File


+ 0
- 0
gbpautomation/heat/db/__init__.py View File


+ 0
- 0
gbpautomation/heat/db/sqlalchemy/__init__.py View File


+ 0
- 0
gbpautomation/heat/db/sqlalchemy/migrate_repo/__init__.py View File


+ 0
- 0
gbpautomation/heat/db/sqlalchemy/migrate_repo/versions/__init__.py View File


+ 0
- 0
gbpautomation/heat/tests/__init__.py View File


+ 23
- 0
gbpautomation/heat/tests/base.py View File

@@ -0,0 +1,23 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+# Copyright 2010-2011 OpenStack Foundation
4
+# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
5
+#
6
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
+# not use this file except in compliance with the License. You may obtain
8
+# a copy of the License at
9
+#
10
+#      http://www.apache.org/licenses/LICENSE-2.0
11
+#
12
+# Unless required by applicable law or agreed to in writing, software
13
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+# License for the specific language governing permissions and limitations
16
+# under the License.
17
+
18
+import testtools
19
+
20
+
21
+class TestCase(testtools.TestCase):
22
+
23
+    """Test case base class for all unit tests."""

+ 28
- 0
gbpautomation/heat/tests/test_gbpautomation.py View File

@@ -0,0 +1,28 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
+# not use this file except in compliance with the License. You may obtain
5
+# a copy of the License at
6
+#
7
+#      http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
+# License for the specific language governing permissions and limitations
13
+# under the License.
14
+
15
+"""
16
+test_gbpautomation
17
+----------------------------------
18
+
19
+Tests for `gbpautomation` module.
20
+"""
21
+
22
+from gbpautomation.heat.tests import base
23
+
24
+
25
+class TestGbpautomation(base.TestCase):
26
+
27
+    def test_something(self):
28
+        pass

+ 10
- 0
openstack-common.conf View File

@@ -0,0 +1,10 @@
1
+[DEFAULT]
2
+
3
+# The list of modules to copy from oslo-incubator.git
4
+module=install_venv_common
5
+module=install_venv
6
+module=with_venv
7
+module=test
8
+
9
+# The base module to hold the copy of openstack.common
10
+base=gbpautomation

+ 6
- 0
requirements.txt View File

@@ -0,0 +1,6 @@
1
+# The order of packages is significant, because pip processes them in the order
2
+# of appearance. Changing the order has an impact on the overall integration
3
+# process, which may cause wedges in the gate later.
4
+
5
+pbr>=0.6,!=0.7,<1.0
6
+Babel>=1.3

+ 125
- 0
run_tests.sh View File

@@ -0,0 +1,125 @@
1
+#!/bin/bash
2
+
3
+BASE_DIR=`dirname $0`
4
+
5
+function usage {
6
+    echo "Usage: $0 [OPTION]..."
7
+    echo "Run Heat's test suite(s)"
8
+    echo ""
9
+    echo "  -V, --virtual-env        Use virtualenv.  Install automatically if not present."
10
+    echo "                           (Default is to run tests in local environment)"
11
+    echo "  -F, --force              Force a clean re-build of the virtual environment. Useful when dependencies have been added."
12
+    echo "  -f, --func               Functional tests have been removed."
13
+    echo "  -u, --unit               Run unit tests (default when nothing specified)"
14
+    echo "  -p, --pep8               Run flake8 and HACKING compliance check (default when nothing specified)"
15
+    echo "  -P, --no-pep8            Don't run flake8 and HACKING compliance check"
16
+    echo "  --all                    Run pep8 and unit tests"
17
+    echo "  -c, --coverage           Generate coverage report"
18
+    echo "  -d, --debug              Run tests with testtools instead of testr. This allows you to use the debugger."
19
+    echo "  -h, --help               Print this usage message"
20
+    exit
21
+}
22
+
23
+# must not assign -a as an option, needed for selecting custom attributes
24
+no_venv=1
25
+function process_option {
26
+    case "$1" in
27
+        -V|--virtual-env) no_venv=0;;
28
+        -F|--force) force=1;;
29
+        -f|--func) test_func=1;;
30
+        -u|--unit) test_unit=1;;
31
+        -p|--pep8) test_pep8=1;;
32
+        -P|--no-pep8) test_pep8=0;;
33
+        --all) test_unit=1; test_pep8=1;;
34
+        -c|--coverage) coverage=1;;
35
+        -d|--debug) debug=1;;
36
+        -h|--help) usage;;
37
+        *) args="$args $1"; test_unit=1;;
38
+    esac
39
+}
40
+
41
+venv=.venv
42
+with_venv=tools/with_venv.sh
43
+wrapper=""
44
+debug=0
45
+
46
+function run_tests {
47
+    echo 'Running tests'
48
+    # Remove any extraneous DB migrations
49
+    find gbpautomation/heat/db/sqlalchemy/migrate_repo/versions/ -name '*.pyc' -delete
50
+
51
+    if [ $debug -eq 1 ]; then
52
+      echo "Debugging..."
53
+      if [ "$args" = "" ]; then
54
+        # Default to running all tests if specific test is not
55
+        # provided.
56
+        testrargs="discover ./gbpautomation/heat/tests"
57
+      fi
58
+      ${wrapper} python -m testtools.run $args $testrargs
59
+
60
+      # Short circuit because all of the testr and coverage stuff
61
+      # below does not make sense when running testtools.run for
62
+      # debugging purposes.
63
+      return $?
64
+    fi
65
+
66
+    # Just run the test suites in current environment
67
+    if [ -n "$args" ] ; then
68
+        args="-t $args"
69
+    fi
70
+    ${wrapper} python setup.py testr --slowest $args
71
+}
72
+
73
+function run_pep8 {
74
+    echo "Running flake8..."
75
+    bash -c "${wrapper} flake8 ${flake8args}"
76
+}
77
+
78
+# run unit tests with pep8 when no arguments are specified
79
+# otherwise process CLI options
80
+if [[ $# == 0 ]]; then
81
+    test_pep8=1
82
+    test_unit=1
83
+else
84
+    for arg in "$@"; do
85
+        process_option $arg
86
+    done
87
+fi
88
+
89
+if [ "$no_venv" == 0 ]
90
+then
91
+    # Remove the virtual environment if --force used
92
+    if [ "$force" == 1 ]; then
93
+        echo "Cleaning virtualenv..."
94
+        rm -rf ${venv}
95
+    fi
96
+    if [ -e ${venv} ]; then
97
+        wrapper="${with_venv}"
98
+    else
99
+        # Automatically install the virtualenv
100
+        python tools/install_venv.py
101
+        wrapper="${with_venv}"
102
+    fi
103
+fi
104
+
105
+result=0
106
+
107
+# If functional or unit tests have been selected, run them
108
+if [ "$test_unit" == 1 ] || [ "$debug" == 1 ] ; then
109
+    run_tests
110
+    result=$?
111
+fi
112
+
113
+# Run pep8 if it was selected
114
+if [ "$test_pep8" == 1 ]; then
115
+    run_pep8
116
+fi
117
+
118
+# Generate coverage report
119
+if [ "$coverage" == 1 ]; then
120
+    echo "Generating coverage report in ./cover"
121
+    ${wrapper} python setup.py testr --coverage --slowest
122
+    ${wrapper} python -m coverage report --show-missing
123
+fi
124
+
125
+exit $result

+ 47
- 0
setup.cfg View File

@@ -0,0 +1,47 @@
1
+[metadata]
2
+name = group-based-policy-automation
3
+summary = Group Based Policy Automation
4
+description-file =
5
+    README.rst
6
+author = OpenStack
7
+author-email = openstack-dev@lists.openstack.org
8
+home-page = http://www.openstack.org/
9
+classifier =
10
+    Environment :: OpenStack
11
+    Intended Audience :: Information Technology
12
+    Intended Audience :: System Administrators
13
+    License :: OSI Approved :: Apache Software License
14
+    Operating System :: POSIX :: Linux
15
+    Programming Language :: Python
16
+    Programming Language :: Python :: 2
17
+    Programming Language :: Python :: 2.7
18
+    Programming Language :: Python :: 2.6
19
+    Programming Language :: Python :: 3
20
+    Programming Language :: Python :: 3.3
21
+    Programming Language :: Python :: 3.4
22
+
23
+[files]
24
+packages =
25
+    gbpautomation
26
+
27
+[build_sphinx]
28
+source-dir = doc/source
29
+build-dir = doc/build
30
+all_files = 1
31
+
32
+[upload_sphinx]
33
+upload-dir = doc/build/html
34
+
35
+[compile_catalog]
36
+directory = gbpautomation/locale
37
+domain = group-based-policy-automation
38
+
39
+[update_catalog]
40
+domain = group-based-policy-automation
41
+output_dir = gbpautomation/locale
42
+input_file = gbpautomation/locale/group-based-policy-automation.pot
43
+
44
+[extract_messages]
45
+keywords = _ gettext ngettext l_ lazy_gettext
46
+mapping_file = babel.cfg
47
+output_file = gbpautomation/locale/group-based-policy-automation.pot

+ 22
- 0
setup.py View File

@@ -0,0 +1,22 @@
1
+#!/usr/bin/env python
2
+# Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
3
+#
4
+# Licensed under the Apache License, Version 2.0 (the "License");
5
+# you may not use this file except in compliance with the License.
6
+# You may obtain a copy of the License at
7
+#
8
+#    http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+# Unless required by applicable law or agreed to in writing, software
11
+# distributed under the License is distributed on an "AS IS" BASIS,
12
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13
+# implied.
14
+# See the License for the specific language governing permissions and
15
+# limitations under the License.
16
+
17
+# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT
18
+import setuptools
19
+
20
+setuptools.setup(
21
+    setup_requires=['pbr'],
22
+    pbr=True)

+ 20
- 0
test-requirements.txt View File

@@ -0,0 +1,20 @@
1
+# The order of packages is significant, because pip processes them in the order
2
+# of appearance. Changing the order has an impact on the overall integration
3
+# process, which may cause wedges in the gate later.
4
+
5
+-e git://github.com/openstack/heat.git@stable/juno#egg=heat
6
+# Hacking already pins down pep8, pyflakes and flake8
7
+hacking>=0.8.0,<0.9
8
+coverage>=3.6
9
+discover
10
+lockfile>=0.8
11
+mock>=1.0
12
+mox>=0.5.3
13
+MySQL-python
14
+oslosphinx>=2.2.0  # Apache-2.0
15
+oslotest>=1.1.0  # Apache-2.0
16
+psycopg2
17
+sphinx>=1.1.2,!=1.2.0,<1.3
18
+testrepository>=0.0.18
19
+testscenarios>=0.4
20
+testtools>=0.9.34

+ 71
- 0
tools/install_venv.py View File

@@ -0,0 +1,71 @@
1
+# Copyright 2010 United States Government as represented by the
2
+# Administrator of the National Aeronautics and Space Administration.
3
+# All Rights Reserved.
4
+#
5
+# Copyright 2010 OpenStack Foundation
6
+# Copyright 2013 IBM Corp.
7
+#
8
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
9
+#    not use this file except in compliance with the License. You may obtain
10
+#    a copy of the License at
11
+#
12
+#         http://www.apache.org/licenses/LICENSE-2.0
13
+#
14
+#    Unless required by applicable law or agreed to in writing, software
15
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17
+#    License for the specific language governing permissions and limitations
18
+#    under the License.
19
+
20
+import os
21
+import sys
22
+
23
+import install_venv_common as install_venv  # noqa
24
+
25
+
26
+def print_help(venv, root):
27
+    help = """
28
+    OpenStack development environment setup is complete.
29
+
30
+    OpenStack development uses virtualenv to track and manage Python
31
+    dependencies while in development and testing.
32
+
33
+    To activate the OpenStack virtualenv for the extent of your current shell
34
+    session you can run:
35
+
36
+    $ source %s/bin/activate
37
+
38
+    Or, if you prefer, you can run commands in the virtualenv on a case by case
39
+    basis by running:
40
+
41
+    $ %s/tools/with_venv.sh <your command>
42
+
43
+    Also, make test will automatically use the virtualenv.
44
+    """
45
+    print(help % (venv, root))
46
+
47
+
48
+def main(argv):
49
+    root = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
50
+
51
+    if os.environ.get('tools_path'):
52
+        root = os.environ['tools_path']
53
+    venv = os.path.join(root, '.venv')
54
+    if os.environ.get('venv'):
55
+        venv = os.environ['venv']
56
+
57
+    pip_requires = os.path.join(root, 'requirements.txt')
58
+    test_requires = os.path.join(root, 'test-requirements.txt')
59
+    py_version = "python%s.%s" % (sys.version_info[0], sys.version_info[1])
60
+    project = 'OpenStack'
61
+    install = install_venv.InstallVenv(root, venv, pip_requires, test_requires,
62
+                                       py_version, project)
63
+    options = install.parse_args(argv)
64
+    install.check_python_version()
65
+    install.check_dependencies()
66
+    install.create_virtualenv(no_site_packages=options.no_site_packages)
67
+    install.install_dependencies()
68
+    print_help(venv, root)
69
+
70
+if __name__ == '__main__':
71
+    main(sys.argv)

+ 172
- 0
tools/install_venv_common.py View File

@@ -0,0 +1,172 @@
1
+# Copyright 2013 OpenStack Foundation
2
+# Copyright 2013 IBM Corp.
3
+#
4
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+#    not use this file except in compliance with the License. You may obtain
6
+#    a copy of the License at
7
+#
8
+#         http://www.apache.org/licenses/LICENSE-2.0
9
+#
10
+#    Unless required by applicable law or agreed to in writing, software
11
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+#    License for the specific language governing permissions and limitations
14
+#    under the License.
15
+
16
+"""Provides methods needed by installation script for OpenStack development
17
+virtual environments.
18
+
19
+Since this script is used to bootstrap a virtualenv from the system's Python
20
+environment, it should be kept strictly compatible with Python 2.6.
21
+
22
+Synced in from openstack-common
23
+"""
24
+
25
+from __future__ import print_function
26
+
27
+import optparse
28
+import os
29
+import subprocess
30
+import sys
31
+
32
+
33
+class InstallVenv(object):
34
+
35
+    def __init__(self, root, venv, requirements,
36
+                 test_requirements, py_version,
37
+                 project):
38
+        self.root = root
39
+        self.venv = venv
40
+        self.requirements = requirements
41
+        self.test_requirements = test_requirements
42
+        self.py_version = py_version
43
+        self.project = project
44
+
45
+    def die(self, message, *args):
46
+        print(message % args, file=sys.stderr)
47
+        sys.exit(1)
48
+
49
+    def check_python_version(self):
50
+        if sys.version_info < (2, 6):
51
+            self.die("Need Python Version >= 2.6")
52
+
53
+    def run_command_with_code(self, cmd, redirect_output=True,
54
+                              check_exit_code=True):
55
+        """Runs a command in an out-of-process shell.
56
+
57
+        Returns the output of that command. Working directory is self.root.
58
+        """
59
+        if redirect_output:
60
+            stdout = subprocess.PIPE
61
+        else:
62
+            stdout = None
63
+
64
+        proc = subprocess.Popen(cmd, cwd=self.root, stdout=stdout)
65
+        output = proc.communicate()[0]
66
+        if check_exit_code and proc.returncode != 0:
67
+            self.die('Command "%s" failed.\n%s', ' '.join(cmd), output)
68
+        return (output, proc.returncode)
69
+
70
+    def run_command(self, cmd, redirect_output=True, check_exit_code=True):
71
+        return self.run_command_with_code(cmd, redirect_output,
72
+                                          check_exit_code)[0]
73
+
74
+    def get_distro(self):
75
+        if (os.path.exists('/etc/fedora-release') or
76
+                os.path.exists('/etc/redhat-release')):
77
+            return Fedora(
78
+                self.root, self.venv, self.requirements,
79
+                self.test_requirements, self.py_version, self.project)
80
+        else:
81
+            return Distro(
82
+                self.root, self.venv, self.requirements,
83
+                self.test_requirements, self.py_version, self.project)
84
+
85
+    def check_dependencies(self):
86
+        self.get_distro().install_virtualenv()
87
+
88
+    def create_virtualenv(self, no_site_packages=True):
89
+        """Creates the virtual environment and installs PIP.
90
+
91
+        Creates the virtual environment and installs PIP only into the
92
+        virtual environment.
93
+        """
94
+        if not os.path.isdir(self.venv):
95
+            print('Creating venv...', end=' ')
96
+            if no_site_packages:
97
+                self.run_command(['virtualenv', '-q', '--no-site-packages',
98
+                                 self.venv])
99
+            else:
100
+                self.run_command(['virtualenv', '-q', self.venv])
101
+            print('done.')
102
+        else:
103
+            print("venv already exists...")
104
+            pass
105
+
106
+    def pip_install(self, *args):
107
+        self.run_command(['tools/with_venv.sh',
108
+                         'pip', 'install', '--upgrade'] + list(args),
109
+                         redirect_output=False)
110
+
111
+    def install_dependencies(self):
112
+        print('Installing dependencies with pip (this can take a while)...')
113
+
114
+        # First things first, make sure our venv has the latest pip and
115
+        # setuptools and pbr
116
+        self.pip_install('pip>=1.4')
117
+        self.pip_install('setuptools')
118
+        self.pip_install('pbr')
119
+
120
+        self.pip_install('-r', self.requirements, '-r', self.test_requirements)
121
+
122
+    def parse_args(self, argv):
123
+        """Parses command-line arguments."""
124
+        parser = optparse.OptionParser()
125
+        parser.add_option('-n', '--no-site-packages',
126
+                          action='store_true',
127
+                          help="Do not inherit packages from global Python "
128
+                               "install.")
129
+        return parser.parse_args(argv[1:])[0]
130
+
131
+
132
+class Distro(InstallVenv):
133
+
134
+    def check_cmd(self, cmd):
135
+        return bool(self.run_command(['which', cmd],
136
+                    check_exit_code=False).strip())
137
+
138
+    def install_virtualenv(self):
139
+        if self.check_cmd('virtualenv'):
140
+            return
141
+
142
+        if self.check_cmd('easy_install'):
143
+            print('Installing virtualenv via easy_install...', end=' ')
144
+            if self.run_command(['easy_install', 'virtualenv']):
145
+                print('Succeeded')
146
+                return
147
+            else:
148
+                print('Failed')
149
+
150
+        self.die('ERROR: virtualenv not found.\n\n%s development'
151
+                 ' requires virtualenv, please install it using your'
152
+                 ' favorite package management tool' % self.project)
153
+
154
+
155
+class Fedora(Distro):
156
+    """This covers all Fedora-based distributions.
157
+
158
+    Includes: Fedora, RHEL, CentOS, Scientific Linux
159
+    """
160
+
161
+    def check_pkg(self, pkg):
162
+        return self.run_command_with_code(['rpm', '-q', pkg],
163
+                                          check_exit_code=False)[1] == 0
164
+
165
+    def install_virtualenv(self):
166
+        if self.check_cmd('virtualenv'):
167
+            return
168
+
169
+        if not self.check_pkg('python-virtualenv'):
170
+            self.die("Please install 'python-virtualenv'.")
171
+
172
+        super(Fedora, self).install_virtualenv()

+ 4
- 0
tools/with_venv.sh View File

@@ -0,0 +1,4 @@
1
+#!/bin/bash
2
+TOOLS=`dirname $0`
3
+VENV=$TOOLS/../.venv
4
+source $VENV/bin/activate && "$@"

+ 50
- 0
tox.ini View File

@@ -0,0 +1,50 @@
1
+[tox]
2
+envlist = py26,py27,pep8
3
+minversion = 1.6
4
+skipsdist = True
5
+
6
+[testenv]
7
+# Note the hash seed is set to 0 until heat can be tested with a
8
+# random hash seed successfully.
9
+setenv = VIRTUAL_ENV={envdir}
10
+         PYTHONHASHSEED=0
11
+usedevelop = True
12
+install_command = pip install {opts} {packages}
13
+deps = -r{toxinidir}/requirements.txt
14
+       -r{toxinidir}/test-requirements.txt
15
+commands =
16
+  python setup.py testr --slowest --testr-args='^(?!functionaltests) {posargs}'
17
+
18
+whitelist_externals = bash
19
+
20
+[testenv:functional]
21
+commands =
22
+  python -c "print('TODO: functional tests')"
23
+
24
+[testenv:pep8]
25
+commands =
26
+    flake8
27
+    # Check that .po and .pot files are valid:
28
+    # bash -c "find gbpautomation -type f -regex '.*\.pot?' -print0|xargs -0 -n 1 msgfmt --check-format -o /dev/null"
29
+
30
+[testenv:venv]
31
+commands = {posargs}
32
+
33
+[testenv:cover]
34
+commands =
35
+  python setup.py testr --coverage --testr-args='{posargs}'
36
+
37
+[testenv:docs]
38
+deps = -r{toxinidir}/requirements.txt
39
+       -r{toxinidir}/test-requirements.txt
40
+       sphinxcontrib-httpdomain
41
+commands = python setup.py build_sphinx
42
+
43
+[flake8]
44
+# H302 import only modules.'bla..' does not import a module
45
+# H404 multi line docstring should start with a summary
46
+# H803 no full stop at the end of the commit message
47
+ignore = H302,H404,H803
48
+show-source = true
49
+builtins = _
50
+exclude=.venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,tools,build

Loading…
Cancel
Save