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.6 / site-packages / dmapi / __pycache__ / service.cpython-36.pyc
Size: Mime:
3

ÿn‚a‹;ã@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(ej)d
ƒZ*ej)dƒZ+ej)dƒZ,ej-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.cCs4tj|ƒ}|j|_|j|_|j|_d|_|jƒ|S)Nr)ÚobjectsÚServiceÚhostÚbinaryÚtopicZreport_countÚcreate)Zthis_servicer
r©r!ú/usr/lib/python3.6/service.pyÚ_create_service_ref4s
r#cCsB|jtjkr>tjtdƒ|j|j|jtjdœƒtj|_|jƒdS)NzKUpdating service version for %(binary)s on %(host)s from %(old)i to %(new)i)rrÚoldÚnew)	rÚservice_objZSERVICE_VERSIONÚLOGÚinforrrZsave)rr!r!r"Ú_update_service_ref>s
r)cCs<tr8tjjr8tjjttjƒjƒd||dt	j
tdƒƒdS)NÚdmapi)Úconfr
ÚprojectrrzOSProfiler is enabled.)rÚCONFr
ZenabledZinitializerZinit_from_confr
Úget_admin_contextZto_dictr'r(r)rrr!r!r"Úsetup_profilerJs
r/cCs2ddlj}ddl}|jƒ}|j|jk	r.tdƒ‚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)r0r1Zhubr!r!r"Ú$assert_eventlet_uses_monotonic_clockUs
r3c	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|ƒjƒ||_||_||_||_tjƒ|_	t
j|jƒ}||	d|ji|
—Ž|_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_readyr
r.r/)
Úselfrrrr9r;r<r=r>ÚargsÚkwargsÚ
manager_classZ
conductor_api)Ú	__class__r!r"r5hs&
zService.__init__cCsd|jj|j|j|jdœS)NzP<%(cls_name)s: host=%(host)s, binary=%(binary)s, manager_class_name=%(manager)s>)Zcls_namerrr9)rEÚ__name__rrr6)rAr!r!r"Ú__repr__s
zService.__repr__c
Cs¦tƒtjƒ}tjtdƒ|j|dœƒ|jƒ|jj	ƒd|_
tjƒ}t
jj||j|jƒ|_|jrnt|jƒnDyt||ƒ|_Wn2tjtjfk
r°t
jj||j|jƒ|_YnX|jjƒ|jdk	rÐ|j|j_tjd|jƒtj|j|jd}|jtj|jj|jƒg}|j |jj!ƒt"j#ƒ}t$j%|||ƒ|_&|j&j'ƒ|jj(ƒtjd|jƒ|j)j*|j|j|ƒ|j+r¢|j,rˆt-j.ƒj/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))rrFNz"Creating RPC server for service %s)rÚserverz0Join ServiceGroup membership for this service %sr)Ú
initial_delayr>)4r3rZversion_string_with_packager'r(rrÚbasic_config_checkr9Z	init_hostZmodel_disconnectedr
r.rrZget_by_host_and_binaryrrÚservice_refr)r#rZServiceTopicExistsZServiceBinaryExistsZpre_start_hookr?ÚdebugÚ	messagingZTargetr	Z
BaseRPCAPIZservice_nameÚextendZadditional_endpointsr@ZNovaObjectSerializerrZ
get_serverr:ÚstartZpost_start_hookr7Újoinr<r=ÚrandomZSystemRandomZrandintZtgZadd_dynamic_timerÚperiodic_tasksr>)rAZverstrÚctxtÚtargetZ	endpointsZ
serializerrIr!r!r"rOˆsR









z
Service.startcCs|jjddƒ}t||ƒS)Nr9)Ú__dict__ÚgetÚgetattr)rAÚkeyr9r!r!r"Ú__getattr__ÎszService.__getattr__c	

CsŽ|s
tj}|s tjjtjdƒ}|s2|jdƒd}|s@tj	|ƒ}|dkrNtj
}|dkr\tj}|dkrjtj}t
jƒ|||||||||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_MANAGERSrVr;r<r=rZinit)
Úclsrrrr9r;r<r=r>r&r!r!r"r Òs*

zService.createcCs@|jƒy|jjƒWn$tjk
r:tjtdƒƒ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)ÚstoprKZdestroyrZNotFoundr'Zwarningr)rAr!r!r"Úkillûs
zService.killcsŽy|jjƒ|jjƒWn0tk
rH}ztjt|ƒƒWYdd}~XnXy|jjƒWn"tk
rztjtdƒƒYnXt	t
|ƒjƒdS)zstop the service and clean up.Nz*Service error occurred during cleanup_host)r:rcÚwaitÚ	Exceptionr'rrr9Zcleanup_hostr4r)rAZex)rEr!r"rc	s
zService.stopFcCstjƒ}|jj||dS)z'Tasks to be run at a periodic interval.)Úraise_on_error)r
r.r9rR)rArgrSr!r!r"rRszService.periodic_taskscCsZytjƒWdQRXWn<tk
rT}z tjtdƒ|ƒtjdƒWYdd}~XnXdS)z7Perform basic config checks before starting processing.Nz"Temporary directory is invalid: %sé)rZtempdirrfr'Úerrorrr^Úexit)rAÚer!r!r"rJs
zService.basic_config_checkcCs|jjƒdS)zreset the service.N)r9Úreset)rAr!r!r"rl)sz
Service.reset)NNNN)NNNNNNNN)F)rFÚ
__module__Ú__qualname__Ú__doc__r5rGrOrYÚclassmethodr rdrcrRrJrlÚ
__classcell__r!r!)rEr"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|_|jƒ|_|p*tjƒ|_|jj|ƒ|_	|}t
td|dƒ|_t
td|dƒ|_
t
td|dƒpztjƒ|_|jr¸|jdkr¸d|}td	ƒ|t|jƒd
œ}tj|ƒ‚||_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_workersrhzG%(worker_name)s value of %(workers)s is invalid, must be greater than 0)Úworker_nameÚworkers)rÚportÚuse_sslÚmax_url_len)ÚnamerrÚ_get_managerr9rÚLoaderÚloaderZload_appZapprWr-rrurZget_worker_countrtrÚstrrZInvalidInputrvZServerrHr?r/)rArxr{rvrwZwnamersÚmsgr!r!r"r51s6





zWSGIService.__init__cCs|jjƒtjjƒdS)zcReset server greenpool size to default and service version cache.

        :returns: None

        N)rHrlr&rZclear_min_version_cache)rAr!r!r"rlWs
zWSGIService.resetcCs(tj|jƒ}|dkrdStj|ƒ}|ƒ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)rarVrrr8)rAr9rDr!r!r"ry`s


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)rHrO)rAr!r!r"rOqs	zWSGIService.startcCs|jjƒdS)z8Stop serving this API.

        :returns: None

        N)rHrc)rAr!r!r"rc|szWSGIService.stopcCs|jjƒdS)zPWait for the service to stop serving this API.

        :returns: None

        N)rHre)rAr!r!r"re„szWSGIService.wait)NFN)
rFrmrnror5rlryrOrcrer!r!r!r"rr.s
&	rrcCstjtddS)NÚmutate)Úrestart_method)rZProcessLauncherr-r!r!r!r"Úprocess_launchersr€cCs&trttdƒƒ‚tjt|dddadS)Nzserve() can only be called oncerhr~)rtr)Ú	_launcherr2rrZlaunchr-)rHrtr!r!r"Úserve—s
r‚cCstjƒdS)N)rrer!r!r!r"re srecCsötjƒ}tjƒtj|ƒ|jddddg}tj|dtj	ƒt
j|ƒtrXtj|ƒtj|t
jjt
jjt
jjtƒddƒƒdd	d
lm}x2|jƒD]&\}}|jt|ƒ|dkr¶dn|dq˜W||d
d|dtj|d
ƒtj|ƒtjd
ƒ|S)Nz
futurist=INFOzkeystoneclient=INFOzoslo_db.sqlalchemy=WARNzcotyledon=INFO)Údefault_log_levelsZapizpolicy.json)Zpolicy_filer)rZDEFAULT)Úgroupr*T)r,Zvalidate_default_valuesZdefault_config_files)rZ
ConfigOptsÚ	oslo_i18nZenable_lazyÚloggingZregister_optionsrƒZset_defaultsrZset_cors_middleware_defaultsÚ
db_optionsÚ
profiler_optsÚpolicy_optsr[r\ÚabspathrPÚdirnameÚ__file__r*rZ	list_optsZ
register_optsÚlistZsetupr
rMZset_transport_defaults)r_Zconfig_filesr+Z
log_levelsrr„rr!r!r"Úprepare_service¤s2





rŽ)N)NN)@ror[rQr^r…Zoslo_messagingrMZoslo_concurrencyrZoslo_configrZoslo_dbrr‡Zoslo_logrr†Zoslo_policyrr‰Zoslo_servicerZ
oslo_utilsrZ
dmapi.confr*r	r
rrr
rrrrrZ
dmapi.i18nrrrrZ
try_importrˆrZosprofiler_initializerZ	getLoggerrFr'r+r-raZIntOptZOPTSr#r)r/r3rrrr€rr‚rerŽr!r!r!r"Ú<module>sP,





O_