Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/landscape/monitor/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyc


Tc@sddlZddlZddlmZmZddlmZddlmZddl	m
Z
mZddlm
Z
ddlmZddlmZd	Zd
efdYZdefd
YZdS(iN(tinlineCallbackstreturnValue(tfetch_async(t	read_file(tLSB_RELEASE_FILENAMEtparse_lsb_release(tfetch_ec2_meta_data(tget_fqdn(t
MonitorPluginitDistributionInfoErrorcBseZRS((t__name__t
__module__(((sB/usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR	stComputerInfocBseZdZdZdZedededZdZ	e
dZe
dZe
e
d	Ze
d
ZdZdZd
ZdZdZe
dZdZRS(s7Plugin captures and reports basic computer information.s
computer-infotcomputers
/proc/meminfot/cCsC||_||_||_||_d|_d|_||_dS(Ni(t	_get_fqdnt_meminfo_filenamet_lsb_release_filenamet
_root_pathtNonet_cloud_instance_metadatat_cloud_retriest_fetch_async(tselfRtmeminfo_filenametlsb_release_filenamet	root_pathR((sB/usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyt__init__s						cCsktt|j||jj|_|jd|jt|jd|j	t|jd|j
tdS(Ns
computer-infosdistribution-infoscloud-instance-metadata(tsuperRtregistertconfigtannotations_patht_annotations_pathtcall_on_acceptedtsend_computer_messagetTruetsend_distribution_messaget$send_cloud_instance_metadata_message(Rtregistry((sB/usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR%s	
	
	cCsO|j}|rKd|d<tjd|jjj||jd|ndS(Ns
computer-infottypes,Queueing message with updated computer info.turgent(t_create_computer_info_messagetloggingtinfoR&tbrokertsend_messaget_session_id(RR(tmessage((sB/usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR"/s

cCsO|j}|rKd|d<tjd|jjj||jd|ndS(Nsdistribution-infoR's0Queueing message with updated distribution info.R((t!_create_distribution_info_messageR*R+R&R,R-R.(RR(R/((sB/usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR$7s

ccsP|jV}|rLd|d<tjd|jjj||jd|ndS(Nscloud-instance-metadataR's6Queueing message with updated cloud instance metadata.R((t'_create_cloud_instance_metadata_messageR*R+R&R,R-R.(RR(R/((sB/usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR%?s


cCsR|jj}|jd|j||jd|j||jd|j|dS(Ns
computer-infosdistribution-infoscloud-instance-metadata(R&R,tcall_if_acceptedR"R$R%(RR(R,((sB/usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pytexchangeIs	
	
	cCsi}|j|d|j|j\}}|j|d||j|d|i}tjj|jrx?tj|jD](}ttjj	|j|||<qWn|r|j|d|n|S(Nthostnamestotal-memorys
total-swaptannotations(
t_add_if_newRt_get_memory_infotostpathtexistsR tlistdirRtjoin(RR/ttotal_memoryt
total_swapR5tkey((sB/usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR)Ss&cCs<||jj|kr8|jj|||||<ndS(N(t_persisttgettset(RR/R?tvalue((sB/usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR6cscCs?|j}||jjdkr;|jjd||SdS(Nsdistribution-info(t_get_distribution_infoR@RARBR(RR/((sB/usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR0hs
cCsi}t|j}xr|D]j}|dkr|jd}|d}|d	krt|djjdd}|||<qqqW|j|dd|ddfS(
s>Get details in megabytes and return a C{(memory, swap)} tuple.s
t:itMemTotalt	SwapTotalit i(RFRG(topenRtsplittinttstriptclose(RR/tfiletlinetpartsR?RC((sB/usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR7os

#
cCs i}|jt|j|S(s#Get details about the distribution.(tupdateRR(RR/((sB/usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyRD}sccsNd}|jdkr@|jtkr@|jV|_|j}nt|dS(s0Fetch cloud metadata and insert it in a message.N(RRRtMETADATA_RETRY_MAXt_fetch_ec2_meta_dataR(RR/((sB/usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyR1scsdjdkrtjdntj}fd}d}|j||j||S(s+Fetch information about the cloud instance.isQuerying cloud meta-data.cs<jd7_jtkr8tjd|jndS(Nis No cloud meta-data available. %s(RRRR*R+tgetErrorMessage(terror(R(sB/usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pytlog_no_meta_data_founds	cSstjd|S(NsAcquired cloud meta-data.(R*R+(tresult((sB/usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pytlog_successs
(RR*R+RRtaddCallbackt
addErrback(RtdeferredRVRX((RsB/usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyRSs	

(R
Rt__doc__tpersist_nametscopeRRRRRtFalseR"R$RR%R3R)R6R0R7RDR1RS(((sB/usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyRs(		
	
					
(R8R*ttwisted.internet.deferRRtlandscape.lib.fetchRtlandscape.lib.fsRtlandscape.lib.lsb_releaseRRtlandscape.lib.cloudRtlandscape.lib.networkRtlandscape.monitor.pluginRRRt	ExceptionR	R(((sB/usr/lib/python2.7/dist-packages/landscape/monitor/computerinfo.pyt<module>s