mistral-lib-0.4.0/0000775000175100017510000000000013234643753013770 5ustar zuulzuul00000000000000mistral-lib-0.4.0/releasenotes/0000775000175100017510000000000013234643753016461 5ustar zuulzuul00000000000000mistral-lib-0.4.0/releasenotes/source/0000775000175100017510000000000013234643753017761 5ustar zuulzuul00000000000000mistral-lib-0.4.0/releasenotes/source/_static/0000775000175100017510000000000013234643753021407 5ustar zuulzuul00000000000000mistral-lib-0.4.0/releasenotes/source/_static/.placeholder0000666000175100017510000000000013234643465023662 0ustar zuulzuul00000000000000mistral-lib-0.4.0/releasenotes/source/conf.py0000666000175100017510000002153013234643465021263 0ustar zuulzuul00000000000000# -*- coding: utf-8 -*- # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. # Glance Release Notes documentation build configuration file, created by # sphinx-quickstart on Tue Nov 3 17:40:50 2015. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. # needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'oslosphinx', 'reno.sphinxext', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. # source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'mistral-lib Release Notes' copyright = u'2016, OpenStack Foundation' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. # The full version, including alpha/beta/rc tags. release = '' # The short X.Y version. version = '' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: # today = '' # Else, today_fmt is used as the format for a strftime call. # today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = [] # The reST default role (used for this markup: `text`) to use for all # documents. # default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. # add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). # add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. # show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. # keep_warnings = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. # html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". # html_title = None # A shorter title for the navigation bar. Default is the same as html_title. # html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. # html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. # html_favicon = None # 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, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. # html_extra_path = [] # 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' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. # html_use_smartypants = True # Custom sidebar templates, maps document names to template names. # html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. # html_additional_pages = {} # If false, no module index is generated. # html_domain_indices = True # If false, no index is generated. # html_use_index = True # If true, the index is split into individual pages for each letter. # html_split_index = False # If true, links to the reST sources are added to the pages. # html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. # html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. # html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. # html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). # html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'GlanceReleaseNotesdoc' # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # 'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ ('index', 'GlanceReleaseNotes.tex', u'Glance Release Notes Documentation', u'Glance Developers', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. # latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. # latex_use_parts = False # If true, show page references after internal links. # latex_show_pagerefs = False # If true, show URL addresses after external links. # latex_show_urls = False # Documents to append as an appendix to all manuals. # latex_appendices = [] # If false, no module index is generated. # latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'glancereleasenotes', u'Glance Release Notes Documentation', [u'Glance Developers'], 1) ] # If true, show URL addresses after external links. # man_show_urls = False # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'GlanceReleaseNotes', u'Glance Release Notes Documentation', u'Glance Developers', 'GlanceReleaseNotes', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. # texinfo_appendices = [] # If false, no module index is generated. # texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. # texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. # texinfo_no_detailmenu = False # -- Options for Internationalization output ------------------------------ locale_dirs = ['locale/'] mistral-lib-0.4.0/releasenotes/source/pike.rst0000666000175100017510000000021713234643465021445 0ustar zuulzuul00000000000000=================================== Pike Series Release Notes =================================== .. release-notes:: :branch: stable/pike mistral-lib-0.4.0/releasenotes/source/mitaka.rst0000666000175100017510000000021113234643465021755 0ustar zuulzuul00000000000000=========================== Mitaka Series Release Notes =========================== .. release-notes:: :branch: origin/stable/mitaka mistral-lib-0.4.0/releasenotes/source/liberty.rst0000666000175100017510000000021613234643465022166 0ustar zuulzuul00000000000000============================ Liberty Series Release Notes ============================ .. release-notes:: :branch: origin/stable/liberty` mistral-lib-0.4.0/releasenotes/source/index.rst0000666000175100017510000000031113234643465021617 0ustar zuulzuul00000000000000============================================ mistral-lib Release Notes ============================================ .. toctree:: :maxdepth: 1 unreleased pike newton mitaka liberty mistral-lib-0.4.0/releasenotes/source/unreleased.rst0000666000175100017510000000016013234643465022641 0ustar zuulzuul00000000000000============================== Current Series Release Notes ============================== .. release-notes:: mistral-lib-0.4.0/releasenotes/source/_templates/0000775000175100017510000000000013234643753022116 5ustar zuulzuul00000000000000mistral-lib-0.4.0/releasenotes/source/_templates/.placeholder0000666000175100017510000000000013234643465024371 0ustar zuulzuul00000000000000mistral-lib-0.4.0/releasenotes/source/newton.rst0000666000175100017510000000021113234643465022021 0ustar zuulzuul00000000000000=========================== Newton Series Release Notes =========================== .. release-notes:: :branch: origin/stable/newton mistral-lib-0.4.0/releasenotes/notes/0000775000175100017510000000000013234643753017611 5ustar zuulzuul00000000000000mistral-lib-0.4.0/releasenotes/notes/.placeholder0000666000175100017510000000000013234643465022064 0ustar zuulzuul00000000000000mistral-lib-0.4.0/releasenotes/notes/rename-task-id-to-task-execution-id-f17d671fcef0127a.yaml0000666000175100017510000000020513234643465031544 0ustar zuulzuul00000000000000--- deprecations: - | The attribute `context.execution.task_id` has been renamed to `context.execution.task_execution_id`. mistral-lib-0.4.0/mistral_lib/0000775000175100017510000000000013234643753016271 5ustar zuulzuul00000000000000mistral-lib-0.4.0/mistral_lib/serialization.py0000666000175100017510000001424313234643465021526 0ustar zuulzuul00000000000000# Copyright 2017 Nokia Networks. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import abc from oslo_serialization import jsonutils _SERIALIZER = None class Serializer(object): """Base interface for entity serializers. A particular serializer knows how to convert a certain object into a string and back from that string into an object whose state is equivalent to the initial object. """ @abc.abstractmethod def serialize(self, entity): """Converts the given object into a string. :param entity: An object to be serialized. :return String containing the state of the object in serialized form. """ raise NotImplementedError @abc.abstractmethod def deserialize(self, data_str): """Converts the given string into an object. :param data_str: String containing the state of the object in serialized form. :return: An object. """ raise NotImplementedError class DictBasedSerializer(Serializer): """Dictionary-based serializer. It slightly simplifies implementing custom serializers by introducing a contract based on dictionary. A serializer class extending this class just needs to implement conversion from object into dict and from dict to object. It doesn't need to convert into string and back as required bye the base serializer contract. Conversion into string is implemented once with regard to possible problems that may occur for collection and primitive types as circular dependencies, correct date format etc. """ def serialize(self, entity): if entity is None: return None entity_dict = self.serialize_to_dict(entity) return jsonutils.dumps( jsonutils.to_primitive(entity_dict, convert_instances=True) ) def deserialize(self, data_str): if data_str is None: return None entity_dict = jsonutils.loads(data_str) return self.deserialize_from_dict(entity_dict) @abc.abstractmethod def serialize_to_dict(self, entity): raise NotImplementedError @abc.abstractmethod def deserialize_from_dict(self, entity_dict): raise NotImplementedError class MistralSerializable(object): """A mixin to generate a serialization key for a custom object.""" @classmethod def get_serialization_key(cls): return "%s.%s" % (cls.__module__, cls.__name__) class PolymorphicSerializer(Serializer): """Polymorphic serializer. The purpose of this class is to serve as a serialization router between serializers that can work with entities of particular type. All concrete serializers associated with concrete entity classes should be registered via method 'register', after that an instance of polymorphic serializer can be used as a universal serializer for an RPC system or something else. When converting an object into a string this serializer also writes a special key into the result string sequence so that it's possible to find a proper serializer when deserializing this object. If a primitive value is given as an entity this serializer doesn't do anything special and simply converts a value into a string using jsonutils. Similar when it converts a string into a primitive value. """ def __init__(self): # {serialization key: serializer} self.serializers = {} @staticmethod def _get_serialization_key(entity_cls): if issubclass(entity_cls, MistralSerializable): return entity_cls.get_serialization_key() return None def register(self, entity_cls, serializer): key = self._get_serialization_key(entity_cls) if not key: return if key in self.serializers: raise RuntimeError( "A serializer for the entity class has already been" " registered: %s" % entity_cls ) self.serializers[key] = serializer def unregister(self, entity_cls): key = self._get_serialization_key(entity_cls) if not key: return if key in self.serializers: del self.serializers[key] def cleanup(self): self.serializers.clear() def serialize(self, entity): if entity is None: return None key = self._get_serialization_key(type(entity)) # Primitive or not registered type. if not key: return jsonutils.dumps( jsonutils.to_primitive(entity, convert_instances=True) ) serializer = self.serializers.get(key) if not serializer: raise RuntimeError( "Failed to find a serializer for the key: %s" % key ) result = { '__serial_key': key, '__serial_data': serializer.serialize(entity) } return jsonutils.dumps(result) def deserialize(self, data_str): if data_str is None: return None data = jsonutils.loads(data_str) if isinstance(data, dict) and '__serial_key' in data: serializer = self.serializers.get(data['__serial_key']) return serializer.deserialize(data['__serial_data']) return data def get_polymorphic_serializer(): global _SERIALIZER if _SERIALIZER is None: _SERIALIZER = PolymorphicSerializer() return _SERIALIZER def register_serializer(entity_cls, serializer): get_polymorphic_serializer().register(entity_cls, serializer) def unregister_serializer(entity_cls): get_polymorphic_serializer().unregister(entity_cls) def cleanup(): get_polymorphic_serializer().cleanup() mistral-lib-0.4.0/mistral_lib/__init__.py0000666000175100017510000000123313234643465020403 0ustar zuulzuul00000000000000# -*- coding: utf-8 -*- # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import pbr.version __version__ = pbr.version.VersionInfo( 'mistral-lib').version_string() mistral-lib-0.4.0/mistral_lib/utils/0000775000175100017510000000000013234643753017431 5ustar zuulzuul00000000000000mistral-lib-0.4.0/mistral_lib/utils/__init__.py0000666000175100017510000000712713234643465021553 0ustar zuulzuul00000000000000# Copyright 2013 - Mirantis, Inc. # Copyright 2017 - Nokia Networks. # Copyright 2017 - Red Hat, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. def cut_dict(d, length=100): """Truncates string representation of a dictionary for a given length. :param d: dictionary to truncate :param length: amount of characters to truncate to :return: string containing given length of characters from the dictionary """ if not isinstance(d, dict): raise ValueError("A dictionary is expected, got: %s" % type(d)) res = "{" idx = 0 for key, value in d.items(): k = str(key) v = str(value) # Processing key. new_len = len(res) + len(k) is_str = isinstance(key, str) if is_str: new_len += 2 if new_len >= length: res += "'%s..." % k[:length - new_len] if is_str else "%s..." % k break else: res += "'%s'" % k if is_str else k res += ": " # Processing value. new_len = len(res) + len(v) is_str = isinstance(value, str) if is_str: new_len += 2 if new_len >= length: res += "'%s..." % v[:length - new_len] if is_str else "%s..." % v break else: res += "'%s'" % v if is_str else v res += ', ' if idx < len(d) - 1 else '}' if len(res) >= length: res += '...' break idx += 1 return res def cut_list(l, length=100): """Truncates string representation of a list for a given length. :param l: list to truncate :param length: amount of characters to truncate to :return: string containing given length of characters from the list """ if not isinstance(l, list): raise ValueError("A list is expected, got: %s" % type(l)) res = '[' for idx, item in enumerate(l): s = str(item) new_len = len(res) + len(s) is_str = isinstance(item, str) if is_str: new_len += 2 if new_len >= length: res += "'%s..." % s[:length - new_len] if is_str else "%s..." % s break else: res += "'%s'" % s if is_str else s res += ', ' if idx < len(l) - 1 else ']' return res def cut_string(s, length=100): """Truncates a string for a given length. :param s: string to truncate :param length: amount of characters to truncate to :return: string containing given length of characters """ if len(s) > length: return "%s..." % s[:length] return s def cut(data, length=100): """Truncates string representation of data for a given length. :param data: a dictionary, list or string to truncate :param length: amount of characters to truncate to :return: string containing given length of characters """ if not data: return data if isinstance(data, list): return cut_list(data, length=length) if isinstance(data, dict): return cut_dict(data, length=length) return cut_string(str(data), length=length) mistral-lib-0.4.0/mistral_lib/exceptions.py0000666000175100017510000000530613234643465021032 0ustar zuulzuul00000000000000# Copyright 2013 - Mirantis, Inc. # Copyright 2015 - StackStorm, Inc. # Copyright 2016 - Brocade Communications Systems, Inc. # Copyright 2016 - Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. class MistralExceptionBase(Exception): """Base class for Mistral specific errors and exceptions. A common parent class to derive MistralError and MistralException classes from. """ message = "An unknown error occurred" http_code = 500 def __init__(self, message=None): if message is not None: self.message = message super(MistralError, self).__init__( '%d: %s' % (self.http_code, self.message)) @property def code(self): """This is here for webob to read. https://github.com/Pylons/webob/blob/master/webob/exc.py """ return self.http_code def __str__(self): return self.message class MistralError(MistralExceptionBase): """Mistral specific error. Reserved for situations that can't be automatically handled. When it occurs it signals that there is a major environmental problem like invalid startup configuration or implementation problem (e.g. some code doesn't take care of certain corner cases). From architectural perspective it's pointless to try to handle this type of problems except doing some finalization work like transaction rollback, deleting temporary files etc. """ message = "An unknown error occurred" class MistralException(Exception): """Mistral specific exception. Reserved for situations that are not critical for program continuation. It is possible to recover from this type of problems automatically and continue program execution. Such problems may be related with invalid user input (such as invalid syntax) or temporary environmental problems. In case if an instance of a certain exception type bubbles up to API layer then this type of exception it must be associated with an http code so it's clear how to represent it for a client. To correctly use this class, inherit from it and define a 'message' and 'http_code' properties. """ message = "An unknown exception occurred" mistral-lib-0.4.0/mistral_lib/tests/0000775000175100017510000000000013234643753017433 5ustar zuulzuul00000000000000mistral-lib-0.4.0/mistral_lib/tests/__init__.py0000666000175100017510000000000013234643465021534 0ustar zuulzuul00000000000000mistral-lib-0.4.0/mistral_lib/tests/test_serialization.py0000666000175100017510000000667613234643465023742 0ustar zuulzuul00000000000000# Copyright 2017 - Nokia Networks. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from mistral_lib import serialization from mistral_lib.tests import base class MyClass(serialization.MistralSerializable): def __init__(self, a, b): self.a = a self.b = b def __eq__(self, other): if not isinstance(other, MyClass): return False return other.a == self.a and other.b == self.b class MyClassSerializer(serialization.DictBasedSerializer): def serialize_to_dict(self, entity): return {'a': entity.a, 'b': entity.b} def deserialize_from_dict(self, entity_dict): return MyClass(entity_dict['a'], entity_dict['b']) class SerializationTest(base.TestCase): def setUp(self): super(SerializationTest, self).setUp() serialization.register_serializer(MyClass, MyClassSerializer()) self.addCleanup(serialization.unregister_serializer, MyClass) def test_dict_based_serializer(self): obj = MyClass('a', 'b') serializer = MyClassSerializer() s = serializer.serialize(obj) self.assertEqual(obj, serializer.deserialize(s)) self.assertIsNone(serializer.serialize(None)) self.assertIsNone(serializer.deserialize(None)) def test_polymorphic_serializer_primitive_types(self): serializer = serialization.get_polymorphic_serializer() self.assertEqual(17, serializer.deserialize(serializer.serialize(17))) self.assertEqual( 0.34, serializer.deserialize(serializer.serialize(0.34)) ) self.assertEqual(-5, serializer.deserialize(serializer.serialize(-5))) self.assertEqual( -6.3, serializer.deserialize(serializer.serialize(-6.3)) ) self.assertFalse(serializer.deserialize(serializer.serialize(False))) self.assertTrue(serializer.deserialize(serializer.serialize(True))) self.assertEqual( 'abc', serializer.deserialize(serializer.serialize('abc')) ) self.assertEqual( {'a': 'b', 'c': 'd'}, serializer.deserialize(serializer.serialize({'a': 'b', 'c': 'd'})) ) self.assertEqual( ['a', 'b', 'c'], serializer.deserialize(serializer.serialize(['a', 'b', 'c'])) ) def test_polymorphic_serializer_custom_object(self): serializer = serialization.get_polymorphic_serializer() obj = MyClass('a', 'b') s = serializer.serialize(obj) self.assertIn('__serial_key', s) self.assertIn('__serial_data', s) self.assertEqual(obj, serializer.deserialize(s)) self.assertIsNone(serializer.serialize(None)) self.assertIsNone(serializer.deserialize(None)) def test_register_twice(self): self.assertRaises( RuntimeError, serialization.register_serializer, MyClass, MyClassSerializer() ) mistral-lib-0.4.0/mistral_lib/tests/test_utils.py0000666000175100017510000000517413234643465022215 0ustar zuulzuul00000000000000# Copyright 2013 - Mirantis, Inc. # Copyright 2017 - Nokia Networks. # Copyright 2017 - Red Hat, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from mistral_lib.tests import base as tests_base from mistral_lib import utils class TestUtils(tests_base.TestCase): def test_cut_string(self): s = 'Hello, Mistral!' self.assertEqual('Hello...', utils.cut_string(s, length=5)) self.assertEqual(s, utils.cut_string(s, length=100)) def test_cut_list(self): l = ['Hello, Mistral!', 'Hello, OpenStack!'] self.assertEqual("['Hello, M...", utils.cut_list(l, 11)) self.assertEqual("['Hello, Mistr...", utils.cut_list(l, 15)) self.assertEqual("['Hello, Mistral!', 'He...", utils.cut_list(l, 24)) self.assertEqual( "['Hello, Mistral!', 'Hello, OpenStack!']", utils.cut_list(l, 100) ) self.assertEqual("[1, 2...", utils.cut_list([1, 2, 3, 4, 5], 4)) self.assertEqual("[1, 2...", utils.cut_list([1, 2, 3, 4, 5], 5)) self.assertEqual("[1, 2, 3...", utils.cut_list([1, 2, 3, 4, 5], 6)) self.assertRaises(ValueError, utils.cut_list, (1, 2)) def test_cut_dict_with_strings(self): d = {'key1': 'value1', 'key2': 'value2'} s = utils.cut_dict(d, 9) self.assertIn(s, ["{'key1': '...", "{'key2': '..."]) s = utils.cut_dict(d, 13) self.assertIn(s, ["{'key1': 'va...", "{'key2': 'va..."]) s = utils.cut_dict(d, 19) self.assertIn( s, ["{'key1': 'value1', ...", "{'key2': 'value2', ..."] ) self.assertIn( utils.cut_dict(d, 100), [ "{'key1': 'value1', 'key2': 'value2'}", "{'key2': 'value2', 'key1': 'value1'}" ] ) def test_cut_dict_with_digits(self): d = {1: 2, 3: 4} s = utils.cut_dict(d, 6) self.assertIn(s, ["{1: 2, ...", "{3: 4, ..."]) s = utils.cut_dict(d, 8) self.assertIn(s, ["{1: 2, 3...", "{3: 4, 1..."]) s = utils.cut_dict(d, 100) self.assertIn(s, ["{1: 2, 3: 4}", "{3: 4, 1: 2}"]) mistral-lib-0.4.0/mistral_lib/tests/base.py0000666000175100017510000000140113234643465020715 0ustar zuulzuul00000000000000# Copyright 2010-2011 OpenStack Foundation # Copyright (c) 2013 Hewlett-Packard Development Company, L.P. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from oslotest import base class TestCase(base.BaseTestCase): """Test case base class for all unit tests.""" mistral-lib-0.4.0/mistral_lib/tests/actions/0000775000175100017510000000000013234643753021073 5ustar zuulzuul00000000000000mistral-lib-0.4.0/mistral_lib/tests/actions/test_base.py0000666000175100017510000000200013234643465023410 0ustar zuulzuul00000000000000# Copyright 2017 Red Hat, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from mistral_lib import actions from mistral_lib.actions import context from mistral_lib.tests import base as tests_base class TestAction(actions.Action): def run(self, context): return context class TestActionsBase(tests_base.TestCase): def test_run_empty_context(self): ctx = context.ActionContext() action = TestAction() result = action.run(ctx) assert result == ctx mistral-lib-0.4.0/mistral_lib/tests/actions/test_context.py0000666000175100017510000000473513234643465024203 0ustar zuulzuul00000000000000# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from mistral_lib.actions import context from mistral_lib.tests import base as tests_base def _fake_context(): security_ctx = context.SecurityContext( auth_uri='auth_uri', auth_cacert='auth_cacert', insecure='insecure', service_catalog='service_catalog', region_name='region_name', is_trust_scoped='is_trust_scoped', redelivered='redelivered', expires_at='expires_at', trust_id='trust_id', is_target='is_target', project_id='project_id') execution_ctx = context.ExecutionContext( workflow_execution_id='workflow_execution_id', task_execution_id='task_execution_id', action_execution_id='action_execution_id', workflow_name='workflow_name', callback_url='callback_url') ctx = context.ActionContext(security_ctx, execution_ctx) return ctx class TestActionsBase(tests_base.TestCase): def test_empty_context(self): ctx = context.ActionContext( context.SecurityContext(), context.ExecutionContext() ) self.assertIsInstance(ctx.security, context.SecurityContext) self.assertIsInstance(ctx.execution, context.ExecutionContext) self.assertEqual(ctx.security.auth_uri, None) self.assertEqual(ctx.execution.workflow_name, None) def test_deprecated_properties(self): ctx = _fake_context() deprecated_properties = [ 'auth_cacert', 'auth_token', 'auth_uri', 'expires_at', 'insecure', 'is_target', 'is_trust_scoped', 'project_id', 'project_name', 'redelivered', 'region_name', 'service_catalog', 'trust_id', 'user_name' ] for deprecated in deprecated_properties: old = getattr(ctx, deprecated) new = getattr(ctx.security, deprecated) self.assertEqual(old, new) mistral-lib-0.4.0/mistral_lib/tests/actions/__init__.py0000666000175100017510000000000013234643465023174 0ustar zuulzuul00000000000000mistral-lib-0.4.0/mistral_lib/yaql/0000775000175100017510000000000013234643753017237 5ustar zuulzuul00000000000000mistral-lib-0.4.0/mistral_lib/yaql/api/0000775000175100017510000000000013234643753020010 5ustar zuulzuul00000000000000mistral-lib-0.4.0/mistral_lib/yaql/api/__init__.py0000666000175100017510000000000013234643465022111 0ustar zuulzuul00000000000000mistral-lib-0.4.0/mistral_lib/yaql/__init__.py0000666000175100017510000000000013234643465021340 0ustar zuulzuul00000000000000mistral-lib-0.4.0/mistral_lib/actions/0000775000175100017510000000000013234643753017731 5ustar zuulzuul00000000000000mistral-lib-0.4.0/mistral_lib/actions/types.py0000666000175100017510000000463013234643465021454 0ustar zuulzuul00000000000000# Copyright 2014 - Mirantis, Inc. # Copyright 2015 - StackStorm, Inc. # Copyright 2016 - Brocade Communications Systems, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from mistral_lib import serialization from mistral_lib import utils class Result(serialization.MistralSerializable): """Explicit data structure containing a result of task execution.""" def __init__(self, data=None, error=None, cancel=False): self.data = data self.error = error self.cancel = cancel def __repr__(self): return 'Result [data=%s, error=%s, cancel=%s]' % ( repr(self.data), repr(self.error), str(self.cancel) ) def cut_repr(self): return 'Result [data=%s, error=%s, cancel=%s]' % ( utils.cut(self.data), utils.cut(self.error), str(self.cancel) ) def is_cancel(self): return self.cancel def is_error(self): return self.error is not None and not self.is_cancel() def is_success(self): return not self.is_error() and not self.is_cancel() def __eq__(self, other): return ( self.data == other.data and self.error == other.error and self.cancel == other.cancel ) def __ne__(self, other): return not self.__eq__(other) def to_dict(self): return ({'result': self.data} if self.is_success() else {'result': self.error}) class ResultSerializer(serialization.DictBasedSerializer): def serialize_to_dict(self, entity): return { 'data': entity.data, 'error': entity.error, 'cancel': entity.cancel } def deserialize_from_dict(self, entity_dict): return Result( entity_dict['data'], entity_dict['error'], entity_dict.get('cancel', False) ) serialization.register_serializer(Result, ResultSerializer()) mistral-lib-0.4.0/mistral_lib/actions/__init__.py0000666000175100017510000000132313234643465022043 0ustar zuulzuul00000000000000# Copyright 2017 - Red Hat, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from mistral_lib.actions.base import Action from mistral_lib.actions.types import Result __all__ = ['Action', 'Result'] mistral-lib-0.4.0/mistral_lib/actions/base.py0000666000175100017510000000662613234643465021231 0ustar zuulzuul00000000000000# Copyright 2016 - Nokia Networks. # Copyright 2017 - Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import abc class Action(object): """Action. Action is a means in Mistral to perform some useful work associated with a workflow during its execution. Every workflow task is configured with an action and when the task runs it eventually delegates to the action. When it happens task parameters get evaluated (calculating expressions, if any) and are treated as action parameters. So in a regular general purpose languages terminology action is a method declaration and task is a method call. Base action class initializer doesn't have arguments. However, concrete action classes may have any number of parameters defining action behavior. These parameters must correspond to parameters declared in action specification (e.g. using DSL or others). """ def __init__(self): # NOTE(d0ugal): We need to define an empty __init__ otherwise # inspect.getargspec will fail in Python 2 for actions that subclass # but don't define their own __init__. pass @abc.abstractmethod def run(self, context): """Run action logic. :param context: a dictionary containing contextual information like execution identifier, workbook name and other data that may be needed for some specific action implementations. :return: Result of the action. Note that for asynchronous actions it should always be None, however, if even it's not None it will be ignored by a caller. Result can be of two types: 1) Any serializable value meaningful from a user perspective (such as string, number or dict). 2) Instance of {mistral.workflow.utils.Result} which has field "data" for success result and field "error" for keeping so called "error result" like HTTP error code and similar. Using the second type allows to communicate a result even in case of error and hence to have conditions in "on-error" clause of direct workflows. Depending on particular action semantics one or another option may be preferable. In case if action failed and there's no need to communicate any error result this method should throw a ActionException. """ pass def is_sync(self): """Returns True if the action is synchronous, otherwise False. :return: True if the action is synchronous and method run() returns final action result. Otherwise returns False which means that a result of method run() should be ignored and a real action result is supposed to be delivered in an asynchronous manner using public API. By default, if a concrete implementation doesn't override this method then the action is synchronous. """ return True mistral-lib-0.4.0/mistral_lib/actions/context.py0000666000175100017510000000653713234643465022004 0ustar zuulzuul00000000000000# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import warnings class ActionContext(object): def __init__(self, security_ctx=None, execution_ctx=None): self.security = security_ctx self.execution = execution_ctx def _deprecation_warning(self, name): warnings.warn( "context.{0} is deprecated from the context passed to actions. " "Please use context.security.{0}. It will be removed in a future " "release.", DeprecationWarning ) def __getattribute__(self, name): deprecated = [ "auth_cacert", "auth_token", "auth_uri", "expires_at", "insecure", "is_target", "is_trust_scoped", "project_id", "project_name", "redelivered", "region_name", "service_catalog", "trust_id", "user_name" ] if name in deprecated: self._deprecation_warning(name) return getattr(self.security, name) return super(ActionContext, self).__getattribute__(name) class SecurityContext(object): def __init__(self, auth_uri=None, auth_cacert=None, insecure=None, service_catalog=None, region_name=None, is_trust_scoped=None, redelivered=None, expires_at=None, trust_id=None, is_target=None, project_id=None, project_name=None, user_name=None, auth_token=None): self.auth_uri = auth_uri self.auth_cacert = auth_cacert self.insecure = insecure self.service_catalog = service_catalog self.region_name = region_name self.is_trust_scoped = is_trust_scoped self.redelivered = redelivered self.expires_at = expires_at self.trust_id = trust_id self.is_target = is_target self.project_id = project_id self.project_name = project_name self.user_name = user_name self.auth_token = auth_token class ExecutionContext(object): def __init__(self, workflow_execution_id=None, task_execution_id=None, action_execution_id=None, workflow_name=None, callback_url=None, task_id=None): self.workflow_execution_id = workflow_execution_id self.task_execution_id = task_execution_id self.action_execution_id = action_execution_id self.workflow_name = workflow_name self.callback_url = callback_url if task_id is not None: self.task_execution_id = task_id self._deprecate_task_id_warning() def _deprecate_task_id_warning(self): warnings.warn( "context.execution.task_id was deprecated in the Queens cycle. " "Please use context.execution.task_execution_id. It will be " "removed in a future release.", DeprecationWarning ) @property def task_id(self): self._deprecate_task_id_warning() return self.task_execution_id mistral-lib-0.4.0/ChangeLog0000664000175100017510000000557113234643752015551 0ustar zuulzuul00000000000000CHANGES ======= 0.4.0 ----- * Updated from global requirements * Updated from global requirements * fix the method description, wrong grammar * Updated from global requirements * Updated from global requirements * Fix the method description * Avoid tox\_install.sh for constraints support * Provide redirection for all security context attributes * Rename task\_id to task\_execution\_id * Add deprecated context parameters to the new security context * Add an empty \_\_init\_\_ method to the base Action class * Revert "Migrate mistral-lib to zuul v3" * Add a representation of the ActionContext in mistral-lib * Migrate mistral-lib to zuul v3 * Cleanup test-requirements * Updated from global requirements * Updated from global requirements * Updated from global requirements * Update reno for stable/pike * Updated from global requirements * Removes unnecessary utf-8 encoding * Drop MANIFEST.in - it's not needed by pbr * Switch from oslosphinx to openstackdocstheme * Apply Pike document structure * Enable warning-is-error * Updated from global requirements * Updated from global requirements * Updated from global requirements 0.2.0 ----- * Updated from global requirements * Updated from global requirements * Update serialization from 'mistral' repo with latest changes * Fix documentation for custom actions * Remove the unused ApplicationContextNotFoundException * Remove unused requirements * Make the Result class more convienient to use * Sync tools/tox\_install.sh with Mistral * Updated from global requirements * Updated from global requirements 0.1.0 ----- * Pass "mistral\_lib" to the coverage test * Fix the package name in the setup.cfg * Adds minimum common shared code for custom actions API * Fix the package name in the coveragerc * Fix the package name in the docs * Fix oslo\_debug\_helper not running * Updated from global requirements * Update test requirement * Updated from global requirements * Remove support for py34 * Updated from global requirements * Show team and repo badges on README * Added reno for stable/mitaka, stable/liberty and stable/newton * Added the Options for Internationalization output in conf.py * Updated from global requirements * Updated from global requirements * Update .coveragerc after the removal of openstack directory * Updated from global requirements * Enable release notes translation * Updated from global requirements * Updated from global requirements * Small changes like deletion of extra underline in the docs * Changed the invalid link in CONTRIBUTING.rst * Replaced the invalid link to documentation with a valid one * Update info in the configuration file * Cleanup tox.ini, enable constraints * Updated from global requirements * Add Babel to the requirements as it is referenced in the setup.cfg * Remove Python 3.3 and add 3.5 to match the main Mistral repo * Remove .mailmap file * Fixes namespace issue * Initial project layout * Added .gitreview mistral-lib-0.4.0/tox.ini0000666000175100017510000000251313234643465015306 0ustar zuulzuul00000000000000[tox] minversion = 2.0 envlist = py35,py27,pep8 skipsdist = True [testenv] usedevelop = True install_command = pip install {opts} {packages} setenv = VIRTUAL_ENV={envdir} PYTHONDONTWRITEBYTECODE = 1 PYTHONWARNINGS=default::DeprecationWarning passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY deps = -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} -r{toxinidir}/test-requirements.txt -r{toxinidir}/requirements.txt commands = find . -type f -name "*.pyc" -delete python setup.py testr --slowest --testr-args='{posargs}' whitelist_externals = rm find [testenv:pep8] commands = flake8 {posargs} [testenv:venv] commands = {posargs} [testenv:cover] commands = python setup.py test --coverage --coverage-package-name=mistral_lib --testr-args='{posargs}' [testenv:docs] commands = python setup.py build_sphinx [testenv:releasenotes] commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html [testenv:debug] whitelist_externals = oslo_debug_helper commands = oslo_debug_helper -t mistral_lib/tests {posargs} [flake8] # E123, E125 skipped as they are invalid PEP-8. show-source = True ignore = E123,E125 builtins = _ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build mistral-lib-0.4.0/setup.py0000666000175100017510000000200613234643465015502 0ustar zuulzuul00000000000000# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. # THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT import setuptools # In python < 2.7.4, a lazy loading of package `pbr` will break # setuptools if some other modules registered functions in `atexit`. # solution from: http://bugs.python.org/issue15881#msg170215 try: import multiprocessing # noqa except ImportError: pass setuptools.setup( setup_requires=['pbr>=2.0.0'], pbr=True) mistral-lib-0.4.0/PKG-INFO0000664000175100017510000000403713234643753015071 0ustar zuulzuul00000000000000Metadata-Version: 1.1 Name: mistral-lib Version: 0.4.0 Summary: Mistral shared routings and utilities (Actions API, YAQL functions API, data types etc.) Home-page: http://docs.openstack.org/developer/mistral/ Author: OpenStack Author-email: openstack-dev@lists.openstack.org License: UNKNOWN Description-Content-Type: UNKNOWN Description: ======================== Team and repository tags ======================== .. image:: http://governance.openstack.org/badges/mistral-lib.svg :target: http://governance.openstack.org/reference/tags/index.html .. Change things from this point on =========== mistral-lib =========== This library contains data types, exceptions, functions and utilities common to Mistral, python-mistralclient and mistral-extra repositories. This library also contains the public interfaces for 3rd party integration (e.g. Actions API, YAQL functions API, etc.) If you want to use OpenStack in your custom actions or functions, you will also need to use http://git.openstack.org/cgit/openstack/mistral-extra . * Free software: Apache license * Documentation: http://docs.openstack.org/developer/mistral * Source: http://git.openstack.org/cgit/openstack/mistral-lib * Bugs: http://bugs.launchpad.net/mistral Features -------- * TODO Platform: UNKNOWN Classifier: Environment :: OpenStack Classifier: Intended Audience :: Information Technology Classifier: Intended Audience :: System Administrators Classifier: License :: OSI Approved :: Apache Software License Classifier: Operating System :: POSIX :: Linux Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 mistral-lib-0.4.0/requirements.txt0000666000175100017510000000044413234643465017260 0ustar zuulzuul00000000000000# The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. pbr!=2.1.0,>=2.0.0 # Apache-2.0 oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0 mistral-lib-0.4.0/AUTHORS0000664000175100017510000000126013234643752015036 0ustar zuulzuul00000000000000Adriano Petrich Andreas Jaeger Andreas Jaeger Arundhati Surpur Brad P. Crochet Dougal Matthews Flavio Percoco Monty Taylor OpenStack Release Bot Renat Akhmerov Ryan Brady Sharat Sharma Zuul guotao nizam ricolin sunqingliang6 zhangyangyang mistral-lib-0.4.0/.coveragerc0000666000175100017510000000011113234643465016104 0ustar zuulzuul00000000000000[run] branch = True source = mistral_lib [report] ignore_errors = True mistral-lib-0.4.0/README.rst0000666000175100017510000000163513234643465015466 0ustar zuulzuul00000000000000======================== Team and repository tags ======================== .. image:: http://governance.openstack.org/badges/mistral-lib.svg :target: http://governance.openstack.org/reference/tags/index.html .. Change things from this point on =========== mistral-lib =========== This library contains data types, exceptions, functions and utilities common to Mistral, python-mistralclient and mistral-extra repositories. This library also contains the public interfaces for 3rd party integration (e.g. Actions API, YAQL functions API, etc.) If you want to use OpenStack in your custom actions or functions, you will also need to use http://git.openstack.org/cgit/openstack/mistral-extra . * Free software: Apache license * Documentation: http://docs.openstack.org/developer/mistral * Source: http://git.openstack.org/cgit/openstack/mistral-lib * Bugs: http://bugs.launchpad.net/mistral Features -------- * TODO mistral-lib-0.4.0/babel.cfg0000666000175100017510000000002113234643465015511 0ustar zuulzuul00000000000000[python: **.py] mistral-lib-0.4.0/setup.cfg0000666000175100017510000000253313234643753015616 0ustar zuulzuul00000000000000[metadata] name = mistral-lib summary = Mistral shared routings and utilities (Actions API, YAQL functions API, data types etc.) description-file = README.rst author = OpenStack author-email = openstack-dev@lists.openstack.org home-page = http://docs.openstack.org/developer/mistral/ classifier = Environment :: OpenStack Intended Audience :: Information Technology Intended Audience :: System Administrators License :: OSI Approved :: Apache Software License Operating System :: POSIX :: Linux Programming Language :: Python Programming Language :: Python :: 2 Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 Programming Language :: Python :: 3.4 Programming Language :: Python :: 3.5 [files] packages = mistral_lib [build_sphinx] source-dir = doc/source build-dir = doc/build all_files = 1 warning-is-error = 1 [upload_sphinx] upload-dir = doc/build/html [compile_catalog] directory = mistral-lib/locale domain = mistral-lib [update_catalog] domain = mistral-lib output_dir = mistral-lib/locale input_file = mistral-lib/locale/mistral-lib.pot [extract_messages] keywords = _ gettext ngettext l_ lazy_gettext mapping_file = babel.cfg output_file = mistral-lib/locale/mistral-lib.pot [build_releasenotes] all_files = 1 build-dir = releasenotes/build source-dir = releasenotes/source [egg_info] tag_build = tag_date = 0 mistral-lib-0.4.0/mistral_lib.egg-info/0000775000175100017510000000000013234643753017763 5ustar zuulzuul00000000000000mistral-lib-0.4.0/mistral_lib.egg-info/dependency_links.txt0000664000175100017510000000000113234643752024030 0ustar zuulzuul00000000000000 mistral-lib-0.4.0/mistral_lib.egg-info/PKG-INFO0000664000175100017510000000403713234643752021063 0ustar zuulzuul00000000000000Metadata-Version: 1.1 Name: mistral-lib Version: 0.4.0 Summary: Mistral shared routings and utilities (Actions API, YAQL functions API, data types etc.) Home-page: http://docs.openstack.org/developer/mistral/ Author: OpenStack Author-email: openstack-dev@lists.openstack.org License: UNKNOWN Description-Content-Type: UNKNOWN Description: ======================== Team and repository tags ======================== .. image:: http://governance.openstack.org/badges/mistral-lib.svg :target: http://governance.openstack.org/reference/tags/index.html .. Change things from this point on =========== mistral-lib =========== This library contains data types, exceptions, functions and utilities common to Mistral, python-mistralclient and mistral-extra repositories. This library also contains the public interfaces for 3rd party integration (e.g. Actions API, YAQL functions API, etc.) If you want to use OpenStack in your custom actions or functions, you will also need to use http://git.openstack.org/cgit/openstack/mistral-extra . * Free software: Apache license * Documentation: http://docs.openstack.org/developer/mistral * Source: http://git.openstack.org/cgit/openstack/mistral-lib * Bugs: http://bugs.launchpad.net/mistral Features -------- * TODO Platform: UNKNOWN Classifier: Environment :: OpenStack Classifier: Intended Audience :: Information Technology Classifier: Intended Audience :: System Administrators Classifier: License :: OSI Approved :: Apache Software License Classifier: Operating System :: POSIX :: Linux Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 mistral-lib-0.4.0/mistral_lib.egg-info/requires.txt0000664000175100017510000000006713234643752022365 0ustar zuulzuul00000000000000pbr!=2.1.0,>=2.0.0 oslo.serialization!=2.19.1,>=2.18.0 mistral-lib-0.4.0/mistral_lib.egg-info/pbr.json0000664000175100017510000000005613234643752021441 0ustar zuulzuul00000000000000{"git_version": "d61073a", "is_release": true}mistral-lib-0.4.0/mistral_lib.egg-info/SOURCES.txt0000664000175100017510000000277213234643753021657 0ustar zuulzuul00000000000000.coveragerc .testr.conf AUTHORS CONTRIBUTING.rst ChangeLog HACKING.rst LICENSE README.rst babel.cfg requirements.txt setup.cfg setup.py test-requirements.txt tox.ini doc/source/conf.py doc/source/index.rst doc/source/contributor/creating_custom_actions.rst doc/source/contributor/index.rst doc/source/install/index.rst doc/source/user/index.rst mistral_lib/__init__.py mistral_lib/exceptions.py mistral_lib/serialization.py mistral_lib.egg-info/PKG-INFO mistral_lib.egg-info/SOURCES.txt mistral_lib.egg-info/dependency_links.txt mistral_lib.egg-info/not-zip-safe mistral_lib.egg-info/pbr.json mistral_lib.egg-info/requires.txt mistral_lib.egg-info/top_level.txt mistral_lib/actions/__init__.py mistral_lib/actions/base.py mistral_lib/actions/context.py mistral_lib/actions/types.py mistral_lib/tests/__init__.py mistral_lib/tests/base.py mistral_lib/tests/test_serialization.py mistral_lib/tests/test_utils.py mistral_lib/tests/actions/__init__.py mistral_lib/tests/actions/test_base.py mistral_lib/tests/actions/test_context.py mistral_lib/utils/__init__.py mistral_lib/yaql/__init__.py mistral_lib/yaql/api/__init__.py releasenotes/notes/.placeholder releasenotes/notes/rename-task-id-to-task-execution-id-f17d671fcef0127a.yaml releasenotes/source/conf.py releasenotes/source/index.rst releasenotes/source/liberty.rst releasenotes/source/mitaka.rst releasenotes/source/newton.rst releasenotes/source/pike.rst releasenotes/source/unreleased.rst releasenotes/source/_static/.placeholder releasenotes/source/_templates/.placeholdermistral-lib-0.4.0/mistral_lib.egg-info/top_level.txt0000664000175100017510000000001413234643752022507 0ustar zuulzuul00000000000000mistral_lib mistral-lib-0.4.0/mistral_lib.egg-info/not-zip-safe0000664000175100017510000000000113234643734022210 0ustar zuulzuul00000000000000 mistral-lib-0.4.0/.testr.conf0000666000175100017510000000047713234643465016070 0ustar zuulzuul00000000000000[DEFAULT] test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION test_id_option=--load-list $IDFILE test_list_option=--list mistral-lib-0.4.0/CONTRIBUTING.rst0000666000175100017510000000121313234643465016430 0ustar zuulzuul00000000000000If you would like to contribute to the development of OpenStack, you must follow the steps in this page: http://docs.openstack.org/infra/manual/developers.html If you already have a good understanding of how the system works and your OpenStack accounts are set up, you can skip to the development workflow section of this documentation to learn how changes to OpenStack should be submitted for review via the Gerrit tool: http://docs.openstack.org/infra/manual/developers.html#development-workflow Pull requests submitted through GitHub will be ignored. Bugs should be filed on Launchpad, not GitHub: https://bugs.launchpad.net/mistral mistral-lib-0.4.0/LICENSE0000666000175100017510000002363713234643465015012 0ustar zuulzuul00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. mistral-lib-0.4.0/doc/0000775000175100017510000000000013234643753014535 5ustar zuulzuul00000000000000mistral-lib-0.4.0/doc/source/0000775000175100017510000000000013234643753016035 5ustar zuulzuul00000000000000mistral-lib-0.4.0/doc/source/conf.py0000777000175100017510000000535213234643465017346 0ustar zuulzuul00000000000000# Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. import os import sys sys.path.insert(0, os.path.abspath('../..')) # -- General configuration ---------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [ 'sphinx.ext.autodoc', 'openstackdocstheme' ] # autodoc generation is a bit aggressive and a nuisance when doing heavy # text edit cycles. # execute "export SPHINX_DEBUG=1" in your terminal to disable # The suffix of source filenames. source_suffix = '.rst' # The master toctree document. master_doc = 'index' # General information about the project. project = u'mistral-lib' copyright = u'2017, Mistral Contributors' # If true, '()' will be appended to :func: etc. cross-reference text. add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). add_module_names = True # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # -- Options for HTML output -------------------------------------------------- # The theme to use for HTML and HTML Help pages. Major themes that come with # html_theme_path = ["."] html_theme = 'openstackdocs' # html_static_path = ['static'] # Output file base name for HTML help builder. htmlhelp_basename = '%sdoc' % project # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass # [howto/manual]). latex_documents = [ ('index', '%s.tex' % project, u'%s Documentation' % project, u'OpenStack Foundation', 'manual'), ] # Example configuration for intersphinx: refer to the Python standard library. #intersphinx_mapping = {'http://docs.python.org/': None} # 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' # Must set this variable to include year, month, day, hours, and minutes. html_last_updated_fmt = '%Y-%m-%d %H:%M' # -- Options for openstackdocstheme ------------------------------------------- repository_name = 'openstack/mistral-lib' bug_project = 'mistral' bug_tag = '' mistral-lib-0.4.0/doc/source/install/0000775000175100017510000000000013234643753017503 5ustar zuulzuul00000000000000mistral-lib-0.4.0/doc/source/install/index.rst0000666000175100017510000000031213234643465021342 0ustar zuulzuul00000000000000============ Installation ============ At the command line:: $ pip install mistral-lib Or, if you have virtualenvwrapper installed:: $ mkvirtualenv mistral-lib $ pip install mistral-lib mistral-lib-0.4.0/doc/source/index.rst0000666000175100017510000000130413234643465017676 0ustar zuulzuul00000000000000Welcome to mistral-lib's documentation! ======================================= The mistral-lib is a library that contains data types, exceptions, functions and utilities common to Mistral, python-mistralclient and mistral-extra repositories. This library also contains the public interfaces for 3rd party integration (e.g. Actions API, YAQL functions API, etc.) Contents: Install guide ------------- **Installation** .. toctree:: :maxdepth: 2 install/index User guide ---------- **Usage** .. toctree:: :maxdepth: 2 user/index Developer guide --------------- .. toctree:: :maxdepth: 2 contributor/index Indices and tables ================== * :ref:`genindex` * :ref:`search` mistral-lib-0.4.0/doc/source/user/0000775000175100017510000000000013234643753017013 5ustar zuulzuul00000000000000mistral-lib-0.4.0/doc/source/user/index.rst0000666000175100017510000000011513234643465020653 0ustar zuulzuul00000000000000===== Usage ===== To use mistral-lib in a project:: import mistral_lib mistral-lib-0.4.0/doc/source/contributor/0000775000175100017510000000000013234643753020407 5ustar zuulzuul00000000000000mistral-lib-0.4.0/doc/source/contributor/creating_custom_actions.rst0000666000175100017510000000277113234643465026060 0ustar zuulzuul00000000000000============================ How to write a Custom Action ============================ 1. Write a class inherited from mistral.actions.Action .. code-block:: python from mistral_lib import actions class RunnerAction(actions.Action): def __init__(self, param): # store the incoming params self.param = param def run(self, context): # Actions can be returned in a manner of ways. The simplest is # return {'status': 0} # or using a Result object. The Result has an optional parameter data # that can be used to transfer information return actions.Result() # Failed executions can also be returned using a workflow Result object # that contains an non empty error parameter such as: # return actions.Result(error="error text") 2. Publish the class in a namespace (in your ``setup.cfg``) .. code-block:: ini [entry_points] mistral.actions = example.runner = my.mistral_plugins.somefile:RunnerAction 3. Reinstall your library package if it was installed in system (not in virtualenv). 4. Run db-sync tool to ensure your actions are in Mistral's database .. code-block:: console $ mistral-db-manage --config-file populate 5. Now you can call the action ``example.runner`` .. code-block:: yaml my_workflow: tasks: my_action_task: action: example.runner input: param: avalue_to_pass_in mistral-lib-0.4.0/doc/source/contributor/index.rst0000666000175100017510000000017413234643465022254 0ustar zuulzuul00000000000000===================== Developer's Reference ===================== .. toctree:: :maxdepth: 3 creating_custom_actions mistral-lib-0.4.0/HACKING.rst0000666000175100017510000000022213234643465015564 0ustar zuulzuul00000000000000mistral-lib Style Commandments ============================== Read the OpenStack Style Commandments http://docs.openstack.org/developer/hacking/ mistral-lib-0.4.0/test-requirements.txt0000666000175100017510000000072213234643465020234 0ustar zuulzuul00000000000000# The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 sphinx!=1.6.6,>=1.6.2 # BSD openstackdocstheme>=1.18.1 # Apache-2.0 oslotest>=3.2.0 # Apache-2.0 testrepository>=0.0.18 # Apache-2.0/BSD # releasenotes reno>=2.5.0 # Apache-2.0