diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..70ea5f8b8 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,60 @@ +--- +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + # whitespace + - id: trailing-whitespace + - id: mixed-line-ending + args: ['--fix', 'lf'] + exclude: '.*\.(svg)$' + - id: check-byte-order-marker + # file format and permissions + - id: check-ast + - id: debug-statements + - id: check-json + files: .*\.json$ + - id: check-yaml + files: .*\.(yaml|yml)$ + # FIXME(sean-k-mooney): we currently have some files + # with incorrect permission, resolve this in a follow up + # - id: check-executables-have-shebangs + # - id: check-shebang-scripts-are-executable + # git + - id: check-added-large-files + - id: check-case-conflict + - id: detect-private-key + - id: check-merge-conflict + - repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.5.5 + hooks: + - id: remove-tabs + exclude: '.*\.(svg)$' + - repo: https://opendev.org/openstack/hacking + rev: 7.0.0 + hooks: + - id: hacking + additional_dependencies: [] + exclude: '^(doc|releasenotes|tools)/.*$' + - repo: https://github.com/hhatto/autopep8 + rev: v2.3.1 + hooks: + - id: autopep8 + files: '^.*\.py$' + # FIXME(sean-k-mooney): we have many typos and some false + # positives that need to be added to the dictionary + # correct this in a followup change + # - repo: https://github.com/codespell-project/codespell + # rev: v2.3.0 + # hooks: + # - id: codespell + # args: ['--ignore-words=doc/dictionary.txt'] + # FIXME(sean-k-mooney): we have many sphinx issues fix them + # in a separate commit to make it easier to review + # - repo: https://github.com/sphinx-contrib/sphinx-lint + # rev: v1.0.0 + # hooks: + # - id: sphinx-lint + # args: [--enable=default-role] + # files: ^doc/|releasenotes|api-guide + # types: [rst] diff --git a/api-ref/source/samples/audit-list-detailed-response.json b/api-ref/source/samples/audit-list-detailed-response.json index 5d1de5d0f..a4a9240e1 100644 --- a/api-ref/source/samples/audit-list-detailed-response.json +++ b/api-ref/source/samples/audit-list-detailed-response.json @@ -30,7 +30,7 @@ } }, "auto_trigger": false, - "force": false, + "force": false, "uuid": "65a5da84-5819-4aea-8278-a28d2b489028", "goal_name": "workload_balancing", "scope": [], diff --git a/api-ref/source/samples/datamodel-list-response.json b/api-ref/source/samples/datamodel-list-response.json index 11de82dda..b76108d31 100644 --- a/api-ref/source/samples/datamodel-list-response.json +++ b/api-ref/source/samples/datamodel-list-response.json @@ -13,9 +13,9 @@ "node_vcpu_ratio": "16.0", "node_memory": "16383", "node_memory_ratio": "1.5", - "node_disk": "37" + "node_disk": "37", "node_disk_ratio": "1.0", - "node_state": "up", + "node_state": "up" }, { "server_uuid": "e2cb5f6f-fa1d-4ba2-be1e-0bf02fa86ba4", @@ -30,9 +30,9 @@ "node_vcpu_ratio": "16.0", "node_memory": "16383", "node_memory_ratio": "1.5", - "node_disk": "37" + "node_disk": "37", "node_disk_ratio": "1.0", - "node_state": "up", + "node_state": "up" } ] } diff --git a/doc/dictionary.txt b/doc/dictionary.txt new file mode 100644 index 000000000..e69de29bb diff --git a/doc/source/conf.py b/doc/source/conf.py index 4515cbb62..04197315e 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -115,7 +115,7 @@ html_theme = 'openstackdocs' htmlhelp_basename = '%sdoc' % project -#openstackdocstheme options +# openstackdocstheme options openstackdocs_repo_name = 'openstack/watcher' openstackdocs_pdf_link = True openstackdocs_auto_name = False diff --git a/releasenotes/notes/stale-action-plan-b6a6b08df873c128.yaml b/releasenotes/notes/stale-action-plan-b6a6b08df873c128.yaml index 9ef9a4c77..661dac021 100644 --- a/releasenotes/notes/stale-action-plan-b6a6b08df873c128.yaml +++ b/releasenotes/notes/stale-action-plan-b6a6b08df873c128.yaml @@ -1,4 +1,4 @@ --- features: - - Check the creation time of the action plan, + - Check the creation time of the action plan, and set its state to SUPERSEDED if it has expired. diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py index dec102502..4e94342cb 100644 --- a/releasenotes/source/conf.py +++ b/releasenotes/source/conf.py @@ -28,12 +28,12 @@ import sys # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) +# sys.path.insert(0, os.path.abspath('.')) # -- General configuration ---------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. @@ -47,7 +47,7 @@ templates_path = ['_templates'] source_suffix = '.rst' # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' @@ -63,37 +63,37 @@ release = '' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all documents -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'native' # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # openstackdocstheme options openstackdocs_repo_name = 'openstack/watcher' @@ -109,26 +109,26 @@ html_theme = 'openstackdocs' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, @@ -137,44 +137,44 @@ html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'watcherdoc' @@ -183,42 +183,42 @@ htmlhelp_basename = 'watcherdoc' # -- Options for LaTeX output ------------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', -# Additional stuff for the LaTeX preamble. -#'preamble': '', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]) latex_documents = [ - ('index', 'watcher.tex', 'Watcher Documentation', - 'Watcher developers', 'manual'), + ('index', 'watcher.tex', 'Watcher Documentation', + 'Watcher developers', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output ------------------------------------------- @@ -231,7 +231,7 @@ man_pages = [ ] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False # -- Options for Texinfo output ----------------------------------------------- @@ -240,19 +240,19 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'watcher', 'Watcher Documentation', - 'Watcher developers', 'watcher', 'One line description of project.', - 'Miscellaneous'), + ('index', 'watcher', 'Watcher Documentation', + 'Watcher developers', 'watcher', 'One line description of project.', + 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' # -- Options for Internationalization output ------------------------------ locale_dirs = ['locale/'] diff --git a/watcher/api/controllers/v1/action.py b/watcher/api/controllers/v1/action.py index 477483509..3746ed8f6 100644 --- a/watcher/api/controllers/v1/action.py +++ b/watcher/api/controllers/v1/action.py @@ -229,6 +229,7 @@ class ActionCollection(collection.Collection): class ActionsController(rest.RestController): """REST controller for Actions.""" + def __init__(self): super(ActionsController, self).__init__() diff --git a/watcher/api/controllers/v1/audit.py b/watcher/api/controllers/v1/audit.py index d9ef67d2d..ccd850e1d 100644 --- a/watcher/api/controllers/v1/audit.py +++ b/watcher/api/controllers/v1/audit.py @@ -468,6 +468,7 @@ class AuditCollection(collection.Collection): class AuditsController(rest.RestController): """REST controller for Audits.""" + def __init__(self): super(AuditsController, self).__init__() self.dc_client = rpcapi.DecisionEngineAPI() diff --git a/watcher/api/controllers/v1/audit_template.py b/watcher/api/controllers/v1/audit_template.py index 57756729e..160b3ad51 100644 --- a/watcher/api/controllers/v1/audit_template.py +++ b/watcher/api/controllers/v1/audit_template.py @@ -475,6 +475,7 @@ class AuditTemplateCollection(collection.Collection): class AuditTemplatesController(rest.RestController): """REST controller for AuditTemplates.""" + def __init__(self): super(AuditTemplatesController, self).__init__() diff --git a/watcher/api/controllers/v1/data_model.py b/watcher/api/controllers/v1/data_model.py index 7ab98200a..5a039e891 100644 --- a/watcher/api/controllers/v1/data_model.py +++ b/watcher/api/controllers/v1/data_model.py @@ -32,6 +32,7 @@ from watcher.decision_engine import rpcapi class DataModelController(rest.RestController): """REST controller for data model""" + def __init__(self): super(DataModelController, self).__init__() diff --git a/watcher/api/controllers/v1/goal.py b/watcher/api/controllers/v1/goal.py index 3e87091db..0f32f29a1 100644 --- a/watcher/api/controllers/v1/goal.py +++ b/watcher/api/controllers/v1/goal.py @@ -153,6 +153,7 @@ class GoalCollection(collection.Collection): class GoalsController(rest.RestController): """REST controller for Goals.""" + def __init__(self): super(GoalsController, self).__init__() diff --git a/watcher/api/controllers/v1/scoring_engine.py b/watcher/api/controllers/v1/scoring_engine.py index 8f439dcd2..7846335e2 100644 --- a/watcher/api/controllers/v1/scoring_engine.py +++ b/watcher/api/controllers/v1/scoring_engine.py @@ -145,6 +145,7 @@ class ScoringEngineCollection(collection.Collection): class ScoringEngineController(rest.RestController): """REST controller for Scoring Engines.""" + def __init__(self): super(ScoringEngineController, self).__init__() diff --git a/watcher/api/controllers/v1/service.py b/watcher/api/controllers/v1/service.py index 98fcc41ab..5552aae5f 100644 --- a/watcher/api/controllers/v1/service.py +++ b/watcher/api/controllers/v1/service.py @@ -175,6 +175,7 @@ class ServiceCollection(collection.Collection): class ServicesController(rest.RestController): """REST controller for Services.""" + def __init__(self): super(ServicesController, self).__init__() diff --git a/watcher/api/controllers/v1/strategy.py b/watcher/api/controllers/v1/strategy.py index d7c928097..91894936a 100644 --- a/watcher/api/controllers/v1/strategy.py +++ b/watcher/api/controllers/v1/strategy.py @@ -196,6 +196,7 @@ class StrategyCollection(collection.Collection): class StrategiesController(rest.RestController): """REST controller for Strategies.""" + def __init__(self): super(StrategiesController, self).__init__() diff --git a/watcher/api/controllers/v1/types.py b/watcher/api/controllers/v1/types.py index 6872d31bc..d76b1ccb9 100644 --- a/watcher/api/controllers/v1/types.py +++ b/watcher/api/controllers/v1/types.py @@ -161,6 +161,7 @@ class MultiType(wtypes.UserType): :param types: Variable-length list of types. """ + def __init__(self, *types): self.types = types diff --git a/watcher/api/controllers/v1/webhooks.py b/watcher/api/controllers/v1/webhooks.py index d2e783a4d..61ae40a0c 100644 --- a/watcher/api/controllers/v1/webhooks.py +++ b/watcher/api/controllers/v1/webhooks.py @@ -32,6 +32,7 @@ LOG = log.getLogger(__name__) class WebhookController(rest.RestController): """REST controller for webhooks resource.""" + def __init__(self): super(WebhookController, self).__init__() self.dc_client = rpcapi.DecisionEngineAPI() diff --git a/watcher/api/hooks.py b/watcher/api/hooks.py index 208a11402..9bcf4d81f 100644 --- a/watcher/api/hooks.py +++ b/watcher/api/hooks.py @@ -83,6 +83,7 @@ class NoExceptionTracebackHook(hooks.PecanHook): # 'on_error' never fired for wsme+pecan pair. wsme @wsexpose decorator # catches and handles all the errors, so 'on_error' dedicated for unhandled # exceptions never fired. + def after(self, state): # Omit empty body. Some errors may not have body at this level yet. if not state.response.body: diff --git a/watcher/api/middleware/auth_token.py b/watcher/api/middleware/auth_token.py index fd01b793d..7d9409f80 100644 --- a/watcher/api/middleware/auth_token.py +++ b/watcher/api/middleware/auth_token.py @@ -33,6 +33,7 @@ class AuthTokenMiddleware(auth_token.AuthProtocol): for public routes in the API. """ + def __init__(self, app, conf, public_api_routes=()): route_pattern_tpl = r'%s(\.json|\.xml)?$' diff --git a/watcher/applier/workflow_engine/default.py b/watcher/applier/workflow_engine/default.py index 0fb8c4e4f..d7f677bb4 100644 --- a/watcher/applier/workflow_engine/default.py +++ b/watcher/applier/workflow_engine/default.py @@ -199,5 +199,6 @@ class TaskFlowNop(flow_task.Task): We need at least two atoms to create a link. """ + def execute(self): pass diff --git a/watcher/common/policy.py b/watcher/common/policy.py index e9d8a0508..14f2b5cad 100644 --- a/watcher/common/policy.py +++ b/watcher/common/policy.py @@ -71,7 +71,6 @@ def init(policy_file=None, rules=None, def enforce(context, rule=None, target=None, do_raise=True, exc=None, *args, **kwargs): - """Checks authorization of a rule against the target and credentials. :param dict context: As much information about the user performing the diff --git a/watcher/decision_engine/model/collector/cinder.py b/watcher/decision_engine/model/collector/cinder.py index f498d156f..dd6b28a07 100644 --- a/watcher/decision_engine/model/collector/cinder.py +++ b/watcher/decision_engine/model/collector/cinder.py @@ -165,6 +165,7 @@ class CinderModelBuilder(base.BaseModelBuilder): - Storage-related knowledge (Cinder) """ + def __init__(self, osc): self.osc = osc self.model = model_root.StorageModelRoot() diff --git a/watcher/decision_engine/model/collector/ironic.py b/watcher/decision_engine/model/collector/ironic.py index 522602290..142fc3cd1 100644 --- a/watcher/decision_engine/model/collector/ironic.py +++ b/watcher/decision_engine/model/collector/ironic.py @@ -78,6 +78,7 @@ class BareMetalModelBuilder(base.BaseModelBuilder): - Baremetal-related knowledge (Ironic) """ + def __init__(self, osc): self.osc = osc self.model = model_root.BaremetalModelRoot()