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 / context.pyc
Size: Mime:
ó
YT{[c@sàdZddlmZddlZddlZddlZddlmZ	ddl
mZddlm
Z
ddlmZddlmZdd	lmZddlZdd
lmZddlmZddlmZdd
lmZddlmZejeƒZia e!ƒZ"e!ƒZ#ga$dej%fd„ƒYZ&ej'de
j(fd„ƒYƒZ(d„Z)dd„Z*d„Z+d„Z,d„Z-d„Z.d„Z/d„Z0ed„ƒZ1d„Z2d„Z3d„Z4d „Z5dS(!sFRequestContext: context for requests that persist through all of nova.iÿÿÿÿ(tcontextmanagerN(tservice_catalog(tplugin(tcontext(tenginefacade(tlog(t	timeutils(t	exception(t_(tobjects(tpolicy(tutilst_ContextAuthPlugincBs5eZdZd„Zd„Zddddd„ZRS(sñA keystoneauth auth plugin that uses the values from the Context.

    Ideally we would use the plugin provided by auth_token middleware however
    this plugin isn't serialized yet so we construct one from the serialized
    auth data.
    cCs2tt|ƒjƒ||_tj|ƒ|_dS(N(tsuperRt__init__t
auth_tokentksa_service_catalogtServiceCatalogV2R(tselfRtsc((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pyR@s	cOs|jS(N(R(Rtargstkwargs((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pyt	get_tokenFsc	Ks%|jjd|d|d|d|ƒS(Ntservice_typetservice_namet	interfacetregion_name(Rturl_for(RtsessionRRRRR((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pytget_endpointIsN(t__name__t
__module__t__doc__RRtNoneR(((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pyR8s
		tRequestContextcBs°eZdZd
d
d
dd
d
d
d
ed
d„
Zd„Zd„Zd„Zd„Z	e
eee	ƒZd„Ze
d„ƒZd
d	„Zd
ed
„Zd„Zd„ZRS(sqSecurity context and request information.

    Represents the user taking a given action within the system.

    tnoc

Ks.|r||d<n|r&||d<ntt|ƒjd||||_||_|sitjƒ}nt|tj	ƒrtj
|ƒ}n||_|rÐg|D]!}|jdƒd
kr£|^q£|_
n	g|_
|	|_||_d|_d|_|
|_|jdkr*tj|ƒ|_ndS(sÉ:param read_deleted: 'no' indicates deleted records are hidden,
                'yes' indicates deleted records are visible,
                'only' indicates that *only* deleted records are visible.

           :param overwrite: Set to False to ensure that the greenthread local
                copy of the index is not overwritten.

           :param user_auth_plugin: The auth plugin for the current request's
                authentication data.
        tuserttenanttis_adminttypetimages
block-storagetvolumev2tvolumev3skey-managert	placementtnetworkN(simages
block-storageR)R*skey-managers	placementsnetwork(R
R"Rtread_deletedtremote_addressRtutcnowt
isinstancetsixtstring_typest
parse_strtimet	timestamptgetRtinstance_lock_checkedtquota_classR!t
db_connectiont
mq_connectiontuser_auth_pluginR&R
tcheck_is_admin(
Rtuser_idt
project_idR&R-R.R4R7RR6R:Rts((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pyRYs2

			
						cCs'|jr|jSt|j|jƒSdS(N(R:RRR(R((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pytget_auth_plugin’s	cCs|jS(N(t
_read_deleted(R((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pyt_get_read_deleted˜scCs2|dkr%ttdƒ|ƒ‚n||_dS(NR#tyestonlys=read_deleted can only be one of 'no', 'yes' or 'only', not %r(snosyessonly(t
ValueErrorRR@(RR-((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pyt_set_read_deleted›s
cCs
|`dS(N(R@(R((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pyt_del_read_deleted¡scCs?tt|ƒjƒ}|jit|ddƒd6t|ddƒd6t|ddƒd6t|ddƒd6t|ddƒd6t|dƒržtj|j	ƒndd6t|ddƒd6t|d	dƒd	6t|d
dƒd
6t|ddƒd6t|ddƒd6t|d
t
ƒd
6ƒ|jit|dtƒd6ƒ|S(NR<R=R&R-R#R.R4t
request_idR7t	user_nameRtproject_nameR6tis_admin_project(R
R"tto_dicttupdatetgetattrR!thasattrRtstrtimeR4tFalsetTrue(Rtvalues((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pyRK§s&	%		cCs”tt|ƒj|d|jdƒd|jdƒd|jddƒd|jdƒd|jdƒd|jdƒd|jdƒd	|jd	tƒƒS(
NR<R=R-R#R.R4R7RR6(R
R"t	from_dictR5RP(tclsRR((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pyRSÅscCsktj|ƒ}tj|jƒ|_t|_d|jkrO|jjdƒn|dk	rg||_n|S(s5Return a version of this context with admin flag set.tadminN(tcopytdeepcopytrolesRQR&tappendR!R-(RR-R((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pytelevatedÖs	cCsh|dkr)i|jd6|jd6}nytj|||ƒSWn!tjk
rc|r_‚ntSXdS(sQVerifies that the given action is valid on the target in this context.

        :param action: string representing the action to be checked.
        :param target: dictionary representing the object of the action
            for object creation this should be a dictionary representing the
            location of the object e.g. ``{'project_id': context.project_id}``.
            If None, then this default target will be considered:
            {'project_id': self.project_id, 'user_id': self.user_id}
        :param fatal: if False, will return False when an exception.Forbidden
           occurs.

        :raises nova.exception.Forbidden: if verification fails and fatal is
            True.

        :return: returns a non-False value (not necessarily "True") if
            authorized and False if not authorized and fatal is False.
        R=R<N(R!R=R<R
t	authorizeRt	ForbiddenRP(Rtactionttargettfatal((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pytcanæs
cCs&tt|ƒjƒ}|j|d<|S(NR&(R
R"tto_policy_valuesR&(RR
((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pyRas
cCsd|jƒS(Ns<Context %s>(RK(R((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pyt__str__sN(RRR R!RPRR?RARERFtpropertyR-RKtclassmethodRSRZRQR`RaRb(((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pyR"Qs"		6								c	CstdddddtdtƒS(s·A helper method to get a blank context.

    Note that overwrite is False here so this context will not update the
    greenthread-local stored context that is used when logging.
    R<R=R&t	overwriteN(R"R!RP(((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pytget_contextsR#cCs%tdddddtd|dtƒS(NR<R=R&R-Re(R"R!RQRP(R-((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pytget_admin_contexts
cCs3|s
tS|jrtS|js+|jr/tStS(s2Indicates if the request context is a normal user.(RPR&R<R=RQ(R((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pytis_user_context&s	cCs*|jr&t|ƒr&tjƒ‚ndS(sRRaise exception.Forbidden() if context is not a user or an
    admin context.
    N(R&RhRR\(tctxt((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pytrequire_context1scCsIt|ƒrE|js$tjƒ‚qE|j|krEtjƒ‚qEndS(s=Ensures a request has permission to access the given project.N(RhR=RR\(RR=((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pytauthorize_project_context9s
	cCsIt|ƒrE|js$tjƒ‚qE|j|krEtjƒ‚qEndS(s:Ensures a request has permission to access the given user.N(RhR<RR\(RR<((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pytauthorize_user_contextBs
	cCsIt|ƒrE|js$tjƒ‚qE|j|krEtjƒ‚qEndS(sAEnsures a request has permission to access the given quota class.N(RhR7RR\(Rt
class_name((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pytauthorize_quota_class_contextKs
	csvˆdk	r`ddlm‰ddlm‰tjˆjƒ‡‡‡‡fd†ƒ}|ƒndˆ_dˆ_dS(s¯Adds database connection information to the context
    for communicating with the given target_cell.

    This is used for permanently targeting a cell in a context.
    Use this when you want all subsequent code to target a cell.

    Passing None for cell_mapping will untarget the context.

    :param context: The RequestContext to add connection information
    :param cell_mapping: An objects.CellMapping object or None
    iÿÿÿÿ(tdb(trpccs¡ytˆj}Wnotk
r‚ˆj}ˆj|ƒˆ_ˆjjdƒsfˆjˆjƒˆ_	nˆjˆj	ftˆj<nX|dˆ_|dˆ_	dS(Ntnoneii(
t
CELL_CACHEtuuidtKeyErrortdatabase_connectiontcreate_context_managerR8t
transport_urlt
startswithtcreate_transportR9(t
cell_tupletdb_connection_string(tcell_mappingRRoRp(sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pyt*get_or_set_cached_cell_and_set_connectionsgs
	
N(	R!tnovaRoRpRtsynchronizedRsR8R9(RR|R}((R|RRoRpsA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pytset_target_cellTs
*
	ccs+tj|jƒƒ}t||ƒ|VdS(s¡Yields a new context with connection information for a specific cell.

    This function yields a copy of the provided context, which is targeted to
    the referenced cell for MQ and DB connections.

    Passing None for cell_mapping will yield an untargetd copy of the context.

    :param context: The RequestContext to add connection information
    :param cell_mapping: An objects.CellMapping object or None
    N(R"RSRKR€(RR|tcctxt((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pyttarget_cell~s
c

s6g}tjjƒ‰i}‡fd†}x<|D]4}	|j|	jtj||	||||Žfƒq1Wtjj|t	j
ƒ[y?x8t|ƒt|ƒkr¿ˆjƒ\}
}|||
<qˆWWnt	j
k
r×nXWdQXxQ|D]I\}
}|
|kr$|j
ƒt||
<tjd|
ƒqå|jƒqåW|S(sÕTarget cells in parallel and return their results.

    The first parameter in the signature of the function to call for each cell
    should be of type RequestContext.

    :param context: The RequestContext for querying cells
    :param cell_mappings: The CellMappings to target in parallel
    :param timeout: The total time in seconds to wait for all the results to be
                    gathered
    :param fn: The function to call for each cell
    :param args: The args for the function to call for each cell, not including
                 the RequestContext
    :param kwargs: The kwargs for the function to call for each cell
    :returns: A dict {cell_uuid: result} containing the joined results. The
              did_not_respond_sentinel will be returned if a cell did not
              respond within the timeout. The raised_exception_sentinel will
              be returned if the call to a cell raised an exception. The
              exception will be logged.
    csx|j}y.t||ƒ}||||Ž}WdQXWn'tk
r`tjd|ƒt}nXˆj||fƒdS(Ns#Error gathering result from cell %s(RsR‚t	ExceptiontLOGRtraised_exception_sentineltput(R|tfnRRRt	cell_uuidRtresult(tqueue(sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pyt
gather_result®s	

Ns+Timed out waiting for response from cell %s(teventletRŠt
LightQueueRYRsRtspawnttimeouttTimeoutRtCellTimeouttlenR5tkilltdid_not_respond_sentinelR„twarningtwait(
Rt
cell_mappingsRR‡RRtgreenthreadstresultsR‹R|RˆR‰tgreenthread((RŠsA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pytscatter_gather_cells–s.



	
c
Cs|tsbtjjtƒƒatjdtdttƒddj	gtD]}|j
^qCƒƒƒntsxtjdƒndS(Ns Found %(count)i cells: %(cells)stcounttcellst,s+No cells are configured, unable to continue(tCELLSR	tCellMappingListtget_allRgR„tdebugtdictR’tjointidentityterror(tc((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pyt
load_cellsÕs	,cOsEtƒgtD]}|jƒs|^q}t||d|||ŽS(s„Target all cells except cell0 in parallel and return their results.

    The first parameter in the signature of the function to call for each cell
    should be of type RequestContext. There is a 60 second timeout for waiting
    on all results to be gathered.

    :param context: The RequestContext for querying cells
    :param fn: The function to call for each cell
    :param args: The args for the function to call for each cell, not including
                 the RequestContext
    :param kwargs: The kwargs for the function to call for each cell
    :returns: A dict {cell_uuid: result} containing the joined results. The
              did_not_respond_sentinel will be returned if a cell did not
              respond within the timeout. The raised_exception_sentinel will
              be returned if the call to a cell raised an exception. The
              exception will be logged.
    i<(R¨RŸtis_cell0R›(RR‡RRtcellR—((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pytscatter_gather_skip_cell0ás%cOs tƒt|td|||ŽS(swTarget all cells in parallel and return their results.

    The first parameter in the signature of the function to call for each cell
    should be of type RequestContext. There is a 60 second timeout for waiting
    on all results to be gathered.

    :param context: The RequestContext for querying cells
    :param fn: The function to call for each cell
    :param args: The args for the function to call for each cell, not including
                 the RequestContext
    :param kwargs: The kwargs for the function to call for each cell
    :returns: A dict {cell_uuid: result} containing the joined results. The
              did_not_respond_sentinel will be returned if a cell did not
              respond within the timeout. The raised_exception_sentinel will
              be returned if the call to a cell raised an exception. The
              exception will be logged.
    i<(R¨R›RŸ(RR‡RR((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pytscatter_gather_all_cellsùs(6R t
contextlibRRVteventlet.queueRŒteventlet.timeouttkeystoneauth1.accessRRt
keystoneauth1Rtoslo_contextRtoslo_db.sqlalchemyRtoslo_logRtloggingt
oslo_utilsRR1R~Rt	nova.i18nRR	R
Rt	getLoggerRR„RrtobjectR”R…RŸtBaseAuthPluginRttransaction_context_providerR"RfRgRhRjRkRlRnR€R‚R›R¨R«R¬(((sA/home/tvault/.virtenv/lib/python2.7/site-packages/nova/context.pyt<module>sJ			º										*	?