Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
dmapi / usr / lib / python2.7 / dist-packages / dmapi / service.pyc
Size: Mime:
ó
‹ý^c@sádZddlZddlZddlZddlmZddlmZddl	Z
ddlmZddl
mZddlmZddlZddlmZdd	lmZdd
lmZddlmZmZmZmZddlmZdd
lmZddlmZddlmZejdƒZejdƒZ ej!e"ƒZ#ej$j%Z%iZ&d„Z'd„Z(d„Z)d„Z*dej+fd„ƒYZ+dej+fd„ƒYZ,d„Z-da/dd„Z0d„Z1dS(s:Generic Node base class for all workers that run on hosts.iÿÿÿÿN(tprocessutils(tlog(tservice(timportutils(tbaserpc(tcontext(tdebugger(t	exception(t_t_LEt_LIt_LW(trpc(tutils(tversion(twsgit
osprofilersosprofiler.initializercCsJtj|ƒ}|j|_|j|_|j|_d|_|jƒ|S(Ni(tobjectstServicethosttbinaryttopictreport_counttcreate(tthis_serviceRR((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyt_create_service_ref's	
cCsm|jtjkritjtdƒi|jd6|jd6|jd6tjd6ƒtj|_|jƒndS(NsKUpdating service version for %(binary)s on %(host)s from %(old)i to %(new)iRRtoldtnew(	Rtservice_objtSERVICE_VERSIONtLOGtinfoR
RRtsave(R((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyt_update_service_ref1s


cCsctr_tjjr_tjjdtdtjƒjƒddd|d|ƒt	j
tdƒƒndS(NtconfRtprojecttdmapiRRsOSProfiler is enabled.(RtCONFtprofilertenabledtinitializertinit_from_confRtget_admin_contexttto_dictRRR
(RR((s1/usr/lib/python2.7/dist-packages/dmapi/service.pytsetup_profiler=scCsLddlj}ddl}|jƒ}|j|jk	rHtdƒ‚ndS(Niÿÿÿÿsgeventlet hub is not using a monotonic clock - periodic tasks will be affected by drifts of system time.(t
eventlet.hubsthubst	monotonictget_hubtclocktRuntimeError(R.R/thub((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyt$assert_eventlet_uses_monotonic_clockHsRc
Bs•eZdZddddd„Zd„Zd„Zd„Zeddddddddd„ƒZ	d„Z
d„Zed„Z
d	„Zd
„ZRS(sõService object for binaries running on hosts.

    A service takes a manager and enables rpc by listening to queues based
    on topic. It also periodically runs tasks on the manager and reports
    its state to the database services table.
    c	
Osþtt|ƒjƒ||_||_||_||_tjƒ|_	t
j|jƒ}|d|j|	|
Ž|_d|_||_||_||_||_|	|
|_|_d|_tjjrêtjƒ}|jtjƒƒnt||jƒdS(NR(tsuperRt__init__RRRtmanager_class_nametservicegrouptAPItservicegroup_apiRtimport_classtmanagertNonet	rpcservertreport_intervaltperiodic_enabletperiodic_fuzzy_delaytperiodic_interval_maxt
saved_argstsaved_kwargst
backdoor_porttobjects_baset
NovaObjecttindirection_apit	conductortwait_until_readyRR*R,(
tselfRRRR<R?R@RARBtargstkwargst
manager_classt
conductor_api((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyR6[s&										cCs3di|jjd6|jd6|jd6|jd6S(NsP<%(cls_name)s: host=%(host)s, binary=%(binary)s, manager_class_name=%(manager)s>tcls_nameRRR<(t	__class__t__name__RRR7(RK((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyt__repr__rs


cCsStƒtjƒ}tjtdƒi|jd6|d6ƒ|jƒ|jj	ƒt
|_tj
ƒ}tjj||j|jƒ|_|jr t|jƒnWyt||ƒ|_Wn>tjtjfk
rötjj||j|jƒ|_nX|jjƒ|jd
k	r%|j|j_ntjd|jƒtjd|jd|jƒ}|jtj |jj!|jƒg}|j"|jj#ƒt$j%ƒ}t&j'|||ƒ|_(|j(j)ƒ|jj*ƒtjd|jƒ|j+j,|j|j|ƒ|j-rO|j.r$t/j0d|j.ƒ}nd
}|j1j2|j3d|d	|j4ƒnd
S(suStart the service.

        This includes starting an RPC service, initializing
        periodic tasks, etc.
        s-Starting %(topic)s node (version %(version)s)RRs"Creating RPC server for service %stservers0Join ServiceGroup membership for this service %sit
initial_delayRBN(5R4Rtversion_string_with_packageRRR
Rtbasic_config_checkR<t	init_hosttFalsetmodel_disconnectedRR*RRtget_by_host_and_binaryRRtservice_refR!RRtServiceTopicExiststServiceBinaryExiststpre_start_hookRER=tdebugt	messagingtTargetRt
BaseRPCAPItservice_nametextendtadditional_endpointsRFtNovaObjectSerializerRt
get_serverR>tstarttpost_start_hookR:tjoinR@RAtrandomtrandintttgtadd_dynamic_timertperiodic_tasksRB(RKtverstrtctxtttargett	endpointst
serializerRU((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyRi{sP

				


	
		cCs"|jjddƒ}t||ƒS(NR<(t__dict__tgetR=tgetattr(RKtkeyR<((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyt__getattr__¿sc	

Csë|stj}n|s4tjjtjdƒ}n|sP|jdƒd}n|shtj	|ƒ}n|dkr€tj}n|dkr˜tj}n|dkr°tj
}ntjƒ|||||d|d|d|d|ƒ}	|	S(	s7Instantiates class and passes back application object.

        :param host: defaults to CONF.host
        :param binary: defaults to basename of executable
        :param topic: defaults to bin_name - 'dmapi-' part
        :param manager: defaults to CONF.<topic>_manager
        :param report_interval: defaults to CONF.report_interval
        :param periodic_enable: defaults to CONF.periodic_enable
        :param periodic_fuzzy_delay: defaults to CONF.periodic_fuzzy_delay
        :param periodic_interval_max: if set, the max time to wait between runs

        isdmapi-iR?R@RARBN(R%Rtostpathtbasenametsystargvt
rpartitiontSERVICE_MANAGERSRwR=R?R@RARtinit(
tclsRRRR<R?R@RARBR((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyRÃs*
	cCsI|jƒy|jjƒWn'tjk
rDtjtdƒƒnXdS(sþDestroy the service object in the datastore.

        NOTE: Although this method is not used anywhere else than tests, it is
        convenient to have it here, so the tests might easily and in clean way
        stop and remove the service_ref.

        s)Service killed that has no database entryN(tstopR\tdestroyRtNotFoundRtwarningR(RK((s1/usr/lib/python2.7/dist-packages/dmapi/service.pytkillìs

cCsy|jjƒ|jjƒWntk
r1nXy|jjƒWn$tk
ritjtdƒƒnXt	t
|ƒjƒdS(sstop the service and clean up.s*Service error occurred during cleanup_hostN(R>R„twaitt	ExceptionR<tcleanup_hostRRR	R5R(RK((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyR„ús


cCs"tjƒ}|jj|d|ƒS(s'Tasks to be run at a periodic interval.traise_on_error(RR*R<Rp(RKRŒRr((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyRp
scCsTytjƒWdQXWn6tk
rO}tjtdƒ|ƒtjdƒnXdS(s7Perform basic config checks before starting processing.Ns"Temporary directory is invalid: %si(R
ttempdirRŠRterrorR	R~texit(RKte((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyRWs

cCs|jjƒdS(sreset the service.N(R<treset(RK((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyR‘sN(RRt
__module__t__doc__R=R6RSRiRztclassmethodRRˆR„RYRpRWR‘(((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyRSs 			D	&			
tWSGIServicecBsMeZdZdedd„Zd„Zd„Zd„Zd„Z	d„Z
RS(s<Provides ability to launch API from a 'paste' configuration.cCs~||_d||_d|_|jƒ|_|p=tjƒ|_|jj	|ƒ|_
|}ttd|dƒ|_
ttd|dƒ|_ttd|dƒp¯tjƒ|_|jr|jdkrd|}tdƒi|d	6t|jƒd
6}tj|ƒ‚n||_tj||j
d|j
d|jd
|jd|ƒ|_|jj|_d|_t||j
ƒdS(sÝInitialize, but do not start the WSGI server.

        :param name: The name of the WSGI server given to the loader.
        :param loader: Loads the WSGI application using the given name.
        :returns: None

        sdmapi-%ss	%s_listens0.0.0.0s%s_listen_portis
%s_workersisG%(worker_name)s value of %(workers)s is invalid, must be greater than 0tworker_nametworkersRtporttuse_ssltmax_url_lenN(tnameRR=Rt_get_managerR<RtLoadertloadertload_apptappRxR%RR˜Rtget_worker_countR—RtstrRtInvalidInputR™tServerRTRER,(RKR›RžR™RštwnameR–tmsg((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyR6!s6	
	
	
							cCs|jjƒtjjƒdS(scReset server greenpool size to default and service version cache.

        :returns: None

        N(RTR‘RRtclear_min_version_cache(RK((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyR‘Gs
cCs8tj|jƒ}|dkr"dStj|ƒ}|ƒS(s$Initialize a Manager object appropriate for this service.

        Use the service name to look up a Manager subclass from the
        configuration and initialize an instance. If no class name
        is configured, just return None.

        :returns: a Manager instance, or None.

        N(RRwRR=RR;(RKR<RN((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyRœPs

cCs|jjƒdS(sÕStart serving this service using loaded configuration.

        Also, retrieve updated port number in case '0' was passed in, which
        indicates a random port should be used.

        :returns: None

        N(RTRi(RK((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyRias	cCs|jjƒdS(s8Stop serving this API.

        :returns: None

        N(RTR„(RK((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyR„lscCs|jjƒdS(sPWait for the service to stop serving this API.

        :returns: None

        N(RTR‰(RK((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyR‰tsN(RRR’R“R=RYR6R‘RœRiR„R‰(((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyR•s&					cCstjtddƒS(Ntrestart_methodtmutate(RtProcessLauncherR%(((s1/usr/lib/python2.7/dist-packages/dmapi/service.pytprocess_launcher}scCs=trttdƒƒ‚ntjt|ddddƒadS(Nsserve() can only be called onceR—iR¨R©(t	_launcherR2RRtlaunchR%(RTR—((s1/usr/lib/python2.7/dist-packages/dmapi/service.pytserve‡scCstjƒdS(N(R¬R‰(((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyR‰s(2R“R{RlR~toslo_concurrencyRtoslo_logRtloggingtoslo_messagingRatoslo_serviceRt
oslo_utilsRR$Rt
dmapi.confRRRt
dmapi.i18nRR	R
RRR
RRt
try_importRtosprofiler_initializert	getLoggerRRRR"R%RRR!R,R4RR•R«R=R¬R®R‰(((s1/usr/lib/python2.7/dist-packages/dmapi/service.pyt<module>sB"	
			Ë_