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    
python3-dmapi / usr / lib / python3 / dist-packages / dmapi / __pycache__ / service.cpython-35.pyc
Size: Mime:


èáþ\¤4ã@södZddlZddlZddlZddlmZddlmZddl	Z
ddlmZddl
mZddlmZddlZddlmZdd	lmZdd
lmZddlmZmZmZmZddlmZdd
lmZddlmZddlmZejdƒZejdƒZ ej!e"ƒZ#ej$j%Z%iZ&dd„Z'dd„Z(dd„Z)dd„Z*Gdd„dej+ƒZ+Gdd„dej+ƒZ,dd„Z-da.dd d!„Z/d"d#„Z0dS)$z:Generic Node base class for all workers that run on hosts.éN)Úprocessutils)Úlog)Úservice)Úimportutils)Úbaserpc)Úcontext)Údebugger)Ú	exception)Ú_Ú_LEÚ_LIÚ_LW)Úrpc)Úutils)Úversion)ÚwsgiÚ
osprofilerzosprofiler.initializercCsJtj|ƒ}|j|_|j|_|j|_d|_|jƒ|S)Nr)ÚobjectsÚServiceÚhostÚbinaryÚtopicZreport_countÚcreate)Zthis_servicerr©rú//usr/lib/python3/dist-packages/dmapi/service.pyÚ_create_service_ref's	
rc
Csf|jtjkrbtjtdƒd|jd|jd|jdtjiƒtj|_|jƒdS)NzKUpdating service version for %(binary)s on %(host)s from %(old)i to %(new)irrÚoldÚnew)	rÚservice_objZSERVICE_VERSIONÚLOGÚinforrrÚsave)rrrrÚ_update_service_ref1s			r"cCs`tr\tjjr\tjjdtdtjƒjƒddd|d|ƒt	j
tdƒƒdS)NÚconfrÚprojectÚdmapirrzOSProfiler is enabled.)rÚCONFZprofilerÚenabledÚinitializerZinit_from_confrÚget_admin_contextZto_dictrr r)rrrrrÚsetup_profiler=sr*cCsIddlj}ddl}|jƒ}|j|jk	rEtdƒ‚dS)Nrzgeventlet hub is not using a monotonic clock - periodic tasks will be affected by drifts of system time.)Z
eventlet.hubsÚhubsÚ	monotonicZget_hubÚclockÚRuntimeError)r+r,ZhubrrrÚ$assert_eventlet_uses_monotonic_clockHsr/csÇeZdZdZdddd‡fdd†Zdd„Zdd„Zd	d
„Zedddddddddd„ƒZ	d
d„Z
‡fdd†Zddd„Zdd„Z
dd„Z‡S)rzõ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.
    Nc	
sûtt|ƒjƒ||_||_||_||_tjƒ|_	t
j|jƒ}||	d|j|
Ž|_d|_
||_||_||_||_|	|
|_|_d|_tjjrçtjƒ}|jtjƒƒt||jƒdS)Nr)ÚsuperrÚ__init__rrrÚmanager_class_nameZservicegroupZAPIÚservicegroup_apirÚimport_classÚmanagerÚ	rpcserverÚreport_intervalÚperiodic_enableÚperiodic_fuzzy_delayÚperiodic_interval_maxZ
saved_argsZsaved_kwargsÚ
backdoor_portÚobjects_baseZ
NovaObjectZindirection_apiZ	conductorZwait_until_readyrr)r*)
Úselfrrrr5r7r8r9r:ÚargsÚkwargsÚ
manager_classZ
conductor_api)Ú	__class__rrr1[s&										zService.__init__c	Cs/dd|jjd|jd|jd|jiS)NzP<%(cls_name)s: host=%(host)s, binary=%(binary)s, manager_class_name=%(manager)s>Úcls_namerrr5)rAÚ__name__rrr2)r=rrrÚ__repr__rs
		zService.__repr__cCsLtƒtjƒ}tjtdƒd|jd|iƒ|jƒ|jj	ƒd|_
tjƒ}t
jj||j|jƒ|_|jržt|jƒnXyt||ƒ|_Wn?tjtjfk
rõt
jj||j|jƒ|_YnX|jjƒ|jdk	r!|j|j_tjd|jƒtjd|jd|jƒ}|jtj|jj|jƒg}|j |jj!ƒt"j#ƒ}t$j%|||ƒ|_&|j&j'ƒ|jj(ƒtjd|jƒ|j)j*|j|j|ƒ|j+rH|j,r t-j.d	|j,ƒ}nd}|j/j0|j1d
|d|j2ƒdS)zuStart the service.

        This includes starting an RPC service, initializing
        periodic tasks, etc.
        z-Starting %(topic)s node (version %(version)s)rrFNz"Creating RPC server for service %sÚserverz0Join ServiceGroup membership for this service %srÚ
initial_delayr:)3r/rZversion_string_with_packagerr rrÚbasic_config_checkr5Z	init_hostZmodel_disconnectedrr)rrZget_by_host_and_binaryrrÚservice_refr"rr	ZServiceTopicExistsZServiceBinaryExistsZpre_start_hookr;ÚdebugÚ	messagingZTargetrZ
BaseRPCAPIZservice_nameÚextendZadditional_endpointsr<ZNovaObjectSerializerrZ
get_serverr6ÚstartZpost_start_hookr3Újoinr8r9ÚrandomÚrandintÚtgZadd_dynamic_timerÚperiodic_tasksr:)r=ZverstrÚctxtÚtargetZ	endpointsZ
serializerrFrrrrL{sP

				


	
		z
Service.startcCs"|jjddƒ}t||ƒS)Nr5)Ú__dict__ÚgetÚgetattr)r=Úkeyr5rrrÚ__getattr__¿szService.__getattr__c	

CsÖ|stj}|s.tjjtjdƒ}|sG|jdƒd}|s\tj	|ƒ}|dkrqtj
}|dkr†tj}|dkr›tj}t
jƒ|||||d|d|d|d|ƒ}	|	S)	a7Instantiates 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

        rzdmapi-éNr7r8r9r:)r&rÚosÚpathÚbasenameÚsysÚargvÚ
rpartitionÚSERVICE_MANAGERSrUr7r8r9rÚinit)
Úclsrrrr5r7r8r9r:rrrrrÃs*				
	zService.createcCsJ|jƒy|jjƒWn(tjk
rEtjtdƒƒYnXdS)zþ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.

        z)Service killed that has no database entryN)ÚstoprHZdestroyr	ZNotFoundrÚwarningr
)r=rrrÚkillìs

zService.killcsƒy|jjƒ|jjƒWntk
r2YnXy|jjƒWn%tk
rktjtdƒƒYnXt	t
|ƒjƒdS)zstop the service and clean up.z*Service error occurred during cleanup_hostN)r6rcÚwaitÚ	Exceptionr5Zcleanup_hostrr	rr0r)r=)rArrrcús


zService.stopFcCs"tjƒ}|jj|d|ƒS)z'Tasks to be run at a periodic interval.Úraise_on_error)rr)r5rQ)r=rhrRrrrrQ
szService.periodic_taskscCsgytjƒWdQRXWnHtk
rb}z(tjtdƒ|ƒtjdƒWYdd}~XnXdS)z7Perform basic config checks before starting processing.Nz"Temporary directory is invalid: %sé)rÚtempdirrgrÚerrorrr]Úexit)r=ÚerrrrGs
zService.basic_config_checkcCs|jjƒdS)zreset the service.N)r5Úreset)r=rrrrnsz
Service.reset)rCÚ
__module__Ú__qualname__Ú__doc__r1rDrLrXÚclassmethodrrercrQrGrnrr)rArrSs 	D&
rc@sgeZdZdZddddd„Zdd„Zdd	„Zd
d„Zdd
„Zdd„Z	dS)ÚWSGIServicez<Provides ability to launch API from a 'paste' configuration.NFcCsy||_d||_d|_|jƒ|_|p=tjƒ|_|jj|ƒ|_	|}t
td|dƒ|_t
td|dƒ|_
t
td|dƒp¯tjƒ|_|jr|jdkrd|}td	ƒd
|dt|jƒi}tj|ƒ‚||_tj||j	d|jd
|j
d|jd|ƒ|_|jj
|_
d|_t||jƒdS)zÝ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

        zdmapi-%sNz	%s_listenz0.0.0.0z%s_listen_portrz
%s_workersrizG%(worker_name)s value of %(workers)s is invalid, must be greater than 0Úworker_nameÚworkersrÚportÚuse_sslÚmax_url_len)ÚnamerrÚ_get_managerr5rÚLoaderÚloaderZload_appZapprVr&rrvrZget_worker_countrur
Ústrr	ZInvalidInputrwZServerrEr;r*)r=ryr|rwrxZwnamertÚmsgrrrr1!s6	
	
								zWSGIService.__init__cCs|jjƒtjjƒdS)zcReset server greenpool size to default and service version cache.

        :returns: None

        N)rErnrrZclear_min_version_cache)r=rrrrnGs
zWSGIService.resetcCs8tj|jƒ}|dkr"dStj|ƒ}|ƒS)a$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`rUrrr4)r=r5r@rrrrzPs

zWSGIService._get_managercCs|jjƒdS)zÕ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)rErL)r=rrrrLas	zWSGIService.startcCs|jjƒdS)z8Stop serving this API.

        :returns: None

        N)rErc)r=rrrrclszWSGIService.stopcCs|jjƒdS)zPWait for the service to stop serving this API.

        :returns: None

        N)rErf)r=rrrrftszWSGIService.wait)
rCrorprqr1rnrzrLrcrfrrrrrss&	rscCstjtddƒS)NÚrestart_methodÚmutate)rZProcessLauncherr&rrrrÚprocess_launcher}srcCs:trttdƒƒ‚tjt|ddddƒadS)Nzserve() can only be called oncerurirr€)Ú	_launcherr.r
rZlaunchr&)rErurrrÚserve‡srƒcCstjƒdS)N)r‚rfrrrrrfsrf)1rqrZrNr]Zoslo_concurrencyrZoslo_logrÚloggingZoslo_messagingrJZoslo_servicerZ
oslo_utilsrr%rZ
dmapi.confrrr	Z
dmapi.i18nr
rrr
rrrrZ
try_importrZosprofiler_initializerÚ	getLoggerrCrr#r&r`rr"r*r/rrsrr‚rƒrfrrrrÚ<module>sB"
Ë_