Current File : //lib/python2.7/site-packages/euca2ools/commands/euimage/pack/metadata.pyo
�
��Xc@s\ddlZddlmZddlmZdefd��YZdefd��YZdS(i����N(tbuild_image_profile(tcheck_dict_whitelisttImagePackMetadatacBsJeZd�Zed��Zed��Zd�Zd�Zd�ZRS(cCs(d|_d|_d|_d|_dS(Ni(tNonetimage_sha256sumt
image_sizetimage_md_sha256sumtversion(tself((sL/usr/lib/python2.7/site-packages/euca2ools/commands/euimage/pack/metadata.pyt__init__!s			cCs*|�}tj|�}t|ddddg�|jd�rut|d�dkrutdj|d���qun|jd�p�i}|jd�s�td��n|d|_|jd	�s�td
��nt|d	�|_|jd�p�i}|jd�std��n|d|_	|S(Ntpacktimagetimage_metadataRis)pack has metadata version {0}; expected 1t	sha256sums)pack: image.sha256sum is missing or emptytsizes#pack: image.size is missing or zeros2pack: image_metadata.sha256sum is missing or empty(
tyamlt	safe_loadRtgettintt
ValueErrortformatRRR(tclstfileobjtnew_mdtmetadatat
image_infot
image_md_info((sL/usr/lib/python2.7/site-packages/euca2ools/commands/euimage/pack/metadata.pytfrom_fileobj's*	
	

cCs&t|��}|j|�SWdQXdS(N(topenR(RtfilenameR((sL/usr/lib/python2.7/site-packages/euca2ools/commands/euimage/pack/metadata.pyt	from_fileFscCs tj|j�|dt�dS(Ntdefault_flow_style(Rt	safe_dumpt%_ImagePackMetadata__serialize_as_dicttFalse(RR((sL/usr/lib/python2.7/site-packages/euca2ools/commands/euimage/pack/metadata.pytdump_to_fileobjKscCs)t|d��}|j|�WdQXdS(Ntw(RR#(RRR((sL/usr/lib/python2.7/site-packages/euca2ools/commands/euimage/pack/metadata.pytdump_to_fileOscCs:ii|jd6|jd6d6i|jd6d6|jd6S(NR
RRRR(RRRR(R((sL/usr/lib/python2.7/site-packages/euca2ools/commands/euimage/pack/metadata.pyt__serialize_as_dictSs(	t__name__t
__module__R	tclassmethodRRR#R%R!(((sL/usr/lib/python2.7/site-packages/euca2ools/commands/euimage/pack/metadata.pyR s			t
ImageMetadatacBsAeZd�Zed��Zed��Zd�Zd�ZRS(cCsCd|_d|_d|_d|_d|_d|_i|_dS(Ni(RtnameRtreleasetepochtarchtdescriptiontprofiles(R((sL/usr/lib/python2.7/site-packages/euca2ools/commands/euimage/pack/metadata.pyR	[s						c	CsZ|�}tj|�}t|dddddddg�|jd�sXtd��n|d|_|jd�s�td	j|j���n|d|_|jd�s�td
j|j���n|d|_|jd�rRyt	|d�|_
Wn)tk
r$tdj|j���nX|j
d
krRtdj|j���qRn|jd�s|tdj|j���n|d|_|jd�s�tdj|j���n|dj�|_
|jd�}|s�tdj|j���nt|t�s tdj|j���nx3|j�D]%\}}t||j�|j|<q-W|S(NRR+RR,R.R/R0sname is missing or emptys(image "{0}": version is missing or emptys(image "{0}": release is missing or emptyR-s%image "{0}": epoch must be an integeris'image "{0}": epoch must not be negatives%image "{0}": arch is missing or emptys,image "{0}": description is missing or emptysUimage "{0}" must have at least one profile (use "default" for a single-profile image)s2image "{0}": profiles must be an associative array(RRRRRR+RRR,RR-R.trstripR/t
isinstancetdicttitemsRR0(RRRRR0tprofile_nametprofile_info((sL/usr/lib/python2.7/site-packages/euca2ools/commands/euimage/pack/metadata.pyRdsX		

	
	

			
			cCs&t|��}|j|�SWdQXdS(N(RR(RRR((sL/usr/lib/python2.7/site-packages/euca2ools/commands/euimage/pack/metadata.pyR�scCs�i|jd6|jd6|jd6|d6}|jrD|j|d<n||jkrktdj|���n|j|j|||||d|�S(Nseuimage:nameseuimage:versionseuimage:releaseseuimage:profiles
euimage:epochsno such profile: "{0}"ttags(R+RR,R-R0RRtinstall(RR5tservicest
image_fileobjRtargsteuimage_tags((sL/usr/lib/python2.7/site-packages/euca2ools/commands/euimage/pack/metadata.pytinstall_profile�s



	
cCs"dj|j|j|j|j�S(Ns{0}-{1}-{2}.{3}(RR+RR,R.(R((sL/usr/lib/python2.7/site-packages/euca2ools/commands/euimage/pack/metadata.pytget_nvra�s(R'R(R	R)RRR=R>(((sL/usr/lib/python2.7/site-packages/euca2ools/commands/euimage/pack/metadata.pyR*Zs
		0	(Rt(euca2ools.commands.euimage.pack.profilesRteuca2ools.utilRtobjectRR*(((sL/usr/lib/python2.7/site-packages/euca2ools/commands/euimage/pack/metadata.pyt<module>s: