Commit Graph

22 Commits

Author SHA1 Message Date
Hervé Beraud 6ccd16cc32 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 5 of a serie of 28 patches

Change-Id: Idb037ded55698790fc1658896f1e2dcdce89f3f9
2020-04-22 12:23:44 +02:00
rabi 2a29d1119e Convert bytes_used to int before comparison
Change-Id: I7fab8c0b3fbda60f68e0b1fef8a2befd2183433d
2018-07-27 17:10:28 +05:30
rabi 3ab4f15a43 Option for retrieving child templates and env files from swift
This provides an option to specify a swift container for stack
actions and all child templates and env files will be fetched
from the container, if available. However, files coming in the
'files' map from the client will have precedence, if the same
is also present in swift.

Change-Id: Ifa21fbcb41fcb77827997cce2d5e9266ba849b17
Story: #1755453
Task: 17353
2018-07-26 09:50:51 +05:30
rabi 7fd82e1b78 Use keystone session with clients
Some of the remaining clients we use now have keystone
session support.

Change-Id: I92dd4c8abea00ea981d7d8e24e396af071c8b080
2017-02-17 17:24:26 +05:30
rabi ddd55567f5 Use timeout as whole seconds in swift plugin
Change-Id: Ib40612fbb88969cf41457c513722a83d1cdc9019
Closes-Bug: #1641800
2016-11-15 08:21:52 +05:30
Steve Baker 299d1f591d Silence swiftclient logging
swiftclient doesn't use oslo_log and logs ERROR with TRACE for
response exceptions like 404. This isn't desirable for heat which
relies on 404s to know a delete is complete.

This change sets the swiftclient logging level to CRITICAL in the
client plugin.

Change-Id: Ie11a6d19068169424ee883ce428aad306d647f0d
Partial-Bug: #1606404
2016-07-28 03:08:41 +00:00
rabi cd125f328e Use keystone session from context in client plugin
Now that we store the keystone session in the context,
we can use them to create the client plugins.

Change-Id: I9c870691ad5f6b1099dba51b5ef4c54360b65122
2016-07-27 04:12:13 +00:00
Jamie Lennox 87a37f5db2 Sync context with oslo.context
Heat makes a lot of variations to the basic oslo.context which are going
to make it very hard to reuse with features added to the base
oslo.context.

There are a number of changes here that will make the heat context
options more like those from oslo.context.

*) context.user and context.tenant are IDs, not names. This will be
   important for policy credentials.

*) kwargs should be passed through to base context so it can be extended
   in the base class.

Change-Id: Ib0d60c6af196ba5c00459110b7a6190cff916d6f
2016-06-17 11:46:00 +10:00
ricolin bed7e1f7c9 Use specified client service name for client usage
Create CLIENT_NAME for every client, which can be used to replace seperated
string for service client name.

Change-Id: Id8425e8cca3ad9cea5f7364fdf057260e1d8f27c
2015-12-11 10:11:49 +08:00
Peter Razumovsky 4138090afd Fix [H405] pep rule in heat/engine/clients
Implements bp docstring-improvements

Change-Id: I789a99e48b61f60dd53e82c59467befbac054deb
2015-09-21 14:51:46 +03:00
Sirushti Murugesan 1023b6262f py34: heat.tests.client/openstack
* importutils.import_object results in a cfg.NoSuchOptError than
  a RuntimeError, handle the cfg.NoSuchOptError too.
* text.MIMEText content cannot be None in python3, use an empty
  string instead if the content is None.
* convert to bytes before using hashlib.sha256
* add a message keyword argument along with the cinder exception
  because self.__class__.message doesn't exist for exceptions in py34
* assert whether the string is against exception.args instead of the
  exception object itself.
* assert against a dictionary rather than a flattened string
  for consistent checking
* convert json strings to json before asserting/comparing

Change-Id: I5bbbc75373ce8009f0791cd2c7df1ba4c2d473b2
2015-08-14 12:09:20 +05:30
ubuntu c9fddd41cb Refactor Adding service_types to client_plugins
As part of the review https://review.openstack.org/#/c/192529
service_types was added to client_plugins to support the
conditional resource plugin availability.

I found its good to organize this code better by adding
str_key for each key defined in the service_types
so that we no longer have to depend on the index when
multiple service_types are available for a client plugin.

implements blueprint: keystone-based-resource-availability

Change-Id: I352525cce991f664abb28df9569d498cd44baf18
2015-07-14 23:34:27 +05:30
Kanagaraj Manickam bc8bdd426c Adds service_types to client_plugins
service_types is added to client_plugins to support the
conditional resource plugin availability.

implements blueprint: keystone-based-resource-availability

Change-Id: I28d606416acd1d47a09f3c62b5236b5f53583f60
2015-06-18 12:18:08 +05:30
Sirushti Murugesan 19ce39d101 Update urllib/httplib/cStringIO to use six.moves
partial blueprint heat-python34-support

Change-Id: I00a7064560a95a33dcb1e621961765822d4e94d4
2015-04-23 19:45:36 +05:30
Steve Baker 7470a5e919 Deployment signal_transport: TEMP_URL_SIGNAL
This change allows swift TempURLs to be used to signal heat from
server deployments.

When signal_transport: TEMP_URL_SIGNAL is specified, the following will happen:
* On creation a swift object will be created with an associated TempURL for PUTs
* The PUT URL is used for the deploy_signal_id input value, along with the new
  deploy_signal_verb input being set to PUT
* In the deployment resource check_complete, the swift object is polled for
  new signal contents, and signal() is called when the swift object contents change

By specifying deployment signal_transport: TEMP_URL_SIGNAL and
server software_config_transport: POLL_TEMP_URL it should now be possible to use
config/deployment resources with only a keystone v2 API (or with a standalone heat)

Implements-Blueprint: software-config-swift-signal

Change-Id: I1dfba248dcfc90c3d872ba35f0aa935cca5c5606
2015-02-25 13:48:52 +13:00
Steve Baker 7401c030ff Always fetch temp URL key before generation
SwiftClientPlugin.get_temp_url has the potential to race with
itself when storing a new tempurl key to the swift account,
leading to tempurls being built with a key that has been
overridden.

This change always fetches the key from swift before creating a
temp URL.

Change-Id: Id5897fdd834cc5d3b74fda8d2317d084a5564c51
Closes-Bug: #1413366
2015-01-22 12:58:58 +13:00
Jason Dunsmore 4e174fc6ac Validate tenant_id part of TempURL in clients
Rackspace Cloud Files uses a UUID for the tenant ID, so move the code that
validates that part of the TempURL to the client.

Change-Id: I996fdc4b4b66e110066353d3b22ea3dab0535a5d
2014-10-14 14:52:51 -05:00
Jason Dunsmore 6bef85931e Add is_conflict() to client plugins
Change-Id: I0f4239869da8cab505723ff6b2dfbb37bef83ff1
2014-10-13 10:57:53 -05:00
Steve Baker bb20eb821b Allow method verb override in get_temp_url
This will allow TempURLs to be used for GET too.

Change-Id: I0eb896d1a5a9a6b54aaa95e7942cc0d48108ea63
Partial-Blueprint: swift-deployment-transport
2014-08-22 14:17:11 +12:00
Jason Dunsmore f388b2e2a8 Add utility functions for Swift TempURLs
blueprint swiftsignal-resource

Change-Id: I88c78b74dfb3c23cf74831bda3a9bdc69df6162a
2014-08-18 10:45:22 -05:00
Steve Baker 9b6d38cd02 Client plugin exception handling methods
This change adds common methods which allow resources
to handle client exceptions without needing to directly
import the exception types.

The most common client resource exception handling is:
* Detecting if an exception is a 404
* Raising any exception which is not a 404
* Detecting if an exception is a 413 (over limit)
* Detecting if an exception was raised by a particular client
  library

Subsequent changes will move to using these methods.

Change-Id: Ib2bd55c31e66b562cfa8388beb450be6c06cc4fb
2014-07-31 16:49:08 -05:00
Steve Baker 76979a4fd1 Implement swift client plugin
This moves the client creation code out of Clients._swift() into
its own client plugin.

Importing swiftclient exceptions from the plugin is an interim
solution until the client plugin mechanism provides a way of
handling client-specific extensions.

Swift is a core project, and python-swiftclient is a dependency,
so the import is now mandatory.

Change-Id: Ib2cff83096639855eaa1e05febbb4b490edd6250
2014-07-09 08:26:48 +12:00