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 / objects / __pycache__ / service.cpython-39.pyc
Size: Mime:
a

[r`eµ7ã@sÊddlmZddlmZddlmZddlmZddl	m
Z
ddl	mZddlmZddlm
Z
e e¡Zd	Zd
difZGdd
„d
ƒZe
jjGdd
„d
e
je
je
jƒƒZe
jjGdd„de
je
jƒƒZdS)é)Úlog)Úversionutils)Ú	exception)Ú_LW)Úbase)Úfields)Údb)ÚobjectséZcompute_rpcz4.13c@s$eZdZdZiZdZdZdd„ZdS)ÚServicez1.20FécOs d|vrtjddd‚t|_dS©NÚversionÚinitzVersion field is immutable©ÚactionÚreason)rÚObjectActionErrorÚSERVICE_VERSIONr©ÚselfÚargsÚkwargs©rú9/usr/lib/python3.9/site-packages/dmapi/objects/service.pyÚ__init__&s
þúService.__init__N)Ú__name__Ú
__module__Ú__qualname__ÚVERSIONÚ_MIN_VERSION_CACHEÚ_SERVICE_VERSION_CACHINGrrrrrrrs
rcsºeZdZdZejdde ¡ejddejddejdde ¡e ¡ejddejdde 	d¡ej
dde ¡e ¡dœ
ZiZdZ‡fdd	„Z
‡fd
d„Zdd
„Zedd„ƒZdd„Zejdd„ƒZejdd„ƒZejdd„ƒZejdd„ƒZeejd6dd„ƒƒZejd7dd„ƒZejdd„ƒZd d!„Zejd"d#„ƒZ ejd$d%„ƒZ!d&d'„Z"d(d)„Z#ejd*d+„ƒZ$e%d,d-„ƒZ&e%d.d/„ƒZ'eejd8d0d1„ƒƒZ(ejd9d2d3„ƒZ)ejd:d4d5„ƒZ*‡Z+S);rz2.0T)Z	read_only)ZnullableÚComputeNode)
ÚidÚuuidÚhostÚbinaryÚtopicZreport_countÚdisabledÚdisabled_reasonÚavailability_zoneÚcompute_nodeÚlast_seen_upÚforced_downrFcs6d|vrtjddd‚tt|ƒj|i|¤Žt|_dSr
)rrÚsuperrrrrr©Ú	__class__rrrQsþrcs’tt|ƒ |||¡t |¡}|dkr4d|vr4|d=|dkrJd|vrJ|d=|dkr`d|vr`|d=|dkrvd|vrv|d=|d	krŽ| |j||¡dS)
N)éér%)r2ér)r2ér.)r2é
r-)r2é
)r/rÚ!obj_make_compatible_from_manifestrZconvert_version_to_tupleÚ_do_compute_nodeÚ_context)rÚ	primitiveÚtarget_versionÚversion_manifestZ_target_versionr0rrr8Zs 
ÿ

ÿz)Service.obj_make_compatible_from_manifestcCsNz"|d}tj ||d¡d}Wnty6YdS0|j||d|d<dS)Nr#r&r)r<r=r,)r	ÚComputeNodeListÚget_all_by_hostÚ	ExceptionZobj_to_primitive)rÚcontextr;r=r<Zcomputerrrr9ksÿÿþzService._do_compute_nodecCs‚d}|jD]d}||vr ||vr q
|dkr,q
q
|dkrLt|t |¡||ƒq
|dkrb| |¡sbq
q
||||<q
||_| ¡|S)N)r+r,rr%)rÚsetattrrZget_attrnameÚgetr:Zobj_reset_changes)rAÚserviceÚ
db_serviceZ
allow_missingÚkeyrrrÚ_from_db_objectvs
zService._from_db_objectcCs†|jstjd| ¡d‚t d|| ¡|jdœ¡|dkrLtjdd|d‚|jdkrjt	j
 |j|j¡}ntj
|jd	‚|d
|_dS)NÚ
obj_load_attr)ÚmethodZobjtypez-Lazy-loading '%(attr)s' on %(name)s id %(id)s)ÚattrÚnamer$r,zattribute %s not lazy-loadablerztvault-contego)Ú
service_idr)r:rZOrphanedObjectErrorZobj_nameÚLOGÚdebugr$rr'r	r>r?r&ZServiceNotFoundr,)rÚattrnameZ
compute_nodesrrrrHŠs*ÿþÿþ
ÿzService.obj_load_attrcCst ||¡}| ||ƒ|¡S©N)rZservice_getrG)ÚclsrArLrErrrÚ	get_by_idŸszService.get_by_idcCst ||¡}| ||ƒ|¡SrP)rZservice_get_by_uuidrG)rQrAZservice_uuidrErrrÚget_by_uuid¤szService.get_by_uuidcCst |||¡}| ||ƒ|¡SrP)rZservice_get_by_host_and_topicrG)rQrAr&r(rErrrÚget_by_host_and_topic©szService.get_by_host_and_topiccCs:zt |||¡}Wntjy(YdS0| ||ƒ|¡SrP)rÚservice_get_by_host_and_binaryrZHostBinaryNotFoundrG©rQrAr&r'rErrrÚget_by_host_and_binary®sÿzService.get_by_host_and_binarycCst ||¡SrP)rZservice_get_by_compute_host)rAr&Ú	use_slaverrrÚ_db_service_get_by_compute_host·sz'Service._db_service_get_by_compute_hostcCs |j|||d}| ||ƒ|¡S©N©rX)rYrG)rQrAr&rXrErrrÚget_by_compute_host¼sÿzService.get_by_compute_hostcCst |||¡}| ||ƒ|¡SrP)rrUrGrVrrrÚget_by_argsÂszService.get_by_argscCsJ| d¡sdS| d¡sdS| |j|j¡}||jkrFtj|j|d‚dS)aEnforce that we are not older that the minimum version.
        This is a loose check to avoid creating or updating our service
        record if we would do so with a version that is older that the current
        minimum of all services. This could happen if we were started with
        older code by accident, either due to a rollback or an old and
        un-updated node suddenly coming back onto the network.
        There is technically a race here between the check and the update,
        but since the minimum version should always roll forward and never
        backwards, we don't need to worry about doing it atomically. Further,
        the consequence for getting this wrong is minor, in that we'll just
        fail to send messages that other services understand.
        rNr')ZthisverÚminver)Úobj_attr_is_setÚget_minimum_versionr:r'rrZ
ServiceTooOld)rr^rrrÚ_check_minimum_versionÇs


ÿzService._check_minimum_versioncCsv| d¡rtjddd‚| ¡| ¡}d|vrFt ¡|d<|d|_t 	|j
|¡}| |j
||¡| t
jj¡dS)Nr$Úcreatezalready createdrr%)r_rrraÚobj_get_changesZ	uuidutilsZ
generate_uuidr%rZservice_creater:rGÚ_send_notificationrÚNotificationActionZCREATE©rÚupdatesrErrrrbÝs
ÿ
zService.createcCsL| ¡}| dd¡| ¡t |j|j|¡}| |j||¡| |¡dS)Nr$)	rcÚpoprarZservice_updater:r$rGÚ _send_status_update_notificationrfrrrÚsaveíszService.savecCs(t| ¡ƒ hd£¡r$| tjj¡dS)N>r*r)r.)ÚsetÚkeysÚintersectionrdrreZUPDATE)rrgrrrri÷sÿz(Service._send_status_update_notificationcCs>t |¡}tjtj |¡tjd|dtjj	|d 
|j¡dS)NrD)Úobjectr)Z	publisherZ
event_typeÚpriorityÚpayload)Zservice_notificationZServiceStatusPayloadZServiceStatusNotificationZnotificationZNotificationPublisherZfrom_service_objZ	EventTyperZNotificationPriorityÚINFOÚemitr:)rrrprrrrdüs
ÿþùùzService._send_notificationcCs"t |j|j¡| tjj¡dSrP)rZservice_destroyr:r$rdrreZDELETE)rrrrÚdestroyszService.destroycCs| ¡d|_dS)NT)Úclear_min_version_cacher"©rQrrrÚenable_min_version_cachesz Service.enable_min_version_cachecCs
i|_dSrP©r!rurrrrtszService.clear_min_version_cachecCst ||¡SrP)rZservice_get_minimum_version)rAÚbinariesrXrrrÚ_db_service_get_minimum_versionsz'Service._db_service_get_minimum_versioncs¶tdd„|Dƒƒs2t dd |¡¡tjddd‚ˆjrNt‡fdd„|Dƒƒr‚ˆj|||d	}|r”d
d„| 	¡Dƒ}ˆj
 |¡n‡fdd„|Dƒ}|r¦t| 
¡ƒ}nd
}t|ƒ}|S)Ncss|]}| d¡VqdS)znova-N)Ú
startswith©Ú.0r'rrrÚ	<genexpr>óz4Service.get_minimum_version_multi.<locals>.<genexpr>z>get_minimum_version called with likely-incorrect binaries `%s'ú,r`zInvalid binary prefixrc3s|]}|ˆjvVqdSrPrwr{rurrr}#sÿr[cSsi|]\}}||pd“qS)rr)r|r'rrrrÚ
<dictcomp>(sÿz5Service.get_minimum_version_multi.<locals>.<dictcomp>csi|]}|ˆj|“qSrrwr{rurrr€-sÿr)ÚallrMZwarningÚjoinrrr"ÚanyryÚitemsr!ÚupdateÚminÚvaluesÚint)rQrArxrXZmin_versionsrrrurÚget_minimum_version_multis8ÿÿÿÿÿþ
ÿz!Service.get_minimum_version_multicCs|j||g|dSrZ)r‰)rQrAr'rXrrrr`8s
ÿzService.get_minimum_version)F)F)F)F)F),rrrr rZIntegerFieldZ	UUIDFieldZStringFieldZBooleanFieldZObjectFieldZ
DateTimeFieldr!r"rr8r9ÚstaticmethodrGrHrÚremotable_classmethodrRrSrTrWrZselect_db_reader_moderYr\r]raZ	remotablerbrjrirdrsÚclassmethodrvrtryr‰r`Ú
__classcell__rrr0rr9st






ó	







	


c@sheZdZdZde d¡iZejdd„ƒZejddd„ƒZ	ejd	d
„ƒZ
ejddd
„ƒZejdd„ƒZdS)ÚServiceListz1.0r	rcCs"t ||¡}t |||ƒtj|¡SrP)rZservice_get_all_by_topicrÚ
obj_make_listr	r)rQrAr(Údb_servicesrrrÚget_by_topicGsÿzServiceList.get_by_topicFcCs&tj|||d}t |||ƒtj|¡S)N©Úinclude_disabled)rZservice_get_all_by_binaryrrr	r)rQrAr'r“rrrrÚ
get_by_binaryMsÿÿzServiceList.get_by_binarycCs"t ||¡}t |||ƒtj|¡SrP)rZservice_get_all_by_hostrrr	r)rQrAr&rrrrÚget_by_hostTsÿzServiceList.get_by_hostNcCs4tj||d}|rt ||¡}t |||ƒtj|¡S)N)r))rZservice_get_allZavailability_zonesZset_availability_zonesrrr	r)rQrAr)Z	set_zonesrrrrÚget_allZsÿÿzServiceList.get_allcCs&tj||dd}t |||ƒtj|¡S)NFr’)rZ#service_get_all_computes_by_hv_typerrr	r)rQrAZhv_typerrrrÚget_all_computes_by_hv_typecsÿÿz'ServiceList.get_all_computes_by_hv_type)F)NF)
rrrr rZListOfObjectsFieldrr‹r‘r”r•r–r—rrrrrŽ?s
ÿ

rŽN)Zoslo_logrZloggingZ
oslo_utilsrZdmapirZ
dmapi.i18nrZ
dmapi.objectsrrrr	Z	getLoggerrrMrZSERVICE_VERSION_HISTORYrZContegoObjectRegistryÚregisterZContegoPersistentObjectZ
ContegoObjectZContegoObjectDictCompatZObjectListBaserŽrrrrÚ<module>s(
þÿ