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-el9 / usr / lib / python3.9 / site-packages / dmapi / __pycache__ / service.cpython-39.pyc
Size: Mime:
a

[r`e‹;ã@sœdZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZ
ddlmZddlmZddlmZdd	lmZddlZdd
lmZmZmZmZmZmZm Z m!Z!m"Z"ddlm#Z#ddl$m%Z%m&Z&m'Z'm(Z(e )d
¡Z*e )d¡Z+e )d¡Z,e -e.¡Z/ej0j1Z1iZ2e
j3dddde
j3ddddgZ4dd„Z5dd„Z6dd„Z7dd„Z8Gdd „d ej9ƒZ9Gd!d"„d"ej9ƒZ:d#d$„Z;da<d+d%d&„Z=d'd(„Z>d,d)d*„Z?dS)-z:Generic Node base class for all workers that run on hosts.éN)Úprocessutils)Úcfg)Úoptions)Úlog©Úopts©Úservice)Úimportutils)	ÚbaserpcÚcontextÚdebuggerÚ	exceptionÚprofilerÚrpcÚutilsÚversionÚwsgi)Údefaults)Ú_Ú_LEÚ_LIÚ_LWzosprofiler.optsÚ
osprofilerzosprofiler.initializerZhttp_timeoutiXzETimeout seconds for HTTP requests. Set it to None to disable timeout.)ÚdefaultÚhelpZevaluation_intervalé<zoPeriod of evaluation cycle, should be >= than configured pipeline interval for collection of underlying meters.cCs4t |¡}|j|_|j|_|j|_d|_| ¡|S)Nr)ÚobjectsÚServiceÚhostÚbinaryÚtopicZreport_countÚcreate)Zthis_servicerr	©r#ú1/usr/lib/python3.9/site-packages/dmapi/service.pyÚ_create_service_ref4s
r%cCsB|jtjkr>t tdƒ|j|j|jtjdœ¡tj|_| ¡dS)NzKUpdating service version for %(binary)s on %(host)s from %(old)i to %(new)i)r rÚoldÚnew)	rÚservice_objZSERVICE_VERSIONÚLOGÚinforr rZsaverr#r#r$Ú_update_service_ref>s
ýþr+cCs<tr8tjjr8tjjtt ¡ ¡d||dt	 
tdƒ¡dS)NÚdmapi)ÚconfrÚprojectr	rzOSProfiler is enabled.)rÚCONFrZenabledZinitializerZinit_from_confrÚget_admin_contextZto_dictr)r*r)r rr#r#r$Úsetup_profilerJs
ûr1cCs4ddlm}ddl}| ¡}|j|jur0tdƒ‚dS)Nrzgeventlet hub is not using a monotonic clock - periodic tasks will be affected by drifts of system time.)Z
eventlet.hubsÚhubsÚ	monotonicZget_hubZclockÚRuntimeError)r2r3Zhubr#r#r$Ú$assert_eventlet_uses_monotonic_clockUsÿr5c	sveZdZdZd‡fdd„	Zdd„Zdd„Zd	d
„Zeddd„ƒZ	d
d„Z
‡fdd„Zddd„Zdd„Z
dd„Z‡ZS)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|ƒ ¡||_||_||_||_t ¡|_	t
 |j¡}||	d|ji|
¤Ž|_d|_
||_||_||_||_|	|
|_|_d|_tjjr¢t ¡}| t ¡¡t||jƒdS)Nr)ÚsuperrÚ__init__rr r!Ú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_readyrr0r1)
Úselfrr r!r;r=r>r?r@ÚargsÚkwargsÚ
manager_classZ
conductor_api©Ú	__class__r#r$r7hs&
zService.__init__cCsd|jj|j|j|jdœS)NzP<%(cls_name)s: host=%(host)s, binary=%(binary)s, manager_class_name=%(manager)s>)Úcls_namerr r;)rHÚ__name__rr r8©rCr#r#r$Ú__repr__süÿzService.__repr__c	Cs¤tƒt ¡}t tdƒ|j|dœ¡| ¡|j 	¡d|_
t ¡}t
j ||j|j¡|_|jrnt|jƒnBzt||ƒ|_Wn0tjtjfy®t
j ||j|j¡|_Yn0|j ¡|jdurÎ|j|j_t d|j¡tj|j|jd}|jt |jj|j¡g}|  |jj!¡t" #¡}t$ %|||¡|_&|j& '¡|j (¡t d|j¡|j) *|j|j|¡|j+r |j,r†t- .¡ /d|j,¡}nd}|j0j1|j2||j3d	dS)
zuStart the service.

        This includes starting an RPC service, initializing
        periodic tasks, etc.
        z-Starting %(topic)s node (version %(version)s))r!rFNz"Creating RPC server for service %s)r!Úserverz0Join ServiceGroup membership for this service %sr)Ú
initial_delayr@)4r5rZversion_string_with_packager)r*rr!Úbasic_config_checkr;Z	init_hostZmodel_disconnectedrr0rrZget_by_host_and_binaryrr Úservice_refr+r%rZServiceTopicExistsZServiceBinaryExistsZpre_start_hookrAÚdebugÚ	messagingZTargetrZ
BaseRPCAPIZservice_nameÚextendZadditional_endpointsrBZNovaObjectSerializerrZ
get_serverr<ÚstartZpost_start_hookr9Újoinr>r?ÚrandomZSystemRandomZrandintÚtgZadd_dynamic_timerÚperiodic_tasksr@)rCZverstrÚctxtÚtargetZ	endpointsZ
serializerrNr#r#r$rTˆsb

ÿ

ÿÿ

ÿ


þ

ÿ
ÿ
ýz
Service.startcCs|j dd¡}t||ƒS)Nr;)Ú__dict__ÚgetÚgetattr)rCÚkeyr;r#r#r$Ú__getattr__ÎszService.__getattr__c	

CsŽ|s
tj}|s tj tjd¡}|s2| d¡d}|s@t 	|¡}|durNtj
}|dur\tj}|durjtj}t
 ¡|||||||||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-éN)r=r>r?r@)r/rÚosÚpathÚbasenameÚsysÚargvÚ
rpartitionÚSERVICE_MANAGERSr\r=r>r?r
Úinit)
Úclsrr r!r;r=r>r?r@r(r#r#r$r"Òs,

üzService.createcCs>| ¡z|j ¡Wn"tjy8t tdƒ¡Yn0dS)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)ÚstoprPZdestroyrZNotFoundr)ZwarningrrKr#r#r$Úkillûs
zService.killc
sŽz|j ¡|j ¡Wn2tyJ}zt t|ƒ¡WYd}~n
d}~00z|j ¡Wn tyzt tdƒ¡Yn0t	t
|ƒ ¡dS)zstop the service and clean up.Nz*Service error occurred during cleanup_host)r<rjÚwaitÚ	Exceptionr)rrr;Zcleanup_hostr6r)rCÚexrGr#r$rj	s
zService.stopFcCst ¡}|jj||dS)z'Tasks to be run at a periodic interval.)Úraise_on_error)rr0r;rX)rCrorYr#r#r$rXszService.periodic_tasksc
Cspz,t ¡Wdƒn1s 0YWn>tyj}z&t tdƒ|¡t d¡WYd}~n
d}~00dS)z7Perform basic config checks before starting processing.Nz"Temporary directory is invalid: %sé)rZtempdirrmr)ÚerrorrrdÚexit)rCÚer#r#r$rOs
"zService.basic_config_checkcCs|j ¡dS)zreset the service.N)r;ÚresetrKr#r#r$rt)sz
Service.reset)NNNN)NNNNNNNN)F)rJÚ
__module__Ú__qualname__Ú__doc__r7rLrTr_Úclassmethodr"rkrjrXrOrtÚ
__classcell__r#r#rGr$r`s$þ	Fþ(

rc@sBeZdZdZddd„Zdd„Zdd	„Zd
d„Zdd
„Zdd„Z	dS)ÚWSGIServicez<Provides ability to launch API from a 'paste' configuration.NFcCsþ||_d||_d|_| ¡|_|p*t ¡|_|j |¡|_	|}t
td|dƒ|_t
td|dƒ|_
t
td|dƒpzt ¡|_|jr¸|jdkr¸d|}td	ƒ|t|jƒd
œ}t |¡‚||_tj||j	|j|j
|j|d|_|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_workersrpzG%(worker_name)s value of %(workers)s is invalid, must be greater than 0)Úworker_nameÚworkers)rÚportÚuse_sslÚmax_url_len)Únamer r!Ú_get_managerr;rÚLoaderÚloaderZload_appZappr]r/rr}rZget_worker_countr|rÚstrrZInvalidInputr~ZServerrMrAr1)rCr€rƒr~rZwnamer{Úmsgr#r#r$r71s>

ÿÿþ
û
zWSGIService.__init__cCs|j ¡tj ¡dS)zcReset server greenpool size to default and service version cache.

        :returns: None

        N)rMrtr(rZclear_min_version_cacherKr#r#r$rtWs
zWSGIService.resetcCs(t |j¡}|durdSt |¡}|ƒ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)rgr\r r
r:)rCr;rFr#r#r$r`s


zWSGIService._get_managercCs|j ¡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)rMrTrKr#r#r$rTqs	zWSGIService.startcCs|j ¡dS)z8Stop serving this API.

        :returns: None

        N)rMrjrKr#r#r$rj|szWSGIService.stopcCs|j ¡dS)zPWait for the service to stop serving this API.

        :returns: None

        N)rMrlrKr#r#r$rl„szWSGIService.wait)NFN)
rJrurvrwr7rtrrTrjrlr#r#r#r$rz.s
&	rzcCstjtddS)NÚmutate)Úrestart_method)r	ZProcessLauncherr/r#r#r#r$Úprocess_launchersrˆcCs&trttdƒƒ‚tjt|dddadS)Nzserve() can only be called oncerpr†)r|r‡)Ú	_launcherr4rr	Zlaunchr/)rMr|r#r#r$Úserve—s

ÿrŠcCst ¡dS)N)r‰rlr#r#r#r$rl srlc	Csît ¡}t ¡t |¡|jgd¢}tj|dt 	¡t
 |¡trTt |¡tj|t
j t
j t
j t¡dd¡¡dddlm}| ¡D]&\}}|jt|ƒ|dkr°dn|d	q’||d
d|dt |d
¡t |¡t d
¡|S)
N)z
futurist=INFOzkeystoneclient=INFOzoslo_db.sqlalchemy=WARNzcotyledon=INFO)Údefault_log_levelsZapizpolicy.json)Zpolicy_filerrZDEFAULT)Úgroupr,T)r.Zvalidate_default_valuesZdefault_config_files)rZ
ConfigOptsÚ	oslo_i18nZenable_lazyÚloggingZregister_optionsr‹Úset_defaultsrZset_cors_middleware_defaultsÚ
db_optionsÚ
profiler_optsÚpolicy_optsrarbÚabspathrUÚdirnameÚ__file__r,rZ	list_optsZ
register_optsÚlistZsetuprrRZset_transport_defaults)reZconfig_filesr-Z
log_levelsrrŒrr#r#r$Úprepare_service¤s6
ÿÿ	

ÿ
ÿÿ

r—)N)NN)@rwrarVrdrZoslo_messagingrRZoslo_concurrencyrZoslo_configrZoslo_dbrrZoslo_logrrŽZoslo_policyrr’Zoslo_servicer	Z
oslo_utilsr
Z
dmapi.confr,rrr
rrrrrrrZ
dmapi.i18nrrrrZ
try_importr‘rZosprofiler_initializerZ	getLoggerrJr)r-r/rgZIntOptZOPTSr%r+r1r5rrzrˆr‰rŠrlr—r#r#r#r$Ú<module>sV,



þþû

O_