Current File : //lib/python2.7/site-packages/cloudinit/config/cc_growpart.pyo |
�
oB�]c @ sC d Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m Z d d l m
Z
e Z i d d 6d g d 6e d
6Z
d e f d � � YZ e j e � Z d
� Z d e f d � � YZ d e f d � � YZ d e f d � � YZ d � Z d � Z d � Z d � Z d � Z d e f d e f f Z d S( s�
Growpart
--------
**Summary:** grow partitions
Growpart resizes partitions to fill the available disk space.
This is useful for cloud instances with a larger amount of disk space available
than the pristine image uses, as it allows the instance to automatically make
use of the extra space.
The devices run growpart on are specified as a list under the ``devices`` key.
Each entry in the devices list can be either the path to the device's
mountpoint in the filesystem or a path to the block device in ``/dev``.
The utility to use for resizing can be selected using the ``mode`` config key.
If ``mode`` key is set to ``auto``, then any available utility (either
``growpart`` or ``gpart``) will be used. If neither utility is available, no
error will be raised. If ``mode`` is set to ``growpart``, then the ``growpart``
utility will be used. If this utility is not available on the system, this will
result in an error. If ``mode`` is set to ``off`` or ``false``, then
``cc_growpart`` will take no action.
There is some functionality overlap between this module and the ``growroot``
functionality of ``cloud-initramfs-tools``. However, there are some situations
where one tool is able to function and the other is not. The default
configuration for both should work for most cloud instances. To explicitly
prevent ``cloud-initramfs-tools`` from running ``growroot``, the file
``/etc/growroot-disabled`` can be created. By default, both ``growroot`` and
``cc_growpart`` will check for the existance of this file and will not run if
it is present. However, this file can be ignored for ``cc_growpart`` by setting
``ignore_growroot_disabled`` to ``true``. For more information on
``cloud-initramfs-tools`` see: https://launchpad.net/cloud-initramfs-tools
Growpart is enabled by default on the root partition. The default config for
growpart is::
growpart:
mode: auto
devices: ["/"]
ignore_growroot_disabled: false
**Internal name:** ``cc_growpart``
**Module frequency:** per always
**Supported distros:** all
**Config keys**::
growpart:
mode: <auto/growpart/off/false>
devices:
- "/"
- "/dev/vdb1"
ignore_growroot_disabled: <true/false>
i����N( t log( t
PER_ALWAYS( t utilt autot modet /t devicest ignore_growroot_disabledt RESIZEc B s e Z d Z d Z d Z d Z RS( t SKIPPEDt CHANGEDt NOCHANGEt FAILED( t __name__t
__module__R R
R R ( ( ( s@ /usr/lib/python2.7/site-packages/cloudinit/config/cc_growpart.pyR T s c C s� d } | d k r` x3 t D]+ \ } } | � } | j � r | } Pq q W| s� t d � � q� n� i } x t D] \ } } | | | <qm W| | k r� t d | � � n | | � } | j � r� | } n | s� t d | � � n | S( NR s No resizers availables unknown resize mode %ss mode %s not available( t Nonet RESIZERSt availablet
ValueErrort TypeError( R t resize_classt _namet resizert curt mmapt kt vt mclass( ( s@ /usr/lib/python2.7/site-packages/cloudinit/config/cc_growpart.pyt resizer_factory^ s(
t ResizeFailedExceptionc B s e Z RS( ( R
R ( ( ( s@ /usr/lib/python2.7/site-packages/cloudinit/config/cc_growpart.pyR | s t ResizeGrowPartc B s e Z d � Z d � Z RS( c C su t j j � } d | d <yA t j d d g d | �\ } } t j d | t j � rY t SWn t j k
rp n Xt
S( Nt Ct LANGt growparts --helpt envs --update\s+( t ost environt copyR t subpt ret searcht DOTALLt Truet ProcessExecutionErrort False( t selft myenvt outt _err( ( s@ /usr/lib/python2.7/site-packages/cloudinit/config/cc_growpart.pyR � s
!c C s� t | � } y t j d d | | g � WnQ t j k
r| } | j d k rr t j t d | | � t | � � n | | f SXy t j d | | g � Wn8 t j k
r� } t j t d | | � t | � � n X| t | � f S( NR! s --dry-runi s&