Commit Graph

54 Commits (ee7ad5f106191323e04a7b861de385c8ee4bfdca)

Author SHA1 Message Date
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
8 years ago
Pavlo Shchelokovskyy 4279bd2923 Enable H305 and H307 style checks
Correct grouping and ordering of imports

Change-Id: I47ea0d53f80d7f0aeb01c1c6afd63713be87ddf4
8 years ago
Pavlo Shchelokovskyy 8415baf6cc Enable E265 style check
block comment should start with '# '

Change-Id: Iffae1b10e81b12ca8455139eae609ddca5e8dd09
9 years ago
Tetiana Lashchova 014bf9d611 Remove i18n import from loguserdata.py
Change-Id: I47bc858e6f0d0b92a103cf40fdf47e1c8d5c89c5
Closes-Bug: #1399642
9 years ago
Tetiana Lashchova 4801c0f894 Use the right log marker functions
According to [1] _LI() should be used for LOG.info(), _LE() for
LOG.exception() and LOG.error(), _LW() for LOG.warning().
The log marker functions must only be used when the message is
sent directly to the log.
Debug level log messages should not be translated.

[1] http://docs.openstack.org/developer/oslo.i18n/guidelines.html

Change-Id: Ib9f92ef6696b9a95ddae74f0d4a0a557c06ecc91
9 years ago
Peter Razumovsky c1aa3d7a4d Fix [H302] errors in heat/cloudinit
Kicked from gate (heat can't pass pep8 atm)

Change-Id: If9100574f091d23c9ae9e0bca94ab16fd4b535ec
9 years ago
Zane Bitter 95ec13c572 Fix cloud-init Python syntax for Python < 2.6
The loguserdata.py file gets uploaded to the servers created by Heat to run
under cloud-init. Since the default versions of Python installed on the
user's server may be very old (e.g. RHEL 5 defaults to Python 2.4), avoid
using the octal syntax introduced for Python 3.0 and backported only as far
as Python 2.6. (Also avoid the old syntax, which will break on Python 3.x.)

Also remove use of the "with" statement from loguserdata.py and
part-handler.py. This statement is only available from Python 2.6 on (or in
Python 2.5 via "from __future__ import with_statement").

Finally, remove use of the "except ExceptionType as value" syntax for
catching exceptions. Again, this was only backported to Python 2.6.

Change-Id: I89e86d00993d51e2514b1e589503c6d966909403
Partial-Bug: #1375864
9 years ago
Thomas Herve db515c54cf Remove translation from loguserdata
The logs in loguserdata don't need to be translated because it's sent
with the po files to instances, and actually break because of gettext
not being used

Closes-Bug: #1325313
Change-Id: I365f3d882b8f64f9710eea4901ac266f9fcf0da3
9 years ago
Christian Berendt 105a806493 all non debug log messages should be translated
Updated a set of files to add missing translation support in the
log messages.

Change-Id: I58d561c5e1ecff550483ee0be696999e927c98ad
Partial-Bug: #1321283
9 years ago
Jenkins d951d9eb58 Merge "Make the first line of every file consistent." 9 years ago
Tomas Sedovic b8eefd1de9 Don't create cloud-init user unless specified
When the the instance_user value from heat.conf is set to empty string/None and
the user doesn't specify Server's admin_user property, Heat will not create a
custom cloud-init user.

The instance_user config option and admin_user property are deprecated and will
be removed in Juno where this behaviour becomes the default.

AWS::EC2::Instance will still create a cloud-init user for CloudFormation
compatibility. In the absence of the instance_user config option, 'ec2-user'
will be used.

Closes-Bug: #1257410
Change-Id: I42dda36045f79be079b2030669284e9db71463d7
9 years ago
Jason Dunsmore af464c9afc Make the first line of every file consistent.
Change-Id: I2e1a809cfca8e88693551d58d33e747f54ee5eb1
9 years ago
Pavlo Shchelokovskyy 72597753ef Order imports in alphabetical order (3/9)
This patch is one in a series to re-enable H306 style check rule
(imports are in alphabetical order). It touches common and cloudinit files.

Implements: blueprint reduce-flake8-ignored-rules (partial)
Change-Id: Ie9838dba11323575165fc3bfdfbd0d0b93f653fa
9 years ago
Tomas Sedovic 00e574e595 Don't disable SELinux in cloud-init's boothook.sh
This is a first step towards fixing #1257410 as outlined in the bug
report.

Disabling SELinux is not necessary, but the fact that we're using both
the `user` directive in cloudinit/config and `useradd` in boothook.sh
is a bit confusing so this documents the reasons for both.

Change-Id: Ife4fec99650341de698eb51741d96f95de00dcf0
Partial-Bug: #1257410
9 years ago
BK Box 265467f5cd Verify setenforce is executable
Some images/distros do not install/use selinux. This small change will
verify that `setenforce` is executable and in the path before attempting
to run the command. This prevents the script from erroring and causing a
failed `cloud-init` run.

Change-Id: I42f802c7994b8d907f0cc4e3b1a38e6fd89dac0c
9 years ago
Jenkins 177946fce7 Merge "Do not override cloud-init cloud_config_modules" 10 years ago
DennyZhang 893a8c980c Change loglevel for certain failures
Change Log.info to Log.error/Log.warning to make trouble shooting
more apparent

Change-Id: Ie293df0c941414da8fb035e4d4b170a0a4c9d397
10 years ago
Clint Byrum 7c005f19c6 Do not override cloud-init cloud_config_modules
In the past it may have been necessary to do this but it causes problems
for users of advanced features. We should be able to operate with the
default OS configuration of cloud-init.

Change-Id: Ic26bffb17b1870d656fea72cf3da3dfe2b7f44d0
Closes-Bug: #1263297
10 years ago
Steve Baker edb7a6dbe9 Call cfn-create-aws-symlinks in boothook.sh
Images which have heat-cfntools installed from rpm or deb
will not have cfn tool links in /opt/aws/bin.

This change runs cfn-create-aws-symlinks during cloud-init
boothook.sh. It should do the following:
* if no cfn tools exist in /opt/aws/bin, symlinks from /usr/bin
  will be created
* if cfn tools exist in /opt/aws/bin, no symlinks are created
* if cfn-create-aws-symlinks doesn't exist, there will be no effect

This is required to use a vanilla Fedora 20 cloud image with heat,
which has heat-cfntools pre-installed.

Change-Id: I5426fdad3031f91b4b9c1f9c9c19ac9cc42cf2dd
10 years ago
Steven Dake 715e5d4f51 Revert "Replace part_handler.py with write-files cloudinit mechanism"
Ubuntu has 0.6 of cloudinit, and write-files doesn't work on that
distro.  Ubuntu does not intend to update cloudinit in their LTS release
to 0.7.

This reverts commit 621f5bfdba.
Fixes: Bug #1207088

Change-Id: If80863883afee28bdde6dd506826ec5710cc0308
10 years ago
Steven Dake 621f5bfdba Replace part_handler.py with write-files cloudinit mechanism
part-handler.py was acting as a write-files mechanism.  Instead just
use the write-files mechanism directly to avoid the complexities of
the part-handler.

blueprint: use-cloudinit-write
Change-Id: I6e80c344743d6fd2fa9a49507de6d50e3d9eea73
10 years ago
Jenkins eade86a674 Merge "Fix loguserdata output to file issue" 10 years ago
guohliu dc41655176 Fix loguserdata output to file issue
Fixes bug #1191685

Change-Id: I2a02b490e45c3cb838243b9dad62cc52b609b336
10 years ago
Angus Salkeld e3caef4452 Use new style classes
Change a couple of old style classes into the newer styled ones.

Change-Id: Ide3bbcd2d24f949a2a550fcc2210617f34c8cd0b
10 years ago
Dirk Mueller 234a1f0f2e Add missing Aapche 2.0 license headers (H102)
Satisfy Hacking check of Hacking 0.6 or newer.

Change-Id: I01d9b44c1681142ef91fd91f678e173239ae6c98
10 years ago
Steven Dake db4bbad6a0 Rename part-handler.py to part_handler.py so it can be imported
Change-Id: I9e7e3be2f3155f3e35b2defdb89e9d84a02ae7cb
10 years ago
Dirk Mueller ede21a2688 Use Python 3.x compatible octal literals
Python 3.x deprecated the 0700 construct. 0o700
works with any version of Python (>= 2.6 tested)

Change-Id: I47fcb79804b75437e6cf4ce966fbfdc05fce26cd
10 years ago
Steve Baker 05ca181e9e Use python logging for loguserdata.py, log to console
Python logging is configured with a stream handler and should
also replicate the previous logging to 0600 /var/log/heat-provision.log

By logging to a stream handler cloud-init will write to its log,
which will show up in the server console log. This means that heat
provisioning can now be monitored without needing to log in with:

nova console-log <servername>

This change also touches the file /var/lib/heat-cfntools/provision-finished
instead of also writing a datestamp to it, which is redundant.

Change-Id: Id0312bd2216a83753df601b17ad16d5355cdb11d
10 years ago
Jeff Peeler d665740935 Change executable file permissions for rpmlint
Fixes: Bug #1158009
Change-Id: I761debfb77be5cf5204af90a013d7f4f043fdb17
Signed-off-by: Jeff Peeler <jpeeler@redhat.com>
10 years ago
Jenkins b91604f8f7 Merge "part-handler: add missing import" 10 years ago
Jenkins 3b43cce6e6 Merge "loguserdata: handle exceptions from running the userdata" 10 years ago
Jenkins 7ed79c6f07 Merge "Allow per-deployment configuration of user id" 10 years ago
Jenkins eb52664146 Merge "Remove ssh from cloud-config-files" 10 years ago
sdake ac8b8f9c42 Allow per-deployment configuration of user id
Previously user ids of new instances were limited to ec2-user.
This patch adds a new configuration option to be placed in
/etc/heat/heat-engine.conf called "default_instance_user" which
allows the default of ec2-user to be overriden.

Note for reviewers that runcmd does not work properly.  It was
actually running after the loguserdata.py script finished execution.

Fixes: Bug #1101347
Change-Id: Ica2dbe63d9dcbce8bb8de298eba452c34ab173d9
10 years ago
sdake 5862514aef Remove ssh from cloud-config-files
the cc_ssh script already executes in cloud config without being
explicitly called.  As it is now, it is executing twice.

Make it execute only once.

Change-Id: I2d53adbea0175f63db71be516639d40aa0f8a1de
10 years ago
Angus Salkeld 655e377d45 loguserdata: handle exceptions from running the userdata
- log the exceptions so the user can diagnose issues.

bug 1154641
Change-Id: Ic085c9f062255a9fa44b3e31b464c9ebd19a947c
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
10 years ago
Angus Salkeld fbea931550 loguserdata: prevent shadowing of arguments and globals
cleaning this up for bug 1154641

Change-Id: I95271bdeba1bba29e78af79de4e2173d07750e4f
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
10 years ago
Angus Salkeld 89005a04e7 part-handler: add missing import
errno is used in the excption but not imported.

bug 1154887
Change-Id: I1c2961f08824d919ed2483a0a9cf54c50862f354
10 years ago
Steven Dake bb65fee164 Remove unused import from loguserdata.py
Change-Id: I0bdf8a51e0d21533c5ce8148cdffcbc92f89fef9
Fixes: Bug #1131275
10 years ago
Steven Dake 737cc26570 Put heat data files in /var/lib/heat-cfntools
The /var/lib/heat-cfntools directory should be owned by the
heat-cfntools package for whichever distro it is included.

This avoids the problem of heat writing to directories owned
by cloud-init.

For the moment, the part handler will continue to write to
/var/lib/cloud/data to be removed at a later date.

Change-Id: I70b714c70ed146d4f6807850d6e7264c6a4624cd
Fixes: Bug #1105806
10 years ago
Steve Baker c598d0d3e8 Refactor loguserdata.py so it can be tested.
- Use distutils.version.LooseVersion for cloud-init version check
- Fix bug 1100287 by setting the following modes:
  - 0600 /var/log/heat-provision.log
  - 0700 /var/lib/heat
  - 0700 /var/lib/cloud/data/cfn-userdata (was 0111!)
- Full test coverage except for where __name__ == '__main__'
- File size has gone from 1218 bytes to 1636. If necessary we could reduce size in the future by using short names

This works for me when launching a template. At least if there are any regressions they can have a test written for the fix.
Change-Id: I04e773a743ec210e90394e50d2bb70c70664e80e
10 years ago
Jeff Peeler 410336810d Hardcode provision-finished file path
A recent change removed the use of the cloudinit module, so write this
log to /var/lib/heat. Functional test paths updated as well.
(User data injection was removed, so that has been deleted as well.)

Change-Id: Ibcaf310a5e4ff9a9ed8b1065bdd411e1b95d4de5
Signed-off-by: Jeff Peeler <jpeeler@redhat.com>
10 years ago
Clint Byrum 8d6aa11e70 Use pkg_resources to detect version of cloud-init
Previously the present of an API call only present in cloud-init 0.6.x
was used to determine whether or not cfn-userdata would have been executed
or not. The API call was removed in 0.7.x. This Fixes bug #1103793

Change-Id: I27129f8ae6144ae7172b7159ed70fc5f0d7d07b9
11 years ago
Jeff Peeler 93c3d93ec4 Handle different cloud-init versions gracefully
Change loguserdata script to python to allow easy detection of which
version of cloud-init installed. Some logging was added to
part-handler.

Took out injecting the command to touch provision-finished in the user
data. This is now handled in loguserdata.py.

Note that up until cloud-init version 0.6.0, the user data is not
passed to part-handler. This behavior is why it's not possible to log
the provisioning process with older versions. (Technically could rely
on the redirection support added post 0.6.0, but having a separate
file just for provisioning seems beneficial.)

fixes bug 1072921

Change-Id: I9005a21bfb74f27208f9195a6e10e1d2b474e91f
Signed-off-by: Jeff Peeler <jpeeler@redhat.com>
11 years ago
Jeff Peeler e5ec6b4b5d Fix cloud-init runcmd to be exec friendly
Can't use colon builtin apparently, or you'll get this:
/var/lib/cloud/instance/scripts/runcmd: line 2:
 {setenforce 0 > /dev/null 2>&1 ||:: No such file or directory

Added cloud-init debug output to get the above, copied from:
http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/doc/examples/cloud-config-chef.txt

Change-Id: I341cf73bc9a0f843d7ab8c99a9d15e1d514654e7
Signed-off-by: Jeff Peeler <jpeeler@redhat.com>
11 years ago
Jeff Peeler eff1af8ae0 Cleanup runcmd to exit 0 and not use 'type'
Change-Id: I37313a772839f56a015431bbb004ad767da0815e
Signed-off-by: Jeff Peeler <jpeeler@redhat.com>
11 years ago
Jeff Peeler 5658f9d4db Do not assume host has selinux utils installed
related to #265

Change-Id: I4a6cff1f05b6f4f88d672cc0d4ce5e8f62a58e47
Signed-off-by: Jeff Peeler <jpeeler@redhat.com>
11 years ago
Jeff Peeler 36af6c7a30 Change file to executable to get rid of rpmlint warning
Change-Id: I5274c04bca9c5f089c39a241cc2ba4ea96e279ac
Signed-off-by: Jeff Peeler <jpeeler@redhat.com>
11 years ago
Steven Dake 99bd84e03b Put selinux in permissive mode by default via a runcmd in cloudconfig
Change-Id: I7db02a967de9a3e85876901163f7611196a9429f
Signed-off-by: Steven Dake <sdake@redhat.com>
11 years ago
Steven Dake dedb9475a9 Log all startup operations to /var/log/heat-startup.log
Change-Id: I0e7f415e7aee60c09d0b5b172742af7a5b313191
Signed-off-by: Steven Dake <sdake@redhat.com>
11 years ago