summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
AgeCommit message (Collapse)Author
2012-08-06add protection against dns-redirection to is_resolvableScott Moser
In an effort to make the EC2 Datasource's search under ec2.archive.ubuntu.com resilient against dns redirection, we add some code to is_resolvable. One future enhancement for this would be to protect against server side round robin results. Ie, if 'bogus-entry' returned 10.0.1.1 one time, and then 10.0.1.2 a second time. We could check if results where within the same 3 octets, and assume invalid if they were.
2012-07-16improve debug via _CLOUD_INIT_SAVE_STDIN and _CLOUD_INIT_SAVE_STDOUTScott Moser
This does 2 things: a.) fixes broken logic in 'close_stdin' previously _CLOUD_INIT_SAVE_STDIN had to be set to false to preserve stdin. "save_stdin" should be true to indicate it should be saved. The net result is that you can stuff just add import pdb; pdb.set_trace() to code, and then run something like: sudo _CLOUD_INIT_SAVE_STDIN=1 _CLOUD_INIT_SAVE_STDOUT=1 \ cloud-init single --name=mounts --frequency=always And enter the debugger even if you had a 'output' that would redirect stdin/out by default, like: output: {all: '| tee -a /var/log/cloud-init-output.log'}
2012-07-12load_yaml: if conversion fails, but string is empty, return defaultScott Moser
the problem sovled here is that most callers of yaml_load do not pass 'None' as a allowed type. I didn't want to change all the callers. If the yaml.safe_load ended up being None we were raising a TypeError and that was getting logged (meaning output to console). Even though the this was not really bad. So, if the type is not in the list, *and* it is not empty, then log exception. If it in the list and empty, just debug. empty input was occurring when cloud-config was empty (no user-data)
2012-07-11do not capture runparts outputScott Moser
runparts output was being captured. This meant that output of user-scripts was being captured and not sent to stdout (console).
2012-07-10Fixes 1012854 by implementing file writing, adjustsJoshua Harlow
other code to have user/group parsing in util instead of in stages.py, renames decomp_str to decomp_gzip since it is more meaningful when named that (as thats all it can decompress).
2012-07-10send welcome message after logging has been appliedScott Moser
in the 'cloud-init init' stages, we want the welcome message to get to the correct output as specified by the system's configuration. Ie, if the local /etc/cloud.config.d had 'output' or 'log_cfg' settings we want those to be able to affect the welcome message also. In normal operation, nothing else will go to stdout or stderr before this, and likely/hopefully nothing terribly important to the logs.
2012-07-09Use the common 'is_false' routine for testing false here insteadharlowja
of a custom list that may confuse people trying to use this.
2012-07-09Update chownbyname to catch the key error when users/groups that are not knownJoshua Harlow
are provided and rethrow it as a OSError (which seems reasonable) and adjust its usage in the log file touching/permission modification stage to catch this error and log it.
2012-07-09fix 'make pylint' warningsScott Moser
On my system (quantal) this 'make pylint' does not complain now.
2012-07-09DataSourceEc2: only do dns check in mirror selectionScott Moser
This returns the check for an archive mirror in the DataSourceEc2 to only do so by DNS resolution. The 'rework' branch had made the check wait and timeout on attempts to reach the mirror. This resulted in 120 seconds of waiting before failure. For now, just go back to the old situation of checking by dns.
2012-07-03Add a check on 'chownbyname' that catches the keyerror and logs it (instead ↵Joshua Harlow
of failing)
2012-07-021. Move the welcome message template string to a constant at the top of the ↵Joshua Harlow
module 2. Fix the usage of multi_log to log to only one of the places (for now) 3. Update comment about multi-log and why write_file isn't used in this case
2012-07-01Merge in pending changes.harlowja
2012-07-011. Rename util functions to is_true and is_falseharlowja
2. Move the config loading functions to where they are used (in stages) 3. Adjust cc_set_passwords to use the is_true and is_false renamed functions 4. Adjust the init stage to have a _read_base_config function used to load the base 'initial' configuration from the following locations a. Kernel cmdline b. Conf.d location (+ the cloud.cfg location) c. Built-in configuration
2012-07-01Add a multi log function that can write to stderr, console and a log debug, ↵Joshua Harlow
useful in certain cases
2012-06-29Refactor the selinux guard to aid in mockingharlowja
1. Adjust the test_util after this mocking to be cleaner
2012-06-29Just log the number of commands 'shellified'Joshua Harlow
2012-06-29Don't always log stdout and stderr (exceptions will capture them if it fails)Joshua Harlow
2012-06-29Reduce the log levels by removing a few statements that happen to often (and ↵Joshua Harlow
aren't very meaningful)
2012-06-29Add the rc code for blkid '2' being valid with a note to as why.Joshua Harlow
2012-06-261. Add a chdir context managerJoshua Harlow
2. Add a abs path joining function that will return the absolute path of a combined path (where applicable)
2012-06-23Fix a bunch of == None casesharlowja
2012-06-221. Move the getkeybyid function back here but add some slight adjustmentsJoshua Harlow
a. Instead of executing a bash string, write out a temporary file and then just execute '/bin/sh' on that file with the right arguments instead. 2. Rename util.SilentTemporaryFile to util.ExtendedTemporaryFile and update the usages of the previous name accordingly, this better reflects what this temp file is. 3. More teenie pep8 line length fixings
2012-06-22Fix syntax err, grrrharlowja
2012-06-221. Add comment about conf.d overriding input configharlowja
2. For reading config from conf.d, collect all the configs then call the mergemany function
2012-06-21Fixup python selinux guards, only try to restore after we check if its ↵harlowja
useful to restore, fix test to work with selinux enabled sysystems
2012-06-211. Update the comment about fstab to just point to 'man fstab'Joshua Harlow
2. Update the mount point adding of '/' to just add it in one place if it does not already exist
2012-06-21Returning whether it was enabled, useful for unit testingJoshua Harlow
2012-06-21Use yaml safe_load just incaseJoshua Harlow
2012-06-20Massive pylint + pep8 fixups!Joshua Harlow
2012-06-191. Cleanup variable names to match more of the pythonic underscore patternJoshua Harlow
2. Seperate config loading from the actual final 'merging' process. a. A util function will now merge multiple config dictionaries after they have all been loaded instead of loading and merging at the same time, which can get confusing to follow.
2012-06-181. Allow the built-in config to be passed in when getting the base configJoshua Harlow
2. Move the cloudinit util function that writes the command line url to a file to here.
2012-06-181. Decreasing of logging in piping routingJoshua Harlow
2. Fixup of merge dict after found out that it depends on the src return for non dict types 3. Only merge kernel config if there was any kernel config
2012-06-171. Add a url response class that urlreading now returns (instead of a tuple). harlowja
a. This allows for more properties to be added as needed in the future, instead of being very restrictive. 2. Fix up all uses of the url reading to now use this new response object. 3. Also fixup user data including, such that if no response actual occurs the url content is not further processed.
2012-06-16Let read_file_or_url util function have good defaultsJoshua Harlow
2012-06-16Correct the mount options to use a comma separated list for the mount ↵Joshua Harlow
options (if any provided/selected)
2012-06-16Add a restricted set of characters which can be used in filenames when ↵Joshua Harlow
cleaning them.
2012-06-16Have the ensure file function be able to take in a file permission.Joshua Harlow
2012-06-161. Add in one function that will do output redirection from config for a ↵Joshua Harlow
given mode. 2. Adjust the usage of items() to iteritems() which will help translation to python 3.
2012-06-15Fixups to ensure that pylint does not find anything major wrong.Joshua Harlow
2012-06-15Inclusion of more utility functions included:Joshua Harlow
1. Adjustments to using more selinux guards around directory creation, chmod... 2. Adding util functions to check if values are false or true (used internally and externally) 3. Move find_devs_with to util.py and allow it to serve multiple use cases 4. Add fork_cb which will fork a process and then call a certain callback (used right now by the resize nonblocking mode) 5. Move functions that performed time_rfc2822 time fetching and uptime fetching to here. 6. Allow the subp util function to act in shell mode 7. Increase logging usefulness in shellify function
2012-06-13Add in a make url function (might be useful).Joshua Harlow
Adjust usage of logexc to use that in the utils file for exceptions that occur. Add in more options to sub function to capture outputs, shell mode and such.
2012-06-11Add centering method + more descriptive mount failure exception message.Joshua Harlow
2012-06-11Pylint cleanups, add a load yaml function that handles errors nicely + other ↵Joshua Harlow
cleanups.
2012-06-09Move cmdline functions here. Cleanup exception trapping. Fixup copyright.Joshua Harlow
2012-06-08Moved the shell functionality back in here.Joshua Harlow
2012-04-04initial checkin of kernel commandline cloud-config url supportScott Moser
2012-03-08Add DataSourceMaaS, a Data Source for Ubuntu Machine as a ServiceScott Moser
LP: #942061
2012-03-07fix pylint and pep8 warningsScott Moser
2012-03-06add headers_cb to doc for wait_for_urlScott Moser