This change allows a Macro returns a 'null' value (as opposed to None)
that makes it effectively cease to exist when that makes sense. If it
appears as a list item, that list item is dropped. If it appears as a
value in a dict, the corresponding key is removed from the dict. If it
appears as a property value, the property is treated as if the user had
not mentioned it in the template.
In all other circumstances (as an argument to a Function, as the top
level of some other field, like an output value), the result will still
appear as None.
A null value is represented internally by the Ellipsis singleton (to
distinguish it from None, which is a value that may appear in the
template from a user or be returned from a Function).
Change-Id: Iaed0982e0db902f6eaf8f986c12b4885bd77e8b9
Story: 2007388
Task: 38976
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 27 of a serie of 28 patches
Change-Id: I85b44a770b0e98885fb10c2874d9c153cc76959a
In order to calculate the dependencies of a ResourceDefinition, we have to
pass it a Stack object. This means we can't infer anything about the
resource's dependencies without instantiating the whole stack, and it means
we can't easily cache the result so we have to walk the entire
properties/metadata every time we need the dependencies.
This change splits a required_resource_names() method (the same as added to
OutputDefinition in the previous patch) out of the dependencies() method.
This new method calculates as much as we can know from the resource
definition alone and caches the result, while the dependencies() method
uses the (cached) result to calculate the graph dependencies for a given
Stack.
This also opens the way in future to changing the Function API to return
dependencies by name instead of as ResourceProxy objects.
Change-Id: Icdd0b2dd41116adae5e57ff3ef0e662ba75e6e2c
If a resource is conditionally defined, depending on it raises an error
in the case it's not defined. This patch fixes that by checking if the
resource is present in the template regardless of the conditions.
Change-Id: Iefae1fcea720bee4ed69ad1a5fe403d52d54433c
Closes-Bug: #1649900
Heat no longer accesses resource definitions as if they were snippets of a
CloudFormation template, but rather uses the APIs of the ResourceDefinition
class. The ability to treat this class as a snippet of CloudFormation
template has been deprecated for several release cycles to allow
third-party plugins to move away from it; this change removes that ability.
Change-Id: Ia9c63662438d4c979b897118b3a7a736161bcbca
This adds support for the following to the template:
heat_template_version: 2016-10-14
resources:
...
res_a:
type: OS::Nova::Server
external_id: the-new-server-id
properties:
...
Co-Authored-By: Rico Lin <rico.l@inwinstack.com>
blueprint external-resources
Change-Id: I8fda1380504d1d8b1e96649bf20b86d6309fdeca
The last remaining code using the deprecated methods in the
ResourceDefinition class to treat the definition like a CloudFormation
template snippet is the tmpl_diff in the Resource class. Replace the dict
diff with a Diff object that has an API which can be queried instead. For
backward compatibility with existing resource plugins, the current diff
objects are for now able to be treated like dicts. However, this is marked
deprecated and can be removed along with the equivalent support for
ResourceDefinitions in the future.
Change-Id: I9ef50f0d9b142d464a1b02da7a46536c532d2ebd
The commit 4188c40beb cleaned up a lot of
places where the warnings module was just being used as a non-standard way
to log a warning. However, the way the module was used in the rsrc_defn
module is correct and should not have been changed. By passing a
DeprecationWarning to warnings.warn() we not only make it easy to find
deprecated functions in the source, we also make it possible for developers
to test whether deprecated code is unused by forcing the exception to be
raised. There's also no point in translating these warnings, since they are
targeted at developers (mostly developers of third-party plugins) and not
operators per se. This patch reverts the change to that one file and its
tests.
Change-Id: I9cb1e739e9f173c8f70cb944e886cc3b49abc5f3
The part of a ResourceDefinition that lists explicit dependencies was not
round-trip stable. As a result, when we copied a new resource definition
into the existing template during a stack update, we would end up rewriting
the template unnecesarily (i.e. even though we check for changes) every
time if depends_on was not specified in the resource originally. At the end
of each update, we write the new template to the DB in its entirety, which
removes these extra lines again, ensuring that we will experience the same
problem on every update. This was causing a *lot* of unnecessary writes.
This change ensures that the definition remains stable across a round-trip,
so that no unnecessary changes appear in the template.
Change-Id: If7292e49755db0153d7d0db9f7d3875fa9c1d408
Closes-Bug: #1494108
Docstring of class ResourceDefinition tells, that backward compatible
methods should be deprecated in favor of using methods in
ResourceDefinitionCore, but there is no any warning message about it.
This patch adds deprecation warnings.
Aslo related tests were changed to check, that deprecation warning is
really raised.
Change-Id: Ie881a1bdb88f4bcb1c03c037bcedf2a328d5d41c
For python3 compatible, using six.string_types instead of
basestring(). six.string_types represent basestring in
python2 and str in python3.
Change-Id: Ib4ba3d164f782601944023b99d6cc1ee2763ee85
Fix the HeatTestCase import issue as required by H302,
a following patch of https://review.openstack.org/#/c/129846/
Change-Id: Iab9a508682e9fe2932b7d00b191c8a4cdea4738b
ResourceDefinition objects compare equal if they are generated from
equivalent templates. Only the MRO stands between us and disaster (since
both superclasses - ResourceDefinitionCore and collections.Mapping - define
__eq__ methods), so add a test to confirm that we are getting the correct
one.
Change-Id: I8181f91f08fd81104fe493539511d6fd129522c8
This class provides a comparable, hashable representation of a resource's
definition in a template that is independent of the template format.
Implements: blueprint resource-template-api
Change-Id: I183114596863fbe0c0ff7cd22134b37493ed0dd9