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    
dmapi / usr / lib / python2.7 / dist-packages / dmapi / context.pyc
Size: Mime:
ó
ÿ^¢`c@sŽdZddlZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZdd	lmZddlZdd
lmZddlmZddlmZdd
lmZejeƒZeƒZeƒZdejfd„ƒYZ ej!de
j"fd„ƒYƒZ"d„Z#dd„Z$d„Z%d„Z&d„Z'd„Z(d„Z)ia*d„Z+ed„ƒZ,dS(sGRequestContext: context for requests that persist through all of dmapi.iÿÿÿÿN(tcontextmanager(tservice_catalog(tplugin(tcontext(tenginefacade(tlog(t	timeutils(t	exception(t_(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(tsuperRt__init__t
auth_tokentksa_service_catalogtServiceCatalogV2R(tselfRtsc((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyR
)s	cOs|jS(N(R(Rtargstkwargs((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyt	get_token/sc	Ks%|jjd|d|d|d|ƒS(Ntservice_typetservice_namet	interfacetregion_name(Rturl_for(RtsessionRRRRR((s1/usr/lib/python2.7/dist-packages/dmapi/context.pytget_endpoint2sN(t__name__t
__module__t__doc__R
RtNoneR(((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyR!s
		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(spSecurity 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|_
|	|_||_|
|_|jdkrtj|ƒ|_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(R's
block-storageR(R)skey-managerR*R+(RR!R
tread_deletedtremote_addressRtutcnowt
isinstancetsixtstring_typest
parse_strtimet	timestamptgetRtinstance_lock_checkedtquota_classtuser_auth_pluginR%R R	tcheck_is_admin(
Rtuser_idt
project_idR%R,R-R3R6RR5R7Rts((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyR
@s.

			
				cCs'|jr|jSt|j|jƒSdS(N(R7RRR(R((s1/usr/lib/python2.7/dist-packages/dmapi/context.pytget_auth_pluginvs	cCs|jS(N(t
_read_deleted(R((s1/usr/lib/python2.7/dist-packages/dmapi/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,((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyt_set_read_deleteds
cCs
|`dS(N(R=(R((s1/usr/lib/python2.7/dist-packages/dmapi/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(NR9R:R%R,R"R-R3t
request_idR6t	user_nameRtproject_nameR5tis_admin_project(RR!tto_dicttupdatetgetattrR thasattrR
tstrtimeR3tFalsetTrue(Rtvalues((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyRH‹s&	%		cCs”tt|ƒj|d|jdƒd|jdƒd|jddƒd|jdƒd|jdƒd|jdƒd|jdƒd	|jd	tƒƒS(
NR9R:R,R"R-R3R6RR5(RR!t	from_dictR4RM(tclsRO((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyRP©scCsktj|ƒ}tj|jƒ|_t|_d|jkrO|jjdƒn|dk	rg||_n|S(s5Return a version of this context with admin flag set.tadminN(tcopytdeepcopytrolesRNR%tappendR R,(RR,R((s1/usr/lib/python2.7/dist-packages/dmapi/context.pytelevatedºs	cCsh|dkr)i|jd6|jd6}nytj|||ƒSWn!tjk
rc|r_‚ntSXdS(sRVerifies 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 dmapi.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:R9N(R R:R9R	t	authorizeRt	ForbiddenRM(Rtactionttargettfatal((s1/usr/lib/python2.7/dist-packages/dmapi/context.pytcanÊs
cCs&tt|ƒjƒ}|j|d<|S(NR%(RR!tto_policy_valuesR%(RR	((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyR^çs
cCsd|jƒS(Ns<Context %s>(RH(R((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyt__str__ìsN(RRRR RMR
R<R>RBRCtpropertyR,RHtclassmethodRPRWRNR]R^R_(((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyR!:s"		3								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.
    R9R:R%t	overwriteN(R!R RM(((s1/usr/lib/python2.7/dist-packages/dmapi/context.pytget_contextðsR"cCs%tdddddtd|dtƒS(NR9R:R%R,Rb(R!R RNRM(R,((s1/usr/lib/python2.7/dist-packages/dmapi/context.pytget_admin_contextüs
cCs3|s
tS|jrtS|js+|jr/tStS(s2Indicates if the request context is a normal user.(RMR%R9R:RN(R((s1/usr/lib/python2.7/dist-packages/dmapi/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%ReRRY(tctxt((s1/usr/lib/python2.7/dist-packages/dmapi/context.pytrequire_contextscCsIt|ƒrE|js$tjƒ‚qE|j|krEtjƒ‚qEndS(s=Ensures a request has permission to access the given project.N(ReR:RRY(RR:((s1/usr/lib/python2.7/dist-packages/dmapi/context.pytauthorize_project_contexts
	cCsIt|ƒrE|js$tjƒ‚qE|j|krEtjƒ‚qEndS(s:Ensures a request has permission to access the given user.N(ReR9RRY(RR9((s1/usr/lib/python2.7/dist-packages/dmapi/context.pytauthorize_user_context&s
	cCsIt|ƒrE|js$tjƒ‚qE|j|krEtjƒ‚qEndS(sAEnsures a request has permission to access the given quota class.N(ReR6RRY(Rt
class_name((s1/usr/lib/python2.7/dist-packages/dmapi/context.pytauthorize_quota_class_context/s
	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_managert
db_connectiont
transport_urlt
startswithtcreate_transportt
mq_connection(t
cell_tupletdb_connection_string(tcell_mappingRRlRm(s1/usr/lib/python2.7/dist-packages/dmapi/context.pyt*get_or_set_cached_cell_and_set_connectionsLs
	
N(	R tdmapiRlRmR
tsynchronizedRpRtRx(RR{R|((R{RRlRms1/usr/lib/python2.7/dist-packages/dmapi/context.pytset_target_cell9s
*
	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!RPRHR(RR{tcctxt((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyttarget_cellcs
(-RRSt
contextlibRtkeystoneauth1.accessRRt
keystoneauth1Rtoslo_contextRtoslo_db.sqlalchemyRtoslo_logRtloggingt
oslo_utilsRR0R}Rt
dmapi.i18nRR	R
t	getLoggerRtLOGtobjecttdid_not_respond_sentineltraised_exception_sentineltBaseAuthPluginRttransaction_context_providerR!RcRdReRgRhRiRkRoRR(((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyt<module>s:			µ										*