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 / virt / hardware.pyc
Size: Mime:
ó
±EYc@s‹ddlZddlZddlZddlmZddlmZddlm	Z	ddlm
Z
ddlZddlZ
ddl
mZddl
mZddlmZmZdd	l
mZdd
lmZddlmZe
jjZejeƒZdZdZd
Zd„Z d„Z!e"d„Z#d„Z$de%fd„ƒYZ&d„Z'd„Z(d„Z)d„Z*d„Z+e"dd„Z-e"dd„Z.d„Z/dd„Z0d„Z1dd„Z2d „Z3d!„Z4d"„Z5d#„Z6d$„Z7d%„Z8d&„Z9d'„Z:d(„Z;d)„Z<d*„Z=d+„Z>d,„Z?dddd-„Z@d.„ZAd/„ZBeCd0„ZDd1„ZEd2„ZFeCeCd3„ZGdS(4iÿÿÿÿN(tlog(t	jsonutils(tstrutils(tunits(tcontext(t	exception(t_t_LI(tobjects(tfields(tinstanceiþÿÿÿiýÿÿÿcCsEtjs
dSttjƒ}|sAtjtdƒtjƒ‚n|S(sZParsing vcpu_pin_set config.

    Returns a set of pcpu ids can be used by instances.
    s"No CPUs available after parsing %rN(tCONFtvcpu_pin_settNonetparse_cpu_specRtInvalidR(t
cpuset_ids((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pytget_vcpu_pin_set*s	c	Cs6tƒ}tƒ}x|jdƒD]}|jƒ}t|ƒdkrLq"n|jddƒ}t|ƒdkrt}|drµ|dddkrµt}t|ddƒ|d<ny/g|D]}t|jƒƒ^q¿\}}Wn*tk
rt	j
tdƒ|ƒ‚nX||kr9t	j
tdƒ|ƒ‚n|s_|tt||dƒƒO}q$|tt||dƒƒO}q"|ddkrày!|j
t|djƒƒƒWq$tk
rÜt	j
tdƒ|ƒ‚q$Xq"y|j
t|ƒƒWq"tk
r#t	j
tdƒ|ƒ‚q"Xq"W||8}|S(	s!Parse a CPU set specification.

    :param spec: cpu set string eg "1-4,^3,6"

    Each element in the list is either a single
    CPU number, a range of CPU numbers, or a
    caret followed by a CPU number to be excluded
    from a previous range.

    :returns: a set of CPU indexes
    t,it-it^sInvalid range expression %rsInvalid exclusion expression %rsInvalid inclusion expression %r(tsettsplittstriptlentFalsetTruetstrtintt
ValueErrorRRRtrangetadd(	tspecRtcpuset_reject_idstruletrange_partstrejecttptstarttend((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyR9sH
		/

  !


cCs|råg}d}xWt|ƒD]I}|dksA||dkrQ|jgƒn|dj|ƒ|}qWg}xc|D][}t|ƒdkr«|jt|dƒƒqy|jd|d|t|ƒdfƒqyWdj|ƒSdjd„t|ƒDƒƒSdS(sdFormat a libvirt CPU range specification.

    :param cpuset: set (or list) of CPU indexes

    Format a set/list of CPU indexes as a libvirt CPU
    range specification. It allow_ranges is true, it
    will try to detect continuous ranges of CPUs,
    otherwise it will just list each CPU index explicitly.

    :returns: a formatted CPU range string
    iiÿÿÿÿis%d-%dRcss|]}t|ƒVqdS(N(R(t.0tid((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pys	<genexpr>šsN(R
tsortedtappendRRtjoin(tcpusettallow_rangestrangest	previndextcpuindextpartstentry((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pytformat_cpu_specys

-
cCsqd„}||jdƒ}|jjddƒ}|o9|dk	ra||kr]tjƒ‚n|S|pp|ppdS(sIGet the number of serial consoles from the flavor or image

    :param flavor: Flavor object to read extra specs from
    :param image_meta: nova.objects.ImageMeta object instance

    If flavor extra specs is not set, then any image meta value is permitted.
    If flavor extra specs *is* set, then this provides the default serial
    port count. The image meta is permitted to override the extra specs, but
    *only* with a lower value. ie

    - flavor hw:serial_port_count=4
      VM gets 4 serial ports
    - flavor hw:serial_port_count=4 and image hw_serial_port_count=2
      VM gets 2 serial ports
    - image hw_serial_port_count=6
      VM gets 6 serial ports
    - flavor hw:serial_port_count=4 and image hw_serial_port_count=6
      Abort guest boot - forbidden to exceed flavor value

    :returns: number of serial ports
    cSs^|j|ƒ}|dk	rZyt|ƒ}WqZtk
rVtjd|d|ƒ‚qZXn|S(Nt	num_portstproperty(tgetR
RRRtImageSerialPortNumberInvalid(tobjR6R5((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt
get_number´s
	shw:serial_port_countthw_serial_port_countiN(textra_specst
propertiesR7R
Rt&ImageSerialPortNumberExceedFlavorValue(tflavort
image_metaR:tflavor_num_portstimage_num_ports((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pytget_number_of_serial_portss	
tInstanceInfocBs,eZddddddd„Zd„ZRS(icCs:||_||_||_||_||_||_dS(s»Create a new Instance Info object

        :param state: the running state, one of the power_state codes
        :param max_mem_kb: (int) the maximum memory in KBytes allowed
        :param mem_kb: (int) the memory in KBytes used by the instance
        :param num_cpu: (int) the number of virtual CPUs for the instance
        :param cpu_time_ns: (int) the CPU time used in nanoseconds
        :param id: a unique ID for the instance
        N(tstatet
max_mem_kbtmem_kbtnum_cputcpu_time_nsR)(tselfRERFRGRHRIR)((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt__init__Ës					cCs"|j|jko!|j|jkS(N(t	__class__t__dict__(RJtother((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt__eq__ÝsN(t__name__t
__module__R
RKRO(((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyRDÉscCs”d}|jdkr4|j|jkr4|d}n|jdkrb|j|jkrb|d}n|jdkr|j|jkr|d}n|S(sbCalculate score for the topology against a desired configuration

    :param wanttopology: nova.objects.VirtCPUTopology instance for
                         preferred topology

    Calculate a score indicating how well this topology
    matches against a preferred topology. A score of 3
    indicates an exact match for sockets, cores and threads.
    A score of 2 indicates a match of sockets & cores or
    sockets & threads or cores and threads. A score of 1
    indicates a match of sockets or cores or threads. A
    score of 0 indicates no match

    :returns: score in range 0 (worst) to 3 (best)
    iiÿÿÿÿi(tsocketstcorestthreads(ttopologytwanttopologytscore((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_score_cpu_topologyâs


cCs;t|jjddƒƒ}t|jjddƒƒ}t|jjddƒƒ}tjdi|d6|d6|d6ƒ|j}|jd	|ƒ}|jd
|ƒ}|jd|ƒ}tjdi|d6|d6|d6ƒ||ksþ||ksþ||kr1tjd|d|d|d
|d|d|ƒ‚nt|jjddƒƒ}	t|jjddƒƒ}
t|jjddƒƒ}tjdi|	d6|
d6|d6ƒ|	|ksË|
|ksË||krÜd}	}
}n|jddƒ}|jddƒ}
|jddƒ}tjdi|d6|
d6|d6ƒ||ks[|
|ks[||krŽtjd|d|
d|d
|d|d|ƒ‚n|dkrÇ|
dkrÇ|dkrÇ|	}|
}
|}ntjdi|d6|
d6|d6|d
6|d6|d6ƒt	j
d|d|
d|ƒt	j
d|d|d|ƒfS(siGet the topology constraints declared in flavor or image

    :param flavor: Flavor object to read extra specs from
    :param image_meta: nova.objects.ImageMeta object instance

    Gets the topology constraints from the configuration defined
    in the flavor extra specs or the image metadata. In the flavor
    this will look for

     hw:cpu_sockets - preferred socket count
     hw:cpu_cores - preferred core count
     hw:cpu_threads - preferred thread count
     hw:cpu_max_sockets - maximum socket count
     hw:cpu_max_cores - maximum core count
     hw:cpu_max_threads - maximum thread count

    In the image metadata this will look at

     hw_cpu_sockets - preferred socket count
     hw_cpu_cores - preferred core count
     hw_cpu_threads - preferred thread count
     hw_cpu_max_sockets - maximum socket count
     hw_cpu_max_cores - maximum core count
     hw_cpu_max_threads - maximum thread count

    The image metadata must be strictly lower than any values
    set in the flavor. All values are, however, optional.

    This will return a pair of nova.objects.VirtCPUTopology instances,
    the first giving the preferred socket/core/thread counts,
    and the second giving the upper limits on socket/core/
    thread counts.

    exception.ImageVCPULimitsRangeExceeded will be raised
    if the maximum counts set against the image exceed
    the maximum counts set against the flavor

    exception.ImageVCPUTopologyRangeExceeded will be raised
    if the preferred counts set against the image exceed
    the maximum counts set against the image or flavor

    :returns: (preferred topology, maximum topology)
    shw:cpu_max_socketsishw:cpu_max_coresshw:cpu_max_threadss/Flavor limits %(sockets)d:%(cores)d:%(threads)dRRRSRTthw_cpu_max_socketsthw_cpu_max_coresthw_cpu_max_threadss.Image limits %(sockets)d:%(cores)d:%(threads)dt
maxsocketstmaxcorest
maxthreadsshw:cpu_socketsiÿÿÿÿshw:cpu_coresshw:cpu_threadss-Flavor pref %(sockets)d:%(cores)d:%(threads)dthw_cpu_socketsthw_cpu_coresthw_cpu_threadss,Image pref %(sockets)d:%(cores)d:%(threads)dsZChosen %(sockets)d:%(cores)d:%(threads)d limits %(maxsockets)d:%(maxcores)d:%(maxthreads)d(RR<R7tLOGtdebugR=RtImageVCPULimitsRangeExceededtImageVCPUTopologyRangeExceededRtVirtCPUTopology(R?R@t
flvmaxsocketstflvmaxcorest
flvmaxthreadstpropsR\R]R^t
flvsocketstflvcorest
flvthreadsRRRSRT((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_get_cpu_topology_constraintssˆ.	
		
		
	
	$		c
Cs~t||jƒ}t||jƒ}t||jƒ}|sEd}ntjdi|d6|d6|d6|d6ƒg}x–td|dƒD]}xxtd|dƒD]c}xZtd|dƒD]E}	|	|||krßq¿n|jtj	d|d|d	|	ƒƒq¿Wq¥Wq‹Wt
|d
tdd„ƒ}tjd
t|ƒƒt|ƒdkrzt
jd|d|d|d	|ƒ‚n|S(sÖGet a list of possible topologies for a vCPU count
    :param vcpus: total number of CPUs for guest instance
    :param maxtopology: nova.objects.VirtCPUTopology for upper limits
    :param allow_threads: if the hypervisor supports CPU threads

    Given a total desired vCPU count and constraints on the
    maximum number of sockets, cores and threads, return a
    list of nova.objects.VirtCPUTopology instances that represent every
    possible topology that satisfies the constraints.

    exception.ImageVCPULimitsRangeImpossible is raised if
    it is impossible to achieve the total vcpu count given
    the maximum limits on sockets, cores & threads.

    :returns: list of nova.objects.VirtCPUTopology instances
    isQBuild topologies for %(vcpus)d vcpu(s) %(maxsockets)d:%(maxcores)d:%(maxthreads)dtvcpusR\R]R^RRRSRTtreversetkeycSs|j|j|j|jfS(N(RRRSRT(tx((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt<lambda>Ès
sGot %d possible topologiesi(tminRRRSRTRbRcRR+RRfR*RRRtImageVCPULimitsRangeImpossible(
Rotmaxtopologyt
allow_threadsR\R]R^tpossibletstctt((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_get_possible_cpu_topologies’s6		cCs„d}x>|D]6}|j|kr(q
n|j|kr
|j}q
q
Wg}x0|D](}|j|kroqTn|j|ƒqTW|S(sëFilter to topologies which closest match to NUMA threads
    :param possible: list of nova.objects.VirtCPUTopology
    :param wantthreads: ideal number of threads

    Determine which topologies provide the closest match to
    the number of threads desired by the NUMA topology of
    the instance.

    The possible topologies may not have any entries
    which match the desired thread count. So this method
    will find the topologies which have the closest
    matching count.

    ie if wantthreads is 4 and the possible topologies
    has entries with 6, 3, 2 or 1 threads, it will
    return the topologies which have 3 threads, as
    this is the closest match not greater than 4.

    :returns: list of nova.objects.VirtCPUTopology
    i(RTR+(RxtwantthreadstmostthreadsRUtbestthreads((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_filter_for_numa_threadsÖs

cCsŽtjtƒ}x.|D]&}t||ƒ}||j|ƒqWg}|j|dƒ|j|dƒ|j|dƒ|j|dƒ|S(s¿Sort the topologies in order of preference
    :param possible: list of nova.objects.VirtCPUTopology instances
    :param wanttopology: nova.objects.VirtCPUTopology for preferred
                         topology

    This takes the list of possible topologies and resorts
    it such that those configurations which most closely
    match the preferred topology are first.

    :returns: sorted list of nova.objects.VirtCPUTopology instances
    iiii(tcollectionstdefaultdicttlistRXR+textend(RxRVtscoresRURWtdesired((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_sort_possible_cpu_topologiess
cCsatjdi|d6|d6|d6ƒt||ƒ\}}tjdi|d6|d6ƒt|j||ƒ}tjd|ƒ|r>d}g|jD]}|jr“|j^q“}	|	rÐtd	„|	Dƒƒ}n|r>|j	d
krút|j	|ƒ}nt
d|ƒ}
tjd|
ƒt||
ƒ}tjd
|ƒq>nt||ƒ}tjd|ƒ|S(sòGet desired CPU topologies according to settings

    :param flavor: Flavor object to query extra specs from
    :param image_meta: nova.objects.ImageMeta object instance
    :param allow_threads: if the hypervisor supports CPU threads
    :param numa_topology: InstanceNUMATopology object that may contain
                          additional topology constraints (such as threading
                          information) that we should consider

    Look at the properties set in the flavor extra specs and
    the image metadata and build up a list of all possible
    valid CPU topologies that can be used in the guest. Then
    return this list sorted in order of preference.

    :returns: sorted list of nova.objects.VirtCPUTopology instances
    slGetting desirable topologies for flavor %(flavor)s and image_meta %(image_meta)s, allow threads: %(threads)sR?R@RTs5Topology preferred %(preferred)s, maximum %(maximum)st	preferredtmaximumsPossible topologies %scss|]}|jVqdS(N(RT(R(ttopo((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pys	<genexpr>Isiÿÿÿÿis(Filtering topologies best for %d threadss Remaining possible topologies %ssSorted desired topologies %sN(
RbRcRnR|RoR
tcellstcpu_topologyRtRTtmaxR€R‡(R?R@Rwt
numa_topologyRˆR‰Rxtmin_requested_threadstcelltcell_topologiestspecified_threadsR†((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_get_desirable_cpu_topologies"s>								
cCst||||ƒdS(sáGet best CPU topology according to settings

    :param flavor: Flavor object to query extra specs from
    :param image_meta: nova.objects.ImageMeta object instance
    :param allow_threads: if the hypervisor supports CPU threads
    :param numa_topology: InstanceNUMATopology object that may contain
                          additional topology constraints (such as threading
                          information) that we should consider

    Look at the properties set in the flavor extra specs and
    the image metadata and build up a list of all possible
    valid CPU topologies that can be used in the guest. Then
    return the best topology to use

    :returns: a nova.objects.VirtCPUTopology instance for best topology
    i(R“(R?R@RwRŽ((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pytget_best_cpu_topology^s	cCs·g|jD]}|j^q
}|jdtƒd„}|jtkr[||||dƒS|jtkr~||||d ƒS|jtkr||||ƒS||||jgƒSdS(sWDetermines whether the cell can accept the request.

    :param host_cell: host cell to fit the instance cell onto
    :param inst_cell: instance cell we want to fit

    :raises: exception.MemoryPageSizeNotSupported if custom page
             size not supported in host cell.

    :returns: The page size able to be handled by host_cell
    RpcSs;|jtj}x$|D]}|j||ƒr|SqWdS(N(tmemoryRtKitcan_fit_hugepages(t	host_cellt	inst_celltavail_pagesizet
inst_cell_memtpagesize((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pytverify_pagesizesƒs
iÿÿÿÿN(tmempagestsize_kbtsortRRœtMEMPAGES_SMALLtMEMPAGES_LARGEtMEMPAGES_ANY(R˜R™tpageRšR((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt$_numa_cell_supports_pagesize_requestus	icstjtƒ}xC|D];}x2tdt|ƒdƒD]}||j|ƒq6WqWd
}d}d„‰‡fd†}d„}	|jtj	j
kr°tjdt|ƒƒnr|jtj	j
krÞtjdt|ƒƒnD|jtj	jkrtjdt|ƒƒntjdt|ƒƒ|jtj	jkrp||krTtjd	ƒd
S|	d|||jƒ}nËxytd„|jƒDƒdtƒD]U\}}
|jtj	j
krÉ|dkrÉq“qÉn|	||
|jƒ}|r“Pq“q“W|jtj	j
kr,|r,tt|jƒtj|
Œƒ}n|||ƒ}|sEd
Stjd
ddt|ƒ|d|ƒ}|j|Œ||_||_|S(sNPack an instance onto a set of siblings

    :param available_siblings: list of sets of CPU id's - available
                               siblings per core
    :param instance_cell: An instance of objects.InstanceNUMACell describing
                          the pinning requirements of the instance
    :param threads_per_core: number of threads per core in host's cell

    :returns: An instance of objects.InstanceNUMACell containing the pinning
              information, and potentially a new topology to be exposed to the
              instance. None if there is no valid way to satisfy the sibling
              requirements for the instance.

    This method will calculate the pinning for the given instance and it's
    topology, making sure that hyperthreads of the instance match up with
    those of the host when the pinning takes effect.

    Currently the strategy for packing is to prefer siblings and try use cores
    evenly, by using emptier cores first. This is achieved by the way we order
    cores in the sibling_sets structure, and the order in which we iterate
    through it.

    The main packing loop that iterates over the sibling_sets dictionary will
    not currently try to look for a fit that maximizes number of siblings, but
    will simply rely on the iteration ordering and picking the first viable
    placement.
    icSst|ƒ|S(s,Number of instance CPUs which will not fill up a host core.

        Best explained by an example: consider set of free host cores as such:
            [(0, 1), (3, 5), (6, 7, 8)]
        This would be a case of 2 threads_per_core AKA an entry for 2 in the
        sibling_sets structure.

        If we attempt to pack a 5 core instance on it - due to the fact that we
        iterate the list in order, we will end up with a single core of the
        instance pinned to a thread "alone" (with id 6), and we would have one
        'orphan' vcpu.
        (R(t
instance_celltthreads_per_core((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_orphans¾s
cstj|ˆ||ƒƒS(s8Threads to expose to the instance via the VirtCPUTopology.

        This is calculated by taking the GCD of the number of threads we are
        considering at the moment, and the number of orphans. An example for
            instance_cell = 6
            threads_per_core = 4

        So we can fit the instance as such:
            [(0, 1, 2, 3), (4, 5, 6, 7), (8, 9, 10, 11)]
              x  x  x  x    x  x

        We can't expose 4 threads, as that will not be a valid topology (all
        cores exposed to the guest have to have an equal number of threads),
        and 1 would be too restrictive, but we want all threads that guest sees
        to be on the same physical core, so we take GCD of 4 (max number of
        threads) and 2 (number of 'orphan' CPUs) and get 2 as the number of
        threads.
        (t	fractionstgcd(R¦R§(R¨(sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_threadsÍscsTˆt|ƒt|ƒkr dSt‡fd†|ƒ}tt|ƒtj|ŒƒS(s Generate a CPU-vCPU pin mapping.Ncst|ƒˆ S(N(Rƒ(Ry(t
threads_no(sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyRsès(RtmaptzipR*t	itertoolstchain(R¬tsibling_settinstance_corestusable_cores((R¬sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_get_pinningãs
s.Requested 'require' thread policy for %d coress-Requested 'prefer' thread policy for %d coress.Requested 'isolate' thread policy for %d coress@User did not specify a thread policy. Using default for %d coress‹Host does not have any fully free thread sibling sets.It is not possible to emulate a non-SMT behavior for the isolate policy without this.Ncss|]}|VqdS(N((R(R{((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pys	<genexpr>sRpRRRSRT(RR‚RƒRRR+R
tcpu_thread_policyR	tCPUThreadAllocationPolicytREQUIRERbRctPREFERtISOLATER-R*titemsRR®R¯R°RRft	pin_vcpusRŒR)(tavailable_siblingsR¦thost_cell_idR§tsibling_setstsibR¬tpinningR«R´R±RU((R¨sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_pack_instance_onto_cores“sp#
 		
				

)			
		cCs9|jt|jƒkrFtjdit|jƒd6|jd6ƒdS|j|jkr€tjdi|jd6|jd6ƒdS|jr¹t|j	||j
ttt|jƒƒƒ}nf|j
tjjkråtjtdƒƒdSg|jD]}t|gƒ^qï}t|||j
ƒ}|s5tjdƒn|S(sËFigure out if cells can be pinned to a host cell and return details

    :param host_cell: objects.NUMACell instance - the host cell that
                      the isntance should be pinned to
    :param instance_cell: objects.InstanceNUMACell instance without any
                          pinning information

    :returns: objects.InstanceNUMACell instance with pinning information,
              or None if instance cannot be pinned to the given host
    s’Not enough available CPUs to schedule instance. Oversubscription is not possible with pinned instances. Required: %(required)s, actual: %(actual)strequiredtactualNs”Not enough available memory to schedule instance. Oversubscription is not possible with pinned instances. Required: %(required)s, actual: %(actual)ssoHost does not support hyperthreading or hyperthreading is disabled, but 'require' threads policy was requested.s2Failed to map instance cell CPUs to host cell CPUs(t
avail_cpusRR-RbRctavail_memoryR•tsiblingsRÁt
free_siblingsR)RR­RµR	R¶R·tinfoRt	free_cpusR(R˜R¦t	numa_celltcpuRÉ((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt$_numa_fit_instance_cell_with_pinning5s0		
	%c	CsË|j|jkr:tjdi|jd6|jd6ƒdSt|jƒt|jƒkrŒtjdit|jƒd6t|jƒd6ƒdS|jrÃt||ƒ}|s®dS|j|_|}n±|rt|j|j}|j	t|jƒ}t|jƒ|j
}|j|j}||krCtjdi|d6|d6ƒdS||krttjd	i|d6|d6ƒdSnd}|jr²t
||ƒ}|s²tjd
|jƒdSn|j|_||_|S(sæCheck if an instance cell can fit and set it's cell id

    :param host_cell: host cell to fit the instance cell onto
    :param instance_cell: instance cell we want to fit
    :param limit_cell: an objects.NUMATopologyLimit or None

    Make sure we can fit the instance cell onto a host cell and if so,
    return a new objects.InstanceNUMACell with the id set to that of
    the host, or None if the cell exceeds the limits of the host

    :returns: a new instance cell or None
    s\Not enough host cell memory to fit instance cell. Required: %(required)d, actual: %(actual)dRÂRÃNsZNot enough host cell CPUs to fit instance cell. Required: %(required)d, actual: %(actual)ds‰Host cell has limitations on usable memory. There is not enough free memory to schedule this instance. Usage: %(usage)d, limit: %(limit)dtusagetlimits†Host cell has limitations on usable CPUs. There are not enough free CPUs to schedule this instance. Usage: %(usage)d, limit: %(limit)dsAHost does not support requested memory pagesize. Requested: %d kB(R•RbRcRR-tcpu_pinning_requestedRÌRœtmemory_usaget	cpu_usagetcpu_allocation_ratiotram_allocation_ratioR
R¥R)(	R˜R¦t
limit_celltnew_instance_cellRÐRÑt	cpu_limitt	ram_limitRœ((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_numa_fit_instance_cellisR	
							
	cCsÁd„}|jdiƒjddƒ}|jjddƒ}|rd|rdtjd|ddƒ‚n|snd	S||ƒ}|rœ|ttfkrœ||ƒS|r½tjd|d|ƒ‚n|S(
sReturn the requested memory page size

    :param flavor: a Flavor object to read extra specs from
    :param image_meta: nova.objects.ImageMeta object instance

    :raises: MemoryPagesSizeInvalid or MemoryPageSizeForbidden
    :returns: a page size requested or MEMPAGES_*
    cSs³|dkrtS|dkr tS|dkr0tSyt|ƒ}WnKtk
ry tj|dtƒtj	}WqŽtk
r‰d}qŽXnX|dkr¯t
jd|ƒ‚n|S(Ntanytlargetsmallt
return_intiRœ(R£R¢R¡RRRtstring_to_bytesRRR–RtMemoryPageSizeInvalid(trequest((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pytcheck_and_return_pages_size¸s"

R<shw:mem_page_sizetthw_mem_page_sizeRœtagainsts<empty>N(R7R=RtMemoryPageSizeForbiddenR
R£R¢(R?R@Ràtflavor_requestt
image_requestRœ((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_numa_get_pagesize_constraints®s"
	
	
	cCstg}|jdiƒ}xKttjjƒD]7}d|}||krKPn|jt||ƒƒq+W|rp|SdS(NR<shw:numa_cpus.%d(R7RRtImageMetaPropstNUMA_NODES_MAXR+R(R?thw_numa_cpusR<tcellidtcpuprop((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_numa_get_flavor_cpu_map_listæs
cCsZt|ƒ}|jjddƒ}|dkr1|S|dk	rRtjddƒ‚n|SdS(NRêtname(RíR=R7R
RtImageNUMATopologyForbidden(R?R@tflavor_cpu_listtimage_cpu_list((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_numa_get_cpu_map_listôs	cCstg}|jdiƒ}xKttjjƒD]7}d|}||krKPn|jt||ƒƒq+W|rp|SdS(NR<shw:numa_mem.%d(R7RRRèRéR+R(R?thw_numa_memR<Rëtmemprop((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_numa_get_flavor_mem_map_lists
cCsZt|ƒ}|jjddƒ}|dkr1|S|dk	rRtjddƒ‚n|SdS(NRóRî(RõR=R7R
RRï(R?R@tflavor_mem_listtimage_mem_list((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_numa_get_mem_map_lists	c	CsMg}d}tt|jƒƒ}xËt|ƒD]½}||}||}	xq|	D]i}
|
|jdkrŠtjd|
d|jdƒ‚n|
|kr«tjd|
ƒ‚n|j|
ƒqOW|jtj	d|d|	d|ƒƒ||}q.W|rtj
dt|ƒƒ‚n||jkr=tj
d|d	|jƒ‚ntjd
|ƒS(NiitcpunumtcpumaxR)R-R•tmemsizetmemtotalR‹(RRRoRtImageNUMATopologyCPUOutOfRangetImageNUMATopologyCPUDuplicatestremoveR+RtInstanceNUMACelltImageNUMATopologyCPUsUnassignedRt	memory_mbt!ImageNUMATopologyMemoryOutOfRangetInstanceNUMATopology(tnodesR?tcpu_listtmem_listR‹ttotalmemt	availcpustnodetmemR-RË((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_numa_get_constraints_manuals2


				cCs(|jdiƒjdƒ}tj|ƒS(NR<shw:cpu_realtime(R7Rtbool_from_string(R?t	flavor_rt((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pytis_realtime_enabled@scCs7|jdiƒjdƒ}|jjdƒ}|p6|S(s0Returns realtime mask based on flavor/image metaR<shw:cpu_realtime_maskthw_cpu_realtime_mask(R7R=(R?timagetflavor_maskt
image_mask((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_get_realtime_maskEscCs‹t||ƒ}|s$tjƒ‚nt|ƒ}t|d|ƒ}||}t|ƒdksrt|ƒdkrtjƒ‚n||fS(sØPartitions vcpus used for realtime and 'normal' vcpus.

    According to a mask specified from flavor or image, returns set of
    vcpus configured for realtime scheduler and set running as a
    'normal' vcpus.
    s, i(RRtRealtimeMaskNotFoundOrInvalidR4RR(t	vcpus_setR?Rtmaskt
vcpus_spectvcpus_rttvcpus_em((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pytvcpus_realtime_topologyLs
$c
CsÐ|j|dks&|j|dkr5tjƒ‚ng}x‚t|ƒD]t}t|j|ƒ}t|j|ƒ}||}tt|||ƒƒ}|jtj	d|d|d|ƒƒqHWtj
d|ƒS(NiR)R-R•R‹(RoRRtImageNUMATopologyAsymmetricRRRR+RRR(RR?R‹R
tncpusRR&R-((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_numa_get_constraints_auto`s
cCs3|jdiƒjdƒ}|jjdƒ}|tjjkrH|}nc|tjjkr„|tjjkr{tjƒ‚n|}n'|tjjkrŸ|}ntjj}t|ƒ}|rÞ|tjjkrÞtj	ƒ‚n%|rt
||ƒrtjƒ‚n|jdiƒjdƒ}|jjdƒ}|tjjkra|sN|r]tjƒ‚n|S|dtjjgkrˆ|p‚|}	n'|r©||kr©tjƒ‚n|}	|rÞxw|jD]}
||
_|	|
_q¿WnQtjdddtt|jƒƒd	|jd
|d|	ƒ}tjd|gƒ}|S(
NR<s
hw:cpu_policyt
hw_cpu_policyshw:cpu_thread_policythw_cpu_thread_policyR)iR-R•t
cpu_policyRµR‹(R7R=R	tCPUAllocationPolicyt	DEDICATEDtSHAREDRtImageCPUPinningForbiddenRtRealtimeConfigurationInvalidRRt#CPUThreadPolicyConfigurationInvalidR
R¶R¸tImageCPUThreadPolicyForbiddenR‹R!RµRRRRRoRR(R?R@RŽt
flavor_policytimage_policyR!trttflavor_thread_policytimage_thread_policyRµRtsingle_cell((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_add_cpu_pinning_constraintrsP								cCsG|dk	rCtj|ƒs.t|ƒdkrCtjd|ƒ‚ndS(s¼Validate NUMA nodes number

    :param nodes: The number of NUMA nodes
    :raises: exception.InvalidNUMANodesNumber if the given
             parameter is not a number or less than 1
    iRN(R
Rtis_int_likeRRtInvalidNUMANodesNumber(R((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_validate_numa_nodes¦sc	CsÇ|jdiƒjdƒ}|j}|dk	rmt|ƒ|jdƒr^tjddƒ‚nt|ƒ}n|jdƒ}t|ƒt||ƒ}d}|s§|r·|p°d}t	||ƒ}t
||ƒ}|dkré|dk	s|dk	r|dkrtjƒ‚n|dk	r.t|ƒ|ksL|dk	r[t|ƒ|kr[tjƒ‚n|dkryt
||ƒ}nt||||ƒ}g|jD]}t|d|ƒ^q˜nt|||ƒS(s$Return topology related to input request

    :param flavor: Flavor object to read extra specs from
    :param image_meta: nova.objects.ImageMeta object instance

    May raise exception.ImageNUMATopologyIncomplete() if the
    image properties are not correctly specified, or
    exception.ImageNUMATopologyForbidden if an attempt is
    made to override flavor settings with image properties.
    exception.InvalidNUMANodesNumber if the number of NUMA
    nodes is less than 1 (or not an integer).

    :returns: InstanceNUMATopology or None
    R<s
hw:numa_nodest
hw_numa_nodesRîiRœN(R7R=R
R2tobj_attr_is_setRRïRRçRòRøtImageNUMATopologyIncompleteRRRR‹tsetattrR/(	R?R@RRjRœRŽRRRz((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pytnuma_get_constraints³s<	
	
)c
Cs`|o	|stjdƒdSt|ƒt|ƒkrctjdit|ƒd6t|ƒd6ƒdSxötj|jt|ƒƒD]Ù}g}xkt||jƒD]W\}}yt|||ƒ}	Wntj	k
r×PnX|	dkrèPn|j|	ƒqžWt|ƒt|ƒkr|s'tj
d|ƒS|dk	rX|j||ƒrXtj
d|ƒSqqWdS(sÈFit the instance topology onto the host topology given the limits

    :param host_topology: objects.NUMATopology object to fit an instance on
    :param instance_topology: objects.InstanceNUMATopology to be fitted
    :param limits: objects.NUMATopologyLimits that defines limits
    :param pci_requests: instance pci_requests
    :param pci_stats: pci_stats for the host

    Given a host and instance topology and optionally limits - this method
    will attempt to fit instance cells onto all permutations of host cells
    by calling the _numa_fit_instance_cell method, and return a new
    InstanceNUMATopology with it's cell ids set to host cell id's of
    the first successful permutation, or None.
    sGRequire both a host and instance NUMA topology to fit instance on host.Ns|There are not enough free cores on the system to schedule the instance correctly. Required: %(required)s, actual: %(actual)sRÂRÃR‹(RbRcRR¯tpermutationsR‹R®RØRtMemoryPageSizeNotSupportedR
R+RRtsupport_requests(
t
host_topologytinstance_topologytlimitstpci_requestst	pci_statsthost_cell_permR‹R˜R¦tgot_cell((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pytnuma_fit_instance_to_hostðs8
				cCsÙi}tjrÕy‘tjtƒ}x{tjD]p}yt|dƒ}Wn1tk
rxtj|ddt	ƒt
j}nXt|dƒ|t|dƒ|<q+WWqÕttt
fk
rÑtjdtjƒ‚qÕXn|S(sØReturns reserved memory pages from host option

    Based from the compute node option reserved_huge_pages, this
    method will return a well formatted list of dict which can be used
    to build NUMATopology.

    :raises: exception.InvalidReservedMemoryPagesOption when
             reserved_huge_pages option is not correctly set.

    :returns: a list of dict ordered by NUMA node ids; keys of dict
              are pages size and values of the number reserved.
    tsizeRÜtcountR
tconf(Rtreserved_huge_pagesRR‚tdictRRRRÝRRR–t	TypeErrortKeyErrorRt InvalidReservedMemoryPagesOption(tbuckettcfgRœ((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pytnuma_get_reserved_huge_pages(s
	
*	c
Cs«g}xž|jD]“}|j|jkr–|jtjd|jd|jdtd|j|j	t
j|j|ƒdd|kr‰|jndƒƒq|j|ƒqW|S(NRŸttotaltuseditreserved(
RžRŸRœR+RtNUMAPagesTopologyRNRROR•RR–RP(thostcelltinstancecelltsignRŠtpages((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt_numa_pagesize_usage_from_cellFs		"c
CsL|dkrdS|pg}g}|r.dnd}x|jD]ú}|j}|j}tjd|jd|jd|jddd	dd
|j	d|j
d|jƒ}x`|D]X}	xO|	jD]D}
|
j|jkr»|||
j}t|
jƒ}|
j
tjjkr0|jr0|ttt|jƒƒ9}n|||7}|
jrn|
jdkrnt||
|ƒ|_	n|	jrÿt|
jjƒƒ}|rÇ|
j
tjjkr·|j|ƒqù|j|ƒqü|
j
tjjkrì|j|ƒqü|j|ƒqÿq»q»Wq«Wtd|ƒ|_td|ƒ|_|j|ƒq>Wtjd
|ƒS(sgGet host topology usage

    :param host: objects.NUMATopology with usage information
    :param instances: list of objects.InstanceNUMATopology
    :param free: If True usage of the host will be decreased

    Sum the usage from all @instances to report the overall
    host topology usage

    :returns: objects.NUMATopology including usage information
    NiÿÿÿÿiR)R-R•RÑiRÐRžtpinned_cpusRÆR‹(R
R‹RÐRÑRtNUMACellR)R-R•RžRWRÆRRµR	R¶R¹RR­RœRVRÏRtcpu_pinningtvaluestunpin_cpus_with_siblingst
unpin_cpustpin_cpus_with_siblingstpin_cpusR+tNUMATopology(
thostt	instancestfreeR‹RTRRRÐRÑtnewcellR
RStcpu_usage_diffRW((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pytnuma_usage_from_instancesVsP
			
		cCs„t|tjƒr|j}nnd|kr7|d}nUd|kr†y#tjjtjƒ|dƒ}WqŒt	j
k
r‚d}qŒXnd}|r€t|tj
ƒrÂtjjtj|ƒƒ}q€t|tƒr€|jdƒ}|r}g|D]r}tjd|ddt|dƒd|dd|jdƒd|jd	ƒd
|jd
ƒd|jdƒƒ^qí}tjd|ƒ}q}q€n|S(
sConvenience method for getting the numa_topology out of instances

    Since we may get an Instance as either a dict, a db object, or an actual
    Instance object, this makes sure we get beck either None, or an instance
    of objects.InstanceNUMATopology class.
    RŽtuuidR‹R)R-R•RœRYtcpu_pinning_rawR!RµN(t
isinstancetobj_instancetInstanceRŽRRtget_by_instance_uuidRtget_admin_contextRtNumaTopologyNotFoundR
tsixtstring_typestobj_from_primitiveRtloadsRGR7RR(R
tinstance_numa_topologyt
dict_cellsRR‹((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pytinstance_topology_from_instance˜s.
	
	|	cCsyt}y|jdƒ}Wntk
r5|j}nX|dk	rot|tjƒrot}t	j
j|ƒ}n||fS(s¹Convenience method for getting the numa_topology out of hosts

    Since we may get a host as either a dict, a db object, or an actual
    ComputeNode object, or an instance of HostState class, this makes sure we
    get back either None, or an instance of objects.NUMATopology class.

    :returns: A two-tuple, first element is the topology itself or None, second
              is a boolean set to True if topology was in JSON format.
    RŽN(RR7tAttributeErrorRŽR
RhRnRoRRR_tobj_from_db_obj(R`twas_jsonthost_numa_topology((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt"host_topology_and_format_from_hostÔs


	cCstt|ƒ}|r|g}nt|ƒ\}}t||d|ƒ}|dk	rp|rp|rp|jƒ}qpn|S(s¸Calculate new 'numa_usage' of 'host' from 'instance' NUMA usage

    This is a convenience method to help us handle the fact that we use several
    different types throughout the code (ComputeNode and Instance objects,
    dicts, scheduler HostState) which may have both json and deserialized
    versions of objects.numa classes.

    Handles all the complexity without polluting the class method with it.

    :param host: nova.objects.ComputeNode instance, or a db object or dict
    :param instance: nova.objects.Instance instance, or a db object or dict
    :param free: if True the returned topology will have it's usage
                 decreased instead.
    :param never_serialize_result: if True result will always be an instance of
                                   objects.NUMATopology class.

    :returns: numa_usage in the format it was on the host or
              objects.NUMATopology instance if never_serialize_result was True
    RbN(RtRyReR
t_to_json(R`R
Rbtnever_serialize_resultRrRxtjsonify_resulttupdated_numa_topology((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt!get_host_numa_usage_from_instanceïs
(HRR©R¯toslo_logRtloggingtoslo_serializationRt
oslo_utilsRRRnt	nova.conftnovaRRt	nova.i18nRRRtnova.objectsR	R
RiRERt	getLoggerRPRbR¡R¢R£RRRR4RCtobjectRDRXRnR|R€R‡R
R“R”R¥RÁRÌRØRçRíRòRõRøRRRRRR/R2R7RBRMRVRReRtRyR~(((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/hardware.pyt<module>sv		@$	,		’	D	*	";	!Ÿ	4E	8		
	
	
	%					4	
	>6		B	<