%PDF- %PDF-
Direktori : /lib/python2.7/site-packages/salt/modules/ |
Current File : //lib/python2.7/site-packages/salt/modules/mdadm_raid.pyo |
� ���^c @@ s d Z d d l m Z m Z m Z d d l Z d d l Z d d l Z d d l Z d d l m Z m Z d d l m Z e j e � Z i d d 6Z d Z d � Z d � Z d d � Z d � Z d � Z d e d � Z d � Z e d � Z d � Z d � Z d S( u. Salt module to manage RAID arrays with mdadm i ( t absolute_importt print_functiont unicode_literalsN( t CommandExecutionErrort SaltInvocationError( t sixu listu list_u raidc C@ s= t d d k r t d f St j j j d � s9 t d f St S( u1 mdadm provides raid functions for Linux u kernelu LinuxuE The mdadm execution module cannot be loaded: only available on Linux.u mdadmuQ The mdadm execution module cannot be loaded: the mdadm binary is not in the path.( t __grains__t Falset saltt utilst patht whicht __virtualname__( ( ( s; /usr/lib/python2.7/site-packages/salt/modules/mdadm_raid.pyt __virtual__ s c C@ s� i } x� t d d d d g d t �j � D]� } d | k rD q, n | j � } | d } i | d 6| | <xL | d D]@ } | j d � d j � } | j d � d } | | | | <qv Wq, W| S( uh List the RAID devices. CLI Example: .. code-block:: bash salt '*' raid.list u cmd.run_stdoutu mdadmu --detailu --scant python_shellu i u devicei u =i ( t __salt__R t splitlinest splitt lower( t rett linet compst devicet compt keyt value( ( s; /usr/lib/python2.7/site-packages/salt/modules/mdadm_raid.pyt list_+ s u /dev/md0c C@ s� i } i | d <t j j | � s@ d } t | j | � � � n d d | g } xGt d | d t �j � D])} | j | � r� ql n d | k r� ql n d | k r,d | k rl | j � } | d d !} i | d d 6| d d 6| d d 6| d d 6| d d 6d j | � d 6| d | d <ql ql n | j d � } | d j � | d <| d j � | d <| d j d d � | d <| d j � | | d <ql W| S( u� Show detail for a specified RAID device CLI Example: .. code-block:: bash salt '*' raid.detail '/dev/md0' u membersu Device {0} doesn't exist!u mdadmu --detailu cmd.run_stdoutR u u :u /dev/i i����u devicei u majori u minori u numberi u raiddeviceu stateu : u _( t osR t existsR t formatR R R t startswithR t joinR t stript replace( R R t msgt cmdR R t state( ( s; /usr/lib/python2.7/site-packages/salt/modules/mdadm_raid.pyt detailE s: # "c C@ s y t | � } Wn t k r$ t SXd d | g } d d g } t d | d t �r� x+ | d D] } | j | d | d � qa Wt d | d t �n t j d � d k r� d } n d } y! t d | d j | � d � Wn t k r� n Xt d � j | � d k rt St Sd S( u� Destroy a RAID device. WARNING This will zero the superblock of all members of the RAID array.. CLI Example: .. code-block:: bash salt '*' raid.destroy /dev/md0 u mdadmu --stopu --zero-superblocku cmd.retcodeR u membersu deviceu os_familyu Debianu /etc/mdadm/mdadm.confu /etc/mdadm.confu file.replaceu ARRAY {0} .*u u raid.listN( R% R R R t appendR t getR R t Nonet True( R t detailst stop_cmdt zero_cmdt numbert cfg_file( ( s; /usr/lib/python2.7/site-packages/salt/modules/mdadm_raid.pyt destroyr s( ! c C@ s d } t d | � r t St S( u� Shut down all arrays that can be shut down (i.e. are not currently in use). CLI Example: .. code-block:: bash salt '*' raid.stop u mdadm --stop --scanu cmd.retcode( R R) R ( R# ( ( s; /usr/lib/python2.7/site-packages/salt/modules/mdadm_raid.pyt stop� s u defaultc K@ s# g } t | � } x� | D]~ } | j d � st | j d j | � � | | t k rt | j t j | | � � qt n | d k r | t | | � 8} q q Wd d | d d d t j | � g | d | d t j | � g | } d j | � } | t k r� | S| t k rt d | d t �Sd S( u Create a RAID device. .. versionchanged:: 2014.7.0 .. warning:: Use with CAUTION, as this function can be very destructive if not used properly! CLI Examples: .. code-block:: bash salt '*' raid.create /dev/md0 level=1 chunk=256 devices="['/dev/xvdd', '/dev/xvde']" test_mode=True .. note:: Adding ``test_mode=True`` as an argument will print out the mdadm command that would have been run. name The name of the array to create. level The RAID level to use when creating the raid. devices A list of devices used to build the array. metadata Version of metadata to use when creating the array. kwargs Optional arguments to be passed to mdadm. returns test_mode=True: Prints out the full command. test_mode=False (Default): Executes command on remote the host(s) and Prints out the mdadm output. .. note:: It takes time to create a RAID array. You can check the progress in "resync_status:" field of the results from the following command: .. code-block:: bash salt '*' raid.detail /dev/md0 For more info, read the ``mdadm(8)`` manpage u __u --{0}u spare-devicesu mdadmu -Cu -Ru -vu -lu -eu -nu u cmd.runR N( t lenR R&