Browse Source

Provide oslo.policies

Add policies to the api based on oslo.policies.
Small changes in documentation. Provide generator for
sample policies file.
Add policies for agent and admin.

Story: 200112
Task: 4807

Depends-On: I76d737bf9d1216b041bc1a518cc2098f28e7da7b
Change-Id: Idf5c4ec1b663ad9ed3ab25744bdf0b7f28cdb1a2
Artur Basiak 1 year ago
parent
commit
32c4560c3b
53 changed files with 853 additions and 647 deletions
  1. 1
    0
      .gitignore
  2. 2
    2
      .testr.conf
  3. 0
    259
      api-guide/source/conf.py
  4. 0
    35
      api-guide/source/index.rst
  5. 0
    0
      api-ref/locale/.gitkeep
  6. 12
    53
      api-ref/source/conf.py
  7. 1
    1
      api-ref/source/index.rst
  8. 0
    7
      config-generator/README.md
  9. 11
    0
      config-generator/README.rst
  10. 1
    0
      config-generator/config.conf
  11. 3
    0
      config-generator/policy.conf
  12. 0
    0
      doc/api-samples/.gitkeep
  13. 1
    0
      doc/source/.gitignore
  14. 0
    0
      doc/source/.gitkeep
  15. 0
    114
      doc/source/_static/events-api.conf.sample
  16. 6
    0
      doc/source/admin/index.rst
  17. 3
    0
      doc/source/cli/index.rst
  18. 0
    7
      doc/source/code/modules.rst
  19. 0
    8
      doc/source/code/monasca_events_api.conf.rst
  20. 0
    35
      doc/source/code/monasca_events_api.rst
  21. 20
    38
      doc/source/conf.py
  22. 3
    0
      doc/source/configuration/index.rst
  23. 3
    0
      doc/source/contributor/.gitignore
  24. 19
    0
      doc/source/contributor/code.rst
  25. 1
    0
      doc/source/contributor/history.rst
  26. 37
    0
      doc/source/contributor/index.rst
  27. 3
    0
      doc/source/glossary.rst
  28. 0
    1
      doc/source/index.rst
  29. 6
    0
      doc/source/install/index.rst
  30. 6
    0
      doc/source/user/index.rst
  31. 31
    0
      etc/monasca/events-api-paste.ini
  32. 0
    0
      monasca_events_api/app/__init__.py
  33. 0
    0
      monasca_events_api/app/core/__init__.py
  34. 41
    0
      monasca_events_api/app/core/request.py
  35. 3
    5
      monasca_events_api/conf/__init__.py
  36. 8
    4
      monasca_events_api/config.py
  37. 58
    0
      monasca_events_api/policies/__init__.py
  38. 30
    0
      monasca_events_api/policies/admin.py
  39. 30
    0
      monasca_events_api/policies/agent.py
  40. 148
    0
      monasca_events_api/policy.py
  41. 0
    0
      monasca_events_api/tests/__init__.py
  42. 0
    0
      monasca_events_api/tests/functional/__init__.py
  43. 0
    0
      monasca_events_api/tests/unit/__init__.py
  44. 95
    0
      monasca_events_api/tests/unit/base.py
  45. 149
    0
      monasca_events_api/tests/unit/test_policy.py
  46. 68
    0
      monasca_events_api/tests/unit/test_request.py
  47. 1
    1
      monasca_events_api/version.py
  48. 9
    0
      releasenotes/notes/add_policies-24ddd2a505f3de6c.yaml
  49. 16
    46
      releasenotes/source/conf.py
  50. 2
    1
      requirements.txt
  51. 13
    6
      setup.cfg
  52. 1
    2
      test-requirements.txt
  53. 11
    22
      tox.ini

+ 1
- 0
.gitignore View File

@@ -32,3 +32,4 @@ log/
32 32
 *config*.yml
33 33
 db/config.yml
34 34
 .coverage.*
35
+*.sample

+ 2
- 2
.testr.conf View File

@@ -2,8 +2,8 @@
2 2
 test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
3 3
              OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
4 4
              OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
5
-             ${PYTHON:-python} -m subunit.run discover monasca $LISTOPT $IDOPTION
5
+             ${PYTHON:-python} -m subunit.run discover $PWD $LISTOPT $IDOPTION
6 6
 
7 7
 test_id_option=--load-list $IDFILE
8 8
 test_list_option=--list
9
-group_regex=monasca_events_api\.tests(?:\.|_)([^_]+)
9
+group_regex=monasca_events_api\.tests\.unit(?:\.|_)([^_]+)

+ 0
- 259
api-guide/source/conf.py View File

@@ -1,259 +0,0 @@
1
-# Licensed under the Apache License, Version 2.0 (the "License");
2
-# you may not use this file except in compliance with the License.
3
-# You may obtain 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,
9
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
10
-# implied.
11
-# See the License for the specific language governing permissions and
12
-# limitations under the License.
13
-#
14
-# Key Manager API documentation build configuration file
15
-#
16
-# All configuration values have a default; values that are commented out
17
-# serve to show the default.
18
-
19
-# -- General configuration ------------------------------------------------
20
-
21
-# If your documentation needs a minimal Sphinx version, state it here.
22
-needs_sphinx = '1.6'
23
-
24
-# Add any Sphinx extension module names here, as strings. They can be
25
-# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
26
-# ones.
27
-extensions = [
28
-    'openstackdocstheme'
29
-]
30
-
31
-# Add any paths that contain templates here, relative to this directory.
32
-templates_path = ['_templates']
33
-
34
-# The suffix of source filenames.
35
-source_suffix = '.rst'
36
-
37
-# The encoding of source files.
38
-source_encoding = 'utf-8'
39
-
40
-# The master toctree document.
41
-master_doc = 'index'
42
-
43
-# General details about project
44
-repository_name = u'openstack/monasca-events-api'
45
-project = u'Monasca Events API Guide'
46
-bug_project = u'monasca-events-api'
47
-bug_tag = u'api-guide'
48
-copyright = u'2014, OpenStack Foundation'
49
-
50
-from monasca_events_api.version import version_info
51
-version = version_info.version_string()
52
-release = version_info.release_string()
53
-
54
-# The language for content autogenerated by Sphinx. Refer to documentation
55
-# for a list of supported languages.
56
-# language = None
57
-
58
-# There are two options for replacing |today|: either, you set today to some
59
-# non-false value, then it is used:
60
-# today = ''
61
-# Else, today_fmt is used as the format for a strftime call.
62
-# today_fmt = '%B %d, %Y'
63
-
64
-# List of patterns, relative to source directory, that match files and
65
-# directories to ignore when looking for source files.
66
-exclude_patterns = []
67
-
68
-# The reST default role (used for this markup: `text`) to use for all
69
-# documents.
70
-# default_role = None
71
-
72
-# If true, '()' will be appended to :func: etc. cross-reference text.
73
-# add_function_parentheses = True
74
-
75
-# If true, the current module name will be prepended to all description
76
-# unit titles (such as .. function::).
77
-# add_module_names = True
78
-
79
-# If true, sectionauthor and moduleauthor directives will be shown in the
80
-# output. They are ignored by default.
81
-# show_authors = False
82
-
83
-# The name of the Pygments (syntax highlighting) style to use.
84
-pygments_style = 'sphinx'
85
-
86
-# A list of ignored prefixes for module index sorting.
87
-# modindex_common_prefix = []
88
-
89
-# If true, keep warnings as "system message" paragraphs in the built documents.
90
-# keep_warnings = False
91
-
92
-
93
-# -- Options for HTML output ----------------------------------------------
94
-
95
-# The theme to use for HTML and HTML Help pages.  See the documentation for
96
-# a list of builtin themes.
97
-html_theme = 'openstackdocs'
98
-
99
-# Theme options are theme-specific and customize the look and feel of a theme
100
-# further.  For a list of options available for each theme, see the
101
-# documentation.
102
-# html_theme_options = {}
103
-
104
-# A shorter title for the navigation bar.  Default is the same as html_title.
105
-html_short_title = 'API Guide'
106
-
107
-# The name of an image file (relative to this directory) to place at the top
108
-# of the sidebar.
109
-# html_logo = None
110
-
111
-# The name of an image file (within the static path) to use as favicon of the
112
-# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
113
-# pixels large.
114
-# html_favicon = None
115
-
116
-# Add any paths that contain custom static files (such as style sheets) here,
117
-# relative to this directory. They are copied after the builtin static files,
118
-# so a file named "default.css" will overwrite the builtin "default.css".
119
-# html_static_path = []
120
-
121
-# Add any extra paths that contain custom files (such as robots.txt or
122
-# .htaccess) here, relative to this directory. These files are copied
123
-# directly to the root of the documentation.
124
-# html_extra_path = []
125
-
126
-# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
127
-# using the given strftime format.
128
-html_last_updated_fmt = '%Y-%m-%d %H:%M'
129
-
130
-# If true, SmartyPants will be used to convert quotes and dashes to
131
-# typographically correct entities.
132
-# html_use_smartypants = True
133
-
134
-# Custom sidebar templates, maps document names to template names.
135
-# html_sidebars = {}
136
-
137
-# Additional templates that should be rendered to pages, maps page names to
138
-# template names.
139
-# html_additional_pages = {}
140
-
141
-# If false, no module index is generated.
142
-# html_domain_indices = True
143
-
144
-# If false, no index is generated.
145
-html_use_index = True
146
-
147
-# If true, the index is split into individual pages for each letter.
148
-# html_split_index = False
149
-
150
-# If true, links to the reST sources are added to the pages.
151
-# html_show_sourcelink = True
152
-
153
-# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
154
-# html_show_sphinx = True
155
-
156
-# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
157
-# html_show_copyright = True
158
-
159
-# If true, an OpenSearch description file will be output, and all pages will
160
-# contain a <link> tag referring to it.  The value of this option must be the
161
-# base URL from which the finished HTML is served.
162
-# html_use_opensearch = ''
163
-
164
-# This is the file name suffix for HTML files (e.g. ".xhtml").
165
-# html_file_suffix = None
166
-
167
-# Output file base name for HTML help builder.
168
-htmlhelp_basename = 'monascaeventsapi-api-guide'
169
-
170
-
171
-# -- Options for LaTeX output ---------------------------------------------
172
-
173
-latex_elements = {
174
-    # The paper size ('letterpaper' or 'a4paper').
175
-    # 'papersize': 'letterpaper',
176
-
177
-    # The font size ('10pt', '11pt' or '12pt').
178
-    # 'pointsize': '10pt',
179
-
180
-    # Additional stuff for the LaTeX preamble.
181
-    # 'preamble': '',
182
-}
183
-
184
-# Grouping the document tree into LaTeX files. List of tuples
185
-# (source start file, target name, title,
186
-#  author, documentclass [howto, manual, or own class]).
187
-latex_documents = [
188
-    ('index', 'MonascaEventsApiAPI.tex', u'Key Manager API Documentation',
189
-     u'OpenStack Foundation', 'manual'),
190
-]
191
-
192
-# The name of an image file (relative to this directory) to place at the top of
193
-# the title page.
194
-# latex_logo = None
195
-
196
-# For "manual" documents, if this is true, then toplevel headings are parts,
197
-# not chapters.
198
-# latex_use_parts = False
199
-
200
-# If true, show page references after internal links.
201
-# latex_show_pagerefs = False
202
-
203
-# If true, show URL addresses after external links.
204
-# latex_show_urls = False
205
-
206
-# Documents to append as an appendix to all manuals.
207
-# latex_appendices = []
208
-
209
-# If false, no module index is generated.
210
-# latex_domain_indices = True
211
-
212
-
213
-# -- Options for manual page output ---------------------------------------
214
-
215
-# One entry per manual page. List of tuples
216
-# (source start file, name, description, authors, manual section).
217
-man_pages = [
218
-    ('index', 'monascaeventsapiapi', u'Monasca Events API Documentation',
219
-     [u'OpenStack Foundation'], 1)
220
-]
221
-
222
-# If true, show URL addresses after external links.
223
-# man_show_urls = False
224
-
225
-
226
-# -- Options for Texinfo output -------------------------------------------
227
-
228
-# Grouping the document tree into Texinfo files. List of tuples
229
-# (source start file, target name, title, author,
230
-#  dir menu entry, description, category)
231
-texinfo_documents = [
232
-    ('index', 'MonascaEventsApiAPIGuide', u'Monasca Events API Guide',
233
-     u'OpenStack Foundation', 'APIGuide',
234
-     'This guide teaches OpenStack Monasca Events service users concepts about '
235
-     'managing keys in an OpenStack cloud with the Monasca Events API.',
236
-     'Miscellaneous'),
237
-]
238
-
239
-# Documents to append as an appendix to all manuals.
240
-# texinfo_appendices = []
241
-
242
-# If false, no module index is generated.
243
-# texinfo_domain_indices = True
244
-
245
-# How to display URL addresses: 'footnote', 'no', or 'inline'.
246
-# texinfo_show_urls = 'footnote'
247
-
248
-# If true, do not generate a @detailmenu in the "Top" node's menu.
249
-# texinfo_no_detailmenu = False
250
-
251
-# -- Options for Internationalization output ------------------------------
252
-locale_dirs = ['locale/']
253
-
254
-# -- Options for PDF output --------------------------------------------------
255
-
256
-pdf_documents = [
257
-    ('index', u'MonascaEventsApiAPIGuide', u'Key Manager API Guide', u'OpenStack '
258
-     'contributors')
259
-]

+ 0
- 35
api-guide/source/index.rst View File

@@ -1,35 +0,0 @@
1
-..
2
-      Copyright 2017 Fujitsu LIMITED
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
-==================
17
-Monasca Events API
18
-==================
19
-
20
-The monasca-events-api project has a RESTful HTTP service called the
21
-Monasca Events API. To this API , services (agents) can send events collected
22
-from OpenStack message bus.
23
-
24
-This guide covers the concepts in the Monasca Events API.
25
-For a full reference listing, please see:
26
-`Monasca Events API Reference <http://developer.openstack.org/api-ref/monasca/#monasca-events-api>`__.
27
-
28
-We welcome feedback, comments and bug reports at
29
-`storyboard/monasca <https://storyboard.openstack.org/#!/project_group/866>`__.
30
-
31
-
32
-Contents
33
-========
34
-.. toctree::
35
-    :maxdepth: 2

monasca_events_api_tempest/__init__.py → api-ref/locale/.gitkeep View File


+ 12
- 53
api-ref/source/conf.py View File

@@ -16,6 +16,8 @@
16 16
 # All configuration values have a default; values that are commented out
17 17
 # serve to show the default.
18 18
 
19
+from monasca_events_api.version import version_info
20
+
19 21
 # -- General configuration ------------------------------------------------
20 22
 
21 23
 # If your documentation needs a minimal Sphinx version, state it here.
@@ -43,18 +45,13 @@ master_doc = 'index'
43 45
 
44 46
 # General details about project
45 47
 repository_name = u'openstack/monasca-events-api'
46
-project = u'Monasca Events Ref Guide'
47
-bug_project = u'monasca-events-api'
48
-bug_tag = u'api-ref'
49
-copyright = u'2014, OpenStack Foundation'
50
-
51
-# The version info for the project you're documenting, acts as replacement for
52
-# |version| and |release|, also used in various other places throughout the
53
-# built documents.
54
-#
55
-from monasca_events_api.version import version_info
56
-version = version_info.version_string()
57
-release = version_info.release_string()
48
+project = u'Monitoring Events API Reference'
49
+version = version_info.canonical_version_string()
50
+release = version_info.version_string_with_vcs()
51
+bug_project = u'866'
52
+bug_tag = u''
53
+copyright = u'2014-present, OpenStack Foundation'
54
+author = u'OpenStack Foundation'
58 55
 
59 56
 # The language for content autogenerated by Sphinx. Refer to documentation
60 57
 # for a list of supported languages.
@@ -173,8 +170,7 @@ html_use_index = True
173 170
 # html_file_suffix = None
174 171
 
175 172
 # Output file base name for HTML help builder.
176
-htmlhelp_basename = 'monascaeventsapi-api-ref'
177
-
173
+htmlhelp_basename = 'MonitoringEventsApiRefDoc'
178 174
 
179 175
 # -- Options for LaTeX output ---------------------------------------------
180 176
 
@@ -193,8 +189,8 @@ latex_elements = {
193 189
 # (source start file, target name, title,
194 190
 #  author, documentclass [howto, manual, or own class]).
195 191
 latex_documents = [
196
-    (master_doc, 'MonascaEventsApi.tex', u'Monasca Events API Documentation',
197
-     u'OpenStack Foundation', 'manual'),
192
+    (master_doc, 'MonitoringEventsApiRef.tex', u'Monitoring Events API Reference',
193
+     [author], 'manual'),
198 194
 ]
199 195
 
200 196
 # The name of an image file (relative to this directory) to place at the top of
@@ -217,42 +213,5 @@ latex_documents = [
217 213
 # If false, no module index is generated.
218 214
 # latex_domain_indices = True
219 215
 
220
-
221
-# -- Options for manual page output ---------------------------------------
222
-
223
-# One entry per manual page. List of tuples
224
-# (source start file, name, description, authors, manual section).
225
-man_pages = [
226
-    (master_doc, 'monascaeventsapi', u'Monasca Events API Documentation',
227
-     [u'OpenStack Foundation'], 1)
228
-]
229
-
230
-# If true, show URL addresses after external links.
231
-# man_show_urls = False
232
-
233
-
234
-# -- Options for Texinfo output -------------------------------------------
235
-
236
-# Grouping the document tree into Texinfo files. List of tuples
237
-# (source start file, target name, title, author,
238
-#  dir menu entry, description, category)
239
-texinfo_documents = [
240
-    (master_doc, 'MonascaEventsAPI', u'Monasca Events API Documentation',
241
-     u'OpenStack Foundation', 'MonascaEventsAPI', 'Monasca Events API',
242
-     'Miscellaneous'),
243
-]
244
-
245
-# Documents to append as an appendix to all manuals.
246
-# texinfo_appendices = []
247
-
248
-# If false, no module index is generated.
249
-# texinfo_domain_indices = True
250
-
251
-# How to display URL addresses: 'footnote', 'no', or 'inline'.
252
-# texinfo_show_urls = 'footnote'
253
-
254
-# If true, do not generate a @detailmenu in the "Top" node's menu.
255
-# texinfo_no_detailmenu = False
256
-
257 216
 # -- Options for Internationalization output ------------------------------
258 217
 locale_dirs = ['locale/']

+ 1
- 1
api-ref/source/index.rst View File

@@ -1,7 +1,7 @@
1 1
 :tocdepth: 2
2 2
 
3 3
 ..
4
-      Copyright 2014-2017 Fujitsu LIMITED
4
+      Copyright 2017 Fujitsu LIMITED
5 5
 
6 6
       Licensed under the Apache License, Version 2.0 (the "License"); you may
7 7
       not use this file except in compliance with the License. You may obtain

+ 0
- 7
config-generator/README.md View File

@@ -1,7 +0,0 @@
1
-# config-generator
2
-
3
-To generate sample configuration execute
4
-
5
-```bash
6
-tox -e genconfig
7
-```

+ 11
- 0
config-generator/README.rst View File

@@ -0,0 +1,11 @@
1
+================
2
+config-generator
3
+================
4
+
5
+To generate sample configuration execute::
6
+
7
+    tox -e genconfig
8
+
9
+To generate the sample policies execute::
10
+
11
+    tox -e genpolicy

config-generator/monasca-events-api.conf → config-generator/config.conf View File

@@ -4,3 +4,4 @@ width = 80
4 4
 format = ini
5 5
 namespace = events.api
6 6
 namespace = oslo.log
7
+namespace = oslo.policy

+ 3
- 0
config-generator/policy.conf View File

@@ -0,0 +1,3 @@
1
+[DEFAULT]
2
+output_file = etc/monasca/events-policy.yaml.sample
3
+namespace = events.api

+ 0
- 0
doc/api-samples/.gitkeep View File


+ 1
- 0
doc/source/.gitignore View File

@@ -0,0 +1 @@
1
+_static/

+ 0
- 0
doc/source/.gitkeep View File


+ 0
- 114
doc/source/_static/events-api.conf.sample View File

@@ -1,114 +0,0 @@
1
-[DEFAULT]
2
-
3
-#
4
-# From oslo.log
5
-#
6
-
7
-# If set to true, the logging level will be set to DEBUG instead of
8
-# the default INFO level. (boolean value)
9
-# Note: This option can be changed without restarting.
10
-#debug = false
11
-
12
-# The name of a logging configuration file. This file is appended to
13
-# any existing logging configuration files. For details about logging
14
-# configuration files, see the Python logging module documentation.
15
-# Note that when logging configuration files are used then all logging
16
-# configuration is set in the configuration file and other logging
17
-# configuration options are ignored (for example,
18
-# logging_context_format_string). (string value)
19
-# Note: This option can be changed without restarting.
20
-# Deprecated group/name - [DEFAULT]/log_config
21
-#log_config_append = <None>
22
-
23
-# Defines the format string for %%(asctime)s in log records. Default:
24
-# %(default)s . This option is ignored if log_config_append is set.
25
-# (string value)
26
-#log_date_format = %Y-%m-%d %H:%M:%S
27
-
28
-# (Optional) Name of log file to send logging output to. If no default
29
-# is set, logging will go to stderr as defined by use_stderr. This
30
-# option is ignored if log_config_append is set. (string value)
31
-# Deprecated group/name - [DEFAULT]/logfile
32
-#log_file = <None>
33
-
34
-# (Optional) The base directory used for relative log_file  paths.
35
-# This option is ignored if log_config_append is set. (string value)
36
-# Deprecated group/name - [DEFAULT]/logdir
37
-#log_dir = <None>
38
-
39
-# Uses logging handler designed to watch file system. When log file is
40
-# moved or removed this handler will open a new log file with
41
-# specified path instantaneously. It makes sense only if log_file
42
-# option is specified and Linux platform is used. This option is
43
-# ignored if log_config_append is set. (boolean value)
44
-#watch_log_file = false
45
-
46
-# Use syslog for logging. Existing syslog format is DEPRECATED and
47
-# will be changed later to honor RFC5424. This option is ignored if
48
-# log_config_append is set. (boolean value)
49
-#use_syslog = false
50
-
51
-# Enable journald for logging. If running in a systemd environment you
52
-# may wish to enable journal support. Doing so will use the journal
53
-# native protocol which includes structured metadata in addition to
54
-# log messages.This option is ignored if log_config_append is set.
55
-# (boolean value)
56
-#use_journal = false
57
-
58
-# Syslog facility to receive log lines. This option is ignored if
59
-# log_config_append is set. (string value)
60
-#syslog_log_facility = LOG_USER
61
-
62
-# Log output to standard error. This option is ignored if
63
-# log_config_append is set. (boolean value)
64
-#use_stderr = false
65
-
66
-# Format string to use for log messages with context. (string value)
67
-#logging_context_format_string = %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [%(request_id)s %(user_identity)s] %(instance)s%(message)s
68
-
69
-# Format string to use for log messages when context is undefined.
70
-# (string value)
71
-#logging_default_format_string = %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s [-] %(instance)s%(message)s
72
-
73
-# Additional data to append to log message when logging level for the
74
-# message is DEBUG. (string value)
75
-#logging_debug_format_suffix = %(funcName)s %(pathname)s:%(lineno)d
76
-
77
-# Prefix each line of exception output with this format. (string
78
-# value)
79
-#logging_exception_prefix = %(asctime)s.%(msecs)03d %(process)d ERROR %(name)s %(instance)s
80
-
81
-# Defines the format string for %(user_identity)s that is used in
82
-# logging_context_format_string. (string value)
83
-#logging_user_identity_format = %(user)s %(tenant)s %(domain)s %(user_domain)s %(project_domain)s
84
-
85
-# List of package logging levels in logger=LEVEL pairs. This option is
86
-# ignored if log_config_append is set. (list value)
87
-#default_log_levels = amqp=WARN,amqplib=WARN,boto=WARN,qpid=WARN,sqlalchemy=WARN,suds=INFO,oslo.messaging=INFO,oslo_messaging=INFO,iso8601=WARN,requests.packages.urllib3.connectionpool=WARN,urllib3.connectionpool=WARN,websocket=WARN,requests.packages.urllib3.util.retry=WARN,urllib3.util.retry=WARN,keystonemiddleware=WARN,routes.middleware=WARN,stevedore=WARN,taskflow=WARN,keystoneauth=WARN,oslo.cache=INFO,dogpile.core.dogpile=INFO
88
-
89
-# Enables or disables publication of error events. (boolean value)
90
-#publish_errors = false
91
-
92
-# The format for an instance that is passed with the log message.
93
-# (string value)
94
-#instance_format = "[instance: %(uuid)s] "
95
-
96
-# The format for an instance UUID that is passed with the log message.
97
-# (string value)
98
-#instance_uuid_format = "[instance: %(uuid)s] "
99
-
100
-# Interval, number of seconds, of log rate limiting. (integer value)
101
-#rate_limit_interval = 0
102
-
103
-# Maximum number of logged messages per rate_limit_interval. (integer
104
-# value)
105
-#rate_limit_burst = 0
106
-
107
-# Log level name used by rate limiting: CRITICAL, ERROR, INFO,
108
-# WARNING, DEBUG or empty string. Logs with level greater or equal to
109
-# rate_limit_except_level are not filtered. An empty string means that
110
-# all levels are filtered. (string value)
111
-#rate_limit_except_level = CRITICAL
112
-
113
-# Enables or disables fatal status of deprecations. (boolean value)
114
-#fatal_deprecations = false

+ 6
- 0
doc/source/admin/index.rst View File

@@ -0,0 +1,6 @@
1
+====================
2
+Administration guide
3
+====================
4
+
5
+.. toctree::
6
+   :maxdepth: 2

+ 3
- 0
doc/source/cli/index.rst View File

@@ -0,0 +1,3 @@
1
+======================
2
+Command Line Interface
3
+======================

+ 0
- 7
doc/source/code/modules.rst View File

@@ -1,7 +0,0 @@
1
-monasca_events_api
2
-==================
3
-
4
-.. toctree::
5
-   :maxdepth: 4
6
-
7
-   monasca_events_api

+ 0
- 8
doc/source/code/monasca_events_api.conf.rst View File

@@ -1,8 +0,0 @@
1
-monasca\_events\_api\.conf package
2
-==================================
3
-
4
-.. automodule:: monasca_events_api.conf
5
-    :members:
6
-    :undoc-members:
7
-    :show-inheritance:
8
-

+ 0
- 35
doc/source/code/monasca_events_api.rst View File

@@ -1,35 +0,0 @@
1
-monasca\_events\_api package
2
-============================
3
-
4
-.. automodule:: monasca_events_api
5
-    :members:
6
-    :undoc-members:
7
-    :show-inheritance:
8
-
9
-Subpackages
10
------------
11
-
12
-.. toctree::
13
-
14
-    monasca_events_api.conf
15
-
16
-Submodules
17
-----------
18
-
19
-monasca\_events\_api\.config module
20
------------------------------------
21
-
22
-.. automodule:: monasca_events_api.config
23
-    :members:
24
-    :undoc-members:
25
-    :show-inheritance:
26
-
27
-monasca\_events\_api\.version module
28
-------------------------------------
29
-
30
-.. automodule:: monasca_events_api.version
31
-    :members:
32
-    :undoc-members:
33
-    :show-inheritance:
34
-
35
-

+ 20
- 38
doc/source/conf.py View File

@@ -1,6 +1,6 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 #
3
-# monasca-events-api documentation build configuration file, created by
3
+# monasca-events-app documentation build configuration file, created by
4 4
 # sphinx-quickstart on Wed Nov 18 12:02:03 2015.
5 5
 #
6 6
 # This file is execfile()d with the current directory set to its
@@ -19,7 +19,9 @@ from monasca_events_api.version import version_info
19 19
 
20 20
 sys.path = [
21 21
     os.path.abspath('../..'),
22
-    os.path.abspath('../../bin')
22
+    os.path.abspath('../../bin'),
23
+    os.path.abspath('./'),
24
+    os.path.abspath('../')
23 25
 ] + sys.path
24 26
 
25 27
 # -- General configuration ------------------------------------------------
@@ -37,25 +39,30 @@ extensions = [
37 39
     'sphinx.ext.autodoc',
38 40
     'sphinx.ext.viewcode',
39 41
     'oslo_config.sphinxconfiggen',
42
+    'oslo_policy.sphinxpolicygen',
40 43
     'oslo_config.sphinxext',
41 44
     'openstackdocstheme',
42 45
 ]
43 46
 
44 47
 # geeneral information about project
45 48
 repository_name = u'openstack/monasca-events-api'
46
-project = u'Monasca Events Dev Docs'
47
-version = version_info.version_string()
48
-release = version_info.release_string()
49
-bug_project = u'monasca-events-api'
50
-bug_tag = u'doc'
49
+project = u'monasca'
50
+version = version_info.canonical_version_string()
51
+release = version_info.version_string_with_vcs()
52
+bug_project = u'866'
53
+bug_tag = u''
51 54
 copyright = u'2017-present, OpenStack Foundation'
52 55
 author = u'OpenStack Foundation'
53 56
 
54 57
 # sample config
55 58
 config_generator_config_file = [
56
-    ('config-generator/monasca-events-api.conf', '_static/events-api')
59
+    ('config-generator/config.conf', '_static/events-api')
57 60
 ]
58 61
 
62
+# sample policy file
63
+policy_generator_config_file = 'config-generator/policy.conf'
64
+sample_policy_basename = '_static/events-api'
65
+
59 66
 # Add any paths that contain templates here, relative to this directory.
60 67
 templates_path = ['_templates']
61 68
 
@@ -194,7 +201,7 @@ html_use_modindex = True
194 201
 #html_search_scorer = 'scorer.js'
195 202
 
196 203
 # Output file base name for HTML help builder.
197
-htmlhelp_basename = 'monasca-events-apidoc'
204
+htmlhelp_basename = 'MonitoringEventsApiDoc'
198 205
 
199 206
 # -- Options for LaTeX output ---------------------------------------------
200 207
 
@@ -216,8 +223,8 @@ latex_elements = {
216 223
 # (source start file, target name, title,
217 224
 #  author, documentclass [howto, manual, or own class]).
218 225
 latex_documents = [
219
-  (master_doc, 'monasca-events-api.tex', u'monasca-events-api Documentation',
220
-   u'Openstack Foundation \\textless{}monasca@lists.launchpad.net\\textgreater{}', 'manual'),
226
+    (master_doc, 'MonitoringEventsApi.tex', u'Monasca Events Documentation',
227
+     [author], 'manual'),
221 228
 ]
222 229
 
223 230
 # The name of an image file (relative to this directory) to place at the top of
@@ -246,37 +253,12 @@ latex_documents = [
246 253
 # One entry per manual page. List of tuples
247 254
 # (source start file, name, description, authors, manual section).
248 255
 man_pages = [
249
-    (master_doc, 'monasca-events-api', u'monasca-events-api Documentation',
256
+    (master_doc, 'monitoringeventsapi', u'Monasca Events Documentation',
250 257
      [author], 1)
251 258
 ]
252 259
 
253 260
 # If true, show URL addresses after external links.
254 261
 #man_show_urls = False
255 262
 
256
-
257
-# -- Options for Texinfo output -------------------------------------------
258
-
259
-# Grouping the document tree into Texinfo files. List of tuples
260
-# (source start file, target name, title, author,
261
-#  dir menu entry, description, category)
262
-texinfo_documents = [
263
-  (master_doc, 'monasca-events-api', u'monasca-events-api Documentation',
264
-   author, 'monasca-events-api', 'Rest-API to collect events from your cloud.',
265
-   'Miscellaneous'),
266
-]
267
-
268
-# Documents to append as an appendix to all manuals.
269
-#texinfo_appendices = []
270
-
271
-# If false, no module index is generated.
272
-#texinfo_domain_indices = True
273
-
274
-# How to display URL addresses: 'footnote', 'no', or 'inline'.
275
-#texinfo_show_urls = 'footnote'
276
-
277
-# If true, do not generate a @detailmenu in the "Top" node's menu.
278
-#texinfo_no_detailmenu = False
279
-
280
-
281 263
 # Example configuration for intersphinx: refer to the Python standard library.
282
-intersphinx_mapping = {'https://doc.python.org/': None}
264
+intersphinx_mapping = {'https://doc.python.org/': None}

+ 3
- 0
doc/source/configuration/index.rst View File

@@ -0,0 +1,3 @@
1
+=============
2
+Configuration
3
+=============

+ 3
- 0
doc/source/contributor/.gitignore View File

@@ -0,0 +1,3 @@
1
+# codebase documentation is autogenerated
2
+# do not track it
3
+api/

+ 19
- 0
doc/source/contributor/code.rst View File

@@ -0,0 +1,19 @@
1
+.. _codedocs:
2
+
3
+======================
4
+Codebase documentation
5
+======================
6
+
7
+Following section contains codebase documentation generated with, a little
8
+bit of assistance, `sphinx.ext.autodoc`_.
9
+
10
+.. _`sphinx.ext.autodoc`: http://www.sphinx-doc.org/en/stable/ext/autodoc.html
11
+
12
+Modules
13
+=======
14
+
15
+.. toctree::
16
+   :maxdepth: 2
17
+
18
+   api/autoindex.rst
19
+

+ 1
- 0
doc/source/contributor/history.rst View File

@@ -0,0 +1 @@
1
+.. include:: ../../../ChangeLog

+ 37
- 0
doc/source/contributor/index.rst View File

@@ -0,0 +1,37 @@
1
+=======================
2
+Contribution Guidelines
3
+=======================
4
+
5
+In the Contributions Guide, you will find documented policies for
6
+developing with monasca-events-api. This includes the processes we use for
7
+blueprints and specs, bugs, contributor on boarding, core reviewer
8
+memberships, and other procedural items.
9
+
10
+monasca-events-api, as with all OpenStack projects, is written with the
11
+following design guidelines in mind:
12
+
13
+* **Component based architecture**: Quickly add new behaviors
14
+* **Highly available**: Scale to very serious workloads
15
+* **Fault tolerant**: Isolated processes avoid cascading failures
16
+* **Recoverable**: Failures should be easy to diagnose, debug, and rectify
17
+* **Open standards**: Be a reference implementation for a community-driven api
18
+
19
+This documentation is generated by the Sphinx toolkit and lives in the source
20
+tree. Additional documentation on monasca-events-api and other components of
21
+OpenStack can be found on the `OpenStack wiki <http://wiki.openstack.org>`_.
22
+
23
+Developer reference
24
+-------------------
25
+
26
+.. toctree::
27
+   :maxdepth: 1
28
+
29
+   code
30
+
31
+Changelog
32
+---------
33
+
34
+.. toctree::
35
+   :maxdepth: 1
36
+
37
+   history

+ 3
- 0
doc/source/glossary.rst View File

@@ -0,0 +1,3 @@
1
+========
2
+Glossary
3
+========

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

@@ -45,4 +45,3 @@ any specific prior release.
45 45
    :maxdepth: 1
46 46
 
47 47
    glossary
48
-

+ 6
- 0
doc/source/install/index.rst View File

@@ -0,0 +1,6 @@
1
+============
2
+Installation
3
+============
4
+
5
+.. toctree::
6
+   :maxdepth: 2

+ 6
- 0
doc/source/user/index.rst View File

@@ -0,0 +1,6 @@
1
+==========
2
+User guide
3
+==========
4
+
5
+.. toctree::
6
+   :maxdepth: 2

+ 31
- 0
etc/monasca/events-api-paste.ini View File

@@ -0,0 +1,31 @@
1
+# Copyright 2017 FUJITSU LIMITED
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
+[DEFAULT]
16
+name = main
17
+
18
+[composite:main]
19
+use = egg:Paste#urlmap
20
+/: ea_version
21
+/v1.0: ea_version_v1
22
+
23
+[pipeline:ea_version_v1]
24
+pipeline = request_id auth
25
+
26
+
27
+[filter:request_id]
28
+paste.filter_factory = oslo_middleware.request_id:RequestId.factory
29
+
30
+[filter:auth]
31
+paste.filter_factory = keystonemiddleware.auth_token:filter_factory

+ 0
- 0
monasca_events_api/app/__init__.py View File


+ 0
- 0
monasca_events_api/app/core/__init__.py View File


+ 41
- 0
monasca_events_api/app/core/request.py View File

@@ -0,0 +1,41 @@
1
+# Copyright 2017 FUJITSU LIMITED
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
+import falcon
16
+
17
+from oslo_context import context
18
+
19
+from monasca_events_api import policy
20
+
21
+
22
+class Request(falcon.Request):
23
+    """Variation of falcon. Request with context.
24
+
25
+    Following class enhances :py:class:`falcon.Request` with
26
+    :py:class:`context.RequestContext`
27
+    """
28
+
29
+    def __init__(self, env, options=None):
30
+        """Init an Request class."""
31
+        super(Request, self).__init__(env, options)
32
+        self.is_admin = None
33
+        self.context = context.RequestContext.from_environ(self.env)
34
+
35
+        if self.is_admin is None:
36
+            self.is_admin = policy.check_is_admin(self)
37
+
38
+    def to_policy_values(self):
39
+        policy = self.context.to_policy_values()
40
+        policy['is_admin'] = self.is_admin
41
+        return policy

+ 3
- 5
monasca_events_api/conf/__init__.py View File

@@ -15,18 +15,16 @@
15 15
 import os
16 16
 import pkgutil
17 17
 
18
-from oslo_config import cfg
19 18
 from oslo_log import log
20 19
 from oslo_utils import importutils
21 20
 
22
-CONF = cfg.CONF
23 21
 LOG = log.getLogger(__name__)
24 22
 
25 23
 
26 24
 def load_conf_modules():
27 25
     """Load all modules that contain configuration.
28 26
 
29
-    Method iterates over modules of :py:module:`monasca_log_api.conf`
27
+    Method iterates over modules of :py:mod:`monasca_events_api.conf`
30 28
     and imports only those that contain following methods:
31 29
 
32 30
     - list_opts (required by oslo_config.genconfig)
@@ -62,7 +60,7 @@ def _list_module_names():
62 60
     return module_names
63 61
 
64 62
 
65
-def register_opts():
63
+def register_opts(conf):
66 64
     """Register all conf modules opts.
67 65
 
68 66
     This method allows different modules to register
@@ -70,7 +68,7 @@ def register_opts():
70 68
 
71 69
     """
72 70
     for mod in load_conf_modules():
73
-        mod.register_opts(CONF)
71
+        mod.register_opts(conf)
74 72
 
75 73
 
76 74
 def list_opts():

+ 8
- 4
monasca_events_api/config.py View File

@@ -12,12 +12,14 @@
12 12
 # License for the specific language governing permissions and limitations
13 13
 # under the License.
14 14
 
15
+from oslo_config import cfg
15 16
 from oslo_log import log
17
+from oslo_policy import opts as policy_opts
16 18
 
17 19
 from monasca_events_api import conf
18 20
 from monasca_events_api import version
19 21
 
20
-CONF = conf.CONF
22
+CONF = cfg.CONF
21 23
 LOG = log.getLogger(__name__)
22 24
 
23 25
 _CONF_LOADED = False
@@ -39,15 +41,17 @@ def parse_args():
39 41
     log.set_defaults()
40 42
     log.register_options(CONF)
41 43
 
42
-    CONF(prog='events-api',
44
+    CONF(args=[],
45
+         prog='events-app',
43 46
          project='monasca',
44 47
          version=version.version_str,
45 48
          description='RESTful API to collect events from cloud')
46 49
 
47 50
     log.setup(CONF,
48
-              product_name='monasca-events-api',
51
+              product_name='monasca-events-app',
49 52
               version=version.version_str)
50 53
 
51
-    conf.register_opts()
54
+    conf.register_opts(CONF)
55
+    policy_opts.set_defaults(CONF)
52 56
 
53 57
     _CONF_LOADED = True

+ 58
- 0
monasca_events_api/policies/__init__.py View File

@@ -0,0 +1,58 @@
1
+# Copyright 2017 FUJITSU LIMITED
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
+import os
16
+import pkgutil
17
+
18
+from oslo_log import log
19
+from oslo_utils import importutils
20
+
21
+LOG = log.getLogger(__name__)
22
+_BASE_MOD_PATH = 'monasca_events_api.policies.'
23
+
24
+
25
+def load_policy_modules():
26
+    """Load all modules that contain policies.
27
+
28
+    Method iterates over modules of :py:mod:`monasca_events_api.policies`
29
+    and imports only those that contain following methods:
30
+
31
+    - list_opts (required by oslo_config.genconfig)
32
+    - register_opts (required by :py:currentmodule:)
33
+
34
+    """
35
+    for modname in _list_module_names():
36
+        mod = importutils.import_module(_BASE_MOD_PATH + modname)
37
+        if hasattr(mod, 'list_rules'):
38
+            yield mod
39
+
40
+
41
+def _list_module_names():
42
+    package_path = os.path.dirname(os.path.abspath(__file__))
43
+    for _, modname, ispkg in pkgutil.iter_modules(path=[package_path]):
44
+        if not (modname == "opts" and ispkg):
45
+            yield modname
46
+
47
+
48
+def list_rules():
49
+    """List all policy modules rules.
50
+
51
+    Goes through all policy modules and yields their rules
52
+
53
+    """
54
+    all_rules = []
55
+    for mod in load_policy_modules():
56
+        rules = mod.list_rules()
57
+        all_rules.extend(rules)
58
+    return all_rules

+ 30
- 0
monasca_events_api/policies/admin.py View File

@@ -0,0 +1,30 @@
1
+# Copyright 2017 FUJITSU LIMITED
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
+from oslo_policy import policy
16
+
17
+
18
+admin_rules = [
19
+    policy.DocumentedRuleDefault(
20
+        name='admin_required',
21
+        check_str='role:admin or is_admin:1',
22
+        description='Admin role',
23
+        operations=[{'path': '/', 'method': 'POST'}]
24
+    ),
25
+]
26
+
27
+
28
+def list_rules():
29
+    """List policy rules for admin access."""
30
+    return admin_rules

+ 30
- 0
monasca_events_api/policies/agent.py View File

@@ -0,0 +1,30 @@
1
+# Copyright 2017 FUJITSU LIMITED
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
+from oslo_policy import policy
16
+
17
+
18
+agent_policies = [
19
+    policy.DocumentedRuleDefault(
20
+        name='events_api:agent_required',
21
+        check_str='role:monasca_events_agent',
22
+        description='Send events to api',
23
+        operations=[{'path': '/v1.0/events', 'method': 'POST'}]
24
+    )
25
+]
26
+
27
+
28
+def list_rules():
29
+    """List policies rules for agent access."""
30
+    return agent_policies

+ 148
- 0
monasca_events_api/policy.py View File

@@ -0,0 +1,148 @@
1
+# Copyright 2017 FUJITSU LIMITED
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
+import copy
16
+
17
+from oslo_config import cfg
18
+from oslo_log import log
19
+from oslo_policy import policy
20
+
21
+from monasca_events_api import policies
22
+
23
+CONF = cfg.CONF
24
+LOG = log.getLogger(__name__)
25
+
26
+_ENFORCER = None
27
+# oslo_policy will read the policy configuration file again when the file
28
+# is changed in runtime so the old policy rules will be saved to
29
+# saved_file_rules and used to compare with new rules to determine the
30
+# rules whether were updated.
31
+saved_file_rules = []
32
+
33
+
34
+def reset():
35
+    """Reset Enforcer class."""
36
+    global _ENFORCER
37
+    if _ENFORCER:
38
+        _ENFORCER.clear()
39
+        _ENFORCER = None
40
+
41
+
42
+def init(policy_file=None, rules=None, default_rule=None, use_conf=True):
43
+    """Init an Enforcer class."""
44
+    global _ENFORCER
45
+    global saved_file_rules
46
+
47
+    if not _ENFORCER:
48
+        _ENFORCER = policy.Enforcer(CONF,
49
+                                    policy_file=policy_file,
50
+                                    rules=rules,
51
+                                    default_rule=default_rule,
52
+                                    use_conf=use_conf
53
+                                    )
54
+        register_rules(_ENFORCER)
55
+        _ENFORCER.load_rules()
56
+    # Only the rules which are loaded from file may be changed
57
+    current_file_rules = _ENFORCER.file_rules
58
+    current_file_rules = _serialize_rules(current_file_rules)
59
+
60
+    if saved_file_rules != current_file_rules:
61
+        saved_file_rules = copy.deepcopy(current_file_rules)
62
+
63
+
64
+def _serialize_rules(rules):
65
+    """Serialize all the Rule object as string.
66
+
67
+    New string is used to compare the rules list.
68
+    """
69
+    result = [(rule_name, str(rule)) for rule_name, rule in rules.items()]
70
+    return sorted(result, key=lambda rule: rule[0])
71
+
72
+
73
+def register_rules(enforcer):
74
+    """Register default policy rules."""
75
+    rules = policies.list_rules()
76
+    enforcer.register_defaults(rules)
77
+
78
+
79
+def authorize(context, action, target, do_raise=True):
80
+    """Verify that the action is valid on the target in this context.
81
+
82
+    :param context: monasca-events-api context
83
+    :param action: String representing the action to be checked. This
84
+                   should be colon separated for clarity.
85
+    :param target: Dictionary representing the object of the action for
86
+                   object creation. This should be a dictionary representing
87
+                   the location of the object e.g.
88
+                   ``{'project_id': 'context.project_id'}``
89
+    :param do_raise: if True (the default), raises PolicyNotAuthorized,
90
+                     if False returns False
91
+    :type context: object
92
+    :type action: str
93
+    :type target: dict
94
+    :type do_raise: bool
95
+    :return: returns a non-False value (not necessarily True) if authorized,
96
+             and the False if not authorized and do_raise if False
97
+
98
+    :raises oslo_policy.policy.PolicyNotAuthorized: if verification fails
99
+    """
100
+    init()
101
+    credentials = context.to_policy_values()
102
+
103
+    try:
104
+        result = _ENFORCER.authorize(action, target, credentials,
105
+                                     do_raise=do_raise, action=action)
106
+        return result
107
+    except policy.PolicyNotRegistered:
108
+        LOG.exception('Policy not registered')
109
+        raise
110
+    except Exception:
111
+        LOG.debug('Policy check for %(action)s failed with credentials '
112
+                  '%(credentials)s',
113
+                  {'action': action, 'credentials': credentials})
114
+        raise
115
+
116
+
117
+def check_is_admin(context):
118
+    """Check if roles contains 'admin' role according to policy settings."""
119
+    init()
120
+    credentials = context.to_policy_values()
121
+    target = credentials
122
+    return _ENFORCER.authorize('admin_required', target, credentials)
123
+
124
+
125
+def set_rules(rules, overwrite=True, use_conf=False):  # pragma: no cover
126
+    """Set rules based on the provided dict of rules.
127
+
128
+    Note:
129
+        Used in tests only.
130
+
131
+    :param rules: New rules to use. It should be an instance of dict
132
+    :param overwrite: Whether to overwrite current rules or update them
133
+                      with the new rules.
134
+    :param use_conf: Whether to reload rules from config file.
135
+    """
136
+    init(use_conf=False)
137
+    _ENFORCER.set_rules(rules, overwrite, use_conf)
138
+
139
+
140
+def get_rules():  # pragma: no cover
141
+    """Get policy rules.
142
+
143
+    Note:
144
+        Used in tests only.
145
+
146
+    """
147
+    if _ENFORCER:
148
+        return _ENFORCER.rules

+ 0
- 0
monasca_events_api/tests/__init__.py View File


+ 0
- 0
monasca_events_api/tests/functional/__init__.py View File


+ 0
- 0
monasca_events_api/tests/unit/__init__.py View File


+ 95
- 0
monasca_events_api/tests/unit/base.py View File

@@ -0,0 +1,95 @@
1
+# Copyright 2017 FUJITSU LIMITED
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
+import os
16
+
17
+import fixtures
18
+from oslo_config import cfg
19
+from oslo_config import fixture as config_fixture
20
+from oslo_context import fixture as oc_fixture
21
+from oslo_log.fixture import logging_error as log_fixture
22
+from oslo_serialization import jsonutils
23
+from oslotest import base
24
+
25
+from monasca_events_api import config
26
+from monasca_events_api import policies
27
+from monasca_events_api import policy
28
+
29
+CONF = cfg.CONF
30
+
31
+
32
+class ConfigFixture(config_fixture.Config):
33
+
34
+    def setUp(self):
35
+        super(ConfigFixture, self).setUp()
36
+        self.addCleanup(self._clean_config_loaded_flag)
37
+        config.parse_args()
38
+
39
+    @staticmethod
40
+    def _clean_config_loaded_flag():
41
+        config._CONF_LOADED = False
42
+
43
+
44
+class BaseTestCase(base.BaseTestCase):
45
+
46
+    def setUp(self):
47
+        super(BaseTestCase, self).setUp()
48
+        self.useFixture(fixtures.NestedTempfile())
49
+        self.useFixture(fixtures.TempHomeDir())
50
+        self.useFixture(log_fixture.get_logging_handle_error_fixture())
51
+        self.useFixture(ConfigFixture(CONF))
52
+        self.useFixture(oc_fixture.ClearRequestContext())
53
+        self.useFixture(PolicyFixture())
54
+
55
+    @staticmethod
56
+    def conf_override(**kw):
57
+        """Override flag variables for a test."""
58
+        group = kw.pop('group', None)
59
+        for k, v in kw.items():
60
+            CONF.set_override(k, v, group)
61
+
62
+
63
+class PolicyFixture(fixtures.Fixture):
64
+    """Override the policy with a completely new policy file.
65
+
66
+    This overrides the policy with a completely fake and synthetic
67
+    policy file.
68
+
69
+    """
70
+
71
+    def setUp(self):
72
+        super(PolicyFixture, self).setUp()
73
+        self._prepare_policy()
74
+        policy.reset()
75
+        policy.init()
76
+        self.addCleanup(policy.reset)
77
+
78
+    def _prepare_policy(self):
79
+        policy_dir = self.useFixture(fixtures.TempDir())
80
+        policy_file = os.path.join(policy_dir.path, 'policy.yaml')
81
+
82
+        # load the fake_policy data and add the missing default rules.
83
+        policy_rules = jsonutils.loads('{}')
84
+        self.add_missing_default_rules(policy_rules)
85
+        with open(policy_file, 'w') as f:
86
+            jsonutils.dump(policy_rules, f)
87
+
88
+        BaseTestCase.conf_override(policy_file=policy_file,
89
+                                   group='oslo_policy')
90
+        BaseTestCase.conf_override(policy_dirs=[], group='oslo_policy')
91
+
92
+    def add_missing_default_rules(self, rules):
93
+        for rule in policies.list_rules():
94
+            if rule.name not in rules:
95
+                rules[rule.name] = rule.check_str

+ 149
- 0
monasca_events_api/tests/unit/test_policy.py View File

@@ -0,0 +1,149 @@
1
+# Copyright 2017 FUJITSU LIMITED
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
+from falcon import testing
15
+
16
+from oslo_context import context
17
+from oslo_policy import policy as os_policy
18
+
19
+from monasca_events_api.app.core import request
20
+from monasca_events_api import policy
21
+from monasca_events_api.tests.unit import base
22
+
23
+
24
+class TestPolicyFileCase(base.BaseTestCase):
25
+    def setUp(self):
26
+        super(TestPolicyFileCase, self).setUp()
27
+        self.context = context.RequestContext(user='fake',
28
+                                              tenant='fake',
29
+                                              is_admin=False)
30
+        self.target = {'tenant_id': 'fake'}
31
+
32
+    def test_modified_policy_reloads(self):
33
+        tmp_file = \
34
+            self.create_tempfiles(files=[('policies', '{}')], ext='.yaml')[0]
35
+        base.BaseTestCase.conf_override(policy_file=tmp_file,
36
+                                        group='oslo_policy')
37
+
38
+        policy.reset()
39
+        policy.init()
40
+
41
+        action = 'example:test'
42
+        rule = os_policy.RuleDefault(action, '')
43
+        policy._ENFORCER.register_defaults([rule])
44
+
45
+        with open(tmp_file, 'w') as policy_file:
46
+            policy_file.write('{"example:test": ""}')
47
+        policy.authorize(self.context, action, self.target)
48
+
49
+        with open(tmp_file, 'w') as policy_file:
50
+            policy_file.write('{"example:test": "!"}')
51
+        policy._ENFORCER.load_rules(True)
52
+        self.assertRaises(os_policy.PolicyNotAuthorized, policy.authorize,
53
+                          self.context, action, self.target)
54
+
55
+
56
+class TestPolicyCase(base.BaseTestCase):
57
+    def setUp(self):
58
+        super(TestPolicyCase, self).setUp()
59
+        rules = [
60
+            os_policy.RuleDefault("true", "@"),
61
+            os_policy.RuleDefault("example:allowed", "@"),
62
+            os_policy.RuleDefault("example:denied", "!"),
63
+            os_policy.RuleDefault("example:lowercase_admin",
64
+                                  "role:admin or role:sysadmin"),
65
+            os_policy.RuleDefault("example:uppercase_admin",
66
+                                  "role:ADMIN or role:sysadmin"),
67
+        ]
68
+        policy.reset()
69
+        policy.init()
70
+        policy._ENFORCER.register_defaults(rules)
71
+
72
+    def test_authorize_nonexist_action_throws(self):
73
+        action = "example:noexist"
74
+        ctx = request.Request(
75
+            testing.create_environ(
76
+                path="/",
77
+                headers={
78
+                    "X_USER_ID": "fake",
79
+                    "X_PROJECT_ID": "fake",
80
+                    "X_ROLES": "member"
81
+                }
82
+            )
83
+        )
84
+        self.assertRaises(os_policy.PolicyNotRegistered, policy.authorize,
85
+                          ctx, action, {})
86
+
87
+    def test_authorize_bad_action_throws(self):
88
+        action = "example:denied"
89
+        ctx = request.Request(
90
+            testing.create_environ(
91
+                path="/",
92
+                headers={
93
+                    "X_USER_ID": "fake",
94
+                    "X_PROJECT_ID": "fake",
95
+                    "X_ROLES": "member"
96
+                }
97
+            )
98
+        )
99
+        self.assertRaises(os_policy.PolicyNotAuthorized, policy.authorize,
100
+                          ctx, action, {})
101
+
102
+    def test_authorize_bad_action_no_exception(self):
103
+        action = "example:denied"
104
+        ctx = request.Request(
105
+            testing.create_environ(
106
+                path="/",
107
+                headers={
108
+                    "X_USER_ID": "fake",
109
+                    "X_PROJECT_ID": "fake",
110
+                    "X_ROLES": "member"
111
+                }
112
+            )
113
+        )
114
+        result = policy.authorize(ctx, action, {}, False)
115
+        self.assertFalse(result)
116
+
117
+    def test_authorize_good_action(self):
118
+        action = "example:allowed"
119
+        ctx = request.Request(
120
+            testing.create_environ(
121
+                path="/",
122
+                headers={
123
+                    "X_USER_ID": "fake",
124
+                    "X_PROJECT_ID": "fake",
125
+                    "X_ROLES": "member"
126
+                }
127
+            )
128
+        )
129
+        result = policy.authorize(ctx, action, False)
130
+        self.assertTrue(result)
131
+
132
+    def test_ignore_case_role_check(self):
133
+        lowercase_action = "example:lowercase_admin"
134
+        uppercase_action = "example:uppercase_admin"
135
+
136
+        admin_context = request.Request(
137
+            testing.create_environ(
138
+                path="/",
139
+                headers={
140
+                    "X_USER_ID": "admin",
141
+                    "X_PROJECT_ID": "fake",
142
+                    "X_ROLES": "AdMiN"
143
+                }
144
+            )
145
+        )
146
+        self.assertTrue(policy.authorize(admin_context, lowercase_action,
147
+                                         {}))
148
+        self.assertTrue(policy.authorize(admin_context, uppercase_action,
149
+                                         {}))

+ 68
- 0
monasca_events_api/tests/unit/test_request.py View File

@@ -0,0 +1,68 @@
1
+# Copyright 2017 FUJITSU LIMITED
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
+from falcon import testing
16
+
17
+from monasca_events_api.app.core import request
18
+from monasca_events_api.tests.unit import base
19
+
20
+
21
+class TestRequest(base.BaseTestCase):
22
+
23
+    def setUp(self):
24
+        super(TestRequest, self).setUp()
25
+
26
+    def test_use_context_from_request(self):
27
+        req = request.Request(
28
+            testing.create_environ(
29
+                path='/',
30
+                headers={
31
+                    'X_AUTH_TOKEN': '1111',
32
+                    'X_USER_ID': '2222',
33
+                    'X_PROJECT_ID': '3333',
34
+                    'X_ROLES': 'goku,vegeta'
35
+                }
36
+            )
37
+        )
38
+        self.assertEqual('1111', req.context.auth_token)
39
+        self.assertEqual('2222', req.context.user_id)
40
+        self.assertEqual('3333', req.context.project_id)
41
+        self.assertItemsEqual(['goku', 'vegeta'], req.context.roles)
42
+
43
+    def test_check_is_admin_from_request(self):
44
+        req = request.Request(
45
+            testing.create_environ(
46
+                path='/',
47
+                headers={
48
+                    'X_USER_ID': '2222',
49
+                    'X_PROJECT_ID': '3333',
50
+                    'X_ROLES': 'admin,burger'
51
+                }
52
+            ),
53
+
54
+        )
55
+        self.assertTrue(req.is_admin)
56
+
57
+    def test_request_context_admin_uppercase(self):
58
+        req = request.Request(
59
+            testing.create_environ(
60
+                path='/',
61
+                headers={
62
+                    'X_USER_ID': '1111',
63
+                    'X_PROJECT_ID': '2222',
64
+                    'X_ROLES': 'Admin,bob'
65
+                }
66
+            )
67
+        )
68
+        self.assertTrue(req.is_admin)

+ 1
- 1
monasca_events_api/version.py View File

@@ -14,5 +14,5 @@
14 14
 
15 15
 import pbr.version
16 16
 
17
-version_info = pbr.version.VersionInfo('monasca-events-api')
17
+version_info = pbr.version.VersionInfo('monasca-events-app')
18 18
 version_str = version_info.version_string()

+ 9
- 0
releasenotes/notes/add_policies-24ddd2a505f3de6c.yaml View File

@@ -0,0 +1,9 @@
1
+---
2
+
3
+features:
4
+  - |
5
+    Initial implementation of oslo.policies.
6
+
7
+other:
8
+  - |
9
+    Add posibility to generate documentation with oslo-config-generator.

+ 16
- 46
releasenotes/source/conf.py View File

@@ -11,6 +11,8 @@
11 11
 # See the License for the specific language governing permissions and
12 12
 # limitations under the License.
13 13
 
14
+from monasca_events_api.version import version_info
15
+
14 16
 # -- General configuration ------------------------------------------------
15 17
 
16 18
 # If your documentation needs a minimal Sphinx version, state it here.
@@ -38,18 +40,13 @@ master_doc = 'index'
38 40
 
39 41
 # General information about the project.
40 42
 repository_name = u'openstack/monasca-events-api'
41
-project = u'Monasca Events Release Notes'
42
-bug_project = u'monasca-events-api'
43
-bug_tag = u'releasenotes'
44
-copyright = u'2014, OpenStack Foundation'
45
-
46
-# The version info for the project you're documenting, acts as replacement for
47
-# |version| and |release|, also used in various other places throughout the
48
-# built documents.
49
-#
50
-from monasca_events_api.version import version_info
43
+project = u'Openstack Monitoring Release Notes'
51 44
 version = version_info.canonical_version_string()
52 45
 release = version_info.version_string_with_vcs()
46
+bug_project = u'866'
47
+bug_tag = u''
48
+copyright = u'2014-present, OpenStack Foundation'
49
+author = u'OpenStack Foundation'
53 50
 
54 51
 # The language for content autogenerated by Sphinx. Refer to documentation
55 52
 # for a list of supported languages.
@@ -172,8 +169,7 @@ html_last_updated_fmt = '%Y-%m-%d %H:%M'
172 169
 # html_file_suffix = None
173 170
 
174 171
 # Output file base name for HTML help builder.
175
-htmlhelp_basename = 'MonascaEventsApiReleaseNotesdoc'
176
-
172
+htmlhelp_basename = 'MonitoringEventsApiReleaseNotesDoc'
177 173
 
178 174
 # -- Options for LaTeX output ---------------------------------------------
179 175
 
@@ -191,11 +187,11 @@ latex_elements = {
191 187
 # Grouping the document tree into LaTeX files. List of tuples
192 188
 # (source start file, target name, title,
193 189
 #  author, documentclass [howto, manual, or own class]).
194
-latex_documents = [
195
-    ('index', 'MonascaEventsApiReleaseNotes.tex',
196
-     u'MonascaEventsApi Release Notes Documentation', u'OpenStack Foundation',
197
-     'manual'),
198
-]
190
+latex_documents = [(
191
+     master_doc, 'MonitoringEventsApiReleaseNotes.tex',
192
+     u'Openstack Monitoring Events API Release Notes Documentation', [author],
193
+     'manual'
194
+)]
199 195
 
200 196
 # The name of an image file (relative to this directory) to place at the top of
201 197
 # the title page.
@@ -223,36 +219,10 @@ latex_documents = [
223 219
 # One entry per manual page. List of tuples
224 220
 # (source start file, name, description, authors, manual section).
225 221
 man_pages = [
226
-    ('index', 'barbicanreleasenotes', u'MonascaEventsApi Release Notes Documentation',
227
-     [u'OpenStack Foundation'], 1)
228
-]
229
-
230
-# If true, show URL addresses after external links.
231
-# man_show_urls = False
232
-
233
-
234
-# -- Options for Texinfo output -------------------------------------------
235
-
236
-# Grouping the document tree into Texinfo files. List of tuples
237
-# (source start file, target name, title, author,
238
-#  dir menu entry, description, category)
239
-texinfo_documents = [
240
-    ('index', 'MonascaEventsApiReleaseNotes', u'MonascaEventsApi Release Notes Documentation',
241
-     u'OpenStack Foundation', 'MonascaEventsApiReleaseNotes',
242
-     'MonascaEventsApi Release Notes Documentation.', 'Miscellaneous'),
222
+    (master_doc, 'monitoringeventsapireleasenotes',
223
+     u'Openstack Monitoring Events API Release Notes', [author],
224
+     1)
243 225
 ]
244 226
 
245
-# Documents to append as an appendix to all manuals.
246
-# texinfo_appendices = []
247
-
248
-# If false, no module index is generated.
249
-# texinfo_domain_indices = True
250
-
251
-# How to display URL addresses: 'footnote', 'no', or 'inline'.
252
-# texinfo_show_urls = 'footnote'
253
-
254
-# If true, do not generate a @detailmenu in the "Top" node's menu.
255
-# texinfo_no_detailmenu = False
256
-
257 227
 # -- Options for Internationalization output ------------------------------
258 228
 locale_dirs = ['locale/']

+ 2
- 1
requirements.txt View File

@@ -10,7 +10,8 @@ oslo.config!=4.3.0,!=4.4.0,>=4.0.0 # Apache-2.0
10 10
 oslo.context>=2.14.0 # Apache-2.0
11 11
 oslo.middleware>=3.27.0 # Apache-2.0
12 12
 oslo.log>=3.22.0 # Apache-2.0
13
-oslo.serialization>=1.10.0 # Apache-2.0
13
+oslo.policy>=1.23.0 # Apache-2.0
14
+oslo.serialization>=1.10.0,!=2.19.1 # Apache-2.0
14 15
 oslo.utils>=3.20.0 # Apache-2.0
15 16
 PasteDeploy>=1.5.0 # MIT
16 17
 eventlet!=0.18.3,!=0.20.1,<0.21.0,>=0.18.2 # MIT

+ 13
- 6
setup.cfg View File

@@ -36,21 +36,25 @@ data_files =
36 36
 oslo.config.opts =
37 37
     events.api = monasca_events_api.conf:list_opts
38 38
 
39
+oslo.policy.policies =
40
+    events.api = monasca_events_api.policies:list_rules
41
+
39 42
 [build_sphinx]
40 43
 all_files = 1
41 44
 build-dir = doc/build
42 45
 source-dir = doc/source
43
-
44
-[build_apiguide]
45
-all_files = 1
46
-build-dir = api-guide/build
47
-source-dir = api-guide/source
46
+warning-is-error = 1
48 47
 
49 48
 [build_apiref]
50 49
 all_files = 1
51 50
 build-dir = api-ref/build
52 51
 source-dir = api-ref/source
53 52
 
53
+[build_releasenotes]
54
+all_files = 1
55
+build-dir = releasenotes/build
56
+source-dir = releasenotes/source
57
+
54 58
 [egg_info]
55 59
 tag_build =
56 60
 tag_date = 0
@@ -60,4 +64,7 @@ tag_svn_revision = 0
60 64
 universal = 1
61 65
 
62 66
 [pbr]
63
-warnerrors = True
67
+autodoc_index_modules = True
68
+autodoc_exclude_modules =
69
+  monasca_events_api.tests.*
70
+api_doc_dir = contributor/api

+ 1
- 2
test-requirements.txt View File

@@ -4,7 +4,6 @@
4 4
 
5 5
 # Install bounded pep8/pyflakes first, then let flake8 install
6 6
 hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
7
-flake8-docstrings==0.2.1.post1 # MIT
8 7
 flake8-import-order==0.12 # LGPLv3
9 8
 bandit>=1.1.0  # Apache-2.0
10 9
 bashate>=0.2 # Apache-2.0
@@ -21,4 +20,4 @@ doc8 # Apache-2.0
21 20
 sphinx>=1.6.2  # BSD
22 21
 os-api-ref>=1.0.0 # Apache-2.0
23 22
 reno!=2.3.1,>=1.8.0 # Apache-2.0
24
-openstackdocstheme>=1.11.0 # Apache-2.0
23
+openstackdocstheme>=1.16.0 # Apache-2.0

+ 11
- 22
tox.ini View File

@@ -6,14 +6,14 @@ skipsdist = True
6 6
 [testenv]
7 7
 usedevelop = True
8 8
 setenv = VIRTUAL_ENV={envdir}
9
-         OS_TEST_PATH=monasca_events_api/tests
9
+         OS_TEST_PATH=monasca_events_api/tests/unit
10 10
          CLIENT_NAME=monasca-events-api
11 11
 passenv = *_proxy
12 12
           *_PROXY
13 13
 whitelist_externals = bash
14 14
                       find
15 15
                       rm
16
-install_command = {toxinidir}/tools/tox_install.sh {env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages}
16
+install_command = {toxinidir}/tools/tox_install.sh {env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?master} {opts} {packages}
17 17
 deps = -r{toxinidir}/test-requirements.txt
18 18
 commands =
19 19
   find ./ -type f -name '*.pyc' -delete
@@ -46,7 +46,7 @@ commands =
46 46
 description = Allows to run unit-test with debug mode enabled
47 47
 commands =
48 48
   {[testenv]commands}
49
-  oslo_debug_helper -t {toxinidir}/monasca_events_api/tests {posargs}
49
+  oslo_debug_helper -t {env:OS_TEST_PATH} {posargs}
50 50
 
51 51
 [testenv:bashate]
52 52
 description = Validates (pep8-like) devstack plugins
@@ -76,20 +76,12 @@ commands =
76 76
   {[testenv:checkniceness]commands}
77 77
 
78 78
 [testenv:docs]
79
-description = Builds api-ref, api-guide, releasenotes and devdocs
79
+description = Builds api-ref, releasenotes and devdocs
80 80
 commands =
81 81
   {[testenv:devdocs]commands}
82
-  {[testenv:api-guide]commands}
83 82
   {[testenv:api-ref]commands}
84 83
   {[testenv:releasenotes]commands}
85 84
 
86
-[testenv:api-guide]
87
-description = Called from CI scripts to test and publish the API Guide
88
-commands =
89
-  rm -rf api-guide/build
90
-  {[testenv:checkjson]commands}
91
-  sphinx-build -W -b html -d api-guide/build/doctrees api-guide/source api-guide/build/html
92
-
93 85
 [testenv:api-ref]
94 86
 description = Called from CI scripts to test and publish the API Ref
95 87
 commands =
@@ -107,16 +99,9 @@ commands =
107 99
 description = Builds developer documentation
108 100
 commands =
109 101
   rm -rf doc/build
110
-  {[testenv:codedocs]commands}
111 102
   {[testenv:checkjson]commands}
112 103
   python setup.py build_sphinx
113 104
 
114
-[testenv:codedocs]
115
-description = Generates codebase documentation
116
-commands =
117
-  rm -rf doc/source/code
118
-  sphinx-apidoc -o doc/source/code -fPM {toxinidir}/monasca_events_api --ext-todo
119
-
120 105
 [testenv:checkniceness]
121 106
 description = Validates (pep-like) documentation
122 107
 skip_install = True
@@ -124,7 +109,6 @@ usedevelop = False
124 109
 commands =
125 110
   doc8 --file-encoding utf-8 {toxinidir}/doc
126 111
   doc8 --file-encoding utf-8 {toxinidir}/api-ref
127
-  doc8 --file-encoding utf-8 {toxinidir}/api-guide
128 112
   doc8 --file-encoding utf-8 {toxinidir}/releasenotes
129 113
 
130 114
 [testenv:checkjson]
@@ -139,13 +123,18 @@ commands =
139 123
 
140 124
 [testenv:genconfig]
141 125
 description = Generates sample documentation file for monasca-events-api
142
-commands = oslo-config-generator --config-file=config-generator/monasca-events-api.conf
126
+commands = oslo-config-generator --config-file=config-generator/config.conf
127
+
128
+[testenv:genpolicy]
129
+description = Generates sample policy.yaml file for monasca-events-api
130
+commands = oslopolicy-sample-generator --config-file=config-generator/policy.conf
143 131
 
144 132
 [testenv:venv]
145 133
 commands = {posargs}
146 134
 
147 135
 [flake8]
148
-exclude = .git,.gitignore,.tox,dist,doc,api-ref,api-guide,releasenotes,documentation,*.egg,build
136
+exclude = .git,.gitignore,.tox,dist,doc,api-ref,releasenotes,*.egg,build,
137
+          __pycache__
149 138
 show-source = True
150 139
 enable-extensions = H203,H106
151 140
 ignore = D100,D104

Loading…
Cancel
Save