summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_disk_setup.py
AgeCommit message (Collapse)Author
2020-06-08Move subp into its own module. (#416)Scott Moser
This was painful, but it finishes a TODO from cloudinit/subp.py. It moves the following from util to subp: ProcessExecutionError subp which target_path I moved subp_blob_in_tempfile into cc_chef, which is its only caller. That saved us from having to deal with it using write_file and temp_utils from subp (which does not import any cloudinit things now). It is arguable that 'target_path' could be moved to a 'path_utils' or something, but in order to use it from subp and also from utils, we had to get it out of utils.
2020-03-23cc_disk_setup: fix RuntimeError (#270)Daniel Watkins
Addresses "Runtime Error: dictionary keys changed during iteration". Co-authored-by: Noah Meyerhans <noahm@debian.org> LP: #1868327
2020-02-07cc_disk_setup: add swap filesystem force flag (#207)Ryan Harper
2020-01-07fixed minor bug with mkswap in cc_disk_setup.py (#143)andreaf74
2018-10-11Correct spelling in an error message (udevadm).Katie McLaughlin
Fix a typo in a RuntimeError path. (udevamd -> udevadm).
2018-04-26net: detect unstable network names and trigger a settle if neededRyan Harper
The cloud-init-local.service expects that any network device name changes have already been completed by the kernel or udev daemon. In some situations we've found that the renaming of interfaces from kernel names (eth0, eth1, etc) to their persistent names (eno1, ens3, enp0s1, etc) may happen after cloud-init-local has started where it reads values from sysfs about what network devices are present, and which device to use as a fallback nic. Subsequently, cloud-init-local would write out network configuration for a kernel device name which would no longer be present by the time that networking services start to bring up the devices. The result is that the instance does not get networking configured. Prior to use of systemd-networkd, the Ubuntu 'networking.service' unit included a call to udevadm settle which is why this race is not seen on a Xenial system. This change adds the ability to detect if an interface has a stable name, if if we find one without stable names and stable names have not been disabled (net.ifnames=0 in /proc/cmdline), then cloud-init will invoke udevadm settle. LP: #1766287
2017-12-15lint: Fix lints seen by pylint version 1.8.1.Chad Smith
This branch resolves lints seen by pylint revision 1.8.1 and updates our pinned tox pylint dependency used by our tox pylint target.
2017-05-26disk_setup: udev settle before attempting partitioning or fs creation.Scott Moser
This attempts to use udevadm settle to wait until devices have been fully "realized". If a device exists, there may still be events in the udev queue that would create its partition table entries. We need to wait until those have been processed also. LP: #1692093
2017-05-22disk_setup: fix several issues with gpt disk partitions.Scott Moser
This fixes several shortcomings of disk_setup with gpt disks. * 'sgdisk -p' was being used to determine the size of a disk. this can fail if it believes there is a bad gpt partition table. Instead we just use blockdev now for both mbr or gpt disks. * parsing of sgdisk -p output assumed that the 'name' of the partition type would not have any spaces (Microsoft basic data) * interaction with sgdisk did not realize that sgdisk wants input of '8300' rather than '83' and will output the same. LP: #1692087
2017-05-17Azure: fix reformatting of ephemeral disks on resize to large types.Scott Moser
Large instance types have a different disk format on the newly partitioned ephemeral drive. So we have to adjust the logic in the Azure datasource to recognize that a disk with 2 partitions and an empty ntfs filesystem on the second one is acceptable. This also adjusts the datasources's builtin fs_setup config to remove the 'replace_fs' entry. This entry was previously ignored, and confusing. I've clarified the doc on that also. LP: #1686514
2017-05-03fs_setup: if cmd is specified, use shell interpretation.Paul Meyer
If 'cmd' is provided to a fs_setup entry, then cloud-init was trying to execute the rendered string as a single name, rather than splitting the string. The change here will pass the string to shell for interpretation so that it is split there. Also fix some documentation errors and warn when fs_opts or overwrite is provided along with 'cmd'. LP: #1687712
2017-04-21pylint: fix all logging warningsJoshua Powers
This will change all instances of LOG.warn to LOG.warning as warn is now a deprecated method. It will also make sure any logging uses lazy logging by passing string format arguments as function parameters.
2017-03-24Fix filesystem creation when using "partition: auto"Jonathan Ballet
Accordingly to the documentation: The ``partition`` option may also be set to ``auto``, in which this module will search for the existance of a filesystem matching the ``label``, ``type`` and ``device`` of the ``fs_setup`` entry and will skip creating the filesystem if one is found. However, using this "auto" flag always recreates the partition no matter if it has been done before or not. This commit fixes a bug in which the "partition" attribute was always set to None although in some cases it should not. LP: #1634678
2016-12-22LICENSE: Allow dual licensing GPL-3 or Apache 2.0Jon Grimm
This has been a recurring ask and we had initially just made the change to the cloud-init 2.0 codebase. As the current thinking is we'll just continue to enhance the current codebase, its desirable to relicense to match what we'd intended as part of the 2.0 plan here. - put a brief description of license in LICENSE file - put full license versions in LICENSE-GPLv3 and LICENSE-Apache2.0 - simplify the per-file header to reference LICENSE - tox: ignore H102 (Apache License Header check) Add license header to files that ship. Reformat headers, make sure everything has vi: at end of file. Non-shipping files do not need the copyright header, but at the moment tests/ have it.
2016-11-22disk_setup: Use sectors as unit when formatting MBR disks with sfdisk.Daniel Watkins
The version of sfdisk in wily (and onwards) only accepts sectors as a valid disk size. As such, this refactors the MBR code path in cc_disk_setup to use sectors. - use --unit=S: while newer versions of sfdisk assume --unit=S, older versions do not so we specifically pass it in. Versions of sfdisk found in supported OSes such as centos6 wont assume --unit=S. - add --force: this exists back to centos 6 (2.17.2), so it should be fine, and is what we ultimately want. "do what I say, even if it is stupid" - keep --Linux. Even though this has been deprecated for quite some time, we keep it until versions that want it are unsupported. If necessary at some point we could check for util linux version and if it had --Linux and use it in those cases. Additionally, improve usefulness of some log messages. LP: #1460715
2016-10-25disk-config: udev settle after partitioning in gpt format.Scott Moser
The function exec_mkpart_gpt was simply not waiting for udev events to flush after calling sgdisk. The corresponding function exec_mkpart_mbr already did. This should fix a transient failure where mkfs would fail with 'not a block device'. LP: #1626243
2016-09-30Improve module documentation and doc cleanup.Wesley Wiedenmeier
This adds lots of config module documentation in a standard format. It will greatly improve the content at readthedocs. Additionally: * Add a 'doc' env to tox.ini * Changed default highlight language for sphinx conf from python to yaml most examples in documentation are yaml configs * Updated datasource examples to highlight sh code properly
2016-09-21Allow ephemeral drive to be unpartitionedPaul Meyer
If device has no partition table, the first line of output from `sgdisk -p <device>` will be "Creating new GPT entries.", instead of something like "Disk /dev/sdb: 266338304 sectors, 127.0 GiB". Also, protect against localized output by adjusting subp calls that parse sgdisk output to set LANG=C.
2016-05-12Fix up a ton of flake8 issuesJoshua Harlow
2016-04-04disk_setup: correctly send --force to mkfs on block devicesScott Moser
Send the --force flag to mkfs or other filesystems when target is a block device. This fixes a general code flow issue where we were setting the --force flag. LP: #1548772
2016-03-03Update pep8 runner and fix pep8 issuesRyan Harper
2015-07-22remove some overly verbose log messagesScott Moser
2015-07-21Extend disk_setup and mounts to handle /dev/disk symlinks.Daniel Watkins
2015-03-18Update is_disk_used for changed enumerate_disk output.Daniel Watkins
Fixes Launchpad bug #1311463.
2015-02-13fix usage of python2 'print'Scott Moser
2015-01-13Find disk size differently for GPT.Daniel Watkins
MBR uses block sizes, which is what the current (apparently portable) code was producing. GPT uses sectors to determine partition size.
2015-01-13Initial run at GPT disk handling.Daniel Watkins
2015-01-13Implement check_partition_gpt_layout.Daniel Watkins
This includes moving some shared logic in to check_partition_layout.
2015-01-13Fix lsblk output option.Daniel Watkins
2014-08-26further remove evidence of pylint.Scott Moser
This just removes comments '# pylint:' things and other code remnents of pylint.
2014-08-26fix(pep8): Fix various pep8 violations and version-lock pep8Jay Faulkner
Fixed all complaints from running "make pep8". Also version locked pep8 in test-requirements.txt to ensure that pep8 requirements don't change without an explicit commit.
2013-10-04pep8 and pylint fixesScott Moser
2013-10-04simplifications and some function renamesScott Moser
2013-10-03Added support for 'ephmeral0.<auto|any|0>' for device mappings in diskBen Howard
formating support.
2013-10-03Make {pep8,pylint,test} pass commit.Ben Howard
2013-10-03Wrapped use of 'lsblk' to a generator function; removed other fcalls to 'lsblk'Ben Howard
2013-10-03Moved ephemeralX.Y handling from Datasource into the cc_disk_setup, which ↵Ben Howard
makes it cloud agnostic.
2013-10-03remove verbosity of log.infoScott Moser
2013-10-03use native python code for wiping partition tableScott Moser
I'm pretty sure the previous code wasn't seeking correctly and probably writing near the end, but not to the end. This is simpler and probably faster.
2013-10-03fix pep8Scott Moser
2013-10-02Added ability to define disks via 'ephemeralX.Y'.Ben Howard
Modified cc_mounts to identify whether ephermalX is partitioned. Changed datasources for Azure and SmartOS to use 'ephemeralX.Y' format. Added disk remove functionally
2013-10-02fix permission changesScott Moser
2013-10-01Reordered several imports in order for test suite to pass.Eric Nordlund
2013-09-27find_device_node: treat label=None as label=""Scott Moser
Since for a string there is no difference, we're just checking for this here.
2013-09-27change LOG.debug('format' % var) to ('format', var)Scott Moser
2013-09-27fix one bugScott Moser
2013-09-27demote .info to .debug, add another debugScott Moser
2013-09-27adjust aliases early rather than late.Scott Moser
this adds 2 functions update_disk_setup_devices update_fs_setup_devices Which update the appropriate datatype, and translate the names. Translating early means we don't have to deal with updating in the mkfs or mkpart calls explicitly. These are more easily unit tested as they just take a dictionary of the expected type and a 'transformer' that should return a new name or None.
2013-09-27update to get functional with any alias in a 'device' entryScott Moser
2013-09-27fix syntax error in last commitScott Moser