Commit Graph

47 Commits

Author SHA1 Message Date
Stephen Finucane 57e9754093 Switch to collections.abc.*
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>
2021-02-01 11:15:59 +00:00
Hervé Beraud 5877da06a1 Remove six and python 2.7 full support
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 4 of a serie of 28 patches

Change-Id: I871c2dad10abc35790e730c7c4c5272f499b7623
2020-04-22 12:23:44 +02:00
Hervé Beraud fccd312871 Remove six and python 2.7 full support
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
2020-04-22 12:23:44 +02:00
Zane Bitter f2b60f308f Validate attributes schema
We always check that a properties schema is valid at the time that it is
created. Do the same for the attributes schema. This will catch programming
errors in the writing of Resource plugins.

Change-Id: I8119aec30b83f1f9e711013a60a828ae4a8337c7
Story: #2003915
2018-09-28 11:56:57 -04:00
Zane Bitter 45e4c53f78 Cache attributes with custom handling
Previously, all caching of attribute values was done via the Attributes
object. However, some resource types override Resource.get_attribute() to
do custom handling of the trailing attribute path or dynamic attribute
names, and in these cases the resulting values were not cached (since they
don't go through the Attributes object).

This patch adds a caching step for these resources:

* OS::Senlin::Cluster
* OS::Heat::ResourceChain
* OS::Heat::ResourceGroup
* OS::Heat::AutoscalingGroup
* OS::Heat::SoftwareDeployment
* OS::Heat::SoftwareDeploymentGroup
* TemplateResource
* AWS::CloudFormation::Stack

Change-Id: I07ac22cc4370a79bd8712e2431fa3272115bc0eb
Co-Authored-By: Crag Wolfe <cwolfe@redhat.com>
Partial-Bug: #1660831
2017-06-27 22:08:03 -04:00
Jenkins 27a60a6931 Merge "Store resource attributes in the DB" 2017-06-27 09:28:07 +00:00
Zane Bitter dc957bc2a6 Revert "Support attributes with dynamic scheme"
This code was never used for anything, as the rest of the patch series
never landed and was abandoned.

This reverts commit 15e52ff5e9.

Change-Id: I7d1a22753e8de1d3adf127c14516ebd667513bfa
2017-06-26 14:39:11 -04:00
Crag Wolfe 0550659f5f Store resource attributes in the DB
Store resource attributes that may be cached in the DB, saving the
cost of re-resolving them later. This works for most resources,
specifically those that do not override the get_attribute() method.

Change-Id: I71f8aa431a60457326167b8c82adc03ca750eda6
Partial-Bug: #1660831
2017-06-21 20:18:46 -04:00
Jenkins ec6b7008c0 Merge "Use a sentinel to indicate when all attributes are required" 2017-04-05 14:26:57 +00:00
Jenkins 9327d2f859 Merge "Add a StackDefinition class" 2017-04-03 06:12:38 +00:00
liyi 8f10215ffd Remove log translations
Log messages are no longer being translated. This removes all use of
the _LE, _LI, and _LW translation markers to simplify logging and to
avoid confusion with new contributions.

See:
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Change-Id: Ieec8028305099422e1b0f8fc84bc90c9ca6c694f
2017-03-25 17:11:50 +08:00
Zane Bitter 06afc2f3b0 Use a sentinel to indicate when all attributes are required
To generate its NodeData, a Resource must know which of its attributes
other parts of the template have dependencies on, which it determines by
asking the intrinsic functions in the template. Currently, the get_attr
function when used with no arguments depends on all of the attributes of
the resource (except 'show'), and it obtains this list from the Resource
itself (via the attributes_schema). This presents a chicken-and-egg problem
if we want to give Functions access only to a ResourceProxy based on the
NodeData.

Resolve this by returning a constant sentinel value (indicating that all
attributes are required) to the Resource, which can determine for itself
what attributes it has.

Change-Id: If209b589278fe1facb06e157fe76209fdd42a8a2
Partially-Implements: blueprint stack-definition
2017-02-24 10:19:21 -05:00
Zane Bitter 903a5106e8 Add a StackDefinition class
This defines clearly the API through which Template/Function plugins
may access data about the stack. That allows us to ensure that we don't
accidentally access data in a highly inefficient manner, and third-party
plugin developers to have confidence that the interface they're using is
stable and won't change without a multi-cycle deprecation process with
ample warning.

Change-Id: I7a67700685770d6d5b9c811e72a8b21221400092
Partially-Implements: blueprint stack-definition
2017-02-24 10:19:21 -05:00
Zane Bitter e1124b2605 Include an OS::stack_id output when generating a template
When generating a template to act as a facade for an existing resource
type, include an OS::stack_id output so that doing get_resource on the
facade resource will return the physical ID of the inner resource.

Change-Id: I257e9cc2eefd2cb8153e94cd05b21fed4b03c6c7
2017-01-10 15:00:43 -05:00
Zane Bitter 5553a6f29c Correct output values when generating templates
Change-Id: Ibb41bec5c6cf4f63a5b8ab1c9a46b7219c3e46fb
Closes-Bug: #1655439
2017-01-10 15:00:39 -05:00
Oleksii Chuprykov f629fb5ffa Do not show HIDDEN props in res type template
Hidden properties and attributes shouldn't be presented
in output of "heat resource-type-template".

Closes-Bug: #1601921

Change-Id: I7d20cd4119b9001094f7b503c7c0940f93287f6e
2016-07-15 13:26:24 +00:00
Zane Bitter e79f28d28a Fix unfortunate spelling error
Change-Id: I2ceab6579112d55f496c0bbe37c42263b54bb0c9
2016-04-04 12:43:16 -04:00
Ethan Lynn 6cf8dc6e56 Fix problems in unicode template support
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
2016-03-04 01:59:40 +00:00
LiuNanke 208d2debd0 Using LOG.warning replace LOG.warn
*Python 3 deprecated the logger.warn method, see:
*https://docs.python.org/3/library/logging.html#logging.warning
*so we prefer to use warning to avoid DeprecationWarning.

Change-Id: I07ee9c97c3548c965aaf83d34b37b23e9baba584
2015-12-29 09:32:42 +00:00
Peter Razumovsky 2da170c435 Fix [H405] pep rule in heat/engine
Fix [H405] rule in heat/engine python
files.

Implements bp docstring-improvements

Change-Id: Iaa1541eb03c4db837ef3a0e4eb22393ba32e270f
2015-09-21 14:51:46 +03:00
Jenkins 044a970bd8 Merge "Support attributes with dynamic scheme" 2015-08-11 15:18:55 +00:00
Angus Salkeld 15e52ff5e9 Support attributes with dynamic scheme
Some resources (software deployment, template resources, etc)
doesn't have static attribute scheme. So when we are trying
to output attributes for such resources the output always
returns None or null. So the patch support this functionality
with the new type of attributes: dynamic scheme attributes.
They allow to resolve dynamic attributes for resource outputs
and fetch such info as nested stack attrs or
software deployment outputs.
The next patch will enable usage of dynamic scheme attributes
for heat resource.

Change-Id: I474addad0bbfe16aa5c562f2d6025c52f175dd4f
Partial-Bug: #1470675
2015-08-10 12:17:01 +03:00
Sergey Kraynev f419c6405e Use base attributes with attribute_schema of class
attribute_schema of Resource class sometimes used directly without
creating instance. It allowed to situation, when attribute_schema is not
updated by base attribute.

This patch adds base_attributes_schema dictionary for these cases.

Also added same approach for resource_facade and updated tests.

Closes-Bug: #1481020

Change-Id: I104dae2fa3f3394195c1fd9bbed1902a9e4ba31f
2015-08-04 09:24:53 +00:00
Sergey Kraynev 658d61ecee Use __iter__ method of Attributes class in __repr__ method
Join method expects list, but six.itervalues(self._attributes)  returns
a Attribute instance, so we should use own __iter__ method for building
list of values.

Closes-Bug: #1473974

Change-Id: I7c5d4a5a8d0142156c3416347940b9e90ed8df5c
2015-07-13 15:23:01 +03:00
Tetiana Lashchova 5f8cef2a4c Add Boolean type to attributes schema
After commit I0f33afe9fac835da9041ff48695bb8cd18660383
some attributes have Bollean type which is missed in
the attributes schema.

Change-Id: I309c5a02b86dc2c8567bd8dfb43f10b31e89dcf8
2015-07-07 16:28:03 +03:00
Alexandr Nedopekin 8fb4050fef Update logging according oslo.i18n recommendations
Removed unused logging import
Replaced % on ,
Source: http://docs.openstack.org/developer/oslo.i18n/guidelines.html

Change-Id: I10e8deb332c5228926a8f3193b2d23325b85af9b
2015-06-29 15:37:04 +01:00
tyagi c38bee4977 Add attribute type for heat resources
Add type field to the schema of the heat resources.
Also added Integer type to attributes schema.

Change-Id: Icd09f28a29a52be1904f76887a37c7f17786c4a6
Implements: blueprint add-type-in-attributes-schema
2015-06-15 03:30:59 -07:00
Sergey Kraynev 989c5c0bf7 Fix wrong definition of assert
Fix warning error message in unittests log, which was added in patch
Ie881a1bdb88f4bcb1c03c037bcedf2a328d5d41c:

"heat/engine/attributes.py:80: SyntaxWarning: assertion is always true,
perhaps remove parentheses?"

Change-Id: I165d3a1f4e281debd8afb390520f18fc59084b87
2015-06-09 10:42:06 -04:00
Sergey Kraynev 3c38459c3f Remove deprecated old attribute schema
This change is a part of changes discussed here:
https://etherpad.openstack.org/p/YVR-heat-liberty-deprecation

- Removed deprecation warning
- Removed hook for old attribute schema
- Re-factored test for type property of attribute schema

Change-Id: Ie48754943386755224a4e19d87bbd083b1b91d1b
2015-06-03 14:50:39 +00:00
tyagi cafd53be11 Add type field to the resource attributes schema
Add data type for the attributes. This will help
1) validating the attibute against its type
2) resource-schema api will show the attribute type
3) template authors will know what type of value to
   expect making indexing and mapping easier
4) generating docs for the attribute type

Implements: blueprint add-type-in-attributes-schema
Change-Id: Ifc92c57ec1ddd2ab5f810587a1d33e762308dd8a
2015-05-06 00:50:47 -07:00
huangtianhua b44df7a1db Support to generate hot template based on resource type
Currently heat supports to create CFN template based on
the given resource type. And this patch adds an option
to allow user to specify template type to generate(support
HOT template at the same time).

blueprint support-to-generate-hot-templates

Change-Id: I55cfb9b0f87e638350f2f6367fb399d772fff7e1
2015-04-28 16:14:52 +08:00
Sirushti Murugesan 640abe0c12 Update the rest of the code to satisfy flake8 in a py34 env
* Use six.moves.reduce
* Update numliteral from 0L to 0
* Use open() instead of file()
* Use rich comparison methods instead of cmp()

partial blueprint heat-python34-support

Change-Id: I9ffd85645563192b5d6124f8dbb71c24245eefc4
2015-04-24 11:53:43 +05:30
Tetiana Lashchova 4c6810ce1a Use six.itervalues(x) instead of x.values()
Change-Id: Ie71072940b7b5e599d9012be0bc1874b2a623003
Partial-Bug: #1446254
2015-04-21 09:05:49 +03:00
Pavlo Shchelokovskyy 4279bd2923 Enable H305 and H307 style checks
Correct grouping and ordering of imports

Change-Id: I47ea0d53f80d7f0aeb01c1c6afd63713be87ddf4
2015-01-20 09:47:25 +02:00
Ethan Lynn a53c73fc4a Using six.string_types for python3 compatible
For python3 compatible, using six.string_types instead of
basestring(). six.string_types represent basestring in
python2 and str in python3.

Change-Id: Ib4ba3d164f782601944023b99d6cc1ee2763ee85
2014-11-03 15:03:56 +08:00
Ethan Lynn 11c1b62052 Remove deprecated function i18n.install('heat')
Since i18n.install() is deprecated, remove it from heat codes and
import i18n._() to where it needed.

blueprint oslo-i18n
Change-Id: Icefada18b5a33112b425cd90d31d3a6a5f06188a
2014-10-13 10:31:28 +08:00
Zane Bitter cacdb47993 Refactor selecting values from an attribute
Move the code to select particular keys/indices from an attribute value out
of the get_attr intrinsic functions and into the attributes module as a
separate function.

Change-Id: I16135159027cc52e8da74a4b5863fc8a8595d582
2014-07-15 10:21:56 -04:00
Steve Baker ab412fee30 Implement caching of resource attributes
The default caching mode cache_local will return the previously
resolved value if it is available.

Whenever any resource changes state, all resource attribute caches
are cleared just in case the state change has side-effects in
other resources.

The caching mode cache_none performs no caching, and is chosen
for attributes which are one of the following:
* Derived from any resource's metadata, resource data or resource_id
* An API call which returns a secret

Caching currently only exists for the duration of the parser.Stack
object, but there is future potential for a caching mode which
caches attributes spanning multiple requests.

Closes-Bug: #1321970

Change-Id: I01bf2983b726f0e81a2b8d5be94627353bdeb406
2014-05-30 13:14:27 +12:00
Sergey Kraynev be26f4089e Deprecating the old style attribute Schema
There is last patch to migrate on new attribute Schema.
The main changes are:
 - Deprecation warning was added in from_attribute function.
   If attribute have old format, it will be converted to new schema format
   and Deprecation warning will be raised.
 - Translation to new Schema was added in function schema_from_outputs.
 - All generic resources have been changed and use new Schema class now.
 - Some others tests have been fixed and use new Schema class now.

Change-Id: Icf92f2d275a86a13c656b0e74b725a442db3e532
Closes-Bug: #1307319
2014-05-28 02:00:53 -04:00
Sergey Kraynev fdc702bc78 Adding attribute schema class for attributes
This patch introduces simple schema class for attributes.
There are two options avaliable for this schema:
 - description
 - support status
It gives ability for adding support status for each attribute.

Change-Id: I46cbf776f315cbe6414005cbee65da1cefdc5f7d
Closes-Bug: #1305584
2014-04-22 08:32:00 -04:00
Jason Dunsmore af464c9afc Make the first line of every file consistent.
Change-Id: I2e1a809cfca8e88693551d58d33e747f54ee5eb1
2014-03-04 09:03:04 -06:00
Jason Dunsmore 97135cbfc0 Remove vim header from files.
Change-Id: Ia6131f8fcac6902c80c80aa805c8cd7a2a41f280
Closes-Bug: #1229324
2014-03-04 08:51:56 -06:00
Angus Salkeld f876b6b175 Wrap engine exceptions in _()
Change-Id: Id68baa3542ec2804169a4411a9b6962a96487ec3
Partial-bug: #1199695
2013-10-18 11:28:12 +11:00
Zane Bitter ea83af8836 RPC: Add an RPC call to get a resource type schema
blueprint resource-properties-schema

Change-Id: Id316393d84b6f1112b80caf14ffb98c937597f40
2013-08-12 09:51:45 +02:00
Zane Bitter fba9a329a6 Clean up the attributes module
Get rid of a lot of boilerplate and dead code.

Change-Id: I3d7c1b0fc1e3754335d05bfc2e1a8e3e6c88ca8c
2013-07-31 13:04:47 +02:00
Randall Burt 69715eb930 Allow template resource use outside of Environment
In addition to using TemplateResource as a means to override another Resource
implementation, this allows template authors to specify a template url
as the Type of resource directly. This allows a user to define new Resource
implementations in addition to overriding existing ones via Environments.

implements blueprint provider-resource

Change-Id: I11cf94dc062fcce0e4ff08765696447fc2411a7f
2013-07-26 10:55:36 -05:00
Randall Burt 42de0c9a3c Introduce a schema for attributes
Similar to properties, adds attribute_schema and attributes members to
Resources in order to facilitate document generation and template
provider stubs for resources.

Change-Id: I5e207360816fbc685c66db68a7fab8afad11bf10
Implements: blueprint attributes-schema
2013-06-19 17:51:03 -05:00