
    Hg                         d dl Z 	 d dlmZmZmZ n# e$ r Y nw xY wd dlmZ  e j        e	          Z
 G d de          ZdS )    N)OptionalListDict)DriveSelectionc                   *    e Zd ZdZ	 	 ddZd Zd ZdS )to_ceph_volume	_NO_CRUSHNFc                 H    || _         |j        | _        || _        || _        d S )N)	selectionspecpreviewosd_id_claims)selfr   r   r   s       ;/usr/lib/python3/dist-packages/ceph/deployment/translate.py__init__zto_ceph_volume.__init__   s)     #N	*    c                    t                      }	 | j                                        D ]]}|j        }|j        p| j        j        p| j        }|t          d          |                    |g           	                    |           ^|S )NzDevice path can't be empty)
dictr   data_devicespathcrush_device_classr   NO_CRUSH
ValueError
setdefaultappend)r   lvcountdevicer   r   s        r   prepare_deviceszto_ceph_volume.prepare_devices   s     )-	
 n1133 	D 	DF ;D) !9/!=  | !=>>>1266==dCCCCr   c           	         d | j                                         D             }d | j                                         D             }d | j                                         D             }| j                                         sg S g }|                                 }t          t          t          |	                                          g                     }|r4|r2|t          |          k    r| j
        j        dk    rt          d          |r4|r2|t          |          k    r| j
        j        dk    rt          d          | j
        j        dk    rt          t          |	                                          g           }d}|d	                    d
                    |                    z  }| j
        j        r"|d                    | j
        j                  z  }|r+|d                    d
                    |                    z  }|dz  }|                    |           n|                                D ]l}	|                    |	          }
|
s| j
        j        dk    r| j
        j        dk    sJ d}|                                 |                                 |t          |
          k     rd}|d                    |
|                   z  }|r*|d                    |                                          z  }|r*|d                    |                                          z  }|	| j        k    r|d                    |	          z  }|                    |           |dz  }|t          |
          k     ȐE| j
        j        dk    rd                    d
                    |
                    }|r+|d                    d
                    |                    z  }|r+|d                    d
                    |                    z  }| j
        j        r"|d                    | j
        j                  z  }| j
        j        r"|d                    | j
        j                  z  }|	| j        k    r|d                    |	          z  }|                    |           nt3          t          |                    D ]*}| j
        j        r||xx         dz  cc<   | j
        j        r-||xx         d                    | j
        j                  z  cc<   | j
        j        r-||xx         d                    | j
        j                  z  cc<   | j        r;||xx         d                    d
                    | j                            z  cc<   | j
        j        dk    r ||xx         dz  cc<   ||xx         d z  cc<   | j        r ||xx         d!z  cc<   ||xx         d"z  cc<   ,|S )#z? Generate ceph-volume commands based on the DriveGroup filters c                     g | ]	}|j         
S  r   .0xs     r   
<listcomp>z&to_ceph_volume.run.<locals>.<listcomp>=   s    BBBafBBBr   c                     g | ]	}|j         
S r!   r"   r#   s     r   r&   z&to_ceph_volume.run.<locals>.<listcomp>>   s    DDD!qvDDDr   c                     g | ]	}|j         
S r!   r"   r#   s     r   r&   z&to_ceph_volume.run.<locals>.<listcomp>?   s    LLLa16LLLr   rawzHNumber of data devices must match number of db devices for raw mode osdszINumber of data devices must match number of wal devices for raw mode osds	filestorezlvm batch --no-autoz {} z --journal-size {}z --journal-devices {}z --filestore	bluestorer   zraw prepare --bluestorez
 --data {}z --block.db {}z --block.wal {}z --crush-device-class {}   zlvm batch --no-auto {}z --db-devices {}z --wal-devices {}z --block-wal-size {}z --block-db-size {}z
 --dmcryptz --osds-per-device {}z --data-allocate-fraction {}z --osd-ids {}z --yesz --no-systemdz	 --reportz --format json)r   
db_deviceswal_devicesjournal_devicesr   r   lensumlistvaluesr   methodr   objectstoreformatjoinjournal_sizer   keysgetreversepopr   block_wal_sizeblock_db_sizerange	encryptedosds_per_devicedata_allocate_fractionr   r   )r   r.   r/   r0   cmdsdevicesdevices_countdevscmddr   dev_counteris                r   runzto_ceph_volume.run9   s&    CBdn&?&?&A&ABBB
DDt~'A'A'C'CDDDLL4>+I+I+K+KLLL~**,, 	I&&((CW^^%5%5 6 6;;<< 	Az 	AZ00ty7G57P7P  "@ A A A  	B{ 	B[!1!111	8HE8Q8Q  "A B B B
 9 K//T'.."2"233R88D'C5<<///Cy% K+22493IJJJ 3.55113 3 3 >!CKK\\^^ .% .%4;KKNN# 9#u,,90K???? #$K&&((('')))%L(9(9997|22<3LMMM% M#3#:#::>>;K;K#L#LLC& O#4#;#;KOO<M<M#N#NNC--#=#D#DQ#G#GGCC(((#q( &L(9(999 Y*k99 399#((<:P:PQQC! O188*9M9MNNN" Q299#((;:O:OPPPy/ W5<<TY=UVVVy. U4;;DI<STTTDM))9@@CCCKK$$$s4yy!! 	, 	,Ay" (Q<'y( UQ299$):STTTy/ cQ9@@Aabbb! PQ?11#((4;M2N2NOOOy5((Q8#Q?*| ,Q;&Q++r   )NF)__name__
__module____qualname__r   r   r   rL   r!   r   r   r   r      sX        H  $	+ 	+ 	+ 	+  8t t t t tr   r   )loggingtypingr   r   r   ImportError(ceph.deployment.drive_selection.selectorr   	getLoggerrM   loggerobjectr   r!   r   r   <module>rW      s    	+++++++++++ 	 	 	D	 D C C C C C		8	$	$_ _ _ _ _V _ _ _ _ _s   
 