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    
Size: Mime:
ó
±EYc@s÷dZddlZddlmZddlmZddlmZddlm	Z	ddl
Z
ddlZddl
ZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlm Z ddlm!Z!ej"e#ƒZ$ej%j&Z&d„Z'd„Z(ddd„Z*dde+d„Z,ddddd„Z-dddddddd„Z.d„Z/d„Z0e+d„Z1e2d„Z3d„Z4d„Z5dS(sPFunctionality related to notifications common to multiple layers of
the system.
iÿÿÿÿN(tcontext(tlog(texcutils(t	timeutils(t	exception(t_LE(tglance(tnetwork(tmodel(tbase(tinstance(tobjects(tfields(trpc(tutilscs‡‡fd†}|S(sÅDecorator for notify which is used from utils.monkey_patch().

        :param name: name of the function
        :param fn: - object of the function
        :returns: fn -- decorated function

    csëi}g|d<i|d<x|D]}|dj|ƒq!Wx |D]}|||d|<qCWtjˆ||ƒpŒtjƒpŒtjjƒ}tjddt	j
pªt	jƒ}t|t	j
jƒ|jƒ}||ˆ|ƒˆ||ŽS(Ntargstkwargtapitpublisher_id(tappendtcommon_contextt"get_context_from_function_and_argstget_currenttnovaRtRequestContextR
tget_notifiertCONFtdefault_publisher_idthosttgetattrtdefault_notification_leveltlowertinfo(RRtbodytargtkeytctxttnotifiertmethod(tfntname(sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/notifications/base.pytwrapped_func:s$



	((R(R'R)((R'R(sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/notifications/base.pytnotify_decorator2scCsftjs
dSi|d6tj|ƒd6|d6}tjdƒjtjƒpXt	j
jƒd|ƒdS(sSend an api.fault notification.NturlRtstatusRs	api.fault(Rtnotify_api_faultstsixt	text_typeR
RterrorRRRRtget_admin_context(R+R,Rtpayload((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/notifications/base.pytsend_api_faultSs	
tcomputec
Cs=tjs
dSt}|d}|d}|d}|d}	||krPt}n$tjdkrt||	krtt}n|rœt||||||	||ƒnyJd}
|d|dkrÆ|d}
nt||d|d|d|
ƒWnPtjk
rt	j
d	d
|ƒn*tk
r8t	jtdƒd
|ƒnXdS(sbSend compute.instance.update notification to report any changes occurred
    in that instance
    Ntvm_statet
task_statetvm_and_task_statetdisplay_nametserviceRtold_display_namesiFailed to send instance update notification. The instance could not be found and was most likely deleted.R
s(Failed to send state update notification(
Rtnotify_on_state_changetFalsetTruetsend_update_with_statestNonet"_send_instance_update_notificationRtInstanceNotFoundtLOGtdebugt	ExceptionR(Rtold_instancetnew_instanceR9Rtupdate_with_state_changetold_vm_statetnew_vm_statetold_task_statetnew_task_stateR:((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/notifications/base.pytsend_updatebs8	



		


c	
Csðtjs
dSt}	|r[t}	||kr4t}	q[tjdkr[||kr[t}	q[n|	rìy5t||d|d|d|d|d|d|ƒWqìtjk
r¿tjd	d
|ƒqìt	k
rètjt
dƒd
|ƒqìXndS(sfSend compute.instance.update notification to report changes if there
    are any, in the instance
    NR7RHRJRIRKR9RsiFailed to send instance update notification. The instance could not be found and was most likely deleted.R
s(Failed to send state update notification(RR;R=R<R@RRARBRCRDR(
RR
RHRIRJRKR9Rt
verify_statestfire_update((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/notifications/base.pyR>•s,		

cCsŠ|dkr|d}n|dkr2|d}n|dkrK|d}n|dkrd|d}ni|d6|d6|d6|d6}|S(NR5R6t	old_statetstateRJRK(R?(R
RHRJRIRKtstates_payload((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/notifications/base.pyt_compute_states_payloadÀs





c	
CsÂt||ddƒ}	|	jt|||||ƒƒtdtƒ\}
}|
|	d<||	d<t||
ƒ}||	d<|r‰||	d<ntj||ƒj	|d|	ƒt
|||	||ƒdS(sfSend 'compute.instance.update' notification to inform observers
    about instance state changes.
    tcurrent_periodtaudit_period_beginningtaudit_period_endingt	bandwidthR:scompute.instance.updateN(tinfo_from_instanceR?tupdateRRtaudit_period_boundsR=tbandwidth_usageR
RR t_send_versioned_instance_update(
RR
RHRJRIRKR9RR:R2taudit_startt	audit_endtbw((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/notifications/base.pyR@Üs	





cCs4|dkrd}n|dkr*d}n|}|S(NRsnova-apiR4snova-compute((R9tbinary((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/notifications/base.pyt_map_service_to_binaryþs		cCs˜tjd|jdƒd|jdƒd|jdƒd|jdƒƒ}tjd|jdƒd|jdƒƒ}g|djƒD]2\}}tjd|d	|d
d|dƒ^qƒ}	|jj}
tjd
|ƒ}tj	d
|d|d|d|	dtj
j|
ƒd|d|jdƒƒ}tjdt
jjdtjdd
dt
jjƒdtjd|pltjdt|ƒƒd|ƒ}
|
j|ƒdS(NRORPRJRKRTRURVtnetwork_nametin_bytestbw_int	out_bytestbw_outR
tstate_updatetaudit_periodtip_addressestflavorR:tpriorityt
event_typetobjecttactiont	publisherRR_R2(tinstance_notificationtInstanceStateUpdatePayloadtgettAuditPeriodPayloadtitemstBandwidthPayloadt
info_cachetnetwork_infot
FlavorPayloadtInstanceUpdatePayloadt	IpPayloadtfrom_network_infotInstanceUpdateNotificationRtNotificationPrioritytINFOtnotification_baset	EventTypetNotificationActiontUPDATEtNotificationPublisherRRR`temit(RR
R2RR9RfRgtlabelR^RVRvRitversioned_payloadtnotification((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/notifications/base.pyR[s>		F							cCsCtjƒ\}}|r-|}tjƒ}n|}|}||fS(sïGet the start and end of the relevant audit usage period

    :param current_period: if True, this will generate a usage for the
        current usage period; if False, this will generate a usage for the
        previous audit period.
    (Rtlast_completed_audit_periodRtutcnow(RStbegintendR\R]((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/notifications/base.pyRY3scs@tjjddƒ‰‡‡‡fd†}tˆtjƒrfˆjj}|dkrot	j
ƒ}qon	|ƒ}g|D]}|d^qv}ˆdg}tjj
ˆ||ƒ}i}	x‚|D]z}
|
j|kr¾d|
j}x3|D]+}|d|
jkrç|dd}PqçqçWtd	|
jd
|
jƒ|	|<q¾q¾W|	S(sYGet bandwidth usage information for the instance for the
    specified audit period.
    tread_deletedtyesc	s߈jdƒr\ˆdjdƒdk	r\ˆdd}t|tjƒrL|Stjj|ƒSytjƒjˆˆƒSWnbt	k
rÚy0t
jƒtj
tdƒdˆƒWdQXWqÛt	k
rÖˆrÐdS‚qÛXnXdS(s1Support for getting network info without objects.RuRvsFailed to get nw_infoR
N(RqR?t
isinstancet
network_modeltNetworkInfothydrateRtAPItget_instance_nw_infoRDRtsave_and_reraise_exceptionRBRR(tcached_info(t
admin_contexttignore_missing_network_datatinstance_ref(sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/notifications/base.pyt_get_nwinfo_old_skoolMs$


taddresstuuidsnet-name-not-found-%sRR„RcReN(RRR1Rtobj_baset
NovaObjectRuRvR?RŽRRtBandwidthUsageListtget_by_uuidstmactdictRcRe(R—R\R–R˜tnw_infotviftmacstuuidst	bw_usagesR^tbR„((R•R–R—sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/notifications/base.pyRZFs*	
	


&cCsJi}x=tj|ƒD],\}}|jdƒr|||d<qqW|S(sZFormat image metadata for use in notifications from the instance
    system metadata.
    timage_i(R.t	iteritemst
startswith(tsystem_metadatat
image_metatmd_keytmd_value((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/notifications/base.pyR«~s
cAKs†d„}d„}d„}tj|jƒ}|jƒ}	|	jddƒ}
|	jddƒ}td|jd|jd	|jd
|j	d|j
d|jd
|
d|jd|d|j
d|jjd|jj|jjd|jjd|jjd|jjd|jd|jd|jd||jƒdt|jƒd||jdd.ƒƒd||jdd.ƒƒd||jdd.ƒƒd|d|jd |jd!|jd"|jd#||jƒd$||jƒd%|j d&|j!ƒ }|d.k	rOg}
xR|D]J}xA|j"ƒD]3}|d'd(|d(<|d)|d*<|
j#|ƒqWqôW|
|d+<nt$|j%ƒ}||d,<|j&|d-<|j'|ƒ|S(/sGet detailed instance information for an instance which is common to all
    notifications.

    :param:instance: nova.objects.Instance
    :param:network_info: network_info provided if not None
    :param:system_metadata: system_metadata DB entries for the instance,
    if not None

    .. note::

        Currently unused here in trunk, but needed for potential custom
        modifications.

    cSs|rt|ƒSdS(Nt(tstr(ts((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/notifications/base.pyt
null_safe_str›scSs|rt|ƒSdS(NR®(tint(R°((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/notifications/base.pyt
null_safe_intžscSs7t|tjƒrtj|ƒS|r/t|ƒSdSdS(NR®(RtdatetimeRtstrtimeR¯(R°((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/notifications/base.pytnull_safe_isotime¡s
R(R®tflavoridt	tenant_idtuser_idtinstance_idR8treservation_idthostnamet
instance_typetinstance_type_idtinstance_flavor_idtarchitecturet	memory_mbtdisk_gbtvcpustroot_gbtephemeral_gbRtnodetavailability_zonet	cell_namet
created_att
terminated_att
deleted_attlaunched_att
image_ref_urltos_typet	kernel_idt
ramdisk_idRPtstate_descriptiontprogresstaccess_ip_v4taccess_ip_v6RR„R™tvif_mact	fixed_ipsR«tmetadataN((Rtgenerate_image_urlt	image_reft
get_flavorRqR t
project_idR¹RšR8R»R¼R¾RÀRiRÁRÄRÅRÃRRÆRÇRÈR¯RÉR?RÎRÏRÐR5R6RÒRÓRÔRÖRR«RªR×RX(RR
RvRªtkwR±R³R¶RÍR½tinstance_type_nametinstance_flavoridt
instance_infoRÖR¢tiptimage_meta_props((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/notifications/base.pyRWŠsj																			




(6t__doc__R´toslo_contextRRtoslo_logRt
oslo_utilsRRR.t	nova.confRtnova.contextRt	nova.i18nRt
nova.imageRRtnova.networkRRŽtnova.notifications.objectsR	R~R
RoRtnova.objectsR›RR
Rt	getLoggert__name__RBtconfRR*R3R?RLR<R>RRR@R`R[RYR=RZR«RW(((sL/home/tvault/.virtenv/lib/python2.7/site-packages/nova/notifications/base.pyt<module>sN	!	3)	 	
	+7