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    
idna / lib / python2.7 / site-packages / nova / scheduler / client / report.pyc
Size: Mime:
ó
±EYc@sddlZddlZddlmZddlmZddlmZddlm	Z
ddlmZ
ddlZddlmZmZmZddlmZdd	lmZejjZe
jeƒZejjZejjZejjZd
„Z de!fd„ƒYZ"dS(
iÿÿÿÿN(t
exceptions(tloading(tsession(tlog(tutils(t_LEt_LIt_LW(tobjects(tfieldscs"tjˆƒ‡fd†ƒ}|S(Ncs¿y!|jrdSˆ|||ŽSWn—tjk
rYtdƒ}tj|ƒt|_nbtjk
rŽtdƒ}tj|ƒt|_n-tjk
rºtdƒ}tj|ƒnXdS(NsbThe placement API endpoint not found. Optional use of placement API for reporting is now disabled.ssNo authentication information found for placement API. Optional use of placement API for reporting is now disabled.s(Placement API service is not responding.(	t	_disabledtks_exctEndpointNotFoundRtLOGtwarningtTruetMissingAuthPlugintConnectFailure(tselftatktmsg(tf(sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pytwrapper&s	

(t	functoolstwraps(RR((RsQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pytsafe_connect%stSchedulerReportClientcBseZdZidd6ejjd6Zd„Zd„Zd„Z	d„Z
d„Zed	„ƒZ
ed
„ƒZdd„Zd„Zd
„Zd„Zed„ƒZd„Zd„Zd„Zed„ƒZed„ƒZd„Zed„ƒZd„ZRS(s(Client class for updating the scheduler.t	placementtservice_typetregion_namecCs=i|_tjtdƒ}tjd|ƒ|_t|_dS(NRtauth(	t_resource_providerstkeystonetload_auth_from_conf_optionstCONFRtSessiont_clienttFalseR
(Rtauth_plugin((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyt__init__Ds
	cCs|jj|d|jdtƒS(Ntendpoint_filtert	raise_exc(R%tgett	ks_filterR&(Rturl((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyR+Ps	cCs%|jj|d|d|jdtƒS(NtjsonR)R*(R%tpostR,R&(RR-tdata((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyR/Us	cCs%|jj|d|d|jdtƒS(NR.R)R*(R%tputR,R&(RR-R0((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyR1^s	cCs|jj|d|jdtƒS(NR)R*(R%tdeleteR,R&(RR-((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyR2gs	cCs¦|jd|ƒ}|jdkrR|jƒ}tjd|d|dd|dƒS|jdkred
Stdƒ}i|d6|jd6|jd	6}tj	||ƒd
S(s(Queries the placement API for a resource provider record with the
        supplied UUID.

        Returns an `objects.ResourceProvider` object if found or None if no
        such resource provider could be found.

        :param uuid: UUID identifier for the resource provider to look up
        s/resource_providers/%siÈtuuidtnamet
generationi”stFailed to retrieve resource provider record from placement API for UUID %(uuid)s. Got %(status_code)d: %(err_text)s.tstatus_codeterr_textN(
R+R6R.RtResourceProvidertNoneRttextR
terror(RR3trespR0Rtargs((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyt_get_resource_providerls
	


cCsd}i|d6|d6}|j||ƒ}|jdkr‚tdƒ}|j||ƒ}tj|ƒtjd|d|ddƒS|jdkrÆtd	ƒ}|j|ƒ}tj|ƒ|j|ƒSt	d
ƒ}i|d6|jd6|j
d6}tj||ƒd
S(s,Calls the placement API to create a new resource provider record.

        Returns an `objects.ResourceProvider` object representing the
        newly-created resource provider object.

        :param uuid: UUID of the new resource provider
        :param name: Name of the resource provider
        s/resource_providersR3R4iÉsdCreated resource provider record via placement API for resource provider with UUID {0} and name {1}.R5ii™srAnother thread already created a resource provider with the UUID {0}. Grabbing that record from the placement API.spFailed to create resource provider record in placement API for UUID %(uuid)s. Got %(status_code)d: %(err_text)s.R6R7N(R/R6RtformatR
tinfoRR8R>RR:R;(RR3R4R-tpayloadR<RR=((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyt_create_resource_provider‹s0


	



cCsw||jkr|j|S|j|ƒ}|dkrf|p>|}|j||ƒ}|dkrfdSn||j|<|S(sEnsures that the placement API has a record of a resource provider
        with the supplied UUID. If not, creates the resource provider record in
        the placement API for the supplied UUID, optionally passing in a name
        for the resource provider.

        The found or created resource provider object is returned from this
        method. If the resource provider object for the supplied uuid was not
        found and the resource provider record could not be created in the
        placement API, we return None.

        :param uuid: UUID identifier for the resource provider to ensure exists
        :param name: Optional name for the resource provider if the record
                     does not exist. If empty, the name is set to the UUID
                     value
        N(R R>R9RB(RR3R4trp((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyt_ensure_resource_providerºs
cCsÆii|jd6dd6dd6dd6dd6|jd6d	6i|jd6tjd6dd6dd6dd6|jd6d
6i|jd6tjdd6dd6dd6dd6|jd6d6}i|d
6}|S(Nttotalitreserveditmin_unittmax_unitt	step_sizetallocation_ratiotVCPUt	MEMORY_MBitDISK_GBtinventories(	tvcpustcpu_allocation_ratiot	memory_mbR#treserved_host_memory_mbtram_allocation_ratiotlocal_gbtreserved_host_disk_mbtdisk_allocation_ratio(Rtcompute_nodeRNR0((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyt_compute_node_inventoryÖs2




cCs7d|j}|j|ƒ}|s-iid6S|jƒS(Ns"/resource_providers/%s/inventoriesRN(R3R+R.(RRWR-tresult((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyt_get_inventoryös

c
Csó|j|ƒ}|j|ƒ}|jdƒ}|r‚|j|j}||jkrvtjdi|jd6|d6ƒn||_n|d|jdiƒkr¢tS|j|jj|d<d|j}|j	||ƒ}|j
dkr'tjtdƒ|jƒ|j|j=|j
|j|jƒtS|setjtd	ƒi|jd
6|j
d6|jd6ƒtS|j
d
kr¬tjtdƒi|jd
6|j
d6|jd6ƒtS|jƒ}|d}	|	|j|j_tjd|j|	fƒtS(söUpdate the inventory for this compute node if needed.

        :param compute_node: The objects.ComputeNode for the operation
        :returns: True if the inventory was updated (or did not need to be),
                  False otherwise.
        tresource_provider_generationsAUpdating our resource provider generation from %(old)i to %(new)itoldtnewRNs"/resource_providers/%s/inventoriesi™s Inventory update conflict for %ss<Failed to update inventory for %(uuid)s: %(status)i %(text)sR3tstatusR:iÈsoReceived unexpected response code %(code)i while trying to update inventory for compute node %(uuid)s: %(text)stcodes)Updated inventory for %s at generation %i(RXRZR+R R3R5R
tdebugRR1R6R@RRDthypervisor_hostnameR&RRR:R.(
RRWR0tcurrt
server_gentmy_rpR-RYtupdated_inventories_resulttnew_gen((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyt_update_inventory_attemptýsR	






	


	cCs^xWdD]O}|j|jkr6tjtdƒƒtS|j|ƒrItStj	dƒqWtS(Niiis-Unable to refresh my resource provider record(iii(
R3R R
RRR&RgRttimetsleep(RRWtattempt((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyt_update_inventory@s
	
cCs1|jƒ|j|j|jƒ|j|ƒdS(s‰Creates or updates stats for the supplied compute node.

        :param compute_node: updated nova.objects.ComputeNode to report
        N(tsaveRDR3RaRk(RRW((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pytupdate_resource_statsPs

cCsftj|j|ƒ}|r!dn	|jj|jj|jj}i|jjt6|jj	t
6|t6S(Ni(t
compute_utilstis_volume_backed_instancet_contexttflavortroot_gbtswaptephemeral_gbRQRLRORKRM(Rtinstancetis_bfvtdisk((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyt_allocationsZs	


cCsSd|j}|j|ƒ}|s&iS|jƒdj|jiƒjdiƒSdS(Ns/allocations/%stallocationst	resources(R3R+R.(RRWRuR-R<((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyt_get_allocations_for_instancegs
cCsAd|j}|j|ƒ}|j||ƒ}||kr—djg|jƒD]\}}d||f^qMƒ}tjdi|jd6|d6ƒdSiii|jd6d6|d6gd	6}	tjd
|	d|ƒ|j||	ƒ}
|
r	tjt	dƒd|ƒn4tj
td
ƒi|jd6|
jd6|
j
d6ƒdS(Ns/allocations/%st,s%s=%ss6Instance %(uuid)s allocations are unchanged: %(alloc)sR3talloctresource_providerRzRys"Sending allocation for instance %sRus!Submitted allocation for instancesEUnable to submit allocation for instance %(uuid)s (%(code)i %(text)s)R_R:(R3RxR{tjointitemsR
R`R1R@RRRR6R:(RRWRuR-tmy_allocationstcurrent_allocationsRtvtallocstrRytr((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyt_allocate_for_instancess6
			/		
	

cCsmd|}|j|ƒ}|r8tjtdƒ|ƒn1tjtdƒi|d6|jd6|jd6ƒdS(Ns/allocations/%ss"Deleted allocation for instance %ssFUnable to delete allocation for instance %(uuid)s: (%(code)i %(text)s)R3R_R:(R2R
R@RRRR6R:(RR3R-R…((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyt_delete_allocation_for_instancešs

	

cCs3|dkr|j||ƒn|j|jƒdS(Ni(R†R‡R3(RRWRutsign((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pytupdate_instance_allocation©scCs8d|j}|j|ƒ}|s&iS|jƒdSdS(Ns"/resource_providers/%s/allocationsRy(R3R+R.(RRWR-R<((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyt_get_allocations¯s

cCsŽ|j|ƒ}|dkr$i}nd„|Dƒ}t|jƒƒt|jƒƒ}x1|D])}tjtdƒ|ƒ|j|ƒq]WdS(NcSsi|]}||d“qS(R3((t.0Ru((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pys
<dictcomp>½s	s)Deleting stale allocation for instance %s(RŠR9tsettkeysR
RRR‡(RRWtinstance_uuidsRyt
instance_dicttremoved_instancesR3((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pytremove_deleted_instances¸s	
"
N(t__name__t
__module__t__doc__R#Rtos_region_nameR,R(R+R/R1R2RR>RBR9RDRXRZRgRkRmRxR{R†R‡R‰RŠR‘(((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyR>s.
							/	 		C	
	
	'		(#RRht
keystoneauth1RRRR!Rtoslo_logRtloggingtnova.computeRRnt	nova.conftnovat	nova.i18nRRRRtnova.objectsR	tconfR#t	getLoggerR’R
t
ResourceClassRKRLRMRtobjectR(((sQ/home/tvault/.virtenv/lib/python2.7/site-packages/nova/scheduler/client/report.pyt<module>s"