403Webshell
Server IP : 23.254.227.96  /  Your IP : 216.73.216.7
Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k
System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64
User : viralblo ( 1001)
PHP Version : 8.1.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3.6/site-packages/cloudinit/config/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.6/site-packages/cloudinit/config/__pycache__/cc_growpart.cpython-36.opt-1.pyc
3

��b84�@s�dZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
ddlmZeZ
ddgdd	�ZGd
d�de�Zeje�Zdd
�ZGdd�de�ZGdd�de�ZGdd�de�Zdd�Zdd�Zdd�Zdd�Zdd�ZdefdeffZdS) a�
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 on which to run growpart 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 the ``mode`` key is set to ``auto``, then any available utility (either
``growpart`` or BSD ``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 existence 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:** always

**Supported distros:** all

**Config keys**::

    growpart:
        mode: <auto/growpart/off/false>
        devices:
            - "/"
            - "/dev/vdb1"
        ignore_growroot_disabled: <true/false>
�N)�log)�subp�
temp_utils�util)�
PER_ALWAYS�auto�/F)�mode�devices�ignore_growroot_disabledc@seZdZdZdZdZdZdS)�RESIZE�SKIPPED�CHANGED�NOCHANGE�FAILEDN)�__name__�
__module__�__qualname__r
rrr�rr�!/usr/lib/python3.6/cc_growpart.pyrUsrc	Cs�d}|dkr@x$tD]\}}|�}|j�r|}PqW|s�td��nXi}xtD]\}}|||<qJW||krrtd|��||�}|j�r�|}|s�td|��|S)NrzNo resizers availablezunknown resize mode %szmode %s not available)�RESIZERS�	available�
ValueError�	TypeError)	r	Zresize_class�_name�resizerZcurZmmap�k�vZmclassrrr�resizer_factory_s(

rc@seZdZdS)�ResizeFailedExceptionN)rrrrrrrr}src@seZdZdd�Zdd�ZdS)�ResizeGrowPartcCsXtjj�}d|d<y*tjddg|d�\}}tjd|�r:dSWntjk
rRYnXdS)	N�C�LANG�growpartz--help)�envz--update\s+TF)�os�environ�copyr�re�search�ProcessExecutionError)�self�myenv�outZ_errrrrr�s
zResizeGrowPart.availablec	&Cs,tjj�}d|d<t|�}tjdd���}tjj|d�}tjj|�sNtj	|d�||d<yt
j
dd||g|d	�WnJt
jk
r�}z,|jd
kr�t
jtd||�t|�|�||fSd}~XnXyt
j
d||g|d	�Wn@t
jk
�r}z t
jtd||�t|�|�WYdd}~XnXWdQRX|t|�fS)
Nr!r"T)Z	needs_exer#i�ZTMPDIRz	--dry-run)r$�z&Failed growpart --dry-run for (%s, %s)zFailed: growpart %s %s)r%r&r'�get_sizerZtempdir�path�join�exists�mkdirrr*�	exit_coder�logexc�LOGr)	r+�diskdev�partnum�partdevr,�beforeZtmpdZgrowpart_tmp�errr�resize�s4


&zResizeGrowPart.resizeN)rrrrr<rrrrr �s
r c@seZdZdd�Zdd�ZdS)�ResizeGpartcCs^tjj�}d|d<y0tjddg|ddgd�\}}tjd|�r@d	SWntjk
rXYnXd
S)Nr!r"�gpart�helprr.)r$�rcszgpart recover TF)r%r&r'rr(r)r*)r+r,Z_out�errrrrr�s
zResizeGpart.availablecCs�ytjdd|g�WnFtjk
rZ}z(|jdkrJtjtd|�t|�|�WYdd}~XnXt|�}ytjddd||g�Wn>tjk
r�}z tjtd||�t|�|�WYdd}~XnX|t|�fS)	a9
        GPT disks store metadata at the beginning (primary) and at the
        end (secondary) of the disk. When launching an image with a
        larger disk compared to the original image, the secondary copy
        is lost. Thus, the metadata will be marked CORRUPT, and need to
        be recovered.
        r>ZrecoverrzFailed: gpart recover %sNr<z-izFailed: gpart resize -i %s %s)rr*r4rr5r6rr/)r+r7r8r9r;r:rrrr<�s
zResizeGpart.resizeN)rrrrr<rrrrr=�s
r=cCs0tj|tj�}ztj|dtj�Stj|�XdS)Nr)r%�open�O_RDONLY�lseek�SEEK_END�close)�filename�fdrrrr/�sr/c
Cs$tjj|�}tjj|�}d|}tj�rVdtj|�}tjd|�}|j	d�|j	d�fStj
�r�dtj|�}tjd|�}|j	d�|j	d�fStjj|�s�t
d||f��tjj|d�}tjj|�s�td	|��tj|�j�}tjj|�}	tjj|	�}
tjtjj|
d
��j�}tjjd|�}||fS)Nz/sys/class/block/%sz/dev/z^(/dev/.+)p([0-9])$r.�z^(/dev/.+)s([0-9])$z%s had no syspath (%s)�	partitionz%s not a partition�devz
/dev/block/%s)r%r0�realpath�basenamerZ
is_FreeBSDZfind_freebsd_partr(r)�groupZis_DragonFlyBSDZfind_dragonflybsd_partr2rr1rZ	load_file�rstrip�dirname)
ZdevpathZrpathZbnameZsyspathZfreebsd_part�mZdragonflybsd_partZptpath�ptnumZrsyspathZdisksyspathZ
diskmajminZdiskdevpathrrr�device_part_info�s,rScCst|jd�r|Stj|�}|s$td��|d}tj�}|dkrp|rptjtj��}|dkrptjj	|�rh|Std��|S)Nz/dev/z,Could not determine device of '%s' % dev_entrz	/dev/rootz!Unable to find device '/dev/root')
�
startswithrZget_mount_inforZis_containerZrootdev_from_cmdlineZget_cmdliner%r0r2)�devent�resultrKZ	containerrrr�
devent2dev
s

rWc>Cs�g}�x�|D�]�}yt|�}Wn:tk
rX}z|j|tjd|f�wWYdd}~XnXytj|�}Wn>tk
r�}z"|j|tjd||ff�wWYdd}~XnXtj|j	�r�tj
|j	�r�|j|tjd|f�qyt|�\}}WnDttfk
�r0}z"|j|tjd||ff�wWYdd}~XnXyZ|j
|||�\}	}
|	|
k�rl|j|tjd||ff�n|j|tjd|||	|
ff�Wqtk
�r�}z"|j|tjd|||ff�WYdd}~XqXqW|S)Nzunable to convert to device: %szstat of '%s' failed: %szdevice '%s' not a block devicezdevice_part_info(%s) failed: %szno change necessary (%s, %s)zchanged (%s, %s) from %s to %sz'failed to resize: disk=%s, ptnum=%s: %s)rWr�appendrr
r%�stat�OSError�S_ISBLK�st_mode�S_ISCHRrSrr<rrrr)rr
�inforUZblockdevr;ZstatretZdiskrR�old�newrrr�resize_devices$sh

&racCs~d|kr|jdt�t|d<|jd�}t|t�s@|jd�dS|jdd�}tj|�rh|jd|�dStj|jdd��r�tj	j
d	�r�|jd
�|jd�dStj|dd
g�}t|�s�|jd�dSyt
|�}WnFttfk
�r}	z$|jd||	f�|dk�r|	�dSd}	~	XnXtj|jdt||fd�}
xH|
D]@\}}}
|tjk�r`|jd||
f�n|jd|||
f��q6WdS)Nr#z.No 'growpart' entry in cfg.  Using default: %sz#'growpart' in config was not a dictr	rzgrowpart disabled: mode=%srFz/etc/growroot-disabledz0growpart disabled: /etc/growroot-disabled existsz&use ignore_growroot_disabled to ignorer
rzgrowpart: empty device listz,growpart unable to find resizer for '%s': %sra)Zlogfunc�msg�func�argsz'%s' resized: %sz'%s' %s: %s)�debug�DEFAULT_CONFIG�get�
isinstance�dictZwarningrZis_falser%r0�isfileZget_cfg_option_list�lenrrrZlog_timerarrr^)rZcfgZ_cloudrZ_argsZmycfgr	r
rr;Zresized�entry�actionrbrrr�handleysJ








rnr#r>)�__doc__r%Zos.pathr(rYZ	cloudinitrZloggingrrrZcloudinit.settingsrZ	frequencyrf�objectrZ	getLoggerrr6r�	Exceptionrr r=r/rSrWrarnrrrrr�<module>As.
2'+U1

Youez - 2016 - github.com/yon3zu
LinuXploit