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/cephusage.pyc


Tc@sddlZddlZddlZddlmZddlmZddlmZddl	m
Z
y#ddlmZe
edZWnek
reZnXde
fd	YZdS(
iN(tthreads(tAccumulator(tCoverageMonitor(t
MonitorPlugin(tRadostget_cluster_statst	CephUsagecBseZdZdZdZdZddejdZdZ	dZ
edZed	Z
d
ZdZdZd
ZRS(s
    Plugin that captures Ceph usage information. This only works if the client
    runs on one of the Ceph monitor nodes, and noops otherwise.

    The plugin requires the 'python-ceph' package to be installed, which is the
    case on a standard "ceph" charm deployment.
    The landscape-client charm should join a ceph-client relation with the ceph
    charm, which will crete a keyring and config file for the landscape-client
    to consume in <data_path>/ceph-client/ceph.landscape-client.conf. It
    contains the following:

    [global]
    auth supported = cephx
    keyring = <keyring-file>
    mon host = <ip>:6789

    The configured keyring can be generated with:

    ceph-authtool <keyring-file> --create-keyring
        --name=client.landscape-client --add-key=<key>
    s
ceph-usagetstorageii<cCsLt|_t|_||_||_g|_d|_||_	d|_
dS(N(tTruetactivet	has_radost
_has_radost	_intervalt_monitor_intervalt_ceph_usage_pointstNonet
_ceph_ring_idt_create_timet_ceph_config(tselftintervaltmonitor_intervaltcreate_time((s?/usr/lib/python2.7/dist-packages/landscape/monitor/cephusage.pyt__init__/s							cCstt|j|tjj|jjjdd|_	t
|j|j|_
t|jddd|j|_|jjj|j|j|jjj|j|jj|jjjd|jjdd|jd	|jtdS(
Nsceph-clientsceph.landscape-client.confg?sCeph usage snapshotRtstoptpriorityis
ceph-usage(tsuperRtregistertostpathtjointregistrytconfigt	data_pathRRt_persistRt_accumulateRRt_monitortreactort
call_everytrunR
tlogtcall_ontcall_on_acceptedtsend_messageR(RR((s?/usr/lib/python2.7/dist-packages/landscape/monitor/cephusage.pyR:s	"cCs;|j}|j}g|_idd6|d6gd6|d6S(Ns
ceph-usagettypesring-idsceph-usagessdata-points(RR(Rtceph_pointstring_id((s?/usr/lib/python2.7/dist-packages/landscape/monitor/cephusage.pytcreate_messageKs			
cCsF|j}|drB|drB|jjj||jd|ndS(Nsring-idsdata-pointsturgent(R/RtbrokerR+t_session_id(RR0tmessage((s?/usr/lib/python2.7/dist-packages/landscape/monitor/cephusage.pyR+TscCs |jjjd|j|dS(Ns
ceph-usage(RR1tcall_if_acceptedR+(RR0((s?/usr/lib/python2.7/dist-packages/landscape/monitor/cephusage.pytexchangeZscCsC|jsdS|jjtj|j}|j|j|S(N(t_should_runR$tpingRt
deferToThreadt_perform_rados_calltaddCallbackt
_handle_usage(Rtdeferred((s?/usr/lib/python2.7/dist-packages/landscape/monitor/cephusage.pyR'^s
cCs]|js
tS|js0tjdt|_tS|jdksUtjj	|jrYtSt
S(s.Returns whether or not this plugin should run.sGThis machine does not appear to be a Ceph machine. Deactivating plugin.N(R	tFalseRtloggingtinfoRRRRtexistsR(R((s?/usr/lib/python2.7/dist-packages/landscape/monitor/cephusage.pyR6gs		
	%cCsatd|jddC}|j}|jdkrWt|jd}||_nWdQX|S(sThe actual Rados interaction.tconffiletrados_idslandscape-clientsutf-8N(RRRRRtunicodetget_fsid(Rtclustert
cluster_statstfsid((s?/usr/lib/python2.7/dist-packages/landscape/monitor/cephusage.pyR9ysc
Csdd
dg}t|j}g}xH|D]@\}}||d}|j||d|}|j|q.Wt|sd	S|d
g}	|	jd|D|jjt|	d	S(sA method to use as callback to the rados interaction.

        Parses the output and stores the usage data in an accumulator.
        ttotaltkbtavailtkb_availtusedtkb_usedisusage.%sNicss|]}t|dVqdS(iN(tint(t.0t
step_value((s?/usr/lib/python2.7/dist-packages/landscape/monitor/cephusage.pys	<genexpr>s(RHRI(RJRK(RLRM(RNRR#tappendtalltextendRttuple(
RRFt	names_mapt	timestamptstep_valuestnametkeytvalueRPtpoint((s?/usr/lib/python2.7/dist-packages/landscape/monitor/cephusage.pyR;s
Ni(t__name__t
__module__t__doc__tpersist_nametscopeRtrun_intervalttimeRRR/R=R+R5R'R6R9R;(((s?/usr/lib/python2.7/dist-packages/landscape/monitor/cephusage.pyRs
							(R>RbRttwisted.internetRtlandscape.accumulateRtlandscape.lib.monitorRtlandscape.monitor.pluginRtradosRthasattrR
tImportErrorR=R(((s?/usr/lib/python2.7/dist-packages/landscape/monitor/cephusage.pyt<module>s