Moves the exception from inside the engine code
to the common code so that we can use it in the
API fault middleware.
Change-Id: I017b95153c358829501f6a5740918cdb005fb32f
Six is in use to help us to keep support for python 2.7.
Since the ussuri cycle we decide to remove the python 2.7
support so we can go ahead and also remove six usage from
the python code.
Review process and help
-----------------------
Removing six introduce a lot of changes and an huge amount of modified files
To simplify reviews we decided to split changes into several patches to avoid
painful reviews and avoid mistakes.
To review this patch you can use the six documentation [1] to obtain help and
understand choices.
Additional informations
-----------------------
Changes related to 'six.b(data)' [2]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
six.b [2] encode the given datas in latin-1 in python3 so I did the same
things in this patch.
Latin-1 is equal to iso-8859-1 [3].
This encoding is the default encoding [4] of certain descriptive HTTP
headers.
I suggest to keep latin-1 for the moment and to move to another encoding
in a follow-up patch if needed to move to most powerful encoding (utf8).
HTML4 support utf8 charset and utf8 is the default charset for HTML5 [5].
Note that this commit message is autogenerated and not necesserly contains
changes related to 'six.b'
[1] https://six.readthedocs.io/
[2] https://six.readthedocs.io/#six.b
[3] https://docs.python.org/3/library/codecs.html#standard-encodings
[4] https://www.w3schools.com/charsets/ref_html_8859.asp
[5] https://www.w3schools.com/html/html_charset.asp
Patch 6 of a serie of 28 patches
Change-Id: Ic56cf6da5ff9ab8f4bd218e6516b87f47165206d
Six is in use to help us to keep support for python 2.7.
Since the ussuri cycle we decide to remove the python 2.7
support so we can go ahead and also remove six usage from
the python code.
Review process and help
-----------------------
Removing six introduce a lot of changes and an huge amount of modified files
To simplify reviews we decided to split changes into several patches to avoid
painful reviews and avoid mistakes.
To review this patch you can use the six documentation [1] to obtain help and
understand choices.
Additional informations
-----------------------
Changes related to 'six.b(data)' [2]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
six.b [2] encode the given datas in latin-1 in python3 so I did the same
things in this patch.
Latin-1 is equal to iso-8859-1 [3].
This encoding is the default encoding [4] of certain descriptive HTTP
headers.
I suggest to keep latin-1 for the moment and to move to another encoding
in a follow-up patch if needed to move to most powerful encoding (utf8).
HTML4 support utf8 charset and utf8 is the default charset for HTML5 [5].
Note that this commit message is autogenerated and not necesserly contains
changes related to 'six.b'
[1] https://six.readthedocs.io/
[2] https://six.readthedocs.io/#six.b
[3] https://docs.python.org/3/library/codecs.html#standard-encodings
[4] https://www.w3schools.com/charsets/ref_html_8859.asp
[5] https://www.w3schools.com/html/html_charset.asp
Patch 3 of a serie of 28 patches
Change-Id: If6e66839c128dde5fb80d90155dedb598da8d53b
It's really confusing every time you have to think about the difference
between requires() and require_by() in the dependencies graph. That was
helped not at all by 5189bbebab, which
added a requires() method to the Dependencies class with a parameter
name that is exactly backwards from correctly representing what it
means, as well as a docstring that is copied without modification from
the required_by() method, which obviously returns the opposite data. In
addition, the new docstring for the Node.requires() function made no
sense.
Change-Id: Ie9d8bedf83947b197f2defd309fd996060514100
The number of nodes in the dependency graph is not huge (one per resource),
but we tend to make a lot of copies - the whole graph must be copied every
time we iterate through it. Since the Node class has only two attributes
and is basically never modified, we can easily save a little memory by
defining __slots__ for it.
Change-Id: Ibe36016a5889c9f1bd89672b1b03b2bc69b7925b
If we use unicode as resource name or parameter,
we are likely to encounter unicode problems.
This patch aims to fix unicode problems, and
there are several things to be clear:
1. For the class wrap with six.python_2_unicode_compatible, in
python2 their original __str__ function will map to __unicode__,
and new __str__ function comes from __unicode__.encode.
So we should always return unicode in __str__() if wrap
with python_2_unicode_compatible.
2. python_2_unicode_compatible will not handle __repr__,
__repr__ should return str in all versions of python.
Co-Authored-By: Ethan Lynn <xjunlin@cn.ibm.com>
Closes-Bug: #1524194
Change-Id: Ib4af43d153e0edf9d66308bf8e7b93a3be501d2e
The process of bringing us into compliance with the H405 pep8 rule has left
us with a lot of docstrings that either don't follow the recommendations of
PEP0257, are misleading, wrong, or nonsensical. This patch attempts to fix
them up.
Change-Id: Icfe90b5ba3102a7e13ab659038a8b2af9019e9e6
* convert map to list in heat.engine.api. This is done because stacks
are garbage collected once we go out of scope using weakrefs. However,
in python 3, since everything is lazily loaded, when we iterate over
the stack['resources'] iterable, we end up referencing the previously
garbage collected stack object. So resolve everything before returning
the list.
* sort the __repr__ of dependencies to return a consistent string
* Don't encode support_status. There is no need to encode it. Without
* this, in py3, we'd effectively be comparing a unicode string to byte string
and thus breaking the environment.get_types() API partially.
* test_case: explcitly cast strings to int before comparing them with integers.
* test_case: use a more accurate sorted expression
partial blueprint heat-python34-support
Change-Id: Ic9d78034b7e5478c4cb14344d64b9e838a12bf57
On Python 3, the decorator does nothing. On Python 2, it aliases the
__str__ method to __unicode__ and creates a new __str__ method that
returns the result of __unicode__() encoded with UTF-8.
All instances of __unicode__ have been removed with the
aforementioned decorator in place instead.
Note: There are some instances of __str__ which aren't handled but
will be once we have actual python34 tests running in the gate.
partial blueprint heat-python34-support
Change-Id: I7271a2581e1c2bbc282933c7da73db810c7e09db
__nonzero__ has been renamed to __bool__ in python3.4. So add the
__bool__ magic method that will in turn call the existing __nonzero__
method. This avoids the scheduler going into an infinte loop when
it checks for the no. of tasks remaining.
partial blueprint heat-python34-support
Change-Id: I5de554805a2af9abc15808427ce489720287f6b3
This is a merge of 4 reviews:
I52f1611d34def3474acba0e5eee054e11c5fc5ad
Ic374a38c9d76763be341d3a80f53fa396c9c2256
Iecd21ccb4392369f66fa1b3a0cf55aad754aeac4
I77b81097d2dcf01efa540237ed5ae14896ed1670
- make sure sender is a tuple (otherwise the serialization
function in sync_point breaks.)
- Update updated_time on any lifecycle operation(CREATE/UPDATE/DELETE)
over a stack.
- adjust sync_point logic to account for deletes
Done by having only a single stack sync point
for both updates and deletes.
- Serialize/deserialize input_data for RPC
- Make GraphKey's the norm in convergence worker
- move temp_update_requires functionality to tests
During intial stages of convergence to simulate the entire cycle
some part of worker code was written in stack.py.
Now that the convergence worker is implemented, this code needs to
be executed only in tests.
- Fix dictionary structure that's passed to resoure.(create/update)
- Temporarily disable loading cache_data for stack to help fix other
issues.
Change-Id: Iecd21ccb4392369f66fa1b3a0cf55aad754aeac4
Co-Authored-by: Sirushti Murugesan <sirushti.murugesan@hp.com>
Co-Authored-by: Rakesh H S <rh-s@hp.com>
When generating the dependencies, the deletion order is already taken
care, hence we need not reverse the graph.
Change-Id: Iff158443f2281a07e3a136a4cf6f77f7be592d3f
Generates the graph for traversal in convergence.
* Updates current traversal for the stack
* Deletes any sync_point entries of previous traversal
* Generates the graph for traversal based on
- resources loaded from db for the stack
- resources that exist in present template
* Stores resource.current_template_id and resource.requires
* Stores the edges of graph in stack.current_deps
* Creates sync_points for each node in graph
* Creates sync_point for stack.
blueprint convergence-prepare-traversal
Change-Id: I507e67b39c820ed46d3b269fc76d6cf18d0ef2d7
When using template which has resource name in unicode to create
stack will failed with encode/decode error.
This patch override __str__ & __unicode__ function in related
classes to make them compatible with unicode.
blueprint: template-unicode-support
Change-Id: Ie677d180d2131abd052101996900414e2b2ef4ad
According to https://wiki.openstack.org/wiki/Python3 dict.iteritems()
should be replaced with six.iteritems(dict).
Change-Id: I9e2881a006433c8b44a3caccebc73bae4973a041
Mutables in the method params defaults might cause errors and
that's why it's anti-pattern in most of the cases and should be
removed.
Change-Id: I8bc284f12ce72082a0482410ec2c20c2fc087a4b
Closes-Bug: #1327473
This patch is one in a series to re-enable H306 style check rule
(imports are in alphabetical order).
It touches engine files (without resources).
Implements: blueprint reduce-flake8-ignored-rules (partial)
Change-Id: Ifd36fc49199c48af891bd8e7cc2d2262a53032eb
in python3.x, there is no method named xrange(),
it has been replaced by range(),which is equal to xrange()
in python2.x. so we must fix this issue.
we use six module to fix this issue.
Change-Id: Ia901798cf16b9a48982e6845fa3e5deffc3bd509
Closes-Bug: #1268439
DependencyTaskGroup currently aborts execution if any exceptions are
raised. This commit provides a way of aggregating all the exceptions
during execution and re-raising them only at the end.
blueprint stack-check
Change-Id: I6af314cc112f9286c8b38739870c6fa8b4ba9b5a
This doesn't solve the problem yet, but clarifies
the format string from the final string.
Partial-bug: #1243883
Change-Id: Ia0f19423248304984cc53926dfb87c6a49c90e11
The OpenStackException.__str__ method returns
self._error_string which is actually a gettextutil.Message
object not a str.
str(o) will check the return type of o.__str__() and raise
TypeError if __str__ returns non-string object.
The fix will not go into oslo as OpenStackException is
about to be deprecated. And this patch is also the first
step to remove all the references to oslo exception.py.
Fixes bug #1208454
Change-Id: Ib6abe3517bcb1b34fc6a71e5c46ee3774e067f9a
Several files use the "_" function, but don't import it from
gettextutils - this leads to a "NameError: name '_' is not
defined" error if you try to import/use the modules from an
interactive python shell or standalone test-code.
Change-Id: Id28b45d71eeda64fbfaa6234b12cff45fcd2ce40
Each resource can generate a list of names of resources which
require this resource as a direct (non transitive) dependency.
This information is returned in the list as well as the show REST calls
so that a diagram of the running stack can be built with a single
request.
Other uses of exposing this information is:
- template authors debugging their own template dependency issues
- integration tests validating template dependencies
Change-Id: Ibe62345afa87e49c4e2152a5fcb74e5ee003124e
Graph objects are mutable, and will in future be used for operations other
than a topological sort, so abstract out the code for deleting backlinks to
a node from the other nodes that have dependencies on it when it is
removed.
Change-Id: I86b81303ed2dffd969a2db10535761f108f4808a
Rather than copying dictionaries internally, provide a separate Graph class
that can be copied externally as well.
Change-Id: Id0bd55944369da59d7da1713369fce0d73ffe814
We're going to start making more use of it, so there's no point hiding it
away inside the Dependencies class.
Change-Id: I10c4a05493697f8834623cd798ef35161a0c219b