The abstract base classes previously defined in 'collections' were moved
to 'collections.abc' in 3.3. The aliases will be removed in 3.10.
Preempt this change now with a simple find-replace:
$ ag -l 'collections.($TYPES)' | \
xargs sed -i 's/\(collections\)\.\($TYPES\)/\1.abc.\2/g'
Where $TYPES is the list of moved ABCs from [1].
[1] https://docs.python.org/3/library/collections.abc.html
Change-Id: Ia282479bb1d466bd2189ebb21b51d91e89b9581e
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Parsing the value of JSON parameters at the time we create them (or
update the default value) results in exceptions occurring while creating
the Stack object, that are then not caught and transformed. The result
is an HTTP 500 Internal Error reported by the API, with an unhelpful
error message.
By not parsing the JSON until it is needed, we ensure that any errors
will occur during validation, where errors are appropriately transformed
(to StackValidationFailed) and annotated with the necessary information
to help the user determine the source.
Depends-On: https://review.opendev.org/#/c/748359/
Change-Id: I70e341c344d6254173ad4519276626230087263a
Story: 2007957
Task: 40443
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
In some scenarios, it is required to categorize the parameter.
Associating tags with the parameter, it is will be easy to
categorize the parameter and add simple validations to users.
This patch introduces a new attribute 'tags' with the parameters,
which is a list of strings.
Change-Id: I20fc95d606b0b8a08d3b46bf33f4860bff49c74f
This reverts the commits f5c32ad8fd and
14fdf72b000c82a80abb2587189dd7c6c7dfa0a0e.
The constraint never worked and the stuff to pass the template to
constraints (which was broken because we actually passed a
ResourceDefinition instead) is a pain. Just get rid of it rather than
fix it.
Change-Id: I4e1e787ad94ac1951f472ea066a9b1c9d3e03611
Closes-Bug: #1661403
Previously, we were not using the specialized parameter class' __str__
method to print the parameters in the stack-show output with python
2.x.
Closes-Bug: #1613415
Change-Id: I44295ae567cef91eb484201099c7646cdb16fe08
Casting a parameter to a number can fail with a type error as well as a
value error. Let's catch it to get a proper validation error.
Change-Id: I63779a6227b834cedeeed1c4d5d49271e15e4ea9
Closes-Bug: #1698365
A typical stack may easily have dozens of parameters, so Parameter objects
are very common in memory. They're also very simple and change rarely, all
of which makes them a good candidate for being made lighter-weight using
slots to avoid creating __dict__.
Change-Id: I23e07876054cbaf220df1c9fc2d663b00130501b
Related-Bug: #1626675
When __new__ returns an instance of the class (or a subclass), Python will
call __init__ on it afterwards. So if we return an initialised object of a
subclass, we end up calling both __new__ and __init__ twice. Avoid this by
calling object.__new__ and passing the desired subclass instead in
ResourceInfo and Parameter. Equivalent changes for Resource and Template
have been in place for some time.
Change-Id: I4c3f0bc9c1a39b9f0b964ccf1c6c638f86b3753e
Use allow_conversion flag to convert comma_delimited_list
to list before validation when using from_parameter.
Change-Id: Id144aade23eee13df227acdb728906c8dd345337
Closes-Bug: #1617019
The validate method for a constraint only accepts the value being
verified. This is sufficient for most data checks (range, regex) and the
calls to one of the service clients. But it is limiting in the sense
that it prevents us from ever having constraints that span multiple
parameters (such as ensuring that two values are compatible).
What caused this is the atttempt to add a constraint to ensure a
parameter's value is a valid Heat resource type. To verify this, the
constraint code needs access to the resolved environment. I opted to
pass the entire template down instead to make things more flexible.
The call to the BaseCustomConstraint (which appears to be the entry
point for most plugins) will attempt to use the new signature with the
template, but will fall back to the original call for backward
compatibility.
Change-Id: I5dc94c964b35578e84da641278a4175a37038498
In Python3, dict.keys() returns a view object rather than a list. This
behaves differently in that changes to the dict also modify the view, and
in that the view type interacts with various operators in different ways to
lists.
One universally correct transformation to preserve Python2 behaviour in
Python3 would be to replace all instances of d.keys() with
list(six.iterkeys(d)), and indeed we did. However, like many automatic
transformations the results are usually unsightly, invariably inefficient,
and frequently absurd. Not least because list(d.keys()) and indeed list(d)
are also equivalent.
This patch changes to using the simplest correct method of accessing the
data we want in each case.
This reverts or rewrites most of commit
4ace95ad47.
Change-Id: Iba3cf48246d8cbc958d8fb577cd700a218b0bebf
Apart from the fact that this method relied on knowledge of the template
format, it also checked nothing useful since we now won't even be able to
create the Parameters object unless all of the parameter definitions are in
fact dicts.
Change-Id: I950420b9016d350a427754d6a482b6ddf456bd6f
Add a new "immutable" boolean field to the parameters section in a HOT
template. A value of True will result in the engine rejecting
stack-updates that include changes to that parameter. When not
specified in the template, "immutable" defaults to False to ensure
backwards compatibility with old templates.
blueprint: immutable-parameters
Change-Id: If17df0b97e96ff2a1926451634e4744d6c3e26f1
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
This changes the _validate methods for the JsonParam and
CommaDelimitedListParam to raise StackValidationFailed execeptions if
the parameters values fail to parse. A failure to parse will be
indicated with a ValueError exception, so that exception is caught and
StackValidationFailed is raised instead.
This brings these parameters in line with the behavior in the other
parameter type classes.
It also makes the validation failures much more helpful to users with
stacks with lots of parameters (TripleO), as the name of the parameter
that failed validation will now be logged as part of the exception.
Change-Id: Ife08272f0e95491c030e5d70499fe31d462c515c
When environment of a stack contained a parameter_defaults section with
a value for a parameter of type comma_delimited_list or json, that default
didn't get applied unless in a nested stack.
The issue was that CommaDelimitedListParam contains a variable to cache
its value, and that cache was only created upon creation of a
CommaDelimitedListParam object, but it wasn't updated on `set_default`
method call. The cache now updates on `set_default` too.
Co-Authored-By: Steven Hardy <shardy@redhat.com>
Change-Id: I85b13a79dbc97a77e20c0d5df8eaf05b3000815e
Closes-Bug: #1504137
* convert to unicode instead of converting to bytes
when flattening lists to strings.
* test: convert to bytes before asserting to maintain
py2 compatibility.
partial blueprint heat-python34-support
Change-Id: I7a9f40e90d829e0764d229526698a78479feeb2f
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
Use parentheses instead of backslash for line continuation.
Plus, usage of escaped quotes in long strings is avoided where it makes
sense.
Change-Id: If2e78012b85a4430c6f03f65784cac2d032cf116
When user provides it's own parameter's value, there is no
reason to check custom constraint on default value of this
parameter. And if there is no user value, default value
validates anyway. So custom_constraint validation of default
values is unnecessary.
Change-Id: Ied3feefc7d062ddb20d42cfc5b2c30be4fdc3227
Closes-bug: #1394100
This give the user a way to set defaults recursively down nested stacks
without having to create the parameter in every template (it's ignored
if the template does not have the parameter).
blueprint env-nested-usability
Change-Id: Ie6b4481417204a527d322fd532c341b9acbce473
Relying on [1], property Dimensions isn't required, but
this template has no Default value for Dimensions
(thereby making it required). This patch fix that omission.
Besides that, parameters have wrong parsing, because if
parameter with type 'CommaDelimitedList' has default
value '', parameter's parsing result would be [u''] instead
of []. this is wrong, so this patch fix it.
[1] http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-alarm.html
Change-Id: I259249659c8b5dc846432f8e08985b148b30d682
Closes-bug: #1386824
Use the -e parameter in template-validate to override any
Default values specified in the template. This has the desirable
effect of making Horizon use parameters updated from the environment
file.
Change-Id: I84405d1d2f5245ab7cb8b909c2ea1407d5b2973e
Closes-Bug: #1388985
For python3 compatible, using six.string_types instead of
basestring(). six.string_types represent basestring in
python2 and str in python3.
Change-Id: Ib4ba3d164f782601944023b99d6cc1ee2763ee85
Since i18n.install() is deprecated, remove it from heat codes and
import i18n._() to where it needed.
blueprint oslo-i18n
Change-Id: Icefada18b5a33112b425cd90d31d3a6a5f06188a