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    
contego / home / tvault / .virtenv / lib / python2.7 / site-packages / nova / compute / resource_tracker.pyc
Size: Mime:
ó
±EYc@s—dZddlZddlmZddlmZddlmZddl	m
Z
ddl	mZddl	mZdd	l	m
Z
ddlZdd
lmZddlmZmZmZddlmZdd
lmZddlmZddlmZddlmZddlm Z ddl!m"Z#ddlm$Z$ddl%m&Z&ej'j(Z(ej)e*ƒZ+dZ,d„Z-d„Z.de/fd„ƒYZ0dS(sœ
Track resources like memory and disk for a compute host.  Provides the
scheduler with useful information about availability through the ComputeNode
model.
iÿÿÿÿN(tlog(t	jsonutils(timportutils(tclaims(tmonitors(ttask_states(t	vm_states(t	exception(t_t_LIt_LW(tobjects(tbase(t	migration(tmanager(trequest(trpc(tclient(tutils(thardwaretcompute_resourcescCso|j}|j}|tjkr%tS|tjtjgkrk|tjtj	tj
tjtjgkrktSt
S(sxReturns True if the instance is in one of the resizing states.

    :param instance: `nova.objects.Instance` object
    (tvm_statet
task_stateRtRESIZEDtTruetACTIVEtSTOPPEDRtRESIZE_PREPtRESIZE_MIGRATINGtRESIZE_MIGRATEDt
RESIZE_FINISHt
REBUILDINGtFalse(tinstancetvmttask((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyt_instance_in_resize_state2s			cCs
|jdkS(NtresizeR
t
evacuation(sresizes	migrations
evacuation(tmigration_type(R
((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyt_is_trackable_migrationFstResourceTrackercBsñeZdZd„Zejeƒd'd„ƒZejeƒd'd'd'd„ƒZ	ejeƒd'd'd„ƒZ
d'd'd'd'd„Zd'd„Zd„Z
d„Zd	„Zejeƒd
„ƒZejeƒd'dd„ƒZejeƒd
„ƒZed„ƒZd„Zd„Zd„Zd„Zd„Zd„Zejeƒd„ƒZd„Zd„Zd„Zd„Zd„Z dd„Z!dd„Z"d„Z#d„Z$e%d „Z&d!„Z'd"„Z(d#„Z)d$„Z*d%„Z+d&„Z,RS((sgCompute helper class for keeping track of resource usage as instances
    are built and destroyed.
    cCsµ||_||_d|_||_d|_tjtj	ƒ|_
i|_i|_t
j|ƒ}|j
|_
tjƒ|_tjƒ|_tj|_tj|_tj|_dS(N(thosttdrivertNonetpci_trackertnodenametcompute_nodeRt
import_objecttCONFtcompute_stats_clasststatsttracked_instancesttracked_migrationsRtMonitorHandlerRtComputeNodet
old_resourcestscheduler_clienttSchedulerClienttram_allocation_ratiotcpu_allocation_ratiotdisk_allocation_ratio(tselfR*R+R.tmonitor_handler((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyt__init__Ts							c	
Cs„|jr |j|ƒtjƒS|jrEtjtdƒd|ƒn|jrjtjtdƒd|ƒn|j	j
|ƒ}tjdi|jj
d6|dd6ƒtjdi|jjd6|jd	d
ƒd6ƒtjj||jƒ}tj||||j|d|d|ƒ}|j}||_|j|ƒ|jrW|jj|||ƒn|j||ƒ|jƒ}|j|ƒ|S(sÔIndicate that some resources are needed for an upcoming compute
        instance build operation.

        This should be called before the compute node is about to perform
        an instance build operation that will consume additional resources.

        :param context: security context
        :param instance: instance to reserve resources for.
        :type instance: nova.objects.instance.Instance object
        :param limits: Dict of oversubscription limits for memory, disk,
                       and CPUs.
        :returns: A Claim ticket representing the reserved resources.  It can
                  be used to revert the resource usage if an error occurs
                  during the instance build.
        sOHost field should not be set on the instance until resources have been claimed.R!sONode field should not be set on the instance until resources have been claimed.s;Memory overhead for %(flavor)d MB instance; %(overhead)d MBtflavort	memory_mbtoverheads9Disk overhead for %(flavor)d GB instance; %(overhead)d GBtdisk_gbitlimits(tdisabledt_set_instance_host_and_nodeRtNopClaimR*tLOGtwarningR
tnodeR+testimate_instance_overheadtdebugRARBtroot_gbtgetRtInstancePCIRequeststget_by_instance_uuidtuuidtClaimR/tclaimed_numa_topologyt
numa_topologyR-tclaim_instancet_update_usage_from_instancetelevatedt_update(	R>tcontextR!RERCtpci_requeststclaimtinstance_numa_topologyRX((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pytinstance_claimes<	

	
	
					
	

cCs4|j}|j|||ddd|d|d|ƒS(s'Create a claim for a rebuild operation.t	move_typeR&REt
image_metaR
(RAt_move_claim(R>RZR!RER`R
t
instance_type((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyt
rebuild_claim¬s	cCs|j|||d|d|ƒS(s3Create a claim for a resize or cold-migration move.R`RE(Ra(R>RZR!RbR`RE((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pytresize_claimµscCs)|p	i}|r"|j|ƒn|j||||ƒ}|jrStjd|ƒS|jj|ƒ}tjdi|j	d6|dd6ƒtjdi|j
jd6|jddƒd6ƒt
j|ƒ}	|j|	_|jrx9|jjD](}
|
jdkrë|	jj|
ƒqëqëWntj||||||j|	d|d	|ƒ}||_g}|jr€|jj||	|jƒ}ntjd
|ƒ}
tjd|d|jd
|jd|j d|jd|j!d|
d|jd|	ƒ	}||_"|j#ƒ|j$|||ƒ|j%ƒ}|j&|ƒ|S(s¯Indicate that resources are needed for a move to this host.

        Move can be either a migrate/resize, live-migrate or an
        evacuate/rebuild operation.

        :param context: security context
        :param instance: instance object to reserve resources for
        :param new_instance_type: new instance_type being resized to
        :param image_meta: instance image metadata
        :param move_type: move type - can be one of 'migration', 'resize',
                         'live-migration', 'evacuate'
        :param limits: Dict of oversubscription limits for memory, disk,
        and CPUs
        :param migration: A migration object if one was already created
                          elsewhere for this operation
        :returns: A Claim ticket representing the reserved resources.  This
        should be turned into finalize  a resource claim or free
        resources after the compute operation is finished.
        R
s;Memory overhead for %(flavor)d MB instance; %(overhead)d MBRARBRCs9Disk overhead for %(flavor)d GB instance; %(overhead)d GBRDiRERRZt
instance_uuidtmigration_idtold_numa_topologytnew_numa_topologytold_pci_devicestnew_pci_devicestold_pci_requeststnew_pci_requestsN('t_claim_existing_migrationt_create_migrationRFRRHR+RLRIRMRBRARNROtpci_requesttget_pci_requests_from_flavorRRReR[trequestst
alias_nameR,tappendt	MoveClaimR/R
R-RVRTRt
PciDeviceListtMigrationContexttidRUtpci_devicestmigration_contexttsavet_update_usage_from_migrationRXRY(R>RZR!tnew_instance_typeR_R`RER
RCRlRR\tclaimed_pci_devices_objstclaimed_pci_devicestmig_contextRX((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyRa¼s^		
																	

cCs¼tjd|jƒƒ}|j|_|j|_|jjƒ|_	|j
j|_|j|_
d|_|j|_|j|_|j|_|rœ||_ntj|ƒ|_|jƒ|S(sÒCreate a migration record for the upcoming resize.  This should
        be done while the COMPUTE_RESOURCES_SEMAPHORE is held so the resource
        claim will not be lost if the audit process starts.
        RZs
pre-migrating(Rt	MigrationRXR*tdest_computeR.t	dest_nodeR+tget_host_ip_addrt	dest_hostRARwtold_instance_type_idtnew_instance_type_idtstatusRRRetsource_computeRKtsource_nodeR't
migration_objtdetermine_migration_typetcreate(R>RZR!R|R_R
((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyRns 	
cCsA|j|_|j|_|jjƒ|_d|_|jƒdS(sGMake an existing migration record count for resource tracking.

        If a migration record was created already before the request made
        it to this compute host, only set up the migration so it's included in
        resource tracking. This should be done while the
        COMPUTE_RESOURCES_SEMAPHORE is held.
        s
pre-migratingN(	R*RR.R‚R+RƒR„R‡Rz(R>R
((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyRm3s
	cCs2|j|_|j|_|j|_|jƒdS(sËTag the instance as belonging to this host.  This should be done
        while the COMPUTE_RESOURCES_SEMAPHORE is held so the resource claim
        will not be lost if the audit process starts.
        N(R*tlaunched_onR.RKRz(R>R!((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyRGAscCs d|_d|_|jƒdS(s×Untag the instance so it no longer belongs to the host.

        This should be done while the COMPUTE_RESOURCES_SEMAPHORE is held so
        the resource claim will not be lost if the audit process starts.
        N(R,R*RKRz(R>R!((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyt_unset_instance_host_and_nodeKs		cCsD|j||dtƒ|jƒ|j|ƒ|j|jƒƒdS(s%Remove usage from the given instance.t
is_removedN(RWRtclear_numa_topologyRŽRYRX(R>RZR!((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pytabort_instance_claimUs

tnew_cCs/|d|jkr+|jj|dƒ\}}|s\|jƒ}|j||||ƒ}n|dk	r+|j|dkr+|jd|d|ƒ}|j|d|ƒ}	|jrù|jd|d|ƒ}
|
rùx$|
D]}|jj	||ƒqÖWqùn|j
|	ddƒ|jƒ}|j|ƒq+ndS(	s0Remove usage for an incoming/outgoing migration.RRRwRUtprefixRxtsigniÿÿÿÿN(R5tpopRXt_get_instance_typeR,Rwt_get_migration_context_resourcet_get_usage_dictR-tfree_devicet
_update_usageRY(R>RZR!RbR“R
titypetctxtRUtusageRxt
pci_device((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pytdrop_move_claim_s(	
cCsP|jr
dS|d}||jkrL|j||ƒ|j|jƒƒndS(sRUpdate the resource usage and stats after a change in an
        instance
        NRR(RFR4RWRYRX(R>RZR!RR((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pytupdate_usage|s	
cCs
|jdkS(N(R/R,(R>((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyRFŒscCs|jr=|j|ƒ|j||ƒ|jj|jƒdS|j|ƒ|_|jrŒ|j|ƒ|j||ƒ|jj|jƒdStj|ƒ|_|j|j_|j|ƒ|jj	ƒt
jtdƒi|jd6|j
d6ƒ|j||ƒ|jj|jƒdS(sàInitialize the compute node if it does not already exist.

        The resource tracker will be inoperable if compute_node
        is not defined. The compute_node will remain undefined if
        we fail to create it or if there is no associated service
        registered.

        If this method has to create a compute node it needs initial
        values - these come from resources.

        :param context: security context
        :param resources: initial values
        Ns4Compute_service record created for %(host)s:%(node)sR*RK(R/t_copy_resourcest_setup_pci_trackerR9tupdate_resource_statst_get_compute_nodeRR7R*RŒRItinfoR	R.(R>RZt	resources((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyt_init_compute_nodes&	
	


cCs|js‹|jr|jjnd}tj|d|ƒ|_d|krj|jdƒ}|jj|ƒn|jjj	ƒ}||j_
ndS(Ntnode_idtpci_passthrough_devices(R-R/RwR,tpci_managert
PciDevTrackerR•t(update_devices_from_hypervisor_resourcesR3tto_device_pools_objtpci_device_pools(R>RZR¦tn_idtdev_jsont
dev_pools_obj((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyR¢¾s		
cCs|jjƒ|jj|jdƒƒtj|jƒ|j_|j|j_|j|j_|j	|j_	|jj
|ƒdS(s]Copy resource values to initialize compute_node and related
        data structures.
        R3N(R3tcleartdigest_statsROtcopytdeepcopyR/R;R<R=tupdate_from_virt_driver(R>R¦((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyR¡Ês
cCsétjƒ}i}x\|jD]Q}y|j|ƒWqtk
rl}tjtdƒi|d6|d6ƒqXqW|jƒ}t	|ƒrå||d<||d<|j
|d<tj|d<t
jdd	d|ƒ}|j|d
|ƒn|S(sUGet the metrics from monitors and
        notify information to message bus.
        s3Cannot get the metrics from %(mon)s; error: %(exc)stmontexcR.tmetricsR*thost_iptservicetcomputescompute.metrics.update(RtMonitorMetricListRtpopulate_metricst	ExceptionRIRJR
tto_listtlenR*R1tmy_ipRtget_notifierR¥(R>RZR.R¹tmetrics_infotmonitorR¸tnotifier((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyt_get_host_metricsÛs"



cCs™tjtdƒi|jd6ƒ|jj|jƒ}tj|d<d|ks^|ddkrkd|d<n|j	|ƒ|j
|ƒ|j||ƒdS(sAOverride in-memory calculations of compute node resource usage based
        on data audited from the hypervisor layer.

        Add in resource claims in progress to account for operations that have
        declared a need for resources, but not necessarily retrieved them from
        the hypervisor layer yet.
        s>Auditing locally available compute resources for node %(node)sRKRºtcpu_infotN(RIR¥R	R.R+tget_available_resourceR1RÂR,t_verify_resourcest _report_hypervisor_resource_viewt_update_available_resource(R>RZR¦((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pytupdate_available_resourceôs



cCsgd„|Dƒ}xP|D]H}y||j|_Wqtk
r^tjdi|jd6ƒqXqWdS(NcSsi|]}||j“qS((RR(t.0tinst((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pys
<dictcomp>s	sBMigration for instance %(uuid)s refers to another host's instance!RR(ReR!tKeyErrorRIRM(R>t
migrationst	instancestinstance_by_uuidR
((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyt_pair_instances_to_migrationss

	c	CsW|j||ƒ|jrdStjj||j|jdddddgƒ}|j||ƒtjj	||j|jƒ}|j
||ƒ|j||ƒ|jƒ}|j
|ƒ|jj|||ƒ|jjjƒ}||j_|jƒ|j||jƒ}tj|ƒ|j_|j|ƒtjtdƒi|jd6|jd6ƒdS(	Ntexpected_attrstsystem_metadataRURARys4Compute_service record updated for %(host)s:%(node)sR*RK(R§RFRtInstanceListtget_by_host_and_nodeR*R.t_update_usage_from_instancest
MigrationListt get_in_progress_by_host_and_nodeRÕt_update_usage_from_migrationst_find_orphaned_instancest_update_usage_from_orphansR-tclean_usageR3R­R/R®t_report_final_resource_viewRÇRtdumpsR¹RYRIR¥R	(R>RZR¦RÓRÒtorphansR±R¹((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyRÍs0			


cCsey tjj||j|jƒSWn>tjk
r`tjt	dƒi|jd6|jd6ƒnXdS(s/Returns compute node for the host and nodename.s,No compute node record for %(host)s:%(node)sR*RKN(
RR7tget_by_host_and_nodenameR*R.RtNotFoundRIRJR
(R>RZ((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyR¤Us	cCs±|d|d}|d|d}|d}|rU||d}tjd|ƒnd}tjd	ƒ|jd
ƒ}tjdi|jd6|d
6|d6|d6|d6ƒdS(s)Log the hypervisor's view of free resources.

        This is just a snapshot of resource usage recorded by the
        virt driver.

        The following resources are logged:
            - free memory
            - free disk
            - free CPUs
            - assignable PCI devices
        RBtmemory_mb_usedtlocal_gbt
local_gb_usedtvcpust
vcpus_usedsHypervisor: free VCPUs: %stunknowns(Hypervisor: VCPU information unavailableR©s”Hypervisor/Node resource view: name=%(node)s free_ram=%(free_ram)sMB free_disk=%(free_disk)sGB free_vcpus=%(free_vcpus)s pci_devices=%(pci_devices)sRKtfree_ramt	free_diskt
free_vcpusRxN(RIRMROR.(R>R¦tfree_ram_mbtfree_disk_gbRéRîRx((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyRÌ^s

	
cCsè|jj}|rK|}|jj}tjtdƒi|d6|d6ƒnd}d}|jjrut|jjƒng}tjtdƒi|jd6|jj	d6|jj
d6|jjd	6|jjd
6|d6|d6|d
6ƒdS(s"Report final calculate of physical memory, used virtual memory,
        disk, usable vCPUs, used virtual CPUs and PCI devices,
        including instance calculations and in-progress resource claims. These
        values will be exposed via the compute node table to the scheduler.
        s=Total usable vcpus: %(tcpu)s, total allocated vcpus: %(ucpu)sttcputucpuisÔFinal resource view: name=%(node)s phys_ram=%(phys_ram)sMB used_ram=%(used_ram)sMB phys_disk=%(phys_disk)sGB used_disk=%(used_disk)sGB total_vcpus=%(total_vcpus)s used_vcpus=%(used_vcpus)s pci_stats=%(pci_stats)sRKtphys_ramtused_ramt	phys_diskt	used_diskttotal_vcpust
used_vcpust	pci_statsN(
R/RéRêRIR¥R	R®tlistR.RBRæRçRè(R>RéRñRòRù((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyRá‚s&
$	




cCs5tj|j|jƒs1tj|jƒ|_tStS(s+Check to see if any resources have changed.(tobj_basetobj_equal_primsR/R8R´RµRR (R>((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyt_resource_change§scCsC|jƒsdS|jj|jƒ|jr?|jj|ƒndS(s<Update partial stats locally and populate them to Scheduler.N(RýR9R£R/R-Rz(R>RZ((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyRY®s
	icCs@|d}|jddƒ}|jj|ƒ}||d7}||jddƒ7}|jj||7_|jj||7_|jj||jddƒ7_|jj||jddƒ7_|jj|jj|j_|jj	|jj|j_
|jj|j_
|dk}tj|j||ƒ}||j_dS(NRBRNiRDtephemeral_gbRéiÿÿÿÿ(ROR+RLR/RæRèRêRBRïRçRðR3t
num_instancestrunning_vmsRt!get_host_numa_usage_from_instanceRU(R>RR”t	mem_usaget
disk_usageRCtfreetupdated_numa_topology((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyRš·s$
""		cCs6|j}||}|r2||kr2t||ƒSdS(N(RytgetattrR,(R>tresourceR!R“Ry((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyR—Òs
	

cCsXt|ƒsdS|j}tjtdƒ|ƒ|j|jkoP|j|jk}|j	|jkot|j
|jk}|o€|}|jj|dƒ}d}	d}
d}|r)|d|jkrö|j||d|ƒ}	|jd|ƒ}
d}q©|j||d|ƒ}	|jd|d	dƒ}
n€|ri|ri|j||d|ƒ}	|jd|ƒ}
d}n@|r©|r©|j||d|ƒ}	|jd|d	dƒ}
n|	rT|j|	d|
ƒ}|jrï|rï|jj||d
|ƒn|j|ƒ|jr&|jjjƒ}
|
|j_ntjƒ}
|
|j_||	f|j|<ndS(srUpdate usage for a single migration.  The record may
        represent an incoming or outbound migration.
        NsUpdating from migration %sitinstance_type_idR’RUitold_R“R”(R(ReRIR¥R	RR*R‚R.RˆR‰R4ROR,R…R–R—R˜R-tupdate_pci_for_instanceRšR3R­R/R®RtPciDevicePoolListR5(R>RZR!R
RRtincomingtoutboundt	same_nodetrecordR›RUR”Rtobj((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyR{Úsb				
		
		
	c
Csmi}i}|jjƒxÜ|D]Ô}|j}y ||krN|j||<nWn)tjk
rz}tjd|ƒq nXt||ƒsªtj	t
dƒd|ƒq n|j|dƒ}|sç|j
r |j
r |j
|j
kr |||<q q Wxn|jƒD]`}||j}	y|j||	|ƒWqtjk
rdtj	t
dƒd|	jƒqqXqWdS(Ns Migration instance not found: %ss*Instance not resizing, skipping migration.Res.Flavor could not be found, skipping migration.(R5R²ReR!RtInstanceNotFoundRIRMR$RJR
ROR,t
updated_attvaluesR{tFlavorNotFoundRR(
R>RZRÒtfilteredRÓR
RRtetother_migrationR!((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyRÝ s8

	

c	Csi|d}||jk}|o6|p6|dtjk}|r^tj|ƒ|j|<d}n|r}|jj|ƒd}n|jj||ƒtj	|jƒ|j
_|s´|r|jrÙ|jj||d|ƒn|j
jj|j
||ƒ|j|j|ƒd|ƒn|jjƒ|j
_|jrS|jjjƒ}||j
_ntjƒ|j
_dS(s#Update usage for a single instance.RRRiiÿÿÿÿR”N(R4RtALLOW_RESOURCE_REMOVALRûtobj_to_primitiveR•R3tupdate_stats_for_instanceR´RµR/R-R
R9treportclienttupdate_instance_allocationRšR˜tcalculate_workloadtcurrent_workloadR­R®RR(	R>RZR!RRRtis_new_instancetis_removed_instanceR”R((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyRWIs2

			
	cCs|jjƒtjd|j_tj|j_d|j_|jj	|jj|j_
|jj|jj|j_d|j_
d|j_x3|D]+}|jtjkr’|j||ƒq’q’W|jjj|j|jjƒƒtd|jj
ƒ|j_
td|jjƒ|j_dS(súCalculate resource usage based on instance utilization.  This is
        different than the hypervisor's view as it will account for all
        instances assigned to the local compute host, even if they are not
        currently powered on.
        iiN(R4R²R1treserved_host_disk_mbR/Rètreserved_host_memory_mbRæRêRBRïRçRðRRRRRRWR9Rtremove_deleted_instancesRtmax(R>RZRÓR!((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyRÚps"
		
c	Cs€t|jjƒƒ}t|jjƒƒ}||B}|jjƒ}t|jƒƒ}||}g|D]}||^qf}|S(smGiven the set of instances and migrations already account for
        by resource tracker, sanity check the hypervisor to determine
        if there are any "orphaned" instances left hanging around.

        Orphans could be consuming memory and should be accounted for in
        usage calculations to guard against potential out of memory
        errors.
        (t	frozensetR4tkeysR5R+tget_per_instance_usage(	R>tuuids1tuuids2tuuidsRtvuuidstorphan_uuidsRRRã((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyRތs	

cCsaxZ|D]R}|d}tjtdƒi|dd6|d6ƒi|d6}|j|ƒqWdS(s$Include orphaned instances in usage.RBsNDetected running orphan instance: %(uuid)s (consuming %(memory_mb)s MB memory)RRN(RIRJR
Rš(R>RãtorphanRBR((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyRß¡s


cCsrddddddddg}g|D]}||kr%|^q%}|rntd	ƒ|}tjd
|ƒ‚ndS(NRéRBRçRÈRêRæRèRUsMissing keys: %streason(RRtInvalidInput(R>R¦t
resource_keystktmissing_keysR.((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyRË®s		%cCs1|jdk}|r&t|d|ƒS|jSdS(s$Get the instance type from instance.R%s%sflavorN(sresize(R'RRA(R>RZR!R“R
tstashed_flavors((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyR–¸scKsÂi}t|tjƒr_i|jjd6|jjd6|jjd6|jjd6|jd6}n1t|tj	ƒrƒt
j|ƒ}n
|j|ƒx+dD]#}||kr—||||<q—q—W|S(s8Make a usage dict _update methods expect.

        Accepts a dict or an Instance or Flavor object, and a set of updates.
        Converts the object to a dict and applies the updates.

        :param object_or_dict: instance or flavor as an object or just a dict
        :param updates: key-value pairs to update the passed object.
                        Currently only considers 'numa_topology', all other
                        keys are ignored.

        :returns: a dict with all the information from object_or_dict updated
                  with updates
        RBRéRNRþRU(s
numa_topology(
t
isinstanceRtInstanceRARBRéRNRþRUtFlavorRûRtupdate(R>tobject_or_dicttupdatesRtkey((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyR˜Ãs




N(-t__name__t
__module__t__doc__R@RtsynchronizedtCOMPUTE_RESOURCE_SEMAPHORER,R^RcRdRaRnRmRGRŽR‘RŸR tpropertyRFR§R¢R¡RÇRÎRÕRÍR¤RÌRáRýRYRšR—R{RÝR RWRÚRÞRßRËR–R˜(((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyR)OsX	F_		
	

	.					6			$	%				F	)'			
	
	(1R=R´toslo_logRtloggingtoslo_serializationRt
oslo_utilsRtnova.computeRRRRt	nova.conftnovaRt	nova.i18nRR	R
Rtnova.objectsRRûR
RŠtnova.pciRRªRRoRtnova.schedulerRR9Rt	nova.virtRtconfR1t	getLoggerR;RIR?R$R(tobjectR)(((sR/home/tvault/.virtenv/lib/python2.7/site-packages/nova/compute/resource_tracker.pyt<module>s4