Even when using boto < 2.6 force the unlazying to occur
It seems like its possible that boto 2.5.2 and below have the lazy loading metadata dictionary so as a precaution we will always take the hit of unlazying the metadata dictionary by traversing it which in the non-lazy dictionary case has no effect (its marginal). This also removes the need to check the boto version and the dependency on setup tools just for this case.
This commit is contained in:
commit
6ceaf14b37
@ -38,9 +38,8 @@
|
|||||||
runs the usage of this lazy loading is hidden and since that lazy loading
|
runs the usage of this lazy loading is hidden and since that lazy loading
|
||||||
will be performed on future attribute access we must traverse the lazy loaded
|
will be performed on future attribute access we must traverse the lazy loaded
|
||||||
dictionary and force it to full expand so that if cloud-init blocks the ec2
|
dictionary and force it to full expand so that if cloud-init blocks the ec2
|
||||||
metadata port the lazy loaded dictionary will continue working properly
|
metadata port the lazy loaded dictionary will continue working properly
|
||||||
instead of trying to make additional url calls which will fail (LP: #1068801)
|
instead of trying to make additional url calls which will fail (LP: #1068801)
|
||||||
- Added dependency: python-pkg-resources (deb), python-setuptools (rpm)
|
|
||||||
- use a set of helper/parsing classes to perform system configuration
|
- use a set of helper/parsing classes to perform system configuration
|
||||||
for easier test. (/etc/sysconfig, /etc/hostname, resolv.conf, /etc/hosts)
|
for easier test. (/etc/sysconfig, /etc/hostname, resolv.conf, /etc/hosts)
|
||||||
0.7.0:
|
0.7.0:
|
||||||
|
@ -16,34 +16,26 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import pkg_resources
|
|
||||||
from pkg_resources import parse_version as pver
|
|
||||||
|
|
||||||
import boto.utils as boto_utils
|
import boto.utils as boto_utils
|
||||||
|
|
||||||
# Versions of boto >= 2.6.0 try to lazily load
|
# Versions of boto >= 2.6.0 (and possibly 2.5.2)
|
||||||
# the metadata backing, which doesn't work so well
|
# try to lazily load the metadata backing, which
|
||||||
# in cloud-init especially since the metadata is
|
# doesn't work so well in cloud-init especially
|
||||||
# serialized and actions are performed where the
|
# since the metadata is serialized and actions are
|
||||||
# metadata server may be blocked (thus the datasource
|
# performed where the metadata server may be blocked
|
||||||
# will start failing) resulting in url exceptions
|
# (thus the datasource will start failing) resulting
|
||||||
# when fields that do exist (or would have existed)
|
# in url exceptions when fields that do exist (or
|
||||||
# do not exist due to the blocking that occurred.
|
# would have existed) do not exist due to the blocking
|
||||||
|
# that occurred.
|
||||||
BOTO_LAZY = False
|
|
||||||
try:
|
|
||||||
_boto_lib = pkg_resources.get_distribution('boto')
|
|
||||||
if _boto_lib.parsed_version > pver("2.5.2"): # pylint: disable=E1103
|
|
||||||
BOTO_LAZY = True
|
|
||||||
except pkg_resources.DistributionNotFound:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def _unlazy_dict(mp):
|
def _unlazy_dict(mp):
|
||||||
if not isinstance(mp, (dict)):
|
if not isinstance(mp, (dict)):
|
||||||
return mp
|
return mp
|
||||||
if not BOTO_LAZY:
|
# Walk over the keys/values which
|
||||||
return mp
|
# forces boto to unlazy itself and
|
||||||
|
# has no effect on dictionaries that
|
||||||
|
# already have there items.
|
||||||
for (_k, v) in mp.items():
|
for (_k, v) in mp.items():
|
||||||
_unlazy_dict(v)
|
_unlazy_dict(v)
|
||||||
return mp
|
return mp
|
||||||
|
@ -33,7 +33,6 @@ PKG_MP = {
|
|||||||
'cheetah': 'python-cheetah',
|
'cheetah': 'python-cheetah',
|
||||||
'configobj': 'python-configobj',
|
'configobj': 'python-configobj',
|
||||||
'oauth': 'python-oauth',
|
'oauth': 'python-oauth',
|
||||||
'pkg_resources': 'python-pkg-resources',
|
|
||||||
'prettytable': 'python-prettytable',
|
'prettytable': 'python-prettytable',
|
||||||
'pyyaml': 'python-yaml',
|
'pyyaml': 'python-yaml',
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,6 @@ PKG_MP = {
|
|||||||
'cheetah': 'python-cheetah',
|
'cheetah': 'python-cheetah',
|
||||||
'configobj': 'python-configobj',
|
'configobj': 'python-configobj',
|
||||||
'oauth': 'python-oauth',
|
'oauth': 'python-oauth',
|
||||||
'pkg_resources': 'python-setuptools',
|
|
||||||
'prettytable': 'python-prettytable',
|
'prettytable': 'python-prettytable',
|
||||||
'pyyaml': 'PyYAML',
|
'pyyaml': 'PyYAML',
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user