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:
ó
Éec@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<n|jdd
ƒtt|ƒjd||||_||_|sytjƒ}nt	|t
jƒrtj|ƒ}n||_
|ràg|D]!}|jdƒdkr³|^q³|_n	g|_|	|_||_|
|_|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.
        tusert
project_idttenanttis_adminttypetimages
block-storagetvolumev2tvolumev3skey-managert	placementtnetworkN(R(s
block-storageR)R*skey-managerR+R,(tpopR RR!R
tread_deletedtremote_addressRtutcnowt
isinstancetsixtstring_typest
parse_strtimet	timestamptgetRtinstance_lock_checkedtquota_classtuser_auth_pluginR&R	tcheck_is_admin(
Rtuser_idR$R&R.R/R5R8RR7R9Rts((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyR
@s0

			
				cCs'|jr|jSt|j|jƒSdS(N(R9RRR(R((s1/usr/lib/python2.7/dist-packages/dmapi/context.pytget_auth_pluginws	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_deleted€s
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(NR;R$R&R.R"R/R5t
request_idR8t	user_nameRtproject_nameR7tis_admin_project(RR!tto_dicttupdatetgetattrR thasattrR
tstrtimeR5tFalsetTrue(Rtvalues((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyRIŒ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/R5R8RR7(RR!t	from_dictR6RN(tclsRP((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyRQªscCsktj|ƒ}tj|jƒ|_t|_d|jkrO|jjdƒn|dk	rg||_n|S(s5Return a version of this context with admin flag set.tadminN(tcopytdeepcopytrolesROR&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$R;N(R R$R;R	t	authorizeRt	ForbiddenRN(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>(RI(R((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyt__str__ísN(RRRR RNR
R=R?RCRDtpropertyR.RItclassmethodRQRXROR^R_R`(((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyR!:s"		4								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 RN(((s1/usr/lib/python2.7/dist-packages/dmapi/context.pytget_contextñsR"cCs%tdddddtd|dtƒS(NR;R$R&R.Rc(R!R RORN(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.(RNR&R;R$RO(R((s1/usr/lib/python2.7/dist-packages/dmapi/context.pytis_user_contexts	cCs*|jr&t|ƒr&tjƒ‚ndS(sRRaise exception.Forbidden() if context is not a user or an
    admin context.
    N(R&RfRRZ(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(RfR$RRZ(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(RfR;RRZ(RR;((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(RfR8RRZ(Rt
class_name((s1/usr/lib/python2.7/dist-packages/dmapi/context.pytauthorize_quota_class_context0s
	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_mappingRRmRn(s1/usr/lib/python2.7/dist-packages/dmapi/context.pyt*get_or_set_cached_cell_and_set_connectionsMs
	
N(	R tdmapiRmRnR
tsynchronizedRqRuRy(RR|R}((R|RRmRns1/usr/lib/python2.7/dist-packages/dmapi/context.pytset_target_cell:s
*
	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!RQRIR€(RR|tcctxt((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyttarget_cellds
(-RRTt
contextlibRtkeystoneauth1.accessRRt
keystoneauth1Rtoslo_contextRtoslo_db.sqlalchemyRtoslo_logRtloggingt
oslo_utilsRR2R~Rt
dmapi.i18nRR	R
t	getLoggerRtLOGtobjecttdid_not_respond_sentineltraised_exception_sentineltBaseAuthPluginRttransaction_context_providerR!RdReRfRhRiRjRlRpR€R‚(((s1/usr/lib/python2.7/dist-packages/dmapi/context.pyt<module>s:			¶										*