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 / objects / __pycache__ / service.cpython-36.opt-1.pyc
Size: Mime:
3

ÿn‚aµ7ã@sÊddlmZddlmZddlmZddlmZddl	m
Z
ddl	mZddlmZddlm
Z
ejeƒ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|krtjddd‚t|_dS)NÚversionÚinitzVersion field is immutable)ÚactionÚreason)rÚObjectActionErrorÚSERVICE_VERSIONr
)ÚselfÚargsÚkwargs©rú/usr/lib/python3.6/service.pyÚ__init__&s

zService.__init__N)Ú__name__Ú
__module__Ú__qualname__ÚVERSIONÚ_MIN_VERSION_CACHEÚ_SERVICE_VERSION_CACHINGrrrrrrrs
rcsºeZdZdZejddejƒejddejddejddejƒejƒejddejddej	dƒej
ddejƒejƒ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_downr
Fcs2d|krtjddd‚tt|ƒj||Žt|_dS)Nr
rzVersion field is immutable)rr)rrÚsuperrrrr
)rrr)Ú	__class__rrrQszService.__init__cs’tt|ƒj|||ƒtj|ƒ}|dkr4d|kr4|d=|dkrJd|krJ|d=|d
kr`d|kr`|d=|dkrvd	|krv|d	=|dkrŽ|j|j||ƒdS)Néér!ér
ér*é
r)é
)r-r.)r-r/)r-r0)r-r1)r-r2)r+rÚ!obj_make_compatible_from_manifestrZconvert_version_to_tupleÚ_do_compute_nodeÚ_context)rÚ	primitiveÚtarget_versionÚversion_manifestZ_target_version)r,rrr3Zs



z)Service.obj_make_compatible_from_manifestcCsNy"|d}tjj||dƒd}Wntk
r6dSX|j||d|d<dS)Nrr"r)r7r8r()r	ÚComputeNodeListÚget_all_by_hostÚ	ExceptionZobj_to_primitive)rÚcontextr6r8r7Zcomputerrrr4kszService._do_compute_nodecCsˆd}xp|jD]f}||kr"||kr"q|dkr.qq|dkrNt|tj|ƒ||ƒq|dkrf|j|ƒrfqq||||<qW||_|jƒ|S)Nr'r(r
r!)r')rÚsetattrrZget_attrnameÚgetr5Zobj_reset_changes)r<ÚserviceÚ
db_serviceZ
allow_missingÚkeyrrrÚ_from_db_objectvszService._from_db_objectcCs†|jstjd|jƒd‚tjd||jƒ|jdœƒ|dkrLtjdd|d‚|jdkrjt	j
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-loadable)rrztvault-contego)Ú
service_idr)r5rZOrphanedObjectErrorZobj_nameÚLOGÚdebugr rr#r	r9r:r"ZServiceNotFoundr()rZattrnameZ
compute_nodesrrrrCŠs 
zService.obj_load_attrcCstj||ƒ}|j||ƒ|ƒS)N)rZservice_getrB)Úclsr<rGr@rrrÚ	get_by_idŸszService.get_by_idcCstj||ƒ}|j||ƒ|ƒS)N)rZservice_get_by_uuidrB)rJr<Zservice_uuidr@rrrÚget_by_uuid¤szService.get_by_uuidcCstj|||ƒ}|j||ƒ|ƒS)N)rZservice_get_by_host_and_topicrB)rJr<r"r$r@rrrÚget_by_host_and_topic©szService.get_by_host_and_topiccCs:ytj|||ƒ}Wntjk
r(dSX|j||ƒ|ƒS)N)rÚservice_get_by_host_and_binaryrZHostBinaryNotFoundrB)rJr<r"r#r@rrrÚget_by_host_and_binary®szService.get_by_host_and_binarycCstj||ƒS)N)rZservice_get_by_compute_host)r<r"Ú	use_slaverrrÚ_db_service_get_by_compute_host·sz'Service._db_service_get_by_compute_hostcCs |j|||d}|j||ƒ|ƒS)N)rP)rQrB)rJr<r"rPr@rrrÚget_by_compute_host¼szService.get_by_compute_hostcCstj|||ƒ}|j||ƒ|ƒS)N)rrNrB)rJr<r"r#r@rrrÚget_by_argsÂszService.get_by_argscCsJ|jdƒsdS|jdƒsdS|j|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.
        r
Nr#)ZthisverÚminver)Úobj_attr_is_setÚget_minimum_versionr5r#r
rZ
ServiceTooOld)rrTrrrÚ_check_minimum_versionÇs


zService._check_minimum_versioncCsv|jdƒrtjddd‚|jƒ|jƒ}d|krFtjƒ|d<|d|_tj	|j
|ƒ}|j|j
||ƒ|jt
jjƒdS)Nr Úcreatezalready created)rrr!)rUrrrWÚobj_get_changesZ	uuidutilsZ
generate_uuidr!rZservice_creater5rBÚ_send_notificationrÚNotificationActionZCREATE)rÚupdatesr@rrrrXÝs

zService.createcCsL|jƒ}|jddƒ|jƒtj|j|j|ƒ}|j|j||ƒ|j|ƒdS)Nr )	rYÚpoprWrZservice_updater5r rBÚ _send_status_update_notification)rr\r@rrrÚsaveíszService.savecCs*t|jƒƒjdddhƒr&|jtjjƒdS)Nr%r&r*)ÚsetÚkeysÚintersectionrZrr[ZUPDATE)rr\rrrr^÷sz(Service._send_status_update_notificationcCs>tj|ƒ}tjtjj|ƒtjd|dtjj	|dj
|jƒdS)Nr?)Úobjectr)Z	publisherZ
event_typeZpriorityÚpayload)Zservice_notificationZServiceStatusPayloadZServiceStatusNotificationZnotificationZNotificationPublisherZfrom_service_objZ	EventTyperZNotificationPriorityÚINFOÚemitr5)rrrdrrrrZüs
zService._send_notificationcCs"tj|j|jƒ|jtjjƒdS)N)rZservice_destroyr5r rZrr[ZDELETE)rrrrÚdestroyszService.destroycCs|jƒd|_dS)NT)Úclear_min_version_cacher)rJrrrÚenable_min_version_cachesz Service.enable_min_version_cachecCs
i|_dS)N)r)rJrrrrhszService.clear_min_version_cachecCstj||ƒS)N)rZservice_get_minimum_version)r<ÚbinariesrPrrrÚ_db_service_get_minimum_versionsz'Service._db_service_get_minimum_versioncs¸tdd„|Dƒƒs2tjddj|ƒƒtjddd‚ˆjsPt‡fdd„|Dƒƒr„ˆj|||d	}|r–d
d„|j	ƒDƒ}ˆj
j|ƒn‡fdd„|Dƒ}|r¨t|j
ƒƒ}nd
}t|ƒ}|S)Ncss|]}|jdƒVqdS)znova-N)Ú
startswith)Ú.0r#rrrú	<genexpr>sz4Service.get_minimum_version_multi.<locals>.<genexpr>z>get_minimum_version called with likely-incorrect binaries `%s'ú,rVzInvalid binary prefix)rrc3s|]}|ˆjkVqdS)N)r)rmr#)rJrrrn#s)rPcSsi|]\}}|pd|“qS)rr)rmr#r
rrrú
<dictcomp>(sz5Service.get_minimum_version_multi.<locals>.<dictcomp>csi|]}ˆj||“qSr)r)rmr#)rJrrrp-sr)ÚallrHZwarningÚjoinrrrÚanyrkÚitemsrÚupdateÚminÚvaluesÚint)rJr<rjrPZmin_versionsr
r)rJrÚget_minimum_version_multis*

z!Service.get_minimum_version_multicCs|j||g|dS)N)rP)ry)rJr<r#rPrrrrV8s
zService.get_minimum_version)F)F)F)F)F),rrrrrZIntegerFieldZ	UUIDFieldZStringFieldZBooleanFieldZObjectFieldZ
DateTimeFieldrrrr3r4ÚstaticmethodrBrCrÚremotable_classmethodrKrLrMrOrZselect_db_reader_moderQrRrSrWZ	remotablerXr_r^rZrgÚclassmethodrirhrkryrVÚ
__classcell__rr)r,rr9s\






		
c@sheZdZdZdejdƒiZejdd„ƒZejddd„ƒZ	ejd	d
„ƒZ
ejddd
„ƒZejdd„ƒZdS)ÚServiceListz1.0r	rcCs"tj||ƒ}tj|||ƒtj|ƒS)N)rZservice_get_all_by_topicrÚ
obj_make_listr	r)rJr<r$Údb_servicesrrrÚget_by_topicGszServiceList.get_by_topicFcCs&tj|||d}tj|||ƒtj|ƒS)N)Úinclude_disabled)rZservice_get_all_by_binaryrrr	r)rJr<r#r‚r€rrrÚ
get_by_binaryMszServiceList.get_by_binarycCs"tj||ƒ}tj|||ƒtj|ƒS)N)rZservice_get_all_by_hostrrr	r)rJr<r"r€rrrÚget_by_hostTszServiceList.get_by_hostNcCs4tj||d}|rtj||ƒ}tj|||ƒtj|ƒS)N)r%)rZservice_get_allZavailability_zonesZset_availability_zonesrrr	r)rJr<r%Z	set_zonesr€rrrÚget_allZszServiceList.get_allcCs&tj||dd}tj|||ƒtj|ƒS)NF)r‚)rZ#service_get_all_computes_by_hv_typerrr	r)rJr<Zhv_typer€rrrÚget_all_computes_by_hv_typecsz'ServiceList.get_all_computes_by_hv_type)F)NF)
rrrrrZListOfObjectsFieldrr{rrƒr„r…r†rrrrr~?sr~N)Zoslo_logrZloggingZ
oslo_utilsrZdmapirZ
dmapi.i18nrZ
dmapi.objectsrrrr	Z	getLoggerrrHrZSERVICE_VERSION_HISTORYrZContegoObjectRegistryÚregisterZContegoPersistentObjectZ
ContegoObjectZContegoObjectDictCompatZObjectListBaser~rrrrÚ<module>s$